Bug 1396539 - Wait correctly for inspector load before resolving toolbox-ready. r=pbro

MozReview-Commit-ID: GP3O1NZqVEE

--HG--
extra : rebase_source : c1454cdb807159d5de56a39bcbfb59676540eb1a
This commit is contained in:
Alexandre Poirot 2017-09-05 11:31:01 +02:00
parent dd00003e0f
commit f4286bf47a
4 changed files with 20 additions and 27 deletions

View File

@ -33,9 +33,7 @@ function testPause() {
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");
});

View File

@ -235,7 +235,7 @@ Inspector.prototype = {
});
},
_deferredOpen: function (defaultSelection) {
_deferredOpen: async function (defaultSelection) {
this.breadcrumbs = new HTMLBreadcrumbs(this);
this.walker.on("new-root", this.onNewRoot);
@ -275,27 +275,25 @@ Inspector.prototype = {
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 () {

View File

@ -1155,7 +1155,7 @@ MarkupView.prototype = {
*/
expandNode: function (node) {
let container = this.getContainer(node);
this._expandContainer(container);
return this._expandContainer(container);
},
/**
@ -1648,7 +1648,7 @@ MarkupView.prototype = {
// 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();

View File

@ -33,7 +33,4 @@ function* startPickerAndAssertSwitchToInspector(toolbox) {
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");
}