Bug 1485676 - Rename DebuggerClient.attachTab to attachTarget. r=jdescottes

Summary:
This method isn't specific to tabs. It can attach to any "target" actor that inherits from BrowsingContextActor.

Depends On D6161

Reviewers: yulia!

Tags: #secure-revision

Bug #: 1485676

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

MozReview-Commit-ID: Exz5fWyWyfN
This commit is contained in:
Alexandre Poirot 2018-09-18 02:18:23 -07:00
Родитель 8724260e30
Коммит f98d0997fe
42 изменённых файлов: 67 добавлений и 64 удалений

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

@ -30,7 +30,7 @@ function initDebuggerClient() {
}
async function attachThread(client, actor) {
let [response, tabClient] = await client.attachTab(actor);
let [response, tabClient] = await client.attachTarget(actor);
let [response2, threadClient] = await tabClient.attachThread(null);
return threadClient;
}

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

@ -18,7 +18,7 @@ function test() {
let tab = yield addTab(TAB1_URL);
let { tabs } = yield listTabs(client);
let [, tabClient] = yield attachTab(client, findTab(tabs, TAB1_URL));
let [, tabClient] = yield attachTarget(client, findTab(tabs, TAB1_URL));
yield listWorkers(tabClient);
// If a page still has pending network requests, it will not be moved into

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

@ -13,9 +13,9 @@ function test() {
let tab = yield addTab(TAB_URL);
let { tabs: tabs1 } = yield listTabs(client1);
let [, tabClient1] = yield attachTab(client1, findTab(tabs1, TAB_URL));
let [, tabClient1] = yield attachTarget(client1, findTab(tabs1, TAB_URL));
let { tabs: tabs2 } = yield listTabs(client2);
let [, tabClient2] = yield attachTab(client2, findTab(tabs2, TAB_URL));
let [, tabClient2] = yield attachTarget(client2, findTab(tabs2, TAB_URL));
yield listWorkers(tabClient1);
yield listWorkers(tabClient2);

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

@ -46,7 +46,7 @@ function testParentProcessTargetActor() {
gClient.addListener("newGlobal", onNewGlobal);
let actor = aResponse.form.actor;
gClient.attachTab(actor).then(([response, tabClient]) => {
gClient.attachTarget(actor).then(([response, tabClient]) => {
tabClient.attachThread(null).then(([aResponse, aThreadClient]) => {
gThreadClient = aThreadClient;
gThreadClient.addListener("newSource", onNewSource);

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

@ -12,7 +12,7 @@ function test() {
let tab = yield addTab(TAB_URL);
let { tabs } = yield listTabs(client);
let [, tabClient] = yield attachTab(client, findTab(tabs, TAB_URL));
let [, tabClient] = yield attachTarget(client, findTab(tabs, TAB_URL));
let { workers } = yield listWorkers(tabClient);
is(workers.length, 0);

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

@ -29,7 +29,7 @@ function test() {
let { tabs } = yield listTabs(client);
let targetTab = findTab(tabs, TAB_URL);
yield attachTab(client, targetTab);
yield attachTarget(client, targetTab);
yield testGetAllocationStack(client, targetTab, tab);

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

@ -30,7 +30,7 @@ function test() {
let client = new DebuggerClient(DebuggerServer.connectPipe());
yield connect(client);
let chrome = yield client.getProcess();
let [, tabClient] = yield attachTab(client, chrome.form);
let [, tabClient] = yield attachTarget(client, chrome.form);
yield tabClient.attachThread();
yield testGetAllocationStack(client, chrome.form, () => {

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

@ -47,7 +47,7 @@ function test() {
let { tabs } = yield listTabs(client);
let targetTab = findTab(tabs, TAB_URL);
yield attachTab(client, targetTab);
yield attachTarget(client, targetTab);
yield testGetFulfillmentStack(client, targetTab, tab);

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

@ -54,7 +54,7 @@ function test() {
let { tabs } = yield listTabs(client);
let targetTab = findTab(tabs, TAB_URL);
yield attachTab(client, targetTab);
yield attachTarget(client, targetTab);
yield testGetRejectionStack(client, targetTab, tab);

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

@ -22,7 +22,7 @@ add_task(async function() {
let tab = await addTab(TAB_URL);
let { tabs } = await listTabs(client);
let [, tabClient] = await attachTab(client, findTab(tabs, TAB_URL));
let [, tabClient] = await attachTarget(client, findTab(tabs, TAB_URL));
await listWorkers(tabClient);
await createWorkerInTab(tab, WORKER_URL);

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

@ -179,7 +179,7 @@ function getAddonActorForId(aClient, aAddonId) {
async function attachTargetActorForUrl(aClient, aUrl) {
let grip = await getTargetActorForUrl(aClient, aUrl);
let [ response ] = await aClient.attachTab(grip.actor);
let [ response ] = await aClient.attachTarget(grip.actor);
return [grip, response];
}
@ -1085,9 +1085,9 @@ function findTab(tabs, url) {
return null;
}
function attachTab(client, tab) {
function attachTarget(client, tab) {
info("Attaching to tab with url '" + tab.url + "'.");
return client.attachTab(tab.actor);
return client.attachTarget(tab.actor);
}
function listWorkers(tabClient) {
@ -1297,7 +1297,7 @@ async function initWorkerDebugger(TAB_URL, WORKER_URL) {
let tab = await addTab(TAB_URL);
let { tabs } = await listTabs(client);
let [, tabClient] = await attachTab(client, findTab(tabs, TAB_URL));
let [, tabClient] = await attachTarget(client, findTab(tabs, TAB_URL));
await createWorkerInTab(tab, WORKER_URL);

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

@ -476,7 +476,7 @@ TabTarget.prototype = {
// Attach the target actor
const attachTarget = async () => {
const [response, tabClient] = await this._client.attachTab(this._form.actor);
const [response, tabClient] = await this._client.attachTarget(this._form.actor);
this.activeTab = tabClient;
this.threadActor = response.threadActor;
};

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

@ -452,7 +452,7 @@ OptionsPanel.prototype = {
}
if (this.target.activeTab && !this.target.chrome) {
const [ response ] = await this.target.client.attachTab(this.target.activeTab._actor);
const [ response ] = await this.target.client.attachTarget(this.target.activeTab._actor);
this._origJavascriptEnabled = !response.javascriptEnabled;
this.disableJSNode.checked = this._origJavascriptEnabled;
this.disableJSNode.addEventListener("click", this._disableJSClicked);

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

@ -85,7 +85,7 @@ function attachToTab() {
let tab = response.tabs[response.selected];
// Attach to the tab.
client.attachTab(tab.actor).then(([response, tabClient]) => {
client.attachTarget(tab.actor).then(([response, tabClient]) => {
if (!tabClient) {
return;
}
@ -121,7 +121,7 @@ Once the application is attached to a tab, it can attach to its thread in order
```javascript
// Assuming the application is already attached to the tab, and response is the first
// argument of the attachTab callback.
// argument of the attachTarget callback.
client.attachThread(response.threadActor).then(function([response, threadClient]) {
if (!threadClient) {
@ -195,7 +195,7 @@ function debugTab() {
// Find the active tab.
let tab = response.tabs[response.selected];
// Attach to the tab.
client.attachTab(tab.actor).then(([response, tabClient]) => {
client.attachTarget(tab.actor).then(([response, tabClient]) => {
if (!tabClient) {
return;
}

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

@ -107,7 +107,7 @@ async function connectAndAttachTab() {
});
const form = await connectDebuggerClient(client);
const actorID = form.actor;
await client.attachTab(actorID);
await client.attachTarget(actorID);
return { client, actorID };
}

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

@ -20,7 +20,7 @@ add_task(async function() {
const form = await connectDebuggerClient(client);
info("Attaching to the active tab.");
await client.attachTab(form.actor);
await client.attachTarget(form.actor);
const front = StyleSheetsFront(client, form);
ok(front, "The StyleSheetsFront was created.");

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

@ -18,7 +18,7 @@ add_task(async function() {
const form = await connectDebuggerClient(client);
info("Attaching to the active tab.");
await client.attachTab(form.actor);
await client.attachTarget(form.actor);
const front = StyleSheetsFront(client, form);
ok(front, "The StyleSheetsFront was created.");

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

@ -32,7 +32,7 @@ async function setup(pageUrl) {
const client = new DebuggerClient(DebuggerServer.connectPipe());
const form = await connectDebuggerClient(client);
const [, tabClient] = await client.attachTab(form.actor);
const [, tabClient] = await client.attachTarget(form.actor);
const [, consoleClient] = await client.attachConsole(form.consoleActor, []);

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

@ -67,7 +67,7 @@ function attachURL(url, callback) {
if (tab.url === url) {
window.removeEventListener("message", loadListener);
// eslint-disable-next-line max-nested-callbacks
client.attachTab(tab.actor).then(function() {
client.attachTarget(tab.actor).then(function() {
try {
callback(null, client, tab, win.document);
} catch (ex) {

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

@ -59,7 +59,7 @@ async function attachURL(url) {
throw new Error(`Could not find a tab matching URL ${url}`);
}
const [, tabClient] = await client.attachTab(attachedTab.actor);
const [, tabClient] = await client.attachTarget(attachedTab.actor);
const [, consoleClient] = await client.attachConsole(attachedTab.consoleActor, []);
return {

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

@ -177,9 +177,9 @@ function findTab(tabs, title) {
return null;
}
function attachTab(client, tab) {
function attachTarget(client, tab) {
dump("Attaching to tab with title '" + tab.title + "'.\n");
return client.attachTab(tab.actor);
return client.attachTarget(tab.actor);
}
function waitForNewSource(threadClient, url) {
@ -357,7 +357,7 @@ function getTestTab(client, title, callback) {
// response packet and a TabClient instance referring to that tab.
function attachTestTab(client, title, callback) {
getTestTab(client, title, function(tab) {
client.attachTab(tab.actor).then(([response, tabClient]) => {
client.attachTarget(tab.actor).then(([response, tabClient]) => {
callback(response, tabClient);
});
});

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

@ -15,14 +15,14 @@ add_task(async function() {
const parentProcessActors = await getParentProcessActors(client);
// We have to attach the chrome target actor before playing with the PromiseActor
await attachTab(client, parentProcessActors);
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.");
const [ tabResponse ] = await attachTab(client, targetTab);
const [ tabResponse ] = await attachTarget(client, targetTab);
await testAttach(client, tabResponse);

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

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

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

@ -19,7 +19,7 @@ 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 attachTab(client, parentProcessActors);
await attachTarget(client, parentProcessActors);
await testNewPromisesEvent(client, parentProcessActors,
v => new Promise(resolve => resolve(v)));

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

@ -21,7 +21,7 @@ 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 attachTab(client, parentProcessActors);
await attachTarget(client, parentProcessActors);
await testPromisesSettled(client, parentProcessActors,
v => new Promise(resolve => resolve(v)),
v => new Promise((resolve, reject) => reject(v)));

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

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

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

@ -28,7 +28,7 @@ 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 attachTab(client, parentProcessActors);
await attachTarget(client, parentProcessActors);
await testPromiseCreationTimestamp(client, parentProcessActors, v => {
return new Promise(resolve => resolve(v));
});

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

@ -19,7 +19,7 @@ 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 attachTab(client, parentProcessActors);
await attachTarget(client, parentProcessActors);
await testGetTimeToSettle(client, parentProcessActors, () => {
const p = new Promise(() => {});
p.name = "p";

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

@ -16,19 +16,19 @@ var EventEmitter = require("devtools/shared/event-emitter");
add_task(async function() {
const client = await startTestDebuggerServer("test-promises-timetosettle");
const parentProcessActors = await getParentProcessActors(client);
await attachTab(client, parentProcessActors);
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 attachTab(client, parentProcessActors);
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 attachTab(client, targetTab);
await attachTarget(client, targetTab);
await testGetTimeToSettle(client, targetTab, v => {
const debuggee =

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

@ -15,7 +15,7 @@ async function run_test() {
const { tabs } = await listTabs(client);
const tab = findTab(tabs, "test");
const [, tabClient] = await attachTab(client, tab);
const [, tabClient] = await attachTarget(client, tab);
const [, threadClient] = await attachThread(tabClient);
await resume(threadClient);

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

@ -17,7 +17,7 @@ async function run_test() {
const { tabs } = await listTabs(client);
const tab = findTab(tabs, "test");
const [, tabClient] = await attachTab(client, tab);
const [, tabClient] = await attachTarget(client, tab);
const [, threadClient] = await attachThread(tabClient);
await resume(threadClient);

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

@ -19,7 +19,7 @@ function run_test() {
const { tabs } = await listTabs(client);
const tab = findTab(tabs, "test");
const [, tabClient] = await attachTab(client, tab);
const [, tabClient] = await attachTarget(client, tab);
const [, threadClient] = await attachThread(tabClient);
await resume(threadClient);

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

@ -18,7 +18,7 @@ function run_test() {
const { tabs } = await listTabs(client);
const tab = findTab(tabs, "test");
const [, tabClient] = await attachTab(client, tab);
const [, tabClient] = await attachTarget(client, tab);
const [, threadClient] = await attachThread(tabClient);
await resume(threadClient);

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

@ -19,7 +19,7 @@ function run_test() {
const { tabs } = await listTabs(client);
const tab = findTab(tabs, "test");
const [, tabClient] = await attachTab(client, tab);
const [, tabClient] = await attachTarget(client, tab);
const [, threadClient] = await attachThread(tabClient);
await resume(threadClient);

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

@ -18,7 +18,7 @@ function run_test() {
const { tabs } = await listTabs(client);
const tab = findTab(tabs, "test");
const [, tabClient] = await attachTab(client, tab);
const [, tabClient] = await attachTarget(client, tab);
const [, threadClient] = await attachThread(tabClient);
await resume(threadClient);

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

@ -18,7 +18,7 @@ function run_test() {
const { tabs } = await listTabs(client);
const tab = findTab(tabs, "test");
const [, tabClient] = await attachTab(client, tab);
const [, tabClient] = await attachTarget(client, tab);
const [, threadClient] = await attachThread(tabClient);
await resume(threadClient);

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

@ -20,7 +20,7 @@ function run_test() {
const { tabs } = await listTabs(client);
const tab = findTab(tabs, "test");
const [, tabClient] = await attachTab(client, tab);
const [, tabClient] = await attachTarget(client, tab);
const [, threadClient] = await attachThread(tabClient);
await resume(threadClient);

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

@ -18,7 +18,7 @@ function run_test() {
const { tabs } = await listTabs(client);
const tab = findTab(tabs, "test");
const [, tabClient] = await attachTab(client, tab);
const [, tabClient] = await attachTarget(client, tab);
const [, threadClient] = await attachThread(tabClient);
await resume(threadClient);

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

@ -18,7 +18,7 @@ function run_test() {
const { tabs } = await listTabs(client);
const tab = findTab(tabs, "test");
const [, tabClient] = await attachTab(client, tab);
const [, tabClient] = await attachTarget(client, tab);
const [, threadClient] = await attachThread(tabClient);
await resume(threadClient);

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

@ -29,7 +29,7 @@ add_task(async function() {
const response = await client.getProcess();
const actor = response.form.actor;
const [, tabClient] = await client.attachTab(actor);
const [, tabClient] = await client.attachTarget(actor);
const [, threadClient] = await tabClient.attachThread(null);
const onResumed = new Promise(resolve => {
threadClient.addOneTimeListener("paused", (event, packet) => {

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

@ -327,20 +327,20 @@ DebuggerClient.prototype = {
},
/**
* Attach to a tab's target actor.
* Attach to a target actor.
*
* @param string targetActor
* The target actor ID for the tab to attach.
*/
attachTab: function(targetActor) {
attachTarget: function(targetActor) {
if (this._clients.has(targetActor)) {
const cachedTab = this._clients.get(targetActor);
const cachedTarget = this._clients.get(targetActor);
const cachedResponse = {
cacheDisabled: cachedTab.cacheDisabled,
javascriptEnabled: cachedTab.javascriptEnabled,
traits: cachedTab.traits,
cacheDisabled: cachedTarget.cacheDisabled,
javascriptEnabled: cachedTarget.javascriptEnabled,
traits: cachedTarget.traits,
};
return promise.resolve([cachedResponse, cachedTab]);
return promise.resolve([cachedResponse, cachedTarget]);
}
const packet = {
@ -348,9 +348,12 @@ DebuggerClient.prototype = {
type: "attach"
};
return this.request(packet).then(response => {
const tabClient = new TabClient(this, response);
this.registerClient(tabClient);
return [response, tabClient];
// TabClient can actually represent targets other than a tab.
// It is planned to be renamed while being converted to a front
// in bug 1485660.
const targetClient = new TabClient(this, response);
this.registerClient(targetClient);
return [response, targetClient];
});
},

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

@ -79,7 +79,7 @@ var _attachConsole = async function(
if (!attachToTab) {
response = await state.dbgClient.getProcess();
await state.dbgClient.attachTab(response.form.actor);
await state.dbgClient.attachTarget(response.form.actor);
const consoleActor = response.form.consoleActor;
state.actor = consoleActor;
state.dbgClient.attachConsole(consoleActor, listeners)
@ -94,7 +94,7 @@ var _attachConsole = async function(
return;
}
const tab = response.tabs[response.selected];
const [, tabClient] = await state.dbgClient.attachTab(tab.actor);
const [, tabClient] = await state.dbgClient.attachTarget(tab.actor);
if (attachToWorker) {
const workerName = "console-test-worker.js#" + new Date().getTime();
const worker = new Worker(workerName);