@@ -231,20 +231,10 @@ HTTPSEverywhere.prototype = {
231231 // content is embedded / requested by JavaScript.
232232 onLocationChange : function ( wp , req , uri ) {
233233 if ( wp instanceof CI . nsIWebProgress ) {
234- var x = wp . DOMWindow ;
235- var top_window ;
236- if ( x instanceof CI . nsIDOMWindow ) {
237- top_window = x . top ; // climb out of iframes
238- if ( top_window . document ) {
239- var alist = new ApplicableList ( this . log , top_window . document ) ;
240- this . setExpando ( top_window , "applicable rules" , alist ) ;
241- this . log ( WARN , "onLocationChange, made new alist for " + uri . spec ) ;
242- } else {
243- this . log ( WARN , "onLocationChange, document is null" ) ;
244- }
245- } else {
246- this . log ( WARN , "onLocationChange: no nsIDOMWindow" ) ;
247- }
234+ this . log ( DBUG , "(Probably) Making new alist in onLocationChange" ) ;
235+ if ( ! this . getApplicableListForDOMWin ( wp . DOMWindow , "onLocChange" ) )
236+ this . log ( WARN , "Something went wrong in onLocationChange" ) ;
237+ this . log ( DBUG , "ok" ) ;
248238 } else {
249239 this . log ( WARN , "onLocationChange: no nsIWebProgress" ) ;
250240 }
@@ -280,15 +270,22 @@ HTTPSEverywhere.prototype = {
280270 // need to be appended to with reference only to the channel
281271 getApplicableListForChannel : function ( channel ) {
282272 var domWin = this . getWindowForChannel ( channel ) ;
283- if ( ! domWin ) return null ;
284- var alist = this . getExpando ( domWin . document , "applicable_rules" , null ) ;
273+ return this . getApplicableListForDOMWin ( domWin , "on-modify-request w " + domWin ) ;
274+ } ,
275+
276+ getApplicableListForDOMWin : function ( domWin , where ) {
277+ if ( ! domWin || ! ( domWin instanceof CI . nsIDOMWindow ) ) {
278+ this . log ( WARN , "Get alist without domWin" ) ;
279+ return null ;
280+ }
281+ var doc = domWin . top . document ;
282+ var alist = this . getExpando ( doc , "applicable_rules" , null ) ;
285283 if ( alist ) {
286- this . log ( WARN , "get AL success" ) ;
287- return alist ;
284+ this . log ( DBUG , "get AL success in " + where ) ;
288285 } else {
289- this . log ( DBUG , "Making new AL in getApplicableListForChannel" ) ;
290- alist = new ApplicableList ( this . log , domWin . document ) ;
291- this . setExpando ( domWin . document , "applicable_rules" , alist ) ;
286+ this . log ( DBUG , "Making new AL in getApplicableListForDOMWin in " + where ) ;
287+ alist = new ApplicableList ( this . log , doc ) ;
288+ this . setExpando ( doc , "applicable_rules" , alist ) ;
292289 }
293290 return alist ;
294291 } ,
@@ -297,7 +294,7 @@ HTTPSEverywhere.prototype = {
297294 observe : function ( subject , topic , data ) {
298295 // Top level glue for the nsIObserver API
299296 var channel = subject ;
300- this . log ( VERB , "Got observer topic: " + topic ) ;
297+ // this.log(VERB,"Got observer topic: "+topic);
301298
302299 if ( topic == "http-on-modify-request" ) {
303300 if ( ! ( channel instanceof CI . nsIHttpChannel ) ) return ;
@@ -309,7 +306,7 @@ HTTPSEverywhere.prototype = {
309306 var lst = this . getApplicableListForChannel ( channel ) ;
310307 HTTPS . replaceChannel ( lst , channel ) ;
311308 } else if ( topic == "http-on-examine-response" ) {
312- this . log ( DBUG , "Got http-on-examine-response " ) ;
309+ this . log ( DBUG , "Got http-on-examine-response @ " + channel . URI . spec ) ;
313310 HTTPS . handleSecureCookies ( channel ) ;
314311 } else if ( topic == "http-on-examine-merged-response" ) {
315312 this . log ( DBUG , "Got http-on-examine-merged-response " ) ;
0 commit comments