--- a/devtools/client/debugger/test/mochitest/browser_dbg_breakpoints-other-tabs.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_breakpoints-other-tabs.js
@@ -32,11 +32,10 @@ var test = Task.async(function* () {
callInTab(tab2, "testCase");
const packet = yield paused;
is(packet.why.type, "debuggerStatement",
"Should have stopped at the debugger statement, not the other tab's breakpoint");
is(packet.frame.where.line, 3,
"Should have stopped at line 3 (debugger statement), not line 2 (other tab's breakpoint)");
- yield teardown(panel1);
yield resumeDebuggerThenCloseAndFinish(panel2);
});
--- a/devtools/client/debugger/test/mochitest/browser_dbg_host-layout.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_host-layout.js
@@ -79,34 +79,34 @@ function getHost(host) {
if (host.indexOf("window") == 0) {
return "window";
}
return host;
}
function resizeToolboxWindow(panel, host) {
let sizeOption = host.split(":")[1];
- let win = panel._toolbox._host._window;
+ let win = panel._toolbox.win.parent;
// should be the same value as BREAKPOINT_SMALL_WINDOW_WIDTH in debugger-view.js
let breakpoint = 850;
if (sizeOption == "big" && win.outerWidth <= breakpoint) {
yield resizeAndWaitForLayoutChange(panel, breakpoint + 300);
} else if (sizeOption == "small" && win.outerWidth >= breakpoint) {
yield resizeAndWaitForLayoutChange(panel, breakpoint - 300);
} else {
info("Window resize unnecessary for host " + host);
}
}
function resizeAndWaitForLayoutChange(panel, width) {
info("Updating toolbox window width to " + width);
- let win = panel._toolbox._host._window;
+ let win = panel._toolbox.win.parent;
let gDebugger = panel.panelWin;
win.resizeTo(width, window.screen.availHeight);
yield waitEventOnce(gDebugger, gDebugger.EVENTS.LAYOUT_CHANGED);
}
function testHost(aPanel, aHostType, aLayoutType) {
let gDebugger = aPanel.panelWin;
--- a/devtools/client/debugger/test/mochitest/browser_dbg_worker-window.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_worker-window.js
@@ -29,18 +29,27 @@ add_task(function* () {
let { workers } = yield listWorkers(tabClient);
let [, workerClient] = yield attachWorker(tabClient,
findWorker(workers, WORKER_URL));
let toolbox = yield gDevTools.showToolbox(TargetFactory.forWorker(workerClient),
"jsdebugger",
Toolbox.HostType.WINDOW);
- is(toolbox._host.type, "window", "correct host");
- ok(toolbox._host._window.document.title.includes(WORKER_URL),
+ is(toolbox.hostType, "window", "correct host");
+
+ yield new Promise(done => {
+ toolbox.win.parent.addEventListener("message", function onmessage(event) {
+ if (event.data.name == "set-host-title") {
+ toolbox.win.parent.removeEventListener("message", onmessage);
+ done();
+ }
+ });
+ });
+ ok(toolbox.win.parent.document.title.includes(WORKER_URL),
"worker URL in host title");
let toolTabs = toolbox.doc.querySelectorAll(".devtools-tab");
let activeTools = [...toolTabs].map(tab=>tab.getAttribute("toolid"));
is(activeTools.join(","), "webconsole,jsdebugger,scratchpad,options",
"Correct set of tools supported by worker");
--- a/devtools/client/debugger/test/mochitest/head.js
+++ b/devtools/client/debugger/test/mochitest/head.js
@@ -742,16 +742,19 @@ AddonDebugger.prototype = {
groupmap.get(group).get(label).url = source.url.split(" -> ").pop();
}
return groups;
}),
_onMessage: function (event) {
+ if (typeof(event.data) !== "string") {
+ return;
+ }
let json = JSON.parse(event.data);
switch (json.name) {
case "toolbox-title":
this.title = json.data.value;
break;
}
}
};
--- a/devtools/client/framework/test/browser_devtools_api.js
+++ b/devtools/client/framework/test/browser_devtools_api.js
@@ -66,17 +66,17 @@ function runTests1(aTab) {
toolbox.once(toolId1 + "-ready", (event, panel) => {
ok(panel, "panel argument available");
events["ready"] = true;
});
});
gDevTools.showToolbox(target, toolId1).then(function (toolbox) {
is(toolbox.target, target, "toolbox target is correct");
- is(toolbox._host.hostTab, gBrowser.selectedTab, "toolbox host is correct");
+ is(toolbox.target.tab, gBrowser.selectedTab, "targeted tab is correct");
ok(events["init"], "init event fired");
ok(events["ready"], "ready event fired");
gDevTools.unregisterTool(toolId1);
// Wait for unregisterTool to select the next tool before calling runTests2,
// otherwise we will receive the wrong select event when waiting for
@@ -134,17 +134,17 @@ function runTests2() {
toolbox.once(toolId2 + "-ready", (event, panel) => {
ok(panel, "panel argument available");
events["ready"] = true;
});
});
gDevTools.showToolbox(target, toolId2).then(function (toolbox) {
is(toolbox.target, target, "toolbox target is correct");
- is(toolbox._host.hostTab, gBrowser.selectedTab, "toolbox host is correct");
+ is(toolbox.target.tab, gBrowser.selectedTab, "targeted tab is correct");
ok(events["init"], "init event fired");
ok(events["build"], "build event fired");
ok(events["ready"], "ready event fired");
continueTests(toolbox);
});
}
--- a/devtools/client/framework/test/browser_toolbox_custom_host.js
+++ b/devtools/client/framework/test/browser_toolbox_custom_host.js
@@ -22,16 +22,19 @@ function test() {
gDevTools.showToolbox(target, null, Toolbox.HostType.CUSTOM, options)
.then(testCustomHost, console.error)
.then(null, console.error);
}, true);
content.location = "data:text/html,test custom host";
function onMessage(event) {
+ if (typeof(event.data) !== "string") {
+ return;
+ }
info("onMessage: " + event.data);
let json = JSON.parse(event.data);
if (json.name == "toolbox-close") {
ok("Got the `toolbox-close` message");
window.removeEventListener("message", onMessage);
cleanup();
}
}
--- a/devtools/client/framework/test/browser_toolbox_raise.js
+++ b/devtools/client/framework/test/browser_toolbox_raise.js
@@ -40,35 +40,35 @@ function testBottomHost(aToolbox) {
function testWindowHost() {
// Make sure toolbox is not focused.
window.addEventListener("focus", onFocus, true);
// Need to wait for focus as otherwise window.focus() is overridden by
// toolbox window getting focused first on Linux and Mac.
let onToolboxFocus = () => {
- toolbox._host._window.removeEventListener("focus", onToolboxFocus, true);
+ toolbox.win.parent.removeEventListener("focus", onToolboxFocus, true);
info("focusing main window.");
window.focus();
};
// Need to wait for toolbox window to get focus.
- toolbox._host._window.addEventListener("focus", onToolboxFocus, true);
+ toolbox.win.parent.addEventListener("focus", onToolboxFocus, true);
}
function onFocus() {
info("Main window is focused before calling toolbox.raise()");
window.removeEventListener("focus", onFocus, true);
// Check if toolbox window got focus.
let onToolboxFocusAgain = () => {
- toolbox._host._window.removeEventListener("focus", onToolboxFocusAgain, false);
+ toolbox.win.parent.removeEventListener("focus", onToolboxFocusAgain, false);
ok(true, "Toolbox window is the focused window after calling toolbox.raise()");
cleanup();
};
- toolbox._host._window.addEventListener("focus", onToolboxFocusAgain, false);
+ toolbox.win.parent.addEventListener("focus", onToolboxFocusAgain, false);
// Now raise toolbox.
toolbox.raise();
}
function cleanup() {
Services.prefs.setCharPref("devtools.toolbox.host", Toolbox.HostType.BOTTOM);
--- a/devtools/client/framework/test/browser_toolbox_toggle.js
+++ b/devtools/client/framework/test/browser_toolbox_toggle.js
@@ -77,17 +77,17 @@ function* testToggleDetachedToolbox(tab,
let onMainWindowFocus = once(window, "focus");
window.focus();
yield onMainWindowFocus;
ok(true, "Main window focused");
info("Verify windowed toolbox is focused instead of closed when using " +
"toggle key from the main window");
- let toolboxWindow = toolbox._host._window;
+ let toolboxWindow = toolbox.win.top;
let onToolboxWindowFocus = once(toolboxWindow, "focus", true);
EventUtils.synthesizeKey(key, modifiers);
yield onToolboxWindowFocus;
ok(true, "Toolbox focused and not destroyed");
info("Verify windowed toolbox is destroyed when using toggle key from its " +
"own window");
--- a/devtools/client/framework/test/browser_toolbox_window_title_changes.js
+++ b/devtools/client/framework/test/browser_toolbox_window_title_changes.js
@@ -2,16 +2,28 @@
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
requestLongerTimeout(5);
var {Toolbox} = require("devtools/client/framework/toolbox");
+// Wait for a given toolbox to get its title updated
+function waitForTitleChange(toolbox) {
+ let deferred = defer();
+ toolbox.win.parent.addEventListener("message", function onmessage(event) {
+ if (event.data.name == "set-host-title") {
+ toolbox.win.parent.removeEventListener("message", onmessage);
+ deferred.resolve();
+ }
+ });
+ return deferred.promise;
+}
+
function test() {
const URL_1 = "data:text/plain;charset=UTF-8,abcde";
const URL_2 = "data:text/plain;charset=UTF-8,12345";
const URL_3 = URL_ROOT + "browser_toolbox_window_title_changes_page.html";
const TOOL_ID_1 = "webconsole";
const TOOL_ID_2 = "jsdebugger";
@@ -23,55 +35,66 @@ function test() {
addTab(URL_1).then(function () {
let target = TargetFactory.forTab(gBrowser.selectedTab);
gDevTools.showToolbox(target, null, Toolbox.HostType.BOTTOM)
.then(function (aToolbox) { toolbox = aToolbox; })
.then(() => toolbox.selectTool(TOOL_ID_1))
// undock toolbox and check title
- .then(() => toolbox.switchHost(Toolbox.HostType.WINDOW))
+ .then(() => {
+ // We have to first switch the host in order to spawn the new top level window
+ // on which we are going to listen from title change event
+ return toolbox.switchHost(Toolbox.HostType.WINDOW)
+ .then(() => waitForTitleChange(toolbox));
+ })
.then(checkTitle.bind(null, NAME_1, URL_1, "toolbox undocked"))
// switch to different tool and check title
- .then(() => toolbox.selectTool(TOOL_ID_2))
+ .then(() => {
+ let onTitleChanged = waitForTitleChange(toolbox);
+ toolbox.selectTool(TOOL_ID_2);
+ return onTitleChanged;
+ })
.then(checkTitle.bind(null, NAME_1, URL_1, "tool changed"))
// navigate to different local url and check title
.then(function () {
- let deferred = defer();
- target.once("navigate", () => deferred.resolve());
+ let onTitleChanged = waitForTitleChange(toolbox);
gBrowser.loadURI(URL_2);
- return deferred.promise;
+ return onTitleChanged;
})
.then(checkTitle.bind(null, NAME_2, URL_2, "url changed"))
// navigate to a real url and check title
.then(() => {
- let deferred = defer();
- target.once("navigate", () => deferred.resolve());
+ let onTitleChanged = waitForTitleChange(toolbox);
gBrowser.loadURI(URL_3);
- return deferred.promise;
+ return onTitleChanged;
})
.then(checkTitle.bind(null, NAME_3, URL_3, "url changed"))
// destroy toolbox, create new one hosted in a window (with a
// different tool id), and check title
.then(function () {
// Give the tools a chance to handle the navigation event before
// destroying the toolbox.
executeSoon(function () {
toolbox.destroy()
.then(function () {
// After destroying the toolbox, a fresh target is required.
target = TargetFactory.forTab(gBrowser.selectedTab);
return gDevTools.showToolbox(target, null, Toolbox.HostType.WINDOW);
})
.then(function (aToolbox) { toolbox = aToolbox; })
- .then(() => toolbox.selectTool(TOOL_ID_1))
+ .then(() => {
+ let onTitleChanged = waitForTitleChange(toolbox);
+ toolbox.selectTool(TOOL_ID_1);
+ return onTitleChanged;
+ })
.then(checkTitle.bind(null, NAME_3, URL_3,
"toolbox destroyed and recreated"))
// clean up
.then(() => toolbox.destroy())
.then(function () {
toolbox = null;
gBrowser.removeCurrentTab();
--- a/devtools/client/framework/test/browser_toolbox_window_title_frame_select.js
+++ b/devtools/client/framework/test/browser_toolbox_window_title_frame_select.js
@@ -20,18 +20,24 @@ const IFRAME_URL = URL_ROOT + "browser_t
add_task(function* () {
Services.prefs.setBoolPref("devtools.command-button-frames.enabled", true);
yield addTab(URL);
let target = TargetFactory.forTab(gBrowser.selectedTab);
let toolbox = yield gDevTools.showToolbox(target, null,
Toolbox.HostType.BOTTOM);
+ let onTitleChanged = waitForTitleChange(toolbox);
yield toolbox.selectTool("inspector");
+ yield onTitleChanged;
+
yield toolbox.switchHost(Toolbox.HostType.WINDOW);
+ // Wait for title change event *after* switch host, in order to listen
+ // for the event on the WINDOW host window, which only exists after switchHost
+ yield waitForTitleChange(toolbox);
is(getTitle(), `Developer Tools - Page title - ${URL}`,
"Devtools title correct after switching to detached window host");
// Wait for tick to avoid unexpected 'popuphidden' event, which
// blocks the frame popup menu opened below. See also bug 1276873
yield waitForTick();
@@ -51,24 +57,27 @@ add_task(function* () {
let topFrameBtn = frames.filter(b => b.label == URL)[0];
let iframeBtn = frames.filter(b => b.label == IFRAME_URL)[0];
ok(topFrameBtn, "Got top level document in the list");
ok(iframeBtn, "Got iframe document in the list");
// Listen to will-navigate to check if the view is empty
let willNavigate = toolbox.target.once("will-navigate");
+ onTitleChanged = waitForTitleChange(toolbox);
+
// Only select the iframe after we are able to select an element from the top
// level document.
let newRoot = toolbox.getPanel("inspector").once("new-root");
info("Select the iframe");
iframeBtn.click();
yield willNavigate;
yield newRoot;
+ yield onTitleChanged;
info("Navigation to the iframe is done, the inspector should be back up");
is(getTitle(), `Developer Tools - Page title - ${URL}`,
"Devtools title was not updated after changing inspected frame");
info("Cleanup toolbox and test preferences.");
yield toolbox.destroy();
toolbox = null;
@@ -78,8 +87,20 @@ add_task(function* () {
Services.prefs.clearUserPref("devtools.toolbox.sideEnabled");
Services.prefs.clearUserPref("devtools.command-button-frames.enabled");
finish();
});
function getTitle() {
return Services.wm.getMostRecentWindow("devtools:toolbox").document.title;
}
+
+// Wait for a given toolbox to get its title updated
+function waitForTitleChange(toolbox) {
+ let deferred = defer();
+ toolbox.win.parent.addEventListener("message", function onmessage(event) {
+ if (event.data.name == "set-host-title") {
+ toolbox.win.parent.removeEventListener("message", onmessage);
+ deferred.resolve();
+ }
+ });
+ return deferred.promise;
+}
--- a/devtools/client/inspector/test/browser_inspector_breadcrumbs_visibility.js
+++ b/devtools/client/inspector/test/browser_inspector_breadcrumbs_visibility.js
@@ -34,17 +34,17 @@ const NODES = [
add_task(function* () {
let { inspector, toolbox } = yield openInspectorForURL(TEST_URI);
// No way to wait for scrolling to end (Bug 1172171)
// Rather than wait a max time; limit test to instant scroll behavior
inspector.breadcrumbs.arrowScrollBox.scrollBehavior = "instant";
yield toolbox.switchHost(Toolbox.HostType.WINDOW);
- let hostWindow = toolbox._host._window;
+ let hostWindow = toolbox.win.parent;
let originalWidth = hostWindow.outerWidth;
let originalHeight = hostWindow.outerHeight;
hostWindow.resizeTo(640, 300);
info("Testing transitions ltr");
yield pushPref("intl.uidirection.en-US", "ltr");
yield testBreadcrumbTransitions(hostWindow, inspector);
--- a/devtools/client/inspector/test/browser_inspector_pane-toggle-04.js
+++ b/devtools/client/inspector/test/browser_inspector_pane-toggle-04.js
@@ -20,17 +20,17 @@ add_task(function* () {
let { inspector, toolbox } = yield openInspectorForURL("about:blank");
let button = inspector.panelDoc.querySelector(".sidebar-toggle");
let panel = inspector.panelDoc.querySelector("#inspector-sidebar-container");
info("Changing toolbox host to a window.");
yield toolbox.switchHost(Toolbox.HostType.WINDOW);
- let hostWindow = toolbox._host._window;
+ let hostWindow = toolbox.win.parent;
let originalWidth = hostWindow.outerWidth;
let originalHeight = hostWindow.outerHeight;
info("Resizing window to switch to the horizontal layout.");
hostWindow.resizeTo(800, 300);
// Check the sidebar is expanded when the test starts.
ok(!panel.classList.contains("pane-collapsed"), "The panel is in expanded state");
--- a/devtools/client/styleeditor/test/browser_styleeditor_sv_resize.js
+++ b/devtools/client/styleeditor/test/browser_styleeditor_sv_resize.js
@@ -16,17 +16,17 @@ add_task(function* () {
is(ui.editors.length, 2, "There are 2 style sheets initially");
info("Changing toolbox host to a window.");
yield toolbox.switchHost(Toolbox.HostType.WINDOW);
let editor = yield ui.editors[0].getSourceEditor();
let originalSourceEditor = editor.sourceEditor;
- let hostWindow = toolbox._host._window;
+ let hostWindow = toolbox.win.parent;
let originalWidth = hostWindow.outerWidth;
let originalHeight = hostWindow.outerHeight;
// to check the caret is preserved
originalSourceEditor.setCursor(originalSourceEditor.getPosition(4));
info("Resizing window.");
hostWindow.resizeTo(120, 480);
--- a/devtools/client/webconsole/test/browser_webconsole_closure_inspection.js
+++ b/devtools/client/webconsole/test/browser_webconsole_closure_inspection.js
@@ -85,10 +85,10 @@ function onGetNameFetch(evt, view) {
}
function onExpandClosure(results) {
let prop = results[0].matchedProp;
ok(prop, "matched the name property in the variables view");
gVariablesView.window.focus();
gJSTerm.once("sidebar-closed", finishTest);
- EventUtils.synthesizeKey("VK_ESCAPE", {});
+ EventUtils.synthesizeKey("VK_ESCAPE", {}, gVariablesView.window);
}