Skip to content

Commit 628ac0a

Browse files
committed
Bug 1668586 - stop messing with web progress listeners when changing remoteness, r=mattwoodrow
Differential Revision: https://phabricator.services.mozilla.com/D92514
1 parent c6ffb4b commit 628ac0a

File tree

3 files changed

+40
-25
lines changed

3 files changed

+40
-25
lines changed

toolkit/content/tests/browser/browser.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ skip-if = os == "linux" && bits == 64 && os_version = "18.04" # Bug 1614739
118118
[browser_isSynthetic.js]
119119
[browser_keyevents_during_autoscrolling.js]
120120
[browser_label_textlink.js]
121+
[browser_remoteness_change_listeners.js]
121122
[browser_suspend_videos_outside_viewport.js]
122123
support-files =
123124
file_outside_viewport_videos.html
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/* Any copyright is dedicated to the Public Domain.
2+
http://creativecommons.org/publicdomain/zero/1.0/ */
3+
4+
"use strict";
5+
6+
/**
7+
* Check that adding progress listeners to a browser doesn't break things
8+
* when switching the remoteness of that browser.
9+
*/
10+
add_task(async function test_remoteness_switch_listeners() {
11+
await BrowserTestUtils.withNewTab("about:support", async function(browser) {
12+
let wpl;
13+
let navigated = new Promise(resolve => {
14+
wpl = {
15+
onLocationChange() {
16+
is(browser.currentURI.spec, "https://example.com/");
17+
if (browser.currentURI?.spec == "https://example.com/") {
18+
resolve();
19+
}
20+
},
21+
QueryInterface: ChromeUtils.generateQI([
22+
Ci.nsISupportsWeakReference,
23+
Ci.nsIWebProgressListener2,
24+
Ci.nsIWebProgressListener,
25+
]),
26+
};
27+
browser.addProgressListener(wpl);
28+
});
29+
30+
let loaded = BrowserTestUtils.browserLoaded(
31+
browser,
32+
null,
33+
"https://example.com/"
34+
);
35+
BrowserTestUtils.loadURI(browser, "https://example.com/");
36+
await Promise.all([loaded, navigated]);
37+
browser.removeProgressListener(wpl);
38+
});
39+
});

toolkit/content/widgets/browser-custom-element.js

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -920,22 +920,6 @@
920920
);
921921
}
922922

923-
/**
924-
* Move the previously-tracked web progress listeners to this <browser>'s
925-
* current WebProgress.
926-
*/
927-
restoreProgressListeners() {
928-
let listeners = this.progressListeners;
929-
this.progressListeners = [];
930-
931-
for (let { weakListener, mask } of listeners) {
932-
let listener = weakListener.get();
933-
if (listener) {
934-
this.addProgressListener(listener, mask);
935-
}
936-
}
937-
}
938-
939923
onPageHide(aEvent) {
940924
if (!this.docShell || !this.fastFind) {
941925
return;
@@ -1050,7 +1034,6 @@
10501034
* the <browser> element may not be initialized yet.
10511035
*/
10521036

1053-
let oldNavigation = this._remoteWebNavigation;
10541037
this._remoteWebNavigation = new LazyModules.RemoteWebNavigation(this);
10551038

10561039
// Initialize contentPrincipal to the about:blank principal for this loadcontext
@@ -1064,13 +1047,6 @@
10641047
// we should re-evaluate the CSP here.
10651048
this._csp = null;
10661049

1067-
if (!oldNavigation) {
1068-
// If we weren't remote, then we're transitioning from local to
1069-
// remote. Add all listeners from the previous <browser> to the new
1070-
// RemoteWebProgress.
1071-
this.restoreProgressListeners();
1072-
}
1073-
10741050
this.messageManager.loadFrameScript(
10751051
"chrome://global/content/browser-child.js",
10761052
true
@@ -1119,7 +1095,6 @@
11191095

11201096
if (!this.isRemoteBrowser) {
11211097
this._remoteWebNavigation = null;
1122-
this.restoreProgressListeners();
11231098
this.addEventListener("pagehide", this.onPageHide, true);
11241099
}
11251100
}

0 commit comments

Comments
 (0)