Bug 1886946: Remove incorrect assertion that buffer is not-pinned. r=sfink
[gecko.git] / toolkit / actors / TestProcessActorChild.jsm
blob20b738262478992ebd6fd6e1bf4fced8338ee843
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 = ["TestProcessActorChild"];
9 class TestProcessActorChild extends JSProcessActorChild {
10   constructor() {
11     super();
12     this.sawActorCreated = false;
13   }
15   actorCreated() {
16     this.sawActorCreated = true;
17   }
19   receiveMessage(aMessage) {
20     switch (aMessage.name) {
21       case "toChild":
22         aMessage.data.toChild = true;
23         this.sendAsyncMessage("toParent", aMessage.data);
24         break;
25       case "asyncAdd":
26         let { a, b } = aMessage.data;
27         return new Promise(resolve => {
28           resolve({ result: a + b });
29         });
30       case "error":
31         return Promise.reject(new SyntaxError(aMessage.data.message));
32       case "exception":
33         return Promise.reject(
34           Components.Exception(aMessage.data.message, aMessage.data.result)
35         );
36       case "done":
37         this.done(aMessage.data);
38         break;
39     }
41     return undefined;
42   }
44   observe(subject, topic, data) {
45     this.lastObserved = { subject, topic, data };
46   }
48   show() {
49     return "TestProcessActorChild";
50   }
52   didDestroy() {
53     Services.obs.notifyObservers(
54       this,
55       "test-js-content-actor-diddestroy",
56       true
57     );
58   }