mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 01:05:45 +00:00
Bug 1539071 - Wait for toolbox destroy to finish before reloading toolbox tab;r=daisuke
Differential Revision: https://phabricator.services.mozilla.com/D26010 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
56fffce764
commit
b6dc05b08d
@ -55,6 +55,7 @@ support-files =
|
||||
!/devtools/client/shared/test/telemetry-test-helpers.js
|
||||
|
||||
[browser_about-devtools-toolbox_load.js]
|
||||
[browser_about-devtools-toolbox_reload.js]
|
||||
[browser_browser_toolbox.js]
|
||||
skip-if = coverage # Bug 1387827
|
||||
[browser_browser_toolbox_debugger.js]
|
||||
|
@ -26,17 +26,3 @@ add_task(async function() {
|
||||
ok(doc.querySelector(".js-error-page"), "Error page is rendered");
|
||||
}
|
||||
});
|
||||
|
||||
async function openAboutToolbox(params) {
|
||||
info("opening about:devtools-toolbox");
|
||||
const querystring = new URLSearchParams();
|
||||
Object.keys(params).forEach(x => querystring.append(x, params[x]));
|
||||
|
||||
const tab = await addTab(`about:devtools-toolbox?${querystring}`);
|
||||
const browser = tab.linkedBrowser;
|
||||
|
||||
return {
|
||||
tab,
|
||||
document: browser.contentDocument,
|
||||
};
|
||||
}
|
||||
|
@ -0,0 +1,54 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Test that about:devtools-toolbox is reloaded correctly when reusing the same debugger
|
||||
* client instance.
|
||||
*/
|
||||
add_task(async function() {
|
||||
const debuggerClient = await createLocalClient();
|
||||
|
||||
info("Preload a local DebuggerClient as this-firefox in the remoteClientManager");
|
||||
const { remoteClientManager } =
|
||||
require("devtools/client/shared/remote-debugging/remote-client-manager");
|
||||
remoteClientManager.setClient("this-firefox", "this-firefox", debuggerClient);
|
||||
registerCleanupFunction(() => {
|
||||
remoteClientManager.removeAllClients();
|
||||
});
|
||||
|
||||
info("Create a dummy target tab");
|
||||
const targetTab = await addTab("data:text/html,somehtml");
|
||||
|
||||
const { tab } = await openAboutToolbox({
|
||||
id: targetTab.linkedBrowser.outerWindowID,
|
||||
remoteId: "this-firefox-this-firefox",
|
||||
type: "tab",
|
||||
});
|
||||
|
||||
info("Reload about:devtools-toolbox page");
|
||||
const onToolboxReady = gDevTools.once("toolbox-ready");
|
||||
tab.linkedBrowser.reload();
|
||||
await onToolboxReady;
|
||||
|
||||
info("Check if about:devtools-toolbox was reloaded correctly");
|
||||
const refreshedDoc = tab.linkedBrowser.contentDocument;
|
||||
ok(refreshedDoc.querySelector(".debug-target-info"),
|
||||
"about:devtools-toolbox header is correctly displayed");
|
||||
|
||||
await removeTab(tab);
|
||||
await removeTab(targetTab);
|
||||
});
|
||||
|
||||
async function createLocalClient() {
|
||||
const { DebuggerClient } = require("devtools/shared/client/debugger-client");
|
||||
const { DebuggerServer } = require("devtools/server/main");
|
||||
DebuggerServer.init();
|
||||
DebuggerServer.registerAllActors();
|
||||
DebuggerServer.allowChromeProcess = true;
|
||||
|
||||
const debuggerClient = new DebuggerClient(DebuggerServer.connectPipe());
|
||||
await debuggerClient.connect();
|
||||
return debuggerClient;
|
||||
}
|
@ -389,3 +389,21 @@ function assertSelectedLocationInDebugger(debuggerPanel, line, column) {
|
||||
is(location.line, line);
|
||||
is(location.column, column);
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a new tab on about:devtools-toolbox with the provided params object used as
|
||||
* queryString.
|
||||
*/
|
||||
async function openAboutToolbox(params) {
|
||||
info("Open about:devtools-toolbox");
|
||||
const querystring = new URLSearchParams();
|
||||
Object.keys(params).forEach(x => querystring.append(x, params[x]));
|
||||
|
||||
const tab = await addTab(`about:devtools-toolbox?${querystring}`);
|
||||
const browser = tab.linkedBrowser;
|
||||
|
||||
return {
|
||||
tab,
|
||||
document: browser.contentDocument,
|
||||
};
|
||||
}
|
||||
|
@ -108,6 +108,14 @@ async function initToolbox(url, host) {
|
||||
target = await client.mainRoot.getTab({ tab });
|
||||
} else {
|
||||
target = await targetFromURL(url);
|
||||
const toolbox = gDevTools.getToolbox(target);
|
||||
if (toolbox && toolbox.isDestroying()) {
|
||||
// If a toolbox already exists for the target, wait for current toolbox destroy to
|
||||
// be finished and retrieve a new valid target. The ongoing toolbox destroy will
|
||||
// destroy the target, so it can not be reused.
|
||||
await toolbox.destroy();
|
||||
target = await targetFromURL(url);
|
||||
}
|
||||
}
|
||||
const options = { customIframe: host };
|
||||
await gDevTools.showToolbox(target, tool, Toolbox.HostType.PAGE, options);
|
||||
|
@ -2905,6 +2905,13 @@ Toolbox.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Public API to check is the current toolbox is currently being destroyed.
|
||||
*/
|
||||
isDestroying: function() {
|
||||
return this._destroyer;
|
||||
},
|
||||
|
||||
/**
|
||||
* Remove all UI elements, detach from target and clear up
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user