Skip to content

Commit

Permalink
Bug 1740292 - [devtools] Stop calling target front attach method. r=n…
Browse files Browse the repository at this point in the history
…chevobbe

Previous patches made attach method become a no-op, so all these callsites can be removed.

Differential Revision: https://phabricator.services.mozilla.com/D130913
  • Loading branch information
ochameau committed Nov 18, 2021
1 parent 5aea7b3 commit 487d967
Show file tree
Hide file tree
Showing 14 changed files with 7 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ add_task(async function() {

const descriptorFront = await client.mainRoot.getMainProcess();
const front = await descriptorFront.getTarget();
await front.attach();
const threadFront = await front.attachThread();

gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, "about:mozilla");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ async function testMainProcess() {

const targetDescriptor = await client.mainRoot.getMainProcess();
const target = await targetDescriptor.getTarget();
await target.attach();

const threadFront = await target.attachThread();
const { sources } = await threadFront.getSources();
Expand Down
2 changes: 0 additions & 2 deletions devtools/client/framework/test/browser_target_support.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
// Test support methods on Target, such as `hasActor` and `getTrait`.

async function testTarget(client, target) {
await target.attach();

is(
target.hasActor("inspector"),
true,
Expand Down
2 changes: 0 additions & 2 deletions devtools/client/framework/test/browser_two_tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ async function checkGetTabFailures(client) {

async function checkSelectedTargetActor(targetFront2) {
// Send a naive request to the second target actor to check if it works
await targetFront2.attach();
const consoleFront = await targetFront2.getFront("console");
const response = await consoleFront.startListeners([]);
ok(
Expand All @@ -97,7 +96,6 @@ async function checkSelectedTargetActor(targetFront2) {

async function checkFirstTargetActor(targetFront1) {
// then send a request to the first target actor to check if it still works
await targetFront1.attach();
const consoleFront = await targetFront1.getFront("console");
const response = await consoleFront.startListeners([]);
ok(
Expand Down
1 change: 0 additions & 1 deletion devtools/client/fronts/descriptors/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ class ProcessDescriptorFront extends DescriptorMixin(
try {
const targetForm = await super.getTarget();
targetFront = await this._createProcessTargetFront(targetForm);
await targetFront.attach();
} catch (e) {
// This is likely to happen if we get a lot of events which drop previous
// processes.
Expand Down
1 change: 0 additions & 1 deletion devtools/client/fronts/descriptors/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ class TabDescriptorFront extends DescriptorMixin(
try {
const targetForm = await super.getTarget();
newTargetFront = this._createTabTarget(targetForm);
await newTargetFront.attach();
this.setTarget(newTargetFront);
} catch (e) {
console.log(
Expand Down
1 change: 0 additions & 1 deletion devtools/client/fronts/descriptors/webextension.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ class WebExtensionDescriptorFront extends DescriptorMixin(
try {
const targetForm = await super.getTarget();
targetFront = this._createWebExtensionTarget(targetForm);
await targetFront.attach();
} catch (e) {
console.log(
`Request to connect to WebExtensionDescriptor "${this.id}" failed: ${e}`
Expand Down
3 changes: 0 additions & 3 deletions devtools/client/responsive/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -755,9 +755,6 @@ class ResponsiveUI {
// enterResponsiveMode whenever there is a target switch.
this.tab.linkedBrowser.enterResponsiveMode();

// Attach current target to the selected browser tab.
await this.currentTarget.attach();

// If the target follows the window global lifecycle, the configuration was already
// restored from the server during target switch, so we can stop here.
// This function is still called at startup to restore potential state from previous
Expand Down
1 change: 0 additions & 1 deletion devtools/client/shared/test/shared-head.js
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,6 @@ async function createAndAttachTargetForTab(tab) {
await commands.targetCommand.startListening();

const target = commands.targetCommand.targetFront;
await target.attach();
return target;
}

Expand Down
11 changes: 2 additions & 9 deletions devtools/docs/contributor/backend/client-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,8 @@ function attachToTab() {
// Find the active tab.
let targetFront = tabs.find(tab => tab.selected);

// Attach to the tab.
targetFront.attach().then(() => {
// Now the targetFront is ready and can be used.

// Attach listeners for client events.
targetFront.on("tabNavigated", onTab);
});
// Attach listeners for client events.
targetFront.on("tabNavigated", onTab);
});
}
```
Expand Down Expand Up @@ -169,8 +164,6 @@ async function debugTab() {
const tabs = await client.mainRoot.listTabs();
// Find the active tab.
let targetFront = tabs.find(tab => tab.selected);
// Attach to the tab.
await targetFront.attach();
// Attach to the thread (context).
const threadFront = await targetFront.attachThread();
// Attach listeners for thread events.
Expand Down
1 change: 0 additions & 1 deletion devtools/server/tests/xpcshell/head_dbg.js
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,6 @@ async function setupTestFromUrl(url) {
const tabs = await listTabs(devToolsClient);
const descriptorFront = findTab(tabs, "test");
const targetFront = await descriptorFront.getTarget();
await targetFront.attach();

const threadFront = await attachThread(targetFront);

Expand Down
4 changes: 2 additions & 2 deletions devtools/shared/commands/commands-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ exports.CommandsFactory = {
// Hack something in order to help TargetMixinFront to distinguish the BrowserConsole
descriptor.createdForBrowserConsole = true;

const target = await descriptor.getTarget();
await target.attach();
// Force fetching the first top level target right away.
await descriptor.getTarget();

const commands = await createCommandsDictionary(descriptor);
return commands;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ async function checkBreakpointBeforeWatchResources() {
tab
);

// Attach the thread actor before running the debugger statement,
// so that it is correctly catched by the thread actor.
info("Attach the top level target");
await targetCommand.targetFront.attach();
// Init the Thread actor via attachAndInitThread in order to ensure
// memoizing the thread front and avoid attaching it twice
info("Attach the top level thread actor");
Expand Down Expand Up @@ -348,9 +344,6 @@ async function checkSetBeforeWatch() {
tab
);

// Attach the target in order to create the thread actor
info("Attach the top level target");
await targetCommand.targetFront.attach();
// Instantiate the thread front in order to be able to set a breakpoint before watching for thread state
info("Attach the top level thread actor");
await targetCommand.targetFront.attachAndInitThread(targetCommand);
Expand Down
6 changes: 3 additions & 3 deletions devtools/shared/webconsole/test/chrome/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ var _attachConsole = async function(listeners, attachToTab, attachToWorker) {
worker = new Worker(workerName);
await waitForMessage(worker);

// listWorkers only works if the browsing context target actor is attached
await target.attach();
const { workers } = await target.listWorkers();
target = workers.filter(w => w.url == workerName)[0];
if (!target) {
Expand All @@ -85,11 +83,13 @@ var _attachConsole = async function(listeners, attachToTab, attachToWorker) {
);
return null;
}
// This is still important to attach workers as target is still a descriptor front
// which "becomes" a target when calling its attach method.
await target.attach();
}
}

// Attach the Target and the target thread in order to instantiate the console client.
await target.attach();
await target.attachThread();

const webConsoleFront = await target.getFront("console");
Expand Down

0 comments on commit 487d967

Please sign in to comment.