Bug 1659376 - Fix Browser Toolbox inspector when print preview is displayed.r=rcaliman.

The issue was that the getHighlighter request for the about:printpreview
target never settled. It appears that the document always stays in an
unitialized readyState, which was causing trouble.
Instead of relying only on readyState, we now call isDocumentReady, which
also checks if the document is loading.

Differential Revision: https://phabricator.services.mozilla.com/D87756
This commit is contained in:
Nicolas Chevobbe 2020-08-25 07:08:12 +00:00
Родитель a00c418cc2
Коммит aaa2b8be93
2 изменённых файлов: 20 добавлений и 4 удалений

Просмотреть файл

@ -20,6 +20,12 @@ loader.lazyRequireGetter(
"devtools/server/actors/highlighters/utils/markup",
true
);
loader.lazyRequireGetter(
this,
"isDocumentReady",
"devtools/server/actors/inspector/utils",
true
);
loader.lazyRequireGetter(
this,
"BoxModelHighlighter",
@ -124,10 +130,10 @@ exports.HighlighterActor = protocol.ActorClassWithSpec(highlighterSpec, {
const onInitialized = new Promise(resolve => {
this._initialized = resolve;
});
// Only try to create the highlighter isntance when the document is loaded,
// Only try to create the highlighter instance when the document is loaded,
// otherwise, wait for the navigate event to fire.
const doc = this._targetActor.window.document;
if (doc.documentElement && doc.readyState != "uninitialized") {
if (doc.documentElement && isDocumentReady(doc)) {
this._createHighlighter();
}

Просмотреть файл

@ -23,6 +23,13 @@ loader.lazyRequireGetter(
"devtools/server/actors/inspector/css-logic",
true
);
loader.lazyRequireGetter(
this,
"isDocumentReady",
"devtools/server/actors/inspector/utils",
true
);
exports.getComputedStyle = node =>
lazyContainer.CssLogic.getComputedStyle(node);
@ -210,7 +217,10 @@ CanvasFrameAnonymousContentHelper.prototype = {
// Only try to create the highlighter when the document is loaded,
// otherwise, wait for the window-ready event to fire.
const doc = this.highlighterEnv.document;
if (doc.documentElement && doc.readyState != "uninitialized") {
if (
doc.documentElement &&
(isDocumentReady(doc) || doc.readyState !== "uninitialized")
) {
this._insert();
}
@ -708,7 +718,7 @@ function waitForContentLoaded(iframeOrWindow) {
}
const doc = iframeOrWindow.contentDocument || iframeOrWindow.document;
if (doc.readyState == "interactive" || doc.readyState == "complete") {
if (isDocumentReady(doc)) {
return Promise.resolve();
}