diff --git a/browser_patches/firefox/BUILD_NUMBER b/browser_patches/firefox/BUILD_NUMBER index 80a313e6ac..550e199c11 100644 --- a/browser_patches/firefox/BUILD_NUMBER +++ b/browser_patches/firefox/BUILD_NUMBER @@ -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 diff --git a/browser_patches/firefox/juggler/content/PageAgent.js b/browser_patches/firefox/juggler/content/PageAgent.js index a453e86a16..5d12f4c24c 100644 --- a/browser_patches/firefox/juggler/content/PageAgent.js +++ b/browser_patches/firefox/juggler/content/PageAgent.js @@ -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 }) {