Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:gorhill/uBlock into fix-475
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Jan 21, 2015
2 parents 7b8392c + 631da22 commit 4b2dced
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions platform/firefox/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

/******************************************************************************/

// Accessing the context of the background page from Console (e.g., about:addons):
// Accessing the context of the background page:
// var win = Services.appShell.hiddenDOMWindow.document.querySelector('iframe[src*=ublock]').contentWindow;

let bgProcess;
Expand All @@ -46,17 +46,17 @@ const restartListener = {
/******************************************************************************/

function startup(data, reason) {
let appShell = Components.classes['@mozilla.org/appshell/appShellService;1']
.getService(Components.interfaces.nsIAppShellService);

let onReady = function(e) {
if ( e ) {
this.removeEventListener(e.type, onReady);
}

let hDoc = Components.classes['@mozilla.org/appshell/appShellService;1']
.getService(Components.interfaces.nsIAppShellService)
.hiddenDOMWindow.document;

bgProcess = hDoc.documentElement.appendChild(
hDoc.createElementNS('http://www.w3.org/1999/xhtml', 'iframe')
let hiddenDoc = appShell.hiddenDOMWindow.document;
bgProcess = hiddenDoc.documentElement.appendChild(
hiddenDoc.createElementNS('http://www.w3.org/1999/xhtml', 'iframe')
);
bgProcess.setAttribute(
'src',
Expand All @@ -75,10 +75,20 @@ function startup(data, reason) {
}

let ww = Components.classes['@mozilla.org/embedcomp/window-watcher;1']
.getService(Components.interfaces.nsIWindowWatcher);
.getService(Components.interfaces.nsIWindowWatcher);

ww.registerNotification({
observe: function(win) {
observe: function(win, topic) {
if ( topic !== 'domwindowopened' ) {
return;
}

try {
appShell.hiddenDOMWindow;
} catch (ex) {
return;
}

ww.unregisterNotification(this);
win.addEventListener('DOMContentLoaded', onReady);
}
Expand Down Expand Up @@ -108,7 +118,8 @@ function shutdown(data, reason) {
function install() {
// https://bugzil.la/719376
Components.classes['@mozilla.org/intl/stringbundle;1']
.getService(Components.interfaces.nsIStringBundleService).flushBundles();
.getService(Components.interfaces.nsIStringBundleService)
.flushBundles();
}

/******************************************************************************/
Expand Down

0 comments on commit 4b2dced

Please sign in to comment.