Bug 1396539 - Wait correctly for inspector load before resolving toolbox-ready. r=pbro
MozReview-Commit-ID: GP3O1NZqVEE
--- a/devtools/client/debugger/test/mochitest/browser_dbg_pause-warning.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_pause-warning.js
@@ -28,19 +28,17 @@ function test() {
});
}
function testPause() {
gDebugger.gThreadClient.addOneTimeListener("paused", () => {
ok(gDebugger.gThreadClient.paused,
"threadClient.paused has been updated to true.");
- gToolbox.once("inspector-selected").then(inspector => {
- inspector.once("inspector-updated").then(testNotificationIsUp1);
- });
+ gToolbox.once("inspector-selected").then(testNotificationIsUp1);
gToolbox.selectTool("inspector");
});
EventUtils.sendMouseEvent({ type: "mousedown" },
gDebugger.document.getElementById("resume"),
gDebugger);
// Evaluate a script to fully pause the debugger
--- a/devtools/client/inspector/inspector.js
+++ b/devtools/client/inspector/inspector.js
@@ -230,17 +230,17 @@ Inspector.prototype = {
}).catch(console.error),
this._target.actorHasMethod("inspector", "resolveRelativeURL").then(value => {
this._supportsResolveRelativeURL = value;
}).catch(console.error),
]);
});
},
- _deferredOpen: function (defaultSelection) {
+ _deferredOpen: async function (defaultSelection) {
this.breadcrumbs = new HTMLBreadcrumbs(this);
this.walker.on("new-root", this.onNewRoot);
this.selection.on("new-node-front", this.onNewSelection);
this.selection.on("detached-front", this.onDetached);
if (this.target.isLocalTab) {
@@ -270,37 +270,35 @@ Inspector.prototype = {
this.target.on("thread-resumed", this.updateDebuggerPausedWarning);
this._toolbox.on("select", this.updateDebuggerPausedWarning);
this.updateDebuggerPausedWarning();
}
this._initMarkup();
this.isReady = false;
- return new Promise(resolve => {
- this.once("markuploaded", () => {
- this.isReady = true;
+ this.setupSearchBox();
+ this.setupSidebar();
+ this.setupExtensionSidebars();
- // All the components are initialized. Let's select a node.
- if (defaultSelection) {
- this.selection.setNodeFront(defaultSelection, "inspector-open");
- this.markup.expandNode(this.selection.nodeFront);
- }
+ await this.once("markuploaded");
+ this.isReady = true;
- // And setup the toolbar only now because it may depend on the document.
- this.setupToolbar();
+ // All the components are initialized. Let's select a node.
+ if (defaultSelection) {
+ let onAllPanelsUpdated = this.once("inspector-updated");
+ this.selection.setNodeFront(defaultSelection, "inspector-open");
+ await onAllPanelsUpdated;
+ await this.markup.expandNode(this.selection.nodeFront);
+ }
- this.emit("ready");
- resolve(this);
- });
-
- this.setupSearchBox();
- this.setupSidebar();
- this.setupExtensionSidebars();
- });
+ // And setup the toolbar only now because it may depend on the document.
+ await this.setupToolbar();
+ this.emit("ready");
+ return this;
},
_onBeforeNavigate: function () {
this._defaultNode = null;
this.selection.setNodeFront(null);
this._destroyMarkup();
this.isDirty = false;
this._pendingSelection = null;
--- a/devtools/client/inspector/markup/markup.js
+++ b/devtools/client/inspector/markup/markup.js
@@ -1150,17 +1150,17 @@ MarkupView.prototype = {
});
},
/**
* Expand the node's children.
*/
expandNode: function (node) {
let container = this.getContainer(node);
- this._expandContainer(container);
+ return this._expandContainer(container);
},
/**
* Expand the entire tree beneath a container.
*
* @param {MarkupContainer} container
* The container to expand.
*/
@@ -1643,17 +1643,17 @@ MarkupView.prototype = {
if (!this._containers) {
return promise.reject("markup view destroyed");
}
this._queuedChildUpdates.delete(container);
// If children are dirty, we got a change notification for this node
// while the request was in progress, we need to do it again.
if (container.childrenDirty) {
- return this._updateChildren(container, {expand: centered});
+ return this._updateChildren(container, {expand: centered || expand});
}
let fragment = this.doc.createDocumentFragment();
for (let child of children.nodes) {
let childContainer = this.importNode(child, flash);
fragment.appendChild(childContainer.elt);
}
--- a/devtools/client/inspector/test/browser_inspector_switch-to-inspector-on-pick.js
+++ b/devtools/client/inspector/test/browser_inspector_switch-to-inspector-on-pick.js
@@ -28,12 +28,9 @@ function openToolbox(tab) {
function* startPickerAndAssertSwitchToInspector(toolbox) {
info("Clicking element picker button.");
let pickButton = toolbox.doc.querySelector("#command-button-pick");
pickButton.click();
info("Waiting for inspector to be selected.");
yield toolbox.once("inspector-selected");
is(toolbox.currentToolId, "inspector", "Switched to the inspector");
-
- info("Waiting for inspector to update.");
- yield toolbox.getCurrentPanel().once("inspector-updated");
}