mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Bug 1277834 - Silence inspector warnings and add promise rejection handlers; r=jdescottes
MozReview-Commit-ID: 6NhwdVTH57R --HG-- extra : rebase_source : 9b96832c8b0258c4de96c22929e1683d4ccec0d8
This commit is contained in:
parent
8bbe0b8391
commit
a08bd75422
@ -91,6 +91,7 @@ function InspectorPanel(iframeWindow, toolbox) {
|
||||
|
||||
this.nodeMenuTriggerInfo = null;
|
||||
|
||||
this._handleRejectionIfNotDestroyed = this._handleRejectionIfNotDestroyed.bind(this);
|
||||
this._onBeforeNavigate = this._onBeforeNavigate.bind(this);
|
||||
this.onNewRoot = this.onNewRoot.bind(this);
|
||||
this._onContextMenu = this._onContextMenu.bind(this);
|
||||
@ -166,6 +167,18 @@ InspectorPanel.prototype = {
|
||||
return this._target.client.traits.pasteHTML;
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle promise rejections for various asynchronous actions, and only log errors if
|
||||
* the inspector panel still exists.
|
||||
* This is useful to silence useless errors that happen when the inspector is closed
|
||||
* while still initializing (and making protocol requests).
|
||||
*/
|
||||
_handleRejectionIfNotDestroyed: function (e) {
|
||||
if (!this._panelDestroyer) {
|
||||
console.error(e);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Figure out what features the backend supports
|
||||
*/
|
||||
@ -258,7 +271,7 @@ InspectorPanel.prototype = {
|
||||
_getPageStyle: function () {
|
||||
return this._toolbox.inspector.getPageStyle().then(pageStyle => {
|
||||
this.pageStyle = pageStyle;
|
||||
});
|
||||
}, this._handleRejectionIfNotDestroyed);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -538,7 +551,8 @@ InspectorPanel.prototype = {
|
||||
});
|
||||
};
|
||||
this._pendingSelection = onNodeSelected;
|
||||
this._getDefaultNodeForSelection().then(onNodeSelected, console.error);
|
||||
this._getDefaultNodeForSelection()
|
||||
.then(onNodeSelected, this._handleRejectionIfNotDestroyed);
|
||||
},
|
||||
|
||||
_selectionCssSelector: null,
|
||||
@ -617,16 +631,7 @@ InspectorPanel.prototype = {
|
||||
this.selection.isElementNode()) {
|
||||
selection.getUniqueSelector().then(selector => {
|
||||
this.selectionCssSelector = selector;
|
||||
}).then(null, e => {
|
||||
// Only log this as an error if the panel hasn't been destroyed in the
|
||||
// meantime.
|
||||
if (!this._panelDestroyer) {
|
||||
console.error(e);
|
||||
} else {
|
||||
console.warn("Could not set the unique selector for the newly " +
|
||||
"selected node, the inspector was destroyed.");
|
||||
}
|
||||
});
|
||||
}, this._handleRejectionIfNotDestroyed);
|
||||
}
|
||||
|
||||
let selfUpdate = this.updating("inspector-panel");
|
||||
@ -1339,7 +1344,7 @@ InspectorPanel.prototype = {
|
||||
if (!this.walker) {
|
||||
return promise.resolve();
|
||||
}
|
||||
return this.walker.clearPseudoClassLocks().then(null, console.error);
|
||||
return this.walker.clearPseudoClassLocks().catch(this._handleRejectionIfNotDestroyed);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -119,6 +119,7 @@ function MarkupView(inspector, frame, controllerWindow) {
|
||||
this._containers = new Map();
|
||||
|
||||
// Binding functions that need to be called in scope.
|
||||
this._handleRejectionIfNotDestroyed = this._handleRejectionIfNotDestroyed.bind(this);
|
||||
this._mutationObserver = this._mutationObserver.bind(this);
|
||||
this._onDisplayChange = this._onDisplayChange.bind(this);
|
||||
this._onMouseClick = this._onMouseClick.bind(this);
|
||||
@ -169,6 +170,18 @@ MarkupView.prototype = {
|
||||
|
||||
_selectedContainer: null,
|
||||
|
||||
/**
|
||||
* Handle promise rejections for various asynchronous actions, and only log errors if
|
||||
* the markup view still exists.
|
||||
* This is useful to silence useless errors that happen when the markup view is
|
||||
* destroyed while still initializing (and making protocol requests).
|
||||
*/
|
||||
_handleRejectionIfNotDestroyed: function (e) {
|
||||
if (!this._destroyer) {
|
||||
console.error(e);
|
||||
}
|
||||
},
|
||||
|
||||
_initTooltips: function () {
|
||||
this.eventDetailsTooltip = new HTMLTooltip(this._inspector.toolbox,
|
||||
{type: "arrow"});
|
||||
@ -591,14 +604,7 @@ MarkupView.prototype = {
|
||||
// Make sure the new selection is navigated to.
|
||||
this.maybeNavigateToNewSelection();
|
||||
return undefined;
|
||||
}).catch(e => {
|
||||
if (!this._destroyer) {
|
||||
console.error(e);
|
||||
} else {
|
||||
console.warn("Could not mark node as selected, the markup-view was " +
|
||||
"destroyed while showing the node.");
|
||||
}
|
||||
});
|
||||
}).catch(this._handleRejectionIfNotDestroyed);
|
||||
|
||||
promise.all([onShowBoxModel, onShow]).then(done);
|
||||
},
|
||||
@ -1031,8 +1037,8 @@ MarkupView.prototype = {
|
||||
|
||||
this._waitForChildren().then(() => {
|
||||
if (this._destroyer) {
|
||||
console.warn("Could not fully update after markup mutations, " +
|
||||
"the markup-view was destroyed while waiting for children.");
|
||||
// Could not fully update after markup mutations, the markup-view was destroyed
|
||||
// while waiting for children. Bail out silently.
|
||||
return;
|
||||
}
|
||||
this._flashMutatedNodes(mutations);
|
||||
@ -1131,16 +1137,7 @@ MarkupView.prototype = {
|
||||
return this._ensureVisible(node);
|
||||
}).then(() => {
|
||||
scrollIntoViewIfNeeded(this.getContainer(node).editor.elt, centered);
|
||||
}, e => {
|
||||
// Only report this rejection as an error if the panel hasn't been
|
||||
// destroyed in the meantime.
|
||||
if (!this._destroyer) {
|
||||
console.error(e);
|
||||
} else {
|
||||
console.warn("Could not show the node, the markup-view was destroyed " +
|
||||
"while waiting for children");
|
||||
}
|
||||
});
|
||||
}, this._handleRejectionIfNotDestroyed);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -1149,8 +1146,8 @@ MarkupView.prototype = {
|
||||
_expandContainer: function (container) {
|
||||
return this._updateChildren(container, {expand: true}).then(() => {
|
||||
if (this._destroyer) {
|
||||
console.warn("Could not expand the node, the markup-view was " +
|
||||
"destroyed");
|
||||
// Could not expand the node, the markup-view was destroyed in the meantime. Just
|
||||
// silently give up.
|
||||
return;
|
||||
}
|
||||
container.setExpanded(true);
|
||||
@ -1687,7 +1684,7 @@ MarkupView.prototype = {
|
||||
|
||||
container.children.appendChild(fragment);
|
||||
return container;
|
||||
}).then(null, console.error);
|
||||
}).catch(this._handleRejectionIfNotDestroyed);
|
||||
this._queuedChildUpdates.set(container, updatePromise);
|
||||
return updatePromise;
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user