Bug 909124 - [b2g desktop] shell.js did not get correct mozbrowserloadstart event to send Gaia the pending chromeEvents. r=fabrice

This commit is contained in:
Rudy Lu 2013-08-28 07:58:27 -04:00
parent a17454fcb3
commit d0ce3f1985

View File

@ -462,35 +462,21 @@ var shell = {
}
break;
case 'mozbrowserloadstart':
if (content.document.location == 'about:blank')
if (content.document.location == 'about:blank') {
this.contentBrowser.addEventListener('mozbrowserlocationchange', this, true);
return;
}
this.contentBrowser.removeEventListener('mozbrowserloadstart', this, true);
this.reportCrash(true);
Cu.import('resource://gre/modules/Webapps.jsm');
DOMApplicationRegistry.allAppsLaunchable = true;
this.sendEvent(window, 'ContentStart');
content.addEventListener('load', function shell_homeLoaded() {
content.removeEventListener('load', shell_homeLoaded);
shell.isHomeLoaded = true;
#ifdef MOZ_WIDGET_GONK
libcutils.property_set('sys.boot_completed', '1');
#endif
Services.obs.notifyObservers(null, "browser-ui-startup-complete", "");
if ('pendingChromeEvents' in shell) {
shell.pendingChromeEvents.forEach((shell.sendChromeEvent).bind(shell));
}
delete shell.pendingChromeEvents;
});
this.notifyContentStart();
break;
case 'mozbrowserlocationchange':
if (content.document.location == 'about:blank') {
return;
}
this.notifyContentStart();
break;
case 'MozApplicationManifest':
try {
if (!Services.prefs.getBoolPref('browser.cache.offline.enable'))
@ -592,6 +578,36 @@ var shell = {
sender.sendAsyncMessage(activity.response, { success: false });
}
}
},
notifyContentStart: function shell_notifyContentStart() {
this.contentBrowser.removeEventListener('mozbrowserloadstart', this, true);
this.contentBrowser.removeEventListener('mozbrowserlocationchange', this, true);
let content = this.contentBrowser.contentWindow;
this.reportCrash(true);
Cu.import('resource://gre/modules/Webapps.jsm');
DOMApplicationRegistry.allAppsLaunchable = true;
this.sendEvent(window, 'ContentStart');
content.addEventListener('load', function shell_homeLoaded() {
content.removeEventListener('load', shell_homeLoaded);
shell.isHomeLoaded = true;
#ifdef MOZ_WIDGET_GONK
libcutils.property_set('sys.boot_completed', '1');
#endif
Services.obs.notifyObservers(null, "browser-ui-startup-complete", "");
if ('pendingChromeEvents' in shell) {
shell.pendingChromeEvents.forEach((shell.sendChromeEvent).bind(shell));
}
delete shell.pendingChromeEvents;
});
}
};