Bug 1478244 - Enable client/debugger/test/mochitest/browser_dbg_target-scoped-actor-01.js in e10s. r=jdescottes

MozReview-Commit-ID: HKT4whszLKX

--HG--
extra : rebase_source : 19c4c11518d1c652099b3e745d7f96e14d987394
This commit is contained in:
Alexandre Poirot 2018-07-25 00:35:36 -07:00
Родитель 42fb2abfdb
Коммит a536d5758a
3 изменённых файлов: 46 добавлений и 41 удалений

Просмотреть файл

@ -400,7 +400,6 @@ skip-if = (e10s && debug) || (os == 'linux' && bits == 32 && debug) # bug 132891
uses-unsafe-cpows = true
skip-if = e10s && debug
[browser_dbg_target-scoped-actor-01.js]
skip-if = e10s # TODO
[browser_dbg_target-scoped-actor-02.js]
skip-if = e10s # TODO
[browser_dbg_terminate-on-tab-close.js]

Просмотреть файл

@ -10,58 +10,35 @@
const ACTORS_URL = CHROME_URL + "testactors.js";
const TAB_URL = EXAMPLE_URL + "doc_empty-tab-01.html";
var gClient;
add_task(async function test() {
await addTab(TAB_URL);
function test() {
DebuggerServer.init();
DebuggerServer.registerAllActors();
DebuggerServer.registerModule(ACTORS_URL, {
await registerActorInContentProcess(ACTORS_URL, {
prefix: "testOne",
constructor: "TestActor1",
type: { target: true },
});
let transport = DebuggerServer.connectPipe();
gClient = new DebuggerClient(transport);
gClient.connect().then(([aType, aTraits]) => {
is(aType, "browser",
"Root actor should identify itself as a browser.");
const transport = DebuggerServer.connectPipe();
const client = new DebuggerClient(transport);
const [ type ] = await client.connect();
is(type, "browser", "Root actor should identify itself as a browser.");
addTab(TAB_URL)
.then(() => attachTargetActorForUrl(gClient, TAB_URL))
.then(testTargetScopedActor)
.then(closeTab)
.then(() => gClient.close())
.then(finish)
.catch(aError => {
ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
});
});
}
const [ grip ] = await attachTargetActorForUrl(client, TAB_URL);
await testTargetScopedActor(client, grip);
await removeTab(gBrowser.selectedTab);
await client.close();
});
function testTargetScopedActor([aGrip, aResponse]) {
let deferred = promise.defer();
ok(aGrip.testOneActor,
async function testTargetScopedActor(client, grip) {
ok(grip.testOneActor,
"Found the test target-scoped actor.");
ok(aGrip.testOneActor.includes("testOne"),
ok(grip.testOneActor.includes("testOne"),
"testOneActor's actorPrefix should be used.");
gClient.request({ to: aGrip.testOneActor, type: "ping" }, aResponse => {
is(aResponse.pong, "pong",
"Actor should respond to requests.");
deferred.resolve();
});
return deferred.promise;
const response = await client.request({ to: grip.testOneActor, type: "ping" });
is(response.pong, "pong", "Actor should respond to requests.");
}
function closeTab() {
return removeTab(gBrowser.selectedTab);
}
registerCleanupFunction(function () {
gClient = null;
});

Просмотреть файл

@ -730,3 +730,32 @@ async function enableWebComponents() {
await pushPref("dom.webcomponents.shadowdom.enabled", true);
await pushPref("dom.webcomponents.customelements.enabled", true);
}
/*
* Register an actor in the content process of the current tab.
*
* Calling DebuggerServer.registerModule only registers the actor in the current process.
* As all test scripts are ran in the parent process, it is only registered here.
* This function helps register them in the content process used for the current tab.
*
* @param {string} url
* Actor module URL or absolute require path
* @param {json} options
* Arguments to be passed to DebuggerServer.registerModule
*/
async function registerActorInContentProcess(url, options) {
function convertChromeToFile(uri) {
return Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIChromeRegistry)
.convertChromeURL(Services.io.newURI(uri)).spec;
}
// chrome://mochitests URI is registered only in the parent process, so convert these
// URLs to file:// one in order to work in the content processes
url = url.startsWith("chrome://mochitests") ? convertChromeToFile(url) : url;
return ContentTask.spawn(gBrowser.selectedBrowser, { url, options }, args => {
// eslint-disable-next-line no-shadow
const { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
const { DebuggerServer } = require("devtools/server/main");
DebuggerServer.registerModule(args.url, args.options);
});
}