Skip to content

Commit 1a22dc9

Browse files
committed
Use loadContext. Closes EFForg#196 (github)
1 parent 46bec90 commit 1a22dc9

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

src/components/https-everywhere.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -409,26 +409,24 @@ HTTPSEverywhere.prototype = {
409409

410410
getWindowForChannel: function(channel) {
411411
// Obtain an nsIDOMWindow from a channel
412+
let loadContext;
412413
try {
413-
var nc = channel.notificationCallbacks ? channel.notificationCallbacks : channel.loadGroup.notificationCallbacks;
414+
loadContext = channel.notificationCallbacks.getInterface(CI.nsILoadContext);
414415
} catch(e) {
415-
this.log(INFO,"no loadgroup notificationCallbacks for "+channel.URI.spec);
416-
return null;
417-
}
418-
if (!nc) {
419-
this.log(DBUG, "no window for " + channel.URI.spec);
420-
return null;
421-
}
422-
try {
423-
var domWin = nc.getInterface(CI.nsIDOMWindow);
424-
} catch(e) {
425-
this.log(INFO, "No window associated with request: " + channel.URI.spec);
426-
return null;
416+
try {
417+
loadContext = channel.loadGroup.notificationCallbacks.getInterface(CI.nsILoadContext);
418+
} catch(e) {
419+
console.log(NOTE, "No loadContext for " + channel.URI.spec);
420+
return null;
421+
}
427422
}
423+
424+
let domWin = loadContext.associatedWindow;
428425
if (!domWin) {
429426
this.log(NOTE, "failed to get DOMWin for " + channel.URI.spec);
430427
return null;
431428
}
429+
432430
domWin = domWin.top;
433431
return domWin;
434432
},

0 commit comments

Comments
 (0)