Bug 1492265 - Use a content process target actor for xpcshell debugging. r=jdescottes

MozReview-Commit-ID: J9XTgC0EBPG

Depends on D7415

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Alexandre Poirot 2018-10-09 09:31:08 +00:00
Родитель 3f86c4c860
Коммит 687cff632b
12 изменённых файлов: 38 добавлений и 22 удалений

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

@ -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);
}

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

@ -24,6 +24,7 @@ const { TabSources } = require("devtools/server/actors/utils/TabSources");
loader.lazyRequireGetter(this, "WorkerTargetActorList", "devtools/server/actors/worker/worker-list", true);
loader.lazyRequireGetter(this, "MemoryActor", "devtools/server/actors/memory", true);
loader.lazyRequireGetter(this, "PromisesActor", "devtools/server/actors/promises", true);
function ContentProcessTargetActor(connection) {
this.conn = connection;
@ -101,6 +102,13 @@ ContentProcessTargetActor.prototype = {
this.memoryActor = new MemoryActor(this.conn, this);
this._contextPool.addActor(this.memoryActor);
}
// Promises actor is being tested by xpcshell test, which uses the content process
// target actor. But this actor isn't being used outside of tests yet.
if (!this._promisesActor) {
this._promisesActor = new PromisesActor(this.conn, this);
this._contextPool.addActor(this._promisesActor);
}
return {
actor: this.actorID,
name: "Content process",
@ -108,6 +116,7 @@ ContentProcessTargetActor.prototype = {
consoleActor: this._consoleActor.actorID,
chromeDebugger: this.threadActor.actorID,
memoryActor: this.memoryActor.actorID,
promisesActor: this._promisesActor.actorID,
traits: {
highlightable: false,

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

@ -15,14 +15,12 @@ add_task(async function() {
const parentProcessActors = await getParentProcessActors(client);
// We have to attach the chrome target actor before playing with the PromiseActor
await attachTarget(client, parentProcessActors);
await testAttach(client, parentProcessActors);
const response = await listTabs(client);
const targetTab = findTab(response.tabs, "promises-actor-test");
ok(targetTab, "Found our target tab.");
await attachTarget(client, targetTab);
await testAttach(client, targetTab);
await close(client);

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

@ -16,7 +16,6 @@ add_task(async function() {
const parentProcessActors = await getParentProcessActors(client);
// We have to attach the chrome target actor before playing with the PromiseActor
await attachTarget(client, parentProcessActors);
await testListPromises(client, parentProcessActors, v =>
new Promise(resolve => resolve(v)));

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

@ -19,7 +19,6 @@ add_task(async function() {
ok(Promise.toString().includes("native code"), "Expect native DOM Promise");
// We have to attach the chrome target actor before playing with the PromiseActor
await attachTarget(client, parentProcessActors);
await testNewPromisesEvent(client, parentProcessActors,
v => new Promise(resolve => resolve(v)));

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

@ -21,7 +21,6 @@ add_task(async function() {
ok(Promise.toString().includes("native code"), "Expect native DOM Promise");
// We have to attach the chrome target actor before playing with the PromiseActor
await attachTarget(client, parentProcessActors);
await testPromisesSettled(client, parentProcessActors,
v => new Promise(resolve => resolve(v)),
v => new Promise((resolve, reject) => reject(v)));

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

@ -14,7 +14,6 @@ var EventEmitter = require("devtools/shared/event-emitter");
add_task(async function() {
const client = await startTestDebuggerServer("test-promises-dependentpromises");
const parentProcessActors = await getParentProcessActors(client);
await attachTarget(client, parentProcessActors);
ok(Promise.toString().includes("native code"), "Expect native DOM Promise.");
@ -32,7 +31,6 @@ add_task(async function() {
const response = await listTabs(client);
const targetTab = findTab(response.tabs, "test-promises-dependentpromises");
ok(targetTab, "Found our target tab.");
await attachTarget(client, targetTab);
await testGetDependentPromises(client, targetTab, () => {
const debuggee =

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

@ -28,7 +28,6 @@ add_task(async function() {
ok(Promise.toString().includes("native code"), "Expect native DOM Promise.");
// We have to attach the chrome target actor before playing with the PromiseActor
await attachTarget(client, parentProcessActors);
await testPromiseCreationTimestamp(client, parentProcessActors, v => {
return new Promise(resolve => resolve(v));
});

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

@ -19,7 +19,6 @@ add_task(async function() {
ok(Promise.toString().includes("native code"), "Expect native DOM Promise.");
// We have to attach the chrome target actor before playing with the PromiseActor
await attachTarget(client, parentProcessActors);
await testGetTimeToSettle(client, parentProcessActors, () => {
const p = new Promise(() => {});
p.name = "p";

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

@ -16,19 +16,16 @@ var EventEmitter = require("devtools/shared/event-emitter");
add_task(async function() {
const client = await startTestDebuggerServer("test-promises-timetosettle");
const parentProcessActors = await getParentProcessActors(client);
await attachTarget(client, parentProcessActors);
ok(Promise.toString().includes("native code"), "Expect native DOM Promise.");
// We have to attach the chrome target actor before playing with the PromiseActor
await attachTarget(client, parentProcessActors);
await testGetTimeToSettle(client, parentProcessActors,
v => new Promise(resolve => setTimeout(() => resolve(v), 100)));
const response = await listTabs(client);
const targetTab = findTab(response.tabs, "test-promises-timetosettle");
ok(targetTab, "Found our target tab.");
await attachTarget(client, targetTab);
await testGetTimeToSettle(client, targetTab, v => {
const debuggee =

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

@ -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",