@@ -298,31 +298,29 @@ function onBeforeRequest(details) {
298298 return ;
299299 }
300300
301- // Clear the content shown in the extension popup.
302- // This needed to be done before this listener returns,
303- // otherwise, the extension page might include rulesets
304- // from previous page.
305- if ( details . type == "main_frame" ) {
306- browserSession . deleteTab ( details . tabId ) ;
307- }
308-
309301 let uri = new URL ( details . url ) ;
310302
311- // Check if a user has disabled HTTPS Everywhere on this site. We should
312- // ensure that all subresources are not run through HTTPS Everywhere as well.
303+ // Normalise hosts with tailing dots, e.g. "www.example.com."
304+ while ( uri . hostname [ uri . hostname . length - 1 ] === '.' && uri . hostname !== '.' ) {
305+ uri . hostname = uri . hostname . slice ( 0 , - 1 ) ;
306+ }
307+
313308 if ( details . type == "main_frame" ) {
309+ // Clear the content from previous browser session.
310+ // This needed to be done before this listener returns,
311+ // otherwise, the extension popup might include rulesets
312+ // from previous page.
313+ browserSession . deleteTab ( details . tabId ) ;
314+
315+ // Check if an user has disabled HTTPS Everywhere on this site. We should
316+ // ensure that all subresources are not run through HTTPS Everywhere as well.
314317 browserSession . putTab ( details . tabId , 'first_party_host' , uri . host , true ) ;
315318 }
316319
317320 if ( disabledList . has ( browserSession . getTab ( details . tabId , 'first_party_host' , null ) ) ) {
318321 return ;
319322 }
320323
321- // Normalise hosts with tailing dots, e.g. "www.example.com."
322- while ( uri . hostname [ uri . hostname . length - 1 ] === '.' && uri . hostname !== '.' ) {
323- uri . hostname = uri . hostname . slice ( 0 , - 1 ) ;
324- }
325-
326324 // Should the request be canceled?
327325 // true if the URL is a http:// connection to a remote canonical host, and not
328326 // a tor hidden service
@@ -566,22 +564,7 @@ function onHeadersReceived(details) {
566564
567565 // Do not upgrade resources if the first-party domain disbled EASE mode
568566 // This is needed for HTTPS sites serve mixed content and is broken
569- let firstPartyHost ;
570- if ( details . type == "main_frame" ) {
571- firstPartyHost = uri . host ;
572- } else {
573- // In Firefox, documentUrl is preferable here, since it will always be the
574- // URL in the URL bar, but it was only introduced in FF 54. We should get
575- // rid of `originUrl` at some point.
576- if ( 'documentUrl' in details ) { // Firefox 54+
577- firstPartyHost = new URL ( details . documentUrl ) . host ;
578- } else if ( 'originUrl' in details ) { // Firefox < 54
579- firstPartyHost = new URL ( details . originUrl ) . host ;
580- } else if ( 'initiator' in details ) { // Chrome
581- firstPartyHost = new URL ( details . initiator ) . host ;
582- }
583- }
584- if ( disabledList . has ( firstPartyHost ) ) {
567+ if ( disabledList . has ( browserSession . getTab ( details . tabId , 'first_party_host' , null ) ) ) {
585568 return { } ;
586569 }
587570
0 commit comments