Bug 1866732 - Part 1: Remove tests for loading JSMs in Actors. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D233362
This commit is contained in:
@@ -14,5 +14,3 @@ support-files = ["head.js"]
|
||||
["browser_sendAsyncMessage.js"]
|
||||
|
||||
["browser_sendQuery.js"]
|
||||
|
||||
["browser_uri_combination.js"]
|
||||
|
||||
@@ -2,22 +2,10 @@
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
"use strict";
|
||||
|
||||
const ERROR_LINE_NUMBERS = {
|
||||
jsm: 31,
|
||||
"sys.mjs": 28,
|
||||
};
|
||||
const EXCEPTION_LINE_NUMBERS = {
|
||||
jsm: ERROR_LINE_NUMBERS.jsm + 3,
|
||||
"sys.mjs": ERROR_LINE_NUMBERS["sys.mjs"] + 3,
|
||||
};
|
||||
const ERROR_COLUMN_NUMBERS = {
|
||||
jsm: 31,
|
||||
"sys.mjs": 31,
|
||||
};
|
||||
const EXCEPTION_COLUMN_NUMBERS = {
|
||||
jsm: 22,
|
||||
"sys.mjs": 22,
|
||||
};
|
||||
const ERROR_LINE_NUMBER = 28;
|
||||
const EXCEPTION_LINE_NUMBER = ERROR_LINE_NUMBER + 3;
|
||||
const ERROR_COLUMN_NUMBER = 31;
|
||||
const EXCEPTION_COLUMN_NUMBER = 22;
|
||||
|
||||
function maybeAsyncStack(offset, column) {
|
||||
if (
|
||||
@@ -39,7 +27,7 @@ function maybeAsyncStack(offset, column) {
|
||||
}
|
||||
|
||||
declTest("sendQuery Error", {
|
||||
async test(browser, _window, fileExt) {
|
||||
async test(browser, _window) {
|
||||
let parent = browser.browsingContext.currentWindowGlobal.domProcess;
|
||||
let actorParent = parent.getActor("TestProcessActor");
|
||||
|
||||
@@ -52,7 +40,7 @@ declTest("sendQuery Error", {
|
||||
is(error.name, "SyntaxError", "Error should have the correct name");
|
||||
is(
|
||||
error.stack,
|
||||
`receiveMessage@resource://testing-common/TestProcessActorChild.${fileExt}:${ERROR_LINE_NUMBERS[fileExt]}:${ERROR_COLUMN_NUMBERS[fileExt]}\n` +
|
||||
`receiveMessage@resource://testing-common/TestProcessActorChild.sys.mjs:${ERROR_LINE_NUMBER}:${ERROR_COLUMN_NUMBER}\n` +
|
||||
asyncStack,
|
||||
"Error should have the correct stack"
|
||||
);
|
||||
@@ -60,7 +48,7 @@ declTest("sendQuery Error", {
|
||||
});
|
||||
|
||||
declTest("sendQuery Exception", {
|
||||
async test(browser, _window, fileExt) {
|
||||
async test(browser, _window) {
|
||||
let parent = browser.browsingContext.currentWindowGlobal.domProcess;
|
||||
let actorParent = parent.getActor("TestProcessActor");
|
||||
|
||||
@@ -80,7 +68,7 @@ declTest("sendQuery Exception", {
|
||||
);
|
||||
is(
|
||||
error.stack,
|
||||
`receiveMessage@resource://testing-common/TestProcessActorChild.${fileExt}:${EXCEPTION_LINE_NUMBERS[fileExt]}:${EXCEPTION_COLUMN_NUMBERS[fileExt]}\n` +
|
||||
`receiveMessage@resource://testing-common/TestProcessActorChild.sys.mjs:${EXCEPTION_LINE_NUMBER}:${EXCEPTION_COLUMN_NUMBER}\n` +
|
||||
asyncStack,
|
||||
"Error should have the correct stack"
|
||||
);
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
add_task(function specify_both() {
|
||||
// Specifying both should throw.
|
||||
|
||||
SimpleTest.doesThrow(() => {
|
||||
ChromeUtils.registerProcessActor("TestProcessActor", {
|
||||
parent: {
|
||||
moduleURI: "resource://testing-common/TestProcessActorParent.jsm",
|
||||
},
|
||||
child: {
|
||||
moduleURI: "resource://testing-common/TestProcessActorChild.jsm",
|
||||
esModuleURI: "resource://testing-common/TestProcessActorChild.sys.mjs",
|
||||
},
|
||||
});
|
||||
}, "Should throw if both moduleURI and esModuleURI are specified.");
|
||||
|
||||
SimpleTest.doesThrow(() => {
|
||||
ChromeUtils.registerProcessActor("TestProcessActor", {
|
||||
parent: {
|
||||
esModuleURI: "resource://testing-common/TestProcessActorParent.sys.mjs",
|
||||
},
|
||||
child: {
|
||||
moduleURI: "resource://testing-common/TestProcessActorChild.jsm",
|
||||
esModuleURI: "resource://testing-common/TestProcessActorChild.sys.mjs",
|
||||
},
|
||||
});
|
||||
}, "Should throw if both moduleURI and esModuleURI are specified.");
|
||||
|
||||
SimpleTest.doesThrow(() => {
|
||||
ChromeUtils.registerProcessActor("TestProcessActor", {
|
||||
parent: {
|
||||
moduleURI: "resource://testing-common/TestProcessActorParent.jsm",
|
||||
esModuleURI: "resource://testing-common/TestProcessActorParent.sys.mjs",
|
||||
},
|
||||
child: {
|
||||
moduleURI: "resource://testing-common/TestProcessActorChild.jsm",
|
||||
},
|
||||
});
|
||||
}, "Should throw if both moduleURI and esModuleURI are specified.");
|
||||
|
||||
SimpleTest.doesThrow(() => {
|
||||
ChromeUtils.registerProcessActor("TestProcessActor", {
|
||||
parent: {
|
||||
moduleURI: "resource://testing-common/TestProcessActorParent.jsm",
|
||||
esModuleURI: "resource://testing-common/TestProcessActorParent.sys.mjs",
|
||||
},
|
||||
child: {
|
||||
esModuleURI: "resource://testing-common/TestProcessActorChild.sys.mjs",
|
||||
},
|
||||
});
|
||||
}, "Should throw if both moduleURI and esModuleURI are specified.");
|
||||
});
|
||||
|
||||
add_task(function specify_mixed() {
|
||||
// Mixing JSM and ESM should work.
|
||||
|
||||
try {
|
||||
ChromeUtils.registerProcessActor("TestProcessActor", {
|
||||
parent: {
|
||||
moduleURI: "resource://testing-common/TestProcessActorParent.jsm",
|
||||
},
|
||||
child: {
|
||||
esModuleURI: "resource://testing-common/TestProcessActorChild.sys.mjs",
|
||||
},
|
||||
});
|
||||
} finally {
|
||||
ChromeUtils.unregisterProcessActor("TestProcessActor");
|
||||
}
|
||||
|
||||
try {
|
||||
ChromeUtils.registerProcessActor("TestProcessActor", {
|
||||
parent: {
|
||||
esModuleURI: "resource://testing-common/TestProcessActorParent.sys.mjs",
|
||||
},
|
||||
child: {
|
||||
moduleURI: "resource://testing-common/TestProcessActorChild.jsm",
|
||||
},
|
||||
});
|
||||
} finally {
|
||||
ChromeUtils.unregisterProcessActor("TestProcessActor");
|
||||
}
|
||||
});
|
||||
@@ -8,23 +8,12 @@
|
||||
const URL = "about:blank";
|
||||
const TEST_URL = "http://test2.example.org/";
|
||||
let processActorOptions = {
|
||||
jsm: {
|
||||
parent: {
|
||||
moduleURI: "resource://testing-common/TestProcessActorParent.jsm",
|
||||
},
|
||||
child: {
|
||||
moduleURI: "resource://testing-common/TestProcessActorChild.jsm",
|
||||
observers: ["test-js-content-actor-child-observer"],
|
||||
},
|
||||
parent: {
|
||||
esModuleURI: "resource://testing-common/TestProcessActorParent.sys.mjs",
|
||||
},
|
||||
"sys.mjs": {
|
||||
parent: {
|
||||
esModuleURI: "resource://testing-common/TestProcessActorParent.sys.mjs",
|
||||
},
|
||||
child: {
|
||||
esModuleURI: "resource://testing-common/TestProcessActorChild.sys.mjs",
|
||||
observers: ["test-js-content-actor-child-observer"],
|
||||
},
|
||||
child: {
|
||||
esModuleURI: "resource://testing-common/TestProcessActorChild.sys.mjs",
|
||||
observers: ["test-js-content-actor-child-observer"],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -41,11 +30,6 @@ function promiseNotification(aNotification) {
|
||||
}
|
||||
|
||||
function declTest(name, cfg) {
|
||||
declTestWithOptions(name, cfg, "jsm");
|
||||
declTestWithOptions(name, cfg, "sys.mjs");
|
||||
}
|
||||
|
||||
function declTestWithOptions(name, cfg, fileExt) {
|
||||
let {
|
||||
url = "about:blank",
|
||||
includeParent = false,
|
||||
@@ -57,8 +41,8 @@ function declTestWithOptions(name, cfg, fileExt) {
|
||||
// Build the actor options object which will be used to register & unregister
|
||||
// our process actor.
|
||||
let actorOptions = {
|
||||
parent: Object.assign({}, processActorOptions[fileExt].parent),
|
||||
child: Object.assign({}, processActorOptions[fileExt].child),
|
||||
parent: Object.assign({}, processActorOptions.parent),
|
||||
child: Object.assign({}, processActorOptions.child),
|
||||
};
|
||||
actorOptions.includeParent = includeParent;
|
||||
if (remoteTypes !== undefined) {
|
||||
@@ -77,7 +61,7 @@ function declTestWithOptions(name, cfg, fileExt) {
|
||||
try {
|
||||
await BrowserTestUtils.withNewTab(url, async browser => {
|
||||
info("browser ready");
|
||||
await Promise.resolve(test(browser, window, fileExt));
|
||||
await Promise.resolve(test(browser, window));
|
||||
});
|
||||
} finally {
|
||||
// Unregister the actor after the test is complete.
|
||||
|
||||
@@ -31,5 +31,3 @@ support-files = [
|
||||
["browser_sendAsyncMessage.js"]
|
||||
|
||||
["browser_sendQuery.js"]
|
||||
|
||||
["browser_uri_combination.js"]
|
||||
|
||||
@@ -2,22 +2,10 @@
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
"use strict";
|
||||
|
||||
const ERROR_LINE_NUMBERS = {
|
||||
jsm: 39,
|
||||
"sys.mjs": 36,
|
||||
};
|
||||
const EXCEPTION_LINE_NUMBERS = {
|
||||
jsm: ERROR_LINE_NUMBERS.jsm + 3,
|
||||
"sys.mjs": ERROR_LINE_NUMBERS["sys.mjs"] + 3,
|
||||
};
|
||||
const ERROR_COLUMN_NUMBERS = {
|
||||
jsm: 31,
|
||||
"sys.mjs": 31,
|
||||
};
|
||||
const EXCEPTION_COLUMN_NUMBERS = {
|
||||
jsm: 22,
|
||||
"sys.mjs": 22,
|
||||
};
|
||||
const ERROR_LINE_NUMBER = 36;
|
||||
const EXCEPTION_LINE_NUMBER = ERROR_LINE_NUMBER + 3;
|
||||
const ERROR_COLUMN_NUMBER = 31;
|
||||
const EXCEPTION_COLUMN_NUMBER = 22;
|
||||
|
||||
function maybeAsyncStack(offset, column) {
|
||||
if (
|
||||
@@ -39,7 +27,7 @@ function maybeAsyncStack(offset, column) {
|
||||
}
|
||||
|
||||
declTest("sendQuery Error", {
|
||||
async test(browser, _window, fileExt) {
|
||||
async test(browser, _window) {
|
||||
let parent = browser.browsingContext.currentWindowGlobal;
|
||||
let actorParent = parent.getActor("TestWindow");
|
||||
|
||||
@@ -52,7 +40,7 @@ declTest("sendQuery Error", {
|
||||
is(error.name, "SyntaxError", "Error should have the correct name");
|
||||
is(
|
||||
error.stack,
|
||||
`receiveMessage@resource://testing-common/TestWindowChild.${fileExt}:${ERROR_LINE_NUMBERS[fileExt]}:${ERROR_COLUMN_NUMBERS[fileExt]}\n` +
|
||||
`receiveMessage@resource://testing-common/TestWindowChild.sys.mjs:${ERROR_LINE_NUMBER}:${ERROR_COLUMN_NUMBER}\n` +
|
||||
asyncStack,
|
||||
"Error should have the correct stack"
|
||||
);
|
||||
@@ -60,7 +48,7 @@ declTest("sendQuery Error", {
|
||||
});
|
||||
|
||||
declTest("sendQuery Exception", {
|
||||
async test(browser, _window, fileExt) {
|
||||
async test(browser, _window) {
|
||||
let parent = browser.browsingContext.currentWindowGlobal;
|
||||
let actorParent = parent.getActor("TestWindow");
|
||||
|
||||
@@ -80,7 +68,7 @@ declTest("sendQuery Exception", {
|
||||
);
|
||||
is(
|
||||
error.stack,
|
||||
`receiveMessage@resource://testing-common/TestWindowChild.${fileExt}:${EXCEPTION_LINE_NUMBERS[fileExt]}:${EXCEPTION_COLUMN_NUMBERS[fileExt]}\n` +
|
||||
`receiveMessage@resource://testing-common/TestWindowChild.sys.mjs:${EXCEPTION_LINE_NUMBER}:${EXCEPTION_COLUMN_NUMBER}\n` +
|
||||
asyncStack,
|
||||
"Error should have the correct stack"
|
||||
);
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
add_task(function specify_both() {
|
||||
// Specifying both should throw.
|
||||
|
||||
SimpleTest.doesThrow(() => {
|
||||
ChromeUtils.registerWindowActor("TestWindow", {
|
||||
parent: {
|
||||
moduleURI: "resource://testing-common/TestWindowParent.jsm",
|
||||
},
|
||||
child: {
|
||||
moduleURI: "resource://testing-common/TestWindowChild.jsm",
|
||||
esModuleURI: "resource://testing-common/TestWindowChild.sys.mjs",
|
||||
},
|
||||
});
|
||||
}, "Should throw if both moduleURI and esModuleURI are specified.");
|
||||
|
||||
SimpleTest.doesThrow(() => {
|
||||
ChromeUtils.registerWindowActor("TestWindow", {
|
||||
parent: {
|
||||
esModuleURI: "resource://testing-common/TestWindowParent.sys.mjs",
|
||||
},
|
||||
child: {
|
||||
moduleURI: "resource://testing-common/TestWindowChild.jsm",
|
||||
esModuleURI: "resource://testing-common/TestWindowChild.sys.mjs",
|
||||
},
|
||||
});
|
||||
}, "Should throw if both moduleURI and esModuleURI are specified.");
|
||||
|
||||
SimpleTest.doesThrow(() => {
|
||||
ChromeUtils.registerWindowActor("TestWindow", {
|
||||
parent: {
|
||||
moduleURI: "resource://testing-common/TestWindowParent.jsm",
|
||||
esModuleURI: "resource://testing-common/TestWindowParent.sys.mjs",
|
||||
},
|
||||
child: {
|
||||
moduleURI: "resource://testing-common/TestWindowChild.jsm",
|
||||
},
|
||||
});
|
||||
}, "Should throw if both moduleURI and esModuleURI are specified.");
|
||||
|
||||
SimpleTest.doesThrow(() => {
|
||||
ChromeUtils.registerWindowActor("TestWindow", {
|
||||
parent: {
|
||||
moduleURI: "resource://testing-common/TestWindowParent.jsm",
|
||||
esModuleURI: "resource://testing-common/TestWindowParent.sys.mjs",
|
||||
},
|
||||
child: {
|
||||
esModuleURI: "resource://testing-common/TestWindowChild.sys.mjs",
|
||||
},
|
||||
});
|
||||
}, "Should throw if both moduleURI and esModuleURI are specified.");
|
||||
});
|
||||
|
||||
add_task(function specify_mixed() {
|
||||
// Mixing JSM and ESM should work.
|
||||
|
||||
try {
|
||||
ChromeUtils.registerWindowActor("TestWindow", {
|
||||
parent: {
|
||||
moduleURI: "resource://testing-common/TestWindowParent.jsm",
|
||||
},
|
||||
child: {
|
||||
esModuleURI: "resource://testing-common/TestWindowChild.sys.mjs",
|
||||
},
|
||||
});
|
||||
} finally {
|
||||
ChromeUtils.unregisterWindowActor("TestWindow");
|
||||
}
|
||||
|
||||
try {
|
||||
ChromeUtils.registerWindowActor("TestWindow", {
|
||||
parent: {
|
||||
esModuleURI: "resource://testing-common/TestWindowParent.sys.mjs",
|
||||
},
|
||||
child: {
|
||||
moduleURI: "resource://testing-common/TestWindowChild.jsm",
|
||||
},
|
||||
});
|
||||
} finally {
|
||||
ChromeUtils.unregisterWindowActor("TestWindow");
|
||||
}
|
||||
});
|
||||
@@ -8,30 +8,15 @@
|
||||
const URL = "about:blank";
|
||||
const TEST_URL = "http://test2.example.org/";
|
||||
let windowActorOptions = {
|
||||
jsm: {
|
||||
parent: {
|
||||
moduleURI: "resource://testing-common/TestWindowParent.jsm",
|
||||
},
|
||||
child: {
|
||||
moduleURI: "resource://testing-common/TestWindowChild.jsm",
|
||||
},
|
||||
parent: {
|
||||
esModuleURI: "resource://testing-common/TestWindowParent.sys.mjs",
|
||||
},
|
||||
"sys.mjs": {
|
||||
parent: {
|
||||
esModuleURI: "resource://testing-common/TestWindowParent.sys.mjs",
|
||||
},
|
||||
child: {
|
||||
esModuleURI: "resource://testing-common/TestWindowChild.sys.mjs",
|
||||
},
|
||||
child: {
|
||||
esModuleURI: "resource://testing-common/TestWindowChild.sys.mjs",
|
||||
},
|
||||
};
|
||||
|
||||
function declTest(name, cfg) {
|
||||
declTestWithOptions(name, cfg, "jsm");
|
||||
declTestWithOptions(name, cfg, "sys.mjs");
|
||||
}
|
||||
|
||||
function declTestWithOptions(name, cfg, fileExt) {
|
||||
let {
|
||||
url = "about:blank",
|
||||
allFrames = false,
|
||||
@@ -47,8 +32,8 @@ function declTestWithOptions(name, cfg, fileExt) {
|
||||
// Build the actor options object which will be used to register & unregister
|
||||
// our window actor.
|
||||
let actorOptions = {
|
||||
parent: { ...windowActorOptions[fileExt].parent },
|
||||
child: { ...windowActorOptions[fileExt].child, events, observers },
|
||||
parent: { ...windowActorOptions.parent },
|
||||
child: { ...windowActorOptions.child, events, observers },
|
||||
};
|
||||
actorOptions.allFrames = allFrames;
|
||||
actorOptions.includeChrome = includeChrome;
|
||||
@@ -71,7 +56,7 @@ function declTestWithOptions(name, cfg, fileExt) {
|
||||
try {
|
||||
await BrowserTestUtils.withNewTab(url, async browser => {
|
||||
info("browser ready");
|
||||
await Promise.resolve(test(browser, window, fileExt));
|
||||
await Promise.resolve(test(browser, window));
|
||||
});
|
||||
} finally {
|
||||
// Unregister the actor after the test is complete.
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
/* 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";
|
||||
|
||||
var EXPORTED_SYMBOLS = ["TestProcessActorChild"];
|
||||
|
||||
class TestProcessActorChild extends JSProcessActorChild {
|
||||
constructor() {
|
||||
super();
|
||||
this.sawActorCreated = false;
|
||||
}
|
||||
|
||||
actorCreated() {
|
||||
this.sawActorCreated = true;
|
||||
}
|
||||
|
||||
receiveMessage(aMessage) {
|
||||
switch (aMessage.name) {
|
||||
case "toChild":
|
||||
aMessage.data.toChild = true;
|
||||
this.sendAsyncMessage("toParent", aMessage.data);
|
||||
break;
|
||||
case "asyncAdd":
|
||||
let { a, b } = aMessage.data;
|
||||
return new Promise(resolve => {
|
||||
resolve({ result: a + b });
|
||||
});
|
||||
case "error":
|
||||
return Promise.reject(new SyntaxError(aMessage.data.message));
|
||||
case "exception":
|
||||
return Promise.reject(
|
||||
Components.Exception(aMessage.data.message, aMessage.data.result)
|
||||
);
|
||||
case "done":
|
||||
this.done(aMessage.data);
|
||||
break;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
observe(subject, topic, data) {
|
||||
this.lastObserved = { subject, topic, data };
|
||||
}
|
||||
|
||||
show() {
|
||||
return "TestProcessActorChild";
|
||||
}
|
||||
|
||||
didDestroy() {
|
||||
Services.obs.notifyObservers(
|
||||
this,
|
||||
"test-js-content-actor-diddestroy",
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
/* 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";
|
||||
|
||||
var EXPORTED_SYMBOLS = ["TestProcessActorParent"];
|
||||
|
||||
class TestProcessActorParent extends JSProcessActorParent {
|
||||
constructor() {
|
||||
super();
|
||||
this.wrappedJSObject = this;
|
||||
this.sawActorCreated = false;
|
||||
}
|
||||
|
||||
actorCreated() {
|
||||
this.sawActorCreated = true;
|
||||
}
|
||||
|
||||
receiveMessage(aMessage) {
|
||||
switch (aMessage.name) {
|
||||
case "init":
|
||||
aMessage.data.initial = true;
|
||||
this.sendAsyncMessage("toChild", aMessage.data);
|
||||
break;
|
||||
case "toParent":
|
||||
aMessage.data.toParent = true;
|
||||
this.sendAsyncMessage("done", aMessage.data);
|
||||
break;
|
||||
case "asyncMul":
|
||||
let { a, b } = aMessage.data;
|
||||
return { result: a * b };
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
show() {
|
||||
return "TestProcessActorParent";
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
/* 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";
|
||||
|
||||
var EXPORTED_SYMBOLS = ["TestWindowChild"];
|
||||
|
||||
var docShellThunks = new Map();
|
||||
|
||||
class TestWindowChild extends JSWindowActorChild {
|
||||
constructor() {
|
||||
super();
|
||||
this.sawActorCreated = false;
|
||||
|
||||
try {
|
||||
void this.contentWindow;
|
||||
} catch (e) {
|
||||
this.uninitializedGetterError = e;
|
||||
}
|
||||
}
|
||||
|
||||
actorCreated() {
|
||||
this.sawActorCreated = true;
|
||||
}
|
||||
|
||||
receiveMessage(aMessage) {
|
||||
switch (aMessage.name) {
|
||||
case "toChild":
|
||||
aMessage.data.toChild = true;
|
||||
this.sendAsyncMessage("toParent", aMessage.data);
|
||||
break;
|
||||
case "asyncAdd":
|
||||
let { a, b } = aMessage.data;
|
||||
return new Promise(resolve => {
|
||||
resolve({ result: a + b });
|
||||
});
|
||||
case "error":
|
||||
return Promise.reject(new SyntaxError(aMessage.data.message));
|
||||
case "exception":
|
||||
return Promise.reject(
|
||||
Components.Exception(aMessage.data.message, aMessage.data.result)
|
||||
);
|
||||
case "done":
|
||||
this.done(aMessage.data);
|
||||
break;
|
||||
case "noncloneReply":
|
||||
// Return a value which is non-cloneable, like a WindowProxy.
|
||||
return this.contentWindow;
|
||||
case "storeActor":
|
||||
docShellThunks.set(this.docShell, this);
|
||||
break;
|
||||
case "checkActor": {
|
||||
let actor = docShellThunks.get(this.docShell);
|
||||
docShellThunks.delete(this.docShell);
|
||||
|
||||
let contentWindow;
|
||||
let error;
|
||||
try {
|
||||
contentWindow = actor.contentWindow;
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
if (error) {
|
||||
return {
|
||||
status: "error",
|
||||
errorType: error.name,
|
||||
};
|
||||
}
|
||||
return {
|
||||
status: "success",
|
||||
valueIsNull: contentWindow === null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
handleEvent(aEvent) {
|
||||
this.sendAsyncMessage("event", { type: aEvent.type });
|
||||
}
|
||||
|
||||
observe(subject, topic, data) {
|
||||
switch (topic) {
|
||||
case "audio-playback":
|
||||
this.done({ subject, topic, data });
|
||||
break;
|
||||
default:
|
||||
this.lastObserved = { subject, topic, data };
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
show() {
|
||||
return "TestWindowChild";
|
||||
}
|
||||
|
||||
didDestroy() {
|
||||
Services.obs.notifyObservers(this, "test-js-window-actor-diddestroy", true);
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
/* 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";
|
||||
|
||||
var EXPORTED_SYMBOLS = ["TestWindowParent"];
|
||||
|
||||
class TestWindowParent extends JSWindowActorParent {
|
||||
constructor() {
|
||||
super();
|
||||
this.wrappedJSObject = this;
|
||||
this.sawActorCreated = false;
|
||||
}
|
||||
|
||||
actorCreated() {
|
||||
this.sawActorCreated = true;
|
||||
}
|
||||
|
||||
receiveMessage(aMessage) {
|
||||
switch (aMessage.name) {
|
||||
case "init":
|
||||
aMessage.data.initial = true;
|
||||
this.sendAsyncMessage("toChild", aMessage.data);
|
||||
break;
|
||||
case "toParent":
|
||||
aMessage.data.toParent = true;
|
||||
this.sendAsyncMessage("done", aMessage.data);
|
||||
break;
|
||||
case "asyncMul":
|
||||
let { a, b } = aMessage.data;
|
||||
return { result: a * b };
|
||||
|
||||
case "event":
|
||||
Services.obs.notifyObservers(
|
||||
this,
|
||||
"test-js-window-actor-parent-event",
|
||||
aMessage.data.type
|
||||
);
|
||||
break;
|
||||
case "messagePort": {
|
||||
const { port } = aMessage.data;
|
||||
port.postMessage("Message sent from parent over a MessagePort.");
|
||||
port.close();
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
show() {
|
||||
return "TestWindowParent";
|
||||
}
|
||||
}
|
||||
@@ -22,13 +22,9 @@ with Files("PictureInPictureChild.sys.mjs"):
|
||||
SPHINX_TREES["actors"] = "docs"
|
||||
|
||||
TESTING_JS_MODULES += [
|
||||
"TestProcessActorChild.jsm",
|
||||
"TestProcessActorChild.sys.mjs",
|
||||
"TestProcessActorParent.jsm",
|
||||
"TestProcessActorParent.sys.mjs",
|
||||
"TestWindowChild.jsm",
|
||||
"TestWindowChild.sys.mjs",
|
||||
"TestWindowParent.jsm",
|
||||
"TestWindowParent.sys.mjs",
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user