Browse Source

Firefox: initialize when hiddenDOMWindow is ready

Probably not the best way to detect its readiness, but it works for now.
This fix should solve the incompatibility with the StartupMaster add-on.
pull/2/head
Deathamns 10 years ago
committed by gorhill
parent
commit
73945064ed
  1. 29
      platform/firefox/bootstrap.js

29
platform/firefox/bootstrap.js

@ -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; // var win = Services.appShell.hiddenDOMWindow.document.querySelector('iframe[src*=ublock]').contentWindow;
let bgProcess; let bgProcess;
@ -46,17 +46,17 @@ const restartListener = {
/******************************************************************************/ /******************************************************************************/
function startup(data, reason) { function startup(data, reason) {
let appShell = Components.classes['@mozilla.org/appshell/appShellService;1']
.getService(Components.interfaces.nsIAppShellService);
let onReady = function(e) { let onReady = function(e) {
if ( e ) { if ( e ) {
this.removeEventListener(e.type, onReady); 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( bgProcess.setAttribute(
'src', 'src',
@ -78,7 +78,17 @@ function startup(data, reason) {
.getService(Components.interfaces.nsIWindowWatcher); .getService(Components.interfaces.nsIWindowWatcher);
ww.registerNotification({ ww.registerNotification({
observe: function(win) {
observe: function(win, topic) {
if ( topic !== 'domwindowopened' ) {
return;
}
try {
appShell.hiddenDOMWindow;
} catch (ex) {
return;
}
ww.unregisterNotification(this); ww.unregisterNotification(this);
win.addEventListener('DOMContentLoaded', onReady); win.addEventListener('DOMContentLoaded', onReady);
} }
@ -108,7 +118,8 @@ function shutdown(data, reason) {
function install() { function install() {
// https://bugzil.la/719376 // https://bugzil.la/719376
Components.classes['@mozilla.org/intl/stringbundle;1'] Components.classes['@mozilla.org/intl/stringbundle;1']
.getService(Components.interfaces.nsIStringBundleService).flushBundles();
.getService(Components.interfaces.nsIStringBundleService)
.flushBundles();
} }
/******************************************************************************/ /******************************************************************************/

Loading…
Cancel
Save