Bug 1886946: Remove incorrect assertion that buffer is not-pinned. r=sfink
[gecko.git] / toolkit / actors / TestWindowParent.jsm
blob8a504737d77370ceee5e2dded5b2432ba8c1b97b
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/. */
5 "use strict";
7 var EXPORTED_SYMBOLS = ["TestWindowParent"];
9 class TestWindowParent extends JSWindowActorParent {
10   constructor() {
11     super();
12     this.wrappedJSObject = this;
13     this.sawActorCreated = false;
14   }
16   actorCreated() {
17     this.sawActorCreated = true;
18   }
20   receiveMessage(aMessage) {
21     switch (aMessage.name) {
22       case "init":
23         aMessage.data.initial = true;
24         this.sendAsyncMessage("toChild", aMessage.data);
25         break;
26       case "toParent":
27         aMessage.data.toParent = true;
28         this.sendAsyncMessage("done", aMessage.data);
29         break;
30       case "asyncMul":
31         let { a, b } = aMessage.data;
32         return { result: a * b };
34       case "event":
35         Services.obs.notifyObservers(
36           this,
37           "test-js-window-actor-parent-event",
38           aMessage.data.type
39         );
40         break;
41       case "messagePort": {
42         const { port } = aMessage.data;
43         port.postMessage("Message sent from parent over a MessagePort.");
44         port.close();
45       }
46     }
48     return undefined;
49   }
51   show() {
52     return "TestWindowParent";
53   }