1 /* vim: set ts=2 sw=2 sts=2 et tw=80: */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
9 var EXPORTED_SYMBOLS = ["TestChild"];
11 class TestChild extends JSWindowActorChild {
16 receiveMessage(aMessage) {
17 switch (aMessage.name) {
19 aMessage.data.toChild = true;
20 this.sendAsyncMessage("toParent", aMessage.data);
23 let { a, b } = aMessage.data;
24 return new Promise(resolve => {
25 resolve({ result: a + b });
28 return Promise.reject(new SyntaxError(aMessage.data.message));
30 return Promise.reject(
31 Components.Exception(aMessage.data.message, aMessage.data.result)
34 this.done(aMessage.data);
42 this.sendAsyncMessage("event", { type: aEvent.type });
45 observe(subject, topic, data) {
47 case "audio-playback":
48 this.done({ subject, topic, data });
51 this.lastObserved = { subject, topic, data };
61 Services.obs.notifyObservers(
63 "test-js-window-actor-willdestroy",
69 Services.obs.notifyObservers(this, "test-js-window-actor-diddestroy", true);