mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 16:25:38 +00:00
Bug 1581093 - Fix blank DevTools window in private browsing, set private flag on host window r=ochameau
Differential Revision: https://phabricator.services.mozilla.com/D56636 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
932bbcdba9
commit
1d6c24996c
@ -16,38 +16,62 @@ add_task(async function runTest() {
|
||||
target = await TargetFactory.forTab(tab);
|
||||
toolbox = await gDevTools.showToolbox(target, "webconsole");
|
||||
|
||||
await testBottomHost();
|
||||
await testLeftHost();
|
||||
await testRightHost();
|
||||
await testWindowHost();
|
||||
await testToolSelect();
|
||||
await testDestroy();
|
||||
await testRememberHost();
|
||||
await testPreviousHost();
|
||||
|
||||
await runHostTests(gBrowser);
|
||||
await toolbox.destroy();
|
||||
|
||||
toolbox = target = null;
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
||||
|
||||
function testBottomHost() {
|
||||
// We run the same host switching tests in a private window.
|
||||
// See Bug 1581093 for an example of issue specific to private windows.
|
||||
add_task(async function runPrivateWindowTest() {
|
||||
info("Create a private window + tab and open the toolbox");
|
||||
const privateWindow = await BrowserTestUtils.openNewBrowserWindow({
|
||||
private: true,
|
||||
});
|
||||
const privateBrowser = privateWindow.gBrowser;
|
||||
privateBrowser.selectedTab = BrowserTestUtils.addTab(privateBrowser, URL);
|
||||
|
||||
const tab = privateBrowser.selectedTab;
|
||||
target = await TargetFactory.forTab(tab);
|
||||
toolbox = await gDevTools.showToolbox(target, "webconsole");
|
||||
|
||||
await runHostTests(privateBrowser);
|
||||
await toolbox.destroy();
|
||||
|
||||
toolbox = target = null;
|
||||
await BrowserTestUtils.closeWindow(privateWindow);
|
||||
});
|
||||
|
||||
async function runHostTests(browser) {
|
||||
await testBottomHost(browser);
|
||||
await testLeftHost(browser);
|
||||
await testRightHost(browser);
|
||||
await testWindowHost(browser);
|
||||
await testToolSelect();
|
||||
await testDestroy(browser);
|
||||
await testRememberHost();
|
||||
await testPreviousHost();
|
||||
}
|
||||
|
||||
function testBottomHost(browser) {
|
||||
checkHostType(toolbox, BOTTOM);
|
||||
|
||||
// test UI presence
|
||||
const panel = gBrowser.getPanel();
|
||||
const panel = browser.getPanel();
|
||||
const iframe = panel.querySelector(".devtools-toolbox-bottom-iframe");
|
||||
ok(iframe, "toolbox bottom iframe exists");
|
||||
|
||||
checkToolboxLoaded(iframe);
|
||||
}
|
||||
|
||||
async function testLeftHost() {
|
||||
async function testLeftHost(browser) {
|
||||
await toolbox.switchHost(LEFT);
|
||||
checkHostType(toolbox, LEFT);
|
||||
|
||||
// test UI presence
|
||||
const panel = gBrowser.getPanel();
|
||||
const panel = browser.getPanel();
|
||||
const bottom = panel.querySelector(".devtools-toolbox-bottom-iframe");
|
||||
ok(!bottom, "toolbox bottom iframe doesn't exist");
|
||||
|
||||
@ -57,12 +81,12 @@ async function testLeftHost() {
|
||||
checkToolboxLoaded(iframe);
|
||||
}
|
||||
|
||||
async function testRightHost() {
|
||||
async function testRightHost(browser) {
|
||||
await toolbox.switchHost(RIGHT);
|
||||
checkHostType(toolbox, RIGHT);
|
||||
|
||||
// test UI presence
|
||||
const panel = gBrowser.getPanel();
|
||||
const panel = browser.getPanel();
|
||||
const bottom = panel.querySelector(".devtools-toolbox-bottom-iframe");
|
||||
ok(!bottom, "toolbox bottom iframe doesn't exist");
|
||||
|
||||
@ -72,11 +96,11 @@ async function testRightHost() {
|
||||
checkToolboxLoaded(iframe);
|
||||
}
|
||||
|
||||
async function testWindowHost() {
|
||||
async function testWindowHost(browser) {
|
||||
await toolbox.switchHost(WINDOW);
|
||||
checkHostType(toolbox, WINDOW);
|
||||
|
||||
const panel = gBrowser.getPanel();
|
||||
const panel = browser.getPanel();
|
||||
const sidebar = panel.querySelector(".devtools-toolbox-side-iframe");
|
||||
ok(!sidebar, "toolbox sidebar iframe doesn't exist");
|
||||
|
||||
@ -92,9 +116,9 @@ async function testToolSelect() {
|
||||
await toolbox.selectTool("inspector");
|
||||
}
|
||||
|
||||
async function testDestroy() {
|
||||
async function testDestroy(browser) {
|
||||
await toolbox.destroy();
|
||||
target = await TargetFactory.forTab(gBrowser.selectedTab);
|
||||
target = await TargetFactory.forTab(browser.selectedTab);
|
||||
toolbox = await gDevTools.showToolbox(target);
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,13 @@ loader.lazyRequireGetter(
|
||||
true
|
||||
);
|
||||
|
||||
loader.lazyRequireGetter(
|
||||
this,
|
||||
"PrivateBrowsingUtils",
|
||||
"resource://gre/modules/PrivateBrowsingUtils.jsm",
|
||||
true
|
||||
);
|
||||
|
||||
/* A host should always allow this much space for the page to be displayed.
|
||||
* There is also a min-height on the browser, but we still don't want to set
|
||||
* frame.height to be larger than that, since it can cause problems with
|
||||
@ -234,9 +241,9 @@ class RightHost extends SidebarHost {
|
||||
/**
|
||||
* Host object for the toolbox in a separate window
|
||||
*/
|
||||
function WindowHost() {
|
||||
function WindowHost(hostTab) {
|
||||
this._boundUnload = this._boundUnload.bind(this);
|
||||
|
||||
this.hostTab = hostTab;
|
||||
EventEmitter.decorate(this);
|
||||
}
|
||||
|
||||
@ -250,7 +257,19 @@ WindowHost.prototype = {
|
||||
*/
|
||||
create: function() {
|
||||
return new Promise(resolve => {
|
||||
const flags = "chrome,centerscreen,resizable,dialog=no";
|
||||
let flags = "chrome,centerscreen,resizable,dialog=no";
|
||||
|
||||
// If we are debugging a tab which is in a Private window, we must also
|
||||
// set the private flag on the DevTools host window. Otherwise switching
|
||||
// hosts between docked and window modes can fail due to incompatible
|
||||
// docshell origin attributes. See 1581093.
|
||||
if (
|
||||
this.hostTab &&
|
||||
PrivateBrowsingUtils.isWindowPrivate(this.hostTab.ownerGlobal)
|
||||
) {
|
||||
flags += ",private";
|
||||
}
|
||||
|
||||
const win = Services.ww.openWindow(
|
||||
null,
|
||||
this.WINDOW_URL,
|
||||
|
Loading…
Reference in New Issue
Block a user