Bug 1492265 - Use a content process target actor for xpcshell debugging r=jdescottes on a CLOSED TREE

MozReview-Commit-ID: J9XTgC0EBPG

Depends on D7415

Differential Revision: https://phabricator.services.mozilla.com/D7416

--HG--
extra : source : 9259cfe05c4ecd43d5e8ca354fa14ba4b96a6ae3
extra : histedit_source : 25c98064b79fd9c132ad19c874b7a535e8742dc2
This commit is contained in:
Alexandre Poirot 2018-10-08 14:26:05 +00:00
Родитель 43fb61451b
Коммит 6b9e5a6f3d
3 изменённых файлов: 29 добавлений и 10 удалений

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

@ -229,8 +229,10 @@ function TabTarget({ form, client, chrome, tab = null }) {
} else {
// browser content toolbox's form will be of the form:
// server0.conn0.content-process0/contentProcessTarget7
// while xpcshell debugging will be:
// server1.conn0.contentProcessTarget7
const isContentProcessTarget =
this._form.actor.match(/conn\d+\.content-process\d+\/contentProcessTarget\d+/);
this._form.actor.match(/conn\d+\.(content-process\d+\/)?contentProcessTarget\d+/);
this._isBrowsingContext = !this.isLegacyAddon && !isContentProcessTarget;
}

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

@ -14,6 +14,10 @@ const { DebuggerServer } = require("devtools/server/main");
loader.lazyRequireGetter(this, "ChromeWindowTargetActor",
"devtools/server/actors/targets/chrome-window", true);
loader.lazyRequireGetter(this, "ContentProcessTargetActor",
"devtools/server/actors/targets/content-process", true);
loader.lazyRequireGetter(this, "ParentProcessTargetActor",
"devtools/server/actors/targets/parent-process", true);
/* Root actor for the remote debugging protocol. */
@ -521,16 +525,30 @@ RootActor.prototype = {
// If the request doesn't contains id parameter or id is 0
// (id == 0, based on onListProcesses implementation)
if ((!("id" in request)) || request.id === 0) {
if (this._parentProcessTargetActor && (!this._parentProcessTargetActor.docShell ||
this._parentProcessTargetActor.docShell.isBeingDestroyed)) {
// Check if we are running on xpcshell. hiddenDOMWindow is going to throw on it.
// When running on xpcshell, there is no valid browsing context to attach to
// and so ParentProcessTargetActor doesn't make sense as it inherits from
// BrowsingContextTargetActor. So instead use ContentProcessTargetActor, which
// matches xpcshell needs.
let isXpcshell = true;
try {
isXpcshell = !Services.wm.getMostRecentWindow(null) &&
!Services.appShell.hiddenDOMWindow;
} catch (e) {}
if (!isXpcshell && this._parentProcessTargetActor &&
(!this._parentProcessTargetActor.docShell ||
this._parentProcessTargetActor.docShell.isBeingDestroyed)) {
this._parentProcessTargetActor.destroy();
this._parentProcessTargetActor = null;
}
if (!this._parentProcessTargetActor) {
// Create a ParentProcessTargetActor for the parent process
const { ParentProcessTargetActor } =
require("devtools/server/actors/targets/parent-process");
this._parentProcessTargetActor = new ParentProcessTargetActor(this.conn);
// Create the target actor for the parent process
if (isXpcshell) {
this._parentProcessTargetActor = new ContentProcessTargetActor(this.conn);
} else {
this._parentProcessTargetActor = new ParentProcessTargetActor(this.conn);
}
this._globalActorPool.manage(this._parentProcessTargetActor);
}

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

@ -28,9 +28,8 @@ add_task(async function() {
// Even though we have no tabs, getProcess gives us the chromeDebugger.
const response = await client.getProcess();
const actor = response.form.actor;
const [, tabClient] = await client.attachTarget(actor);
const [, threadClient] = await tabClient.attachThread(null);
const { chromeDebugger } = response.form;
const [, threadClient] = await client.attachThread(chromeDebugger);
const onResumed = new Promise(resolve => {
threadClient.addOneTimeListener("paused", (event, packet) => {
equal(packet.why.type, "breakpoint",