browser(firefox): emit iframe lifecycle when initial navigation fails (#3389)

This commit is contained in:
Dmitry Gozman 2020-08-11 16:05:34 -07:00 committed by GitHub
parent 6054f14794
commit da95b73b59
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 22 deletions

View file

@ -1,2 +1,2 @@
1156
Changed: yurys@chromium.org Mon Aug 10 20:28:44 GMTST 2020
1157
Changed: dgozman@gmail.com Tue Aug 11 14:21:42 PDT 2020

View file

@ -58,6 +58,7 @@ class FrameData {
this._runtime = runtime;
this._frame = frame;
this._isolatedWorlds = new Map();
this._initialNavigationDone = false;
this.reset();
}
@ -277,19 +278,22 @@ class PageAgent {
// Sometimes we initialize later than the first about:blank page is opened.
// In this case, the page might've been loaded already, and we need to issue
// the `DOMContentLoaded` and `load` events.
if (mainFrame.url() === 'about:blank' && readyState === 'complete') {
this._browserPage.emit('pageEventFired', {
frameId: this._frameTree.mainFrame().id(),
name: 'DOMContentLoaded',
});
this._browserPage.emit('pageEventFired', {
frameId: this._frameTree.mainFrame().id(),
name: 'load',
});
}
if (mainFrame.url() === 'about:blank' && readyState === 'complete')
this._emitAllEvents(this._frameTree.mainFrame());
}
}
_emitAllEvents(frame) {
this._browserPage.emit('pageEventFired', {
frameId: frame.id(),
name: 'DOMContentLoaded',
});
this._browserPage.emit('pageEventFired', {
frameId: frame.id(),
name: 'load',
});
}
_onExecutionContextCreated(executionContext) {
this._browserRuntime.emit('runtimeExecutionContextCreated', {
executionContextId: executionContext.id(),
@ -330,16 +334,8 @@ class PageAgent {
const props = subject.QueryInterface(Ci.nsIPropertyBag2);
const hasUrl = props.hasKey('url');
const createdDocShell = props.getPropertyAsInterface('createdTabDocShell', Ci.nsIDocShell);
if (!hasUrl && createdDocShell === this._docShell && this._frameTree.forcePageReady()) {
this._browserPage.emit('pageEventFired', {
frameId: this._frameTree.mainFrame().id(),
name: 'DOMContentLoaded',
});
this._browserPage.emit('pageEventFired', {
frameId: this._frameTree.mainFrame().id(),
name: 'load',
});
}
if (!hasUrl && createdDocShell === this._docShell && this._frameTree.forcePageReady())
this._emitAllEvents(this._frameTree.mainFrame());
}
_setInterceptFileChooserDialog({enabled}) {
@ -438,6 +434,10 @@ class PageAgent {
navigationId,
errorText,
});
const frameData = this._frameData.get(frame);
if (!frameData._initialNavigationDone && frame !== this._frameTree.mainFrame())
this._emitAllEvents(frame);
frameData._initialNavigationDone = true;
}
_onSameDocumentNavigation(frame) {
@ -454,6 +454,7 @@ class PageAgent {
url: frame.url(),
name: frame.name(),
});
this._frameData.get(frame)._initialNavigationDone = true;
}
_onGlobalObjectCreated({ frame }) {