2019-01-28 22:01:40 +03:00
|
|
|
/* vim: set ts=2 sw=2 sts=2 et tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
"use strict";
|
|
|
|
|
2019-05-10 18:01:42 +03:00
|
|
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
|
|
|
|
2019-01-28 22:01:40 +03:00
|
|
|
var EXPORTED_SYMBOLS = ["TestChild"];
|
|
|
|
|
|
|
|
class TestChild extends JSWindowActorChild {
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
|
2019-04-15 18:49:02 +03:00
|
|
|
receiveMessage(aMessage) {
|
2019-02-08 16:02:08 +03:00
|
|
|
switch (aMessage.name) {
|
|
|
|
case "toChild":
|
|
|
|
aMessage.data.toChild = true;
|
2019-02-21 22:53:59 +03:00
|
|
|
this.sendAsyncMessage("toParent", aMessage.data);
|
2019-02-08 16:02:08 +03:00
|
|
|
break;
|
2019-04-17 21:18:28 +03:00
|
|
|
case "asyncAdd":
|
|
|
|
let { a, b } = aMessage.data;
|
|
|
|
return new Promise(resolve => {
|
|
|
|
resolve({ result: a + b });
|
|
|
|
});
|
2019-02-08 16:02:08 +03:00
|
|
|
case "done":
|
|
|
|
this.done(aMessage.data);
|
|
|
|
break;
|
|
|
|
}
|
2019-04-17 21:18:28 +03:00
|
|
|
|
|
|
|
return undefined;
|
2019-02-08 16:02:08 +03:00
|
|
|
}
|
|
|
|
|
2019-02-22 18:17:03 +03:00
|
|
|
handleEvent(aEvent) {
|
|
|
|
this.sendAsyncMessage("event", { type: aEvent.type });
|
|
|
|
}
|
|
|
|
|
2019-03-01 21:24:58 +03:00
|
|
|
observe(subject, topic, data) {
|
2019-07-23 19:09:27 +03:00
|
|
|
switch (topic) {
|
|
|
|
case "audio-playback":
|
2019-07-23 19:50:19 +03:00
|
|
|
this.done({ subject, topic, data });
|
2019-07-23 19:09:27 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
this.lastObserved = { subject, topic, data };
|
|
|
|
break;
|
|
|
|
}
|
2019-03-01 21:24:58 +03:00
|
|
|
}
|
|
|
|
|
2019-01-28 22:01:40 +03:00
|
|
|
show() {
|
|
|
|
return "TestChild";
|
|
|
|
}
|
2019-05-10 18:01:42 +03:00
|
|
|
|
|
|
|
willDestroy() {
|
|
|
|
Services.obs.notifyObservers(
|
|
|
|
this,
|
|
|
|
"test-js-window-actor-willdestroy",
|
|
|
|
true
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
didDestroy() {
|
|
|
|
Services.obs.notifyObservers(this, "test-js-window-actor-diddestroy", true);
|
|
|
|
}
|
2019-01-28 22:01:40 +03:00
|
|
|
}
|