Skip to content

Commit 4233516

Browse files
committed
Make onLocationChange work in e10s
In e10s, nsIWebProgressListeners don't fire when expected, which causes the applicableList to never be cleared. Work around by running a tab progress listener in a context where gBrowser is accessible.
1 parent beced0a commit 4233516

File tree

2 files changed

+14
-39
lines changed

2 files changed

+14
-39
lines changed

src/chrome/content/toolbar_button.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@ httpsEverywhere.toolbarButton = {
8282
false
8383
);
8484

85+
// add listener for top-level location change across all tabs
86+
let httpseProgressListener = {
87+
onLocationChange: function(aBrowser, aWebProgress, aRequest, aLoc) {
88+
HTTPSEverywhere.log(DBUG, "Got on location change!");
89+
HTTPSEverywhere.onLocationChange(aBrowser);
90+
}
91+
};
92+
gBrowser.addTabsProgressListener(httpseProgressListener);
93+
8594
// hook event for when page loads
8695
var onPageLoad = function() {
8796
// Timeout is used for a number of reasons.

src/components/https-everywhere.js

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,6 @@ HTTPSEverywhere.prototype = {
269269
[ Components.interfaces.nsIObserver,
270270
Components.interfaces.nsISupports,
271271
Components.interfaces.nsISupportsWeakReference,
272-
Components.interfaces.nsIWebProgressListener,
273-
Components.interfaces.nsIWebProgressListener2,
274272
Components.interfaces.nsIChannelEventSink ]),
275273

276274
wrappedJSObject: null, // Initialized by constructor
@@ -298,47 +296,15 @@ HTTPSEverywhere.prototype = {
298296
obj[key] = value;
299297
},
300298

301-
// XXX: This never fires in e10s
302-
onStateChange: function(wp, req, flags, status) {
303-
if ((flags & CI.nsIWebProgressListener.STATE_START) &&
304-
(flags & CI.nsIWebProgressListener.STATE_IS_DOCUMENT) &&
305-
wp.isTopLevel) {
306-
let channel = req.QueryInterface(CI.nsIChannel);
307-
let browser = this.getBrowserForChannel(channel);
308-
if (!browser) {
309-
this.log(WARN, "Unable to get <browser> for "+channel.URI.spec);
310-
return;
311-
}
312-
dump("In on location change\n");
313-
this.newApplicableListForBrowser(browser);
314-
}
315-
},
316-
317299
// We use onLocationChange to make a fresh list of rulesets that could have
318300
// applied to the content in the current page (the "applicable list" is used
319301
// for the context menu in the UI). This will be appended to as various
320302
// content is embedded / requested by JavaScript.
321-
// XXX: This never fires in e10s
322-
onLocationChange: function(wp, req, uri) {
323-
if (wp instanceof CI.nsIWebProgress) {
324-
let location = uri.spec;
325-
if(location.substr(0, 6) == "about:"){
326-
return;
327-
}
328-
if (!req || !(req instanceof CI.nsIChannel)) {
329-
this.log(WARN, "Bad request " + req + " for " + uri.spec);
330-
return;
331-
}
332-
let browser = this.getBrowserForChannel(req);
333-
if (!browser) {
334-
this.log(WARN, "Unable to get browser for " + uri.spec);
335-
return;
336-
}
337-
dump("ON LOCATION $$$$$$$$$$\n");
338-
if (!this.newApplicableListForBrowser(browser))
339-
this.log(WARN,"Something went wrong in onLocationChange");
340-
} else {
341-
this.log(WARN,"onLocationChange: no nsIWebProgress");
303+
onLocationChange: function(browser) {
304+
try {
305+
this.newApplicableListForBrowser(browser);
306+
} catch (e) {
307+
this.log(WARN, "Couldn't make applicable list"+e);
342308
}
343309
},
344310

0 commit comments

Comments
 (0)