зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1671676 - [devtools] Update browser_setupInParentChild.js to only test setupInParent r=ochameau
Depends on D93821 Differential Revision: https://phabricator.services.mozilla.com/D93822
This commit is contained in:
Родитель
138356ac36
Коммит
f78ea8ee85
|
@ -42,10 +42,10 @@ support-files =
|
|||
storage-secured-iframe.html
|
||||
stylesheets-nested-iframes.html
|
||||
test-errors-actor.js
|
||||
test-setup-in-parent.js
|
||||
test-spawn-actor-in-parent.js
|
||||
test-window.xhtml
|
||||
inspector-helpers.js
|
||||
setup-in-child.js
|
||||
setup-in-parent.js
|
||||
storage-helpers.js
|
||||
!/devtools/client/shared/test/shared-head.js
|
||||
|
@ -153,7 +153,7 @@ skip-if = e10s # Bug 1183605 - devtools/server/tests/browser/ tests are still di
|
|||
skip-if = e10s # Bug 1183605 - devtools/server/tests/browser/ tests are still disabled in E10S
|
||||
[browser_perf-samples-01.js]
|
||||
[browser_perf-samples-02.js]
|
||||
[browser_setupInParentChild.js]
|
||||
[browser_setup_in_parent.js]
|
||||
[browser_spawn_actor_in_parent.js]
|
||||
[browser_storage_browser_toolbox_indexeddb.js]
|
||||
[browser_storage_cookies-duplicate-names.js]
|
||||
|
|
|
@ -1,76 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Bug 1181100 - Test DevToolsServerConnection.setupInParent and DevToolsServer.setupInChild
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const {
|
||||
connectToFrame,
|
||||
} = require("devtools/server/connectors/frame-connector");
|
||||
|
||||
add_task(async () => {
|
||||
// Create a minimal browser with a message manager
|
||||
const browser = document.createXULElement("browser");
|
||||
browser.setAttribute("type", "content");
|
||||
document.body.appendChild(browser);
|
||||
|
||||
// Instantiate a minimal server
|
||||
DevToolsServer.init();
|
||||
if (!DevToolsServer.createRootActor) {
|
||||
DevToolsServer.registerAllActors();
|
||||
}
|
||||
|
||||
// Fake a connection to an iframe
|
||||
const transport = DevToolsServer.connectPipe();
|
||||
const conn = transport._serverConnection;
|
||||
const client = new DevToolsClient(transport);
|
||||
|
||||
// Wait for a response from setupInChild
|
||||
const onChild = msg => {
|
||||
Services.ppmm.removeMessageListener("test:setupChild", onChild);
|
||||
const args = msg.json;
|
||||
|
||||
is(args[0], 1, "Got first numeric argument");
|
||||
is(args[1], "two", "Got second string argument");
|
||||
is(args[2].three, true, "Got last JSON argument");
|
||||
|
||||
// Ask the child to call setupInParent
|
||||
DevToolsServer.setupInChild({
|
||||
module:
|
||||
"chrome://mochitests/content/browser/devtools/server/tests/browser/setup-in-child.js",
|
||||
setupChild: "callParent",
|
||||
});
|
||||
};
|
||||
Services.ppmm.addMessageListener("test:setupChild", onChild);
|
||||
|
||||
// Wait also for a reponse from setupInParent called from setup-in-child.js
|
||||
const onDone = new Promise(resolve => {
|
||||
const onParent = (_, topic, args) => {
|
||||
Services.obs.removeObserver(onParent, "test:setupParent");
|
||||
args = JSON.parse(args);
|
||||
|
||||
is(args[0], true, "Got `mm` argument, a message manager");
|
||||
ok(args[1].match(/server\d+.conn\d+.child\d+/), "Got `prefix` argument");
|
||||
|
||||
resolve();
|
||||
};
|
||||
Services.obs.addObserver(onParent, "test:setupParent");
|
||||
});
|
||||
|
||||
// Instanciate e10s machinery and call setupInChild
|
||||
await connectToFrame(conn, browser);
|
||||
DevToolsServer.setupInChild({
|
||||
module:
|
||||
"chrome://mochitests/content/browser/devtools/server/tests/browser/setup-in-child.js",
|
||||
setupChild: "setupChild",
|
||||
args: [1, "two", { three: true }],
|
||||
});
|
||||
await onDone;
|
||||
|
||||
await client.close();
|
||||
DevToolsServer.destroy();
|
||||
browser.remove();
|
||||
});
|
|
@ -0,0 +1,52 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
const ACTOR_URL =
|
||||
"chrome://mochitests/content/browser/devtools/server/tests/browser/test-setup-in-parent.js";
|
||||
|
||||
const { TestSetupInParentFront } = require(ACTOR_URL);
|
||||
|
||||
add_task(async function() {
|
||||
const browser = await addTab("data:text/html;charset=utf-8,foo");
|
||||
|
||||
info("Register target-scoped actor in the content process");
|
||||
await registerActorInContentProcess(ACTOR_URL, {
|
||||
prefix: "testSetupInParent",
|
||||
constructor: "TestSetupInParentActor",
|
||||
type: { target: true },
|
||||
});
|
||||
|
||||
const tab = gBrowser.getTabForBrowser(browser);
|
||||
const target = await TargetFactory.forTab(tab);
|
||||
await target.attach();
|
||||
const { client } = target;
|
||||
const form = target.targetForm;
|
||||
|
||||
// As this Front isn't instantiated by protocol.js, we have to manually
|
||||
// set its actor ID and manage it:
|
||||
const front = new TestSetupInParentFront(client);
|
||||
front.actorID = form.testSetupInParentActor;
|
||||
front.manage(front);
|
||||
|
||||
// Wait also for a reponse from setupInParent called from setup-in-child.js
|
||||
const onDone = new Promise(resolve => {
|
||||
const onParent = (_, topic, args) => {
|
||||
Services.obs.removeObserver(onParent, "test:setupParent");
|
||||
args = JSON.parse(args);
|
||||
|
||||
is(args[0], true, "Got `mm` argument, a message manager");
|
||||
ok(args[1].match(/server\d+.conn\d+.child\d+/), "Got `prefix` argument");
|
||||
|
||||
resolve();
|
||||
};
|
||||
Services.obs.addObserver(onParent, "test:setupParent");
|
||||
});
|
||||
|
||||
await front.callSetupInParent();
|
||||
await onDone;
|
||||
|
||||
await target.destroy();
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
|
@ -1,23 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
const { Cc } = require("chrome");
|
||||
const cpmm = Cc["@mozilla.org/childprocessmessagemanager;1"].getService();
|
||||
const { DevToolsServer } = require("devtools/server/devtools-server");
|
||||
|
||||
exports.setupChild = function(a, b, c) {
|
||||
cpmm.sendAsyncMessage("test:setupChild", [a, b, c]);
|
||||
};
|
||||
|
||||
exports.callParent = function() {
|
||||
// Hack! Fetch DevToolsServerConnection objects directly within DevToolsServer guts.
|
||||
for (const id in DevToolsServer._connections) {
|
||||
const conn = DevToolsServer._connections[id];
|
||||
// eslint-disable-next-line no-restricted-properties
|
||||
conn.setupInParent({
|
||||
module:
|
||||
"chrome://mochitests/content/browser/devtools/server/tests/browser/setup-in-parent.js",
|
||||
setupParent: "setupParent",
|
||||
args: [{ one: true }, 2, "three"],
|
||||
});
|
||||
}
|
||||
};
|
|
@ -0,0 +1,33 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
const protocol = require("devtools/shared/protocol");
|
||||
const { FrontClassWithSpec } = protocol;
|
||||
|
||||
const spec = protocol.generateActorSpec({
|
||||
typeName: "testSetupInParent",
|
||||
|
||||
methods: {
|
||||
callSetupInParent: {
|
||||
request: {},
|
||||
response: {},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
exports.TestSetupInParentActor = protocol.ActorClassWithSpec(spec, {
|
||||
callSetupInParent: async function() {
|
||||
// eslint-disable-next-line no-restricted-properties
|
||||
this.conn.setupInParent({
|
||||
module:
|
||||
"chrome://mochitests/content/browser/devtools/server/tests/browser/setup-in-parent.js",
|
||||
setupParent: "setupParent",
|
||||
args: [{ one: true }, 2, "three"],
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
class TestSetupInParentFront extends FrontClassWithSpec(spec) {}
|
||||
exports.TestSetupInParentFront = TestSetupInParentFront;
|
Загрузка…
Ссылка в новой задаче