Skip to content

Commit 3b42328

Browse files
authored
browser(firefox): a different way to emit 'load' event (#4080)
Using WebProgressListener events works in all cases. Currently used `pageshow` event will stop being emitted in future when loading was stopped with `window.stop()` api. References #3995
1 parent aafe5da commit 3b42328

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

browser_patches/firefox/BUILD_NUMBER

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
1184
2-
Changed: [email protected] Tue Oct 6 12:04:41 PDT 2020
1+
1185
2+
Changed: [email protected] Wed Oct 7 08:45:05 PDT 2020

browser_patches/firefox/juggler/content/FrameTree.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ class FrameTree {
196196
const isStart = flag & Ci.nsIWebProgressListener.STATE_START;
197197
const isTransferring = flag & Ci.nsIWebProgressListener.STATE_TRANSFERRING;
198198
const isStop = flag & Ci.nsIWebProgressListener.STATE_STOP;
199+
const isDocument = flag & Ci.nsIWebProgressListener.STATE_IS_DOCUMENT;
199200

200201
if (isStart) {
201202
// Starting a new navigation.
@@ -225,6 +226,9 @@ class FrameTree {
225226
if (frame === this._mainFrame && status !== Cr.NS_BINDING_ABORTED)
226227
this.forcePageReady();
227228
}
229+
230+
if (isStop && isDocument)
231+
this.emit(FrameTree.Events.Load, frame);
228232
}
229233

230234
onFrameLocationChange(progress, request, location, flags) {
@@ -303,6 +307,7 @@ FrameTree.Events = {
303307
NavigationAborted: 'navigationaborted',
304308
SameDocumentNavigation: 'samedocumentnavigation',
305309
PageReady: 'pageready',
310+
Load: 'load',
306311
};
307312

308313
class Frame {

browser_patches/firefox/juggler/content/PageAgent.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ class PageAgent {
163163
helper.addObserver(this._onWindowOpenInNewContext.bind(this), 'juggler-window-open-in-new-context'),
164164
helper.addObserver(this._filePickerShown.bind(this), 'juggler-file-picker-shown'),
165165
helper.addEventListener(this._messageManager, 'DOMContentLoaded', this._onDOMContentLoaded.bind(this)),
166-
helper.addEventListener(this._messageManager, 'pageshow', this._onLoad.bind(this)),
167166
helper.addObserver(this._onDocumentOpenLoad.bind(this), 'juggler-document-open-loaded'),
168167
helper.addEventListener(this._messageManager, 'error', this._onError.bind(this)),
168+
helper.on(this._frameTree, 'load', this._onLoad.bind(this)),
169169
helper.on(this._frameTree, 'bindingcalled', this._onBindingCalled.bind(this)),
170170
helper.on(this._frameTree, 'frameattached', this._onFrameAttached.bind(this)),
171171
helper.on(this._frameTree, 'framedetached', this._onFrameDetached.bind(this)),
@@ -389,11 +389,7 @@ class PageAgent {
389389
});
390390
}
391391

392-
_onLoad(event) {
393-
const docShell = event.target.ownerGlobal.docShell;
394-
const frame = this._frameTree.frameForDocShell(docShell);
395-
if (!frame)
396-
return;
392+
_onLoad(frame) {
397393
this._browserPage.emit('pageEventFired', {
398394
frameId: frame.id(),
399395
name: 'load'

0 commit comments

Comments
 (0)