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/. */
6 var docShellThunks = new Map();
8 export class TestWindowChild extends JSWindowActorChild {
11 this.sawActorCreated = false;
14 void this.contentWindow;
16 this.uninitializedGetterError = e;
21 this.sawActorCreated = true;
24 receiveMessage(aMessage) {
25 switch (aMessage.name) {
27 aMessage.data.toChild = true;
28 this.sendAsyncMessage("toParent", aMessage.data);
31 let { a, b } = aMessage.data;
32 return new Promise(resolve => {
33 resolve({ result: a + b });
36 return Promise.reject(new SyntaxError(aMessage.data.message));
38 return Promise.reject(
39 Components.Exception(aMessage.data.message, aMessage.data.result)
42 this.done(aMessage.data);
45 // Return a value which is non-cloneable, like a WindowProxy.
46 return this.contentWindow;
48 docShellThunks.set(this.docShell, this);
51 let actor = docShellThunks.get(this.docShell);
52 docShellThunks.delete(this.docShell);
57 contentWindow = actor.contentWindow;
64 errorType: error.name,
69 valueIsNull: contentWindow === null,
78 this.sendAsyncMessage("event", { type: aEvent.type });
81 observe(subject, topic, data) {
83 case "audio-playback":
84 this.done({ subject, topic, data });
87 this.lastObserved = { subject, topic, data };
93 return "TestWindowChild";
97 Services.obs.notifyObservers(this, "test-js-window-actor-diddestroy", true);