Bug 1611096 - Check webprogresslistener as a fallback for non loaded documents r=rcaliman,ochameau

Depends on D62624

With the previous implementation, an uninitialized document could be returned as a root node.
Here we try to be more explicit and wait for a correct root node. However in some cases a document can remain uninitialized and will never transition to any other state.
If the document is uninitialized but is not currently loading, we should consider it as a valid root node.

Differential Revision: https://phabricator.services.mozilla.com/D62625
This commit is contained in:
Julian Descottes 2020-05-08 21:53:53 +00:00
Родитель d5b84fb6fe
Коммит 9483eb9c71
1 изменённых файлов: 12 добавлений и 4 удалений

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

@ -395,12 +395,20 @@ var WalkerActor = protocol.ActorClassWithSpec(walkerSpec, {
}, },
_isRootDocumentReady() { _isRootDocumentReady() {
if (!this.rootDoc) { if (this.rootDoc) {
return false; const { readyState } = this.rootDoc;
if (readyState == "interactive" || readyState == "complete") {
return true;
}
} }
const { readyState } = this.rootDoc; // A document might stay forever in unitialized state.
return readyState == "interactive" || readyState == "complete"; // If the target actor is not currently loading a document,
// assume the document is ready.
const webProgress = this.rootDoc.defaultView.docShell.QueryInterface(
Ci.nsIWebProgress
);
return !webProgress.isLoadingDocument;
}, },
/** /**