Skip to content

Commit

Permalink
Move listener registration behind INITIALIZED flag
Browse files Browse the repository at this point in the history
Should fix JS errors when restoring a browser session.

Also lets tests check badger.INITIALIZED to see if listeners are ready.
  • Loading branch information
ghostwords committed Jun 1, 2018
1 parent f52e5f8 commit fde33ef
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions src/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,15 @@ function Badger() {
}
});

// TODO: register all privacy badger listeners here in the storage callback
// start all the listeners
incognito.startListeners();
webrequest.startListeners();
HeuristicBlocking.startListeners();
FirefoxAndroid.startListeners();
startBackgroundListeners();

console.log("Privacy Badger is ready to rock!");
console.log("Set DEBUG=1 to view console messages.");

self.INITIALIZED = true;
});
Expand Down Expand Up @@ -800,21 +808,4 @@ function startBackgroundListeners() {
}
}

/**
* lets get this party started
*/
console.log('Loading badgers into the pen.');
var badger = window.badger = new Badger();

/**
* Start all the listeners
*/
incognito.startListeners();
webrequest.startListeners();
HeuristicBlocking.startListeners();
FirefoxAndroid.startListeners();
startBackgroundListeners();

// TODO move listeners and this message behind INITIALIZED
console.log('Privacy badger is ready to rock!');
console.log('Set DEBUG=1 to view console messages.');

0 comments on commit fde33ef

Please sign in to comment.