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 var EXPORTED_SYMBOLS = ["TestWindowChild"];
9 var docShellThunks = new Map();
11 class TestWindowChild extends JSWindowActorChild {
14 this.sawActorCreated = false;
17 void this.contentWindow;
19 this.uninitializedGetterError = e;
24 this.sawActorCreated = true;
27 receiveMessage(aMessage) {
28 switch (aMessage.name) {
30 aMessage.data.toChild = true;
31 this.sendAsyncMessage("toParent", aMessage.data);
34 let { a, b } = aMessage.data;
35 return new Promise(resolve => {
36 resolve({ result: a + b });
39 return Promise.reject(new SyntaxError(aMessage.data.message));
41 return Promise.reject(
42 Components.Exception(aMessage.data.message, aMessage.data.result)
45 this.done(aMessage.data);
48 // Return a value which is non-cloneable, like a WindowProxy.
49 return this.contentWindow;
51 docShellThunks.set(this.docShell, this);
54 let actor = docShellThunks.get(this.docShell);
55 docShellThunks.delete(this.docShell);
60 contentWindow = actor.contentWindow;
67 errorType: error.name,
72 valueIsNull: contentWindow === null,
81 this.sendAsyncMessage("event", { type: aEvent.type });
84 observe(subject, topic, data) {
86 case "audio-playback":
87 this.done({ subject, topic, data });
90 this.lastObserved = { subject, topic, data };
96 return "TestWindowChild";
100 Services.obs.notifyObservers(this, "test-js-window-actor-diddestroy", true);