diff --git a/platform/firefox/frameModule.js b/platform/firefox/frameModule.js index 3f35fa966..ef5f04c2b 100644 --- a/platform/firefox/frameModule.js +++ b/platform/firefox/frameModule.js @@ -231,6 +231,14 @@ var contentObserver = { context = (context.ownerDocument || context).defaultView; } + // https://github.com/gorhill/uBlock/issues/1893 + // I don't know why this happens. I observed that when it occurred, the + // resource was not seen by the HTTP observer, as if it was a spurious + // call to shouldLoad(). + if ( !context ) { + return this.ACCEPT; + } + // The context for the toolbar popup is an iframe element here, // so check context.top instead of context if ( !context.top || !context.location ) { diff --git a/platform/firefox/vapi-client.js b/platform/firefox/vapi-client.js index e4bfca544..6bff1b684 100644 --- a/platform/firefox/vapi-client.js +++ b/platform/firefox/vapi-client.js @@ -23,14 +23,14 @@ addMessageListener, removeMessageListener, sendAsyncMessage, outerShutdown */ +'use strict'; + // For non background pages /******************************************************************************/ (function(self) { -'use strict'; - // https://github.com/chrisaljoudi/uBlock/issues/464 if ( document instanceof HTMLDocument === false ) { // https://github.com/chrisaljoudi/uBlock/issues/1528 diff --git a/src/js/contentscript.js b/src/js/contentscript.js index ae813bc7f..2bcc93a1f 100644 --- a/src/js/contentscript.js +++ b/src/js/contentscript.js @@ -1500,16 +1500,17 @@ vAPI.domSurveyor = (function() { /******************************************************************************/ vAPI.domIsLoaded = function(ev) { + // This can happen on Firefox. For instance: + // https://github.com/gorhill/uBlock/issues/1893 + if ( window.location === null ) { + return; + } + if ( ev instanceof Event ) { document.removeEventListener('DOMContentLoaded', vAPI.domIsLoaded); } vAPI.domIsLoaded = null; - // I've seen this happens on Firefox - if ( window.location === null ) { - return; - } - vAPI.executionCost.start(); vAPI.domWatcher.start();