From 04dad2716562cb8bad8ff0db21e7267204e0967d Mon Sep 17 00:00:00 2001 From: gorhill Date: Wed, 17 Jun 2015 17:56:04 -0400 Subject: this fixes warnings about "Services" being undefined after re-enabling uBlock --- platform/firefox/frameModule.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/platform/firefox/frameModule.js b/platform/firefox/frameModule.js index 87edc75..fa5e76b 100644 --- a/platform/firefox/frameModule.js +++ b/platform/firefox/frameModule.js @@ -135,6 +135,17 @@ const contentObserver = { // https://bugzil.la/612921 shouldLoad: function(type, location, origin, context) { + // For whatever reason, sometimes the global scope is completely + // uninitialized at this point. Repro steps: + // - Launch FF with uBlock enabled + // - Disable uBlock + // - Enable uBlock + // - Services and all other global variables are undefined + // Hopefully will eventually understand why this happens. + if ( Services === undefined ) { + return this.ACCEPT; + } + if ( !context ) { return this.ACCEPT; } @@ -284,6 +295,17 @@ const contentObserver = { }, observe: function(doc) { + // For whatever reason, sometimes the global scope is completely + // uninitialized at this point. Repro steps: + // - Launch FF with uBlock enabled + // - Disable uBlock + // - Enable uBlock + // - Services and all other global variables are undefined + // Hopefully will eventually understand why this happens. + if ( Services === undefined ) { + return; + } + let win = doc.defaultView; if ( !win ) { -- cgit v1.1