Skip to content

Commit

Permalink
Backed out changeset 03250652b3a0 (bug 1266134) for failing browser_d…
Browse files Browse the repository at this point in the history
…bg_on-pause-raise.js on OSX and Windows. r=backout
  • Loading branch information
Archaeopteryx committed Oct 7, 2016
1 parent 99e8bde commit 6809e5a
Show file tree
Hide file tree
Showing 19 changed files with 166 additions and 453 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ var test = Task.async(function* () {
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);
});
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function getHost(host) {

function resizeToolboxWindow(panel, host) {
let sizeOption = host.split(":")[1];
let win = panel._toolbox.win.parent;
let win = panel._toolbox._host._window;

// should be the same value as BREAKPOINT_SMALL_WINDOW_WIDTH in debugger-view.js
let breakpoint = 850;
Expand All @@ -101,7 +101,7 @@ function resizeToolboxWindow(panel, host) {
function resizeAndWaitForLayoutChange(panel, width) {
info("Updating toolbox window width to " + width);

let win = panel._toolbox.win.parent;
let win = panel._toolbox._host._window;
let gDebugger = panel.panelWin;

win.resizeTo(width, window.screen.availHeight);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,8 @@ add_task(function* () {
"jsdebugger",
Toolbox.HostType.WINDOW);

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),
is(toolbox._host.type, "window", "correct host");
ok(toolbox._host._window.document.title.includes(WORKER_URL),
"worker URL in host title");

let toolTabs = toolbox.doc.querySelectorAll(".devtools-tab");
Expand Down
3 changes: 0 additions & 3 deletions devtools/client/debugger/test/mochitest/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -751,9 +751,6 @@ AddonDebugger.prototype = {
}),

_onMessage: function (event) {
if (typeof(event.data) !== "string") {
return;
}
let json = JSON.parse(event.data);
switch (json.name) {
case "toolbox-title":
Expand Down
44 changes: 27 additions & 17 deletions devtools/client/framework/devtools.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const defer = require("devtools/shared/defer");

// Load gDevToolsBrowser toolbox lazily as they need gDevTools to be fully initialized
loader.lazyRequireGetter(this, "Toolbox", "devtools/client/framework/toolbox", true);
loader.lazyRequireGetter(this, "ToolboxHostManager", "devtools/client/framework/toolbox-host-manager", true);
loader.lazyRequireGetter(this, "gDevToolsBrowser", "devtools/client/framework/devtools-browser", true);

const {defaultTools: DefaultTools, defaultThemes: DefaultThemes} =
Expand All @@ -19,7 +18,6 @@ const EventEmitter = require("devtools/shared/event-emitter");
const {JsonView} = require("devtools/client/jsonview/main");
const AboutDevTools = require("devtools/client/framework/about-devtools-toolbox");
const {when: unload} = require("sdk/system/unload");
const {Task} = require("devtools/shared/task");

const FORBIDDEN_IDS = new Set(["toolbox", ""]);
const MAX_ORDINAL = 99;
Expand Down Expand Up @@ -399,27 +397,35 @@ DevTools.prototype = {
* @return {Toolbox} toolbox
* The toolbox that was opened
*/
showToolbox: Task.async(function* (target, toolId, hostType, hostOptions) {
showToolbox: function (target, toolId, hostType, hostOptions) {
let deferred = defer();

let toolbox = this._toolboxes.get(target);
if (toolbox) {

if (hostType != null && toolbox.hostType != hostType) {
yield toolbox.switchHost(hostType);
}
let hostPromise = (hostType != null && toolbox.hostType != hostType) ?
toolbox.switchHost(hostType) :
promise.resolve(null);

if (toolId != null && toolbox.currentToolId != toolId) {
yield toolbox.selectTool(toolId);
hostPromise = hostPromise.then(function () {
return toolbox.selectTool(toolId);
});
}

toolbox.raise();
} else {
let manager = new ToolboxHostManager(target, hostType, hostOptions);

toolbox = yield manager.create(toolId);
this._toolboxes.set(target, toolbox);
return hostPromise.then(function () {
toolbox.raise();
return toolbox;
});
}
else {
// No toolbox for target, create one
toolbox = new Toolbox(target, toolId, hostType, hostOptions);

this.emit("toolbox-created", toolbox);

this._toolboxes.set(target, toolbox);

toolbox.once("destroy", () => {
this.emit("toolbox-destroy", target);
});
Expand All @@ -429,12 +435,16 @@ DevTools.prototype = {
this.emit("toolbox-destroyed", target);
});

yield toolbox.open();
this.emit("toolbox-ready", toolbox);
// If toolId was passed in, it will already be selected before the
// open promise resolves.
toolbox.open().then(() => {
deferred.resolve(toolbox);
this.emit("toolbox-ready", toolbox);
});
}

return toolbox;
}),
return deferred.promise;
},

/**
* Return the toolbox for a given target.
Expand Down
1 change: 0 additions & 1 deletion devtools/client/framework/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ DevToolsModules(
'target-from-url.js',
'target.js',
'toolbox-highlighter-utils.js',
'toolbox-host-manager.js',
'toolbox-hosts.js',
'toolbox-options.js',
'toolbox.js',
Expand Down
4 changes: 2 additions & 2 deletions devtools/client/framework/test/browser_devtools_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function runTests1(aTab) {

gDevTools.showToolbox(target, toolId1).then(function (toolbox) {
is(toolbox.target, target, "toolbox target is correct");
is(toolbox.target.tab, gBrowser.selectedTab, "targeted tab is correct");
is(toolbox._host.hostTab, gBrowser.selectedTab, "toolbox host is correct");

ok(events["init"], "init event fired");
ok(events["ready"], "ready event fired");
Expand Down Expand Up @@ -139,7 +139,7 @@ function runTests2() {

gDevTools.showToolbox(target, toolId2).then(function (toolbox) {
is(toolbox.target, target, "toolbox target is correct");
is(toolbox.target.tab, gBrowser.selectedTab, "targeted tab is correct");
is(toolbox._host.hostTab, gBrowser.selectedTab, "toolbox host is correct");

ok(events["init"], "init event fired");
ok(events["build"], "build event fired");
Expand Down
3 changes: 0 additions & 3 deletions devtools/client/framework/test/browser_toolbox_custom_host.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ function test() {
});

function onMessage(event) {
if (typeof(event.data) !== "string") {
return;
}
info("onMessage: " + event.data);
let json = JSON.parse(event.data);
if (json.name == "toolbox-close") {
Expand Down
8 changes: 4 additions & 4 deletions devtools/client/framework/test/browser_toolbox_raise.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ function testWindowHost() {
// Need to wait for focus as otherwise window.focus() is overridden by
// toolbox window getting focused first on Linux and Mac.
let onToolboxFocus = () => {
toolbox.win.parent.removeEventListener("focus", onToolboxFocus, true);
toolbox._host._window.removeEventListener("focus", onToolboxFocus, true);
info("focusing main window.");
window.focus();
};
// Need to wait for toolbox window to get focus.
toolbox.win.parent.addEventListener("focus", onToolboxFocus, true);
toolbox._host._window.addEventListener("focus", onToolboxFocus, true);
}

function onFocus() {
Expand All @@ -56,11 +56,11 @@ function onFocus() {

// Check if toolbox window got focus.
let onToolboxFocusAgain = () => {
toolbox.win.parent.removeEventListener("focus", onToolboxFocusAgain, false);
toolbox._host._window.removeEventListener("focus", onToolboxFocusAgain, false);
ok(true, "Toolbox window is the focused window after calling toolbox.raise()");
cleanup();
};
toolbox.win.parent.addEventListener("focus", onToolboxFocusAgain, false);
toolbox._host._window.addEventListener("focus", onToolboxFocusAgain, false);

// Now raise toolbox.
toolbox.raise();
Expand Down
2 changes: 1 addition & 1 deletion devtools/client/framework/test/browser_toolbox_toggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function* testToggleDetachedToolbox(tab, key, modifiers) {

info("Verify windowed toolbox is focused instead of closed when using " +
"toggle key from the main window");
let toolboxWindow = toolbox.win.top;
let toolboxWindow = toolbox._host._window;
let onToolboxWindowFocus = once(toolboxWindow, "focus", true);
EventUtils.synthesizeKey(key, modifiers);
yield onToolboxWindowFocus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,35 +28,28 @@ function test() {
.then(() => toolbox.selectTool(TOOL_ID_1))

// undock toolbox and check title
.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(() => toolbox.switchHost(Toolbox.HostType.WINDOW))
.then(checkTitle.bind(null, NAME_1, URL_1, "toolbox undocked"))

// switch to different tool and check title
.then(() => {
let onTitleChanged = waitForTitleChange(toolbox);
toolbox.selectTool(TOOL_ID_2);
return onTitleChanged;
})
.then(() => toolbox.selectTool(TOOL_ID_2))
.then(checkTitle.bind(null, NAME_1, URL_1, "tool changed"))

// navigate to different local url and check title
.then(function () {
let onTitleChanged = waitForTitleChange(toolbox);
let deferred = defer();
target.once("navigate", () => deferred.resolve());
gBrowser.loadURI(URL_2);
return onTitleChanged;
return deferred.promise;
})
.then(checkTitle.bind(null, NAME_2, URL_2, "url changed"))

// navigate to a real url and check title
.then(() => {
let onTitleChanged = waitForTitleChange(toolbox);
let deferred = defer();
target.once("navigate", () => deferred.resolve());
gBrowser.loadURI(URL_3);
return onTitleChanged;
return deferred.promise;
})
.then(checkTitle.bind(null, NAME_3, URL_3, "url changed"))

Expand All @@ -73,11 +66,7 @@ function test() {
return gDevTools.showToolbox(target, null, Toolbox.HostType.WINDOW);
})
.then(function (aToolbox) { toolbox = aToolbox; })
.then(() => {
let onTitleChanged = waitForTitleChange(toolbox);
toolbox.selectTool(TOOL_ID_1);
return onTitleChanged;
})
.then(() => toolbox.selectTool(TOOL_ID_1))
.then(checkTitle.bind(null, NAME_3, URL_3,
"toolbox destroyed and recreated"))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,8 @@ add_task(function* () {
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");
Expand Down Expand Up @@ -62,8 +56,6 @@ add_task(function* () {
// 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");
Expand All @@ -72,7 +64,6 @@ add_task(function* () {

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}`,
Expand Down
14 changes: 0 additions & 14 deletions devtools/client/framework/test/shared-head.js
Original file line number Diff line number Diff line change
Expand Up @@ -580,17 +580,3 @@ function emptyClipboard() {
function isWindows() {
return Services.appinfo.OS === "WINNT";
}

/**
* 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;
}
Loading

0 comments on commit 6809e5a

Please sign in to comment.