Bug 603676 - Fire a UIReadyDelayed event for panel and feedback initialization [r=mfinkle]
--- a/mobile/app/profile/extensions/feedback@mobile.mozilla.org/content/overlay.js
+++ b/mobile/app/profile/extensions/feedback@mobile.mozilla.org/content/overlay.js
@@ -38,24 +38,21 @@
var Feedback = {
init: function(aEvent) {
let appInfo = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULAppInfo);
document.getElementById("feedback-about").setAttribute("desc", appInfo.version);
// A simple frame script to fill in the referrer page
messageManager.loadFrameScript("data:,addMessageListener('Feedback:InitPage', function(m) { content.document.getElementById('id_url').value = m.json.referrer; });", true);
- // Try to delay the widget initialization during startup
- messageManager.addMessageListener("DOMContentLoaded", function() {
- // We only want to delay one time
- messageManager.removeMessageListener("DOMContentLoaded", arguments.callee, true);
-
- // We unhide the panelUI so the XBL and settings can initialize
+ // Delay the widget initialization during startup.
+ window.addEventListener("UIReadyDelayed", function(aEvent) {
+ window.removeEventListener(aEvent.type, arguments.callee, false);
document.getElementById("feedback-container").hidden = false;
- });
+ }, false);
},
openFeedback: function(aURL) {
let currentURL = Browser.selectedBrowser.currentURI.spec;
let newTab = BrowserUI.newTab(aURL);
// Tell the feedback page to fill in the referrer URL
newTab.browser.messageManager.addMessageListener("DOMContentLoaded", function() {
--- a/mobile/chrome/content/browser-ui.js
+++ b/mobile/chrome/content/browser-ui.js
@@ -440,25 +440,33 @@ var BrowserUI = {
window.addEventListener("keydown", this, true);
// listening escape to dismiss dialog on VK_ESCAPE
window.addEventListener("keypress", this, true);
// listening AppCommand to handle special keys
window.addEventListener("AppCommand", this, true);
- // Push the panel initialization out of the startup path
- // (Using a message because we have no good way to delay-init [Bug 535366])
+ // We can delay some initialization until after startup. We wait until
+ // the first page is shown, then dispatch a UIReadyDelayed event.
messageManager.addMessageListener("pageshow", function() {
if (getBrowser().currentURI.spec == "about:blank")
return;
- // We only want to delay one time
messageManager.removeMessageListener("pageshow", arguments.callee, true);
+ let event = document.createEvent("Events");
+ event.initEvent("UIReadyDelayed", true, false);
+ window.dispatchEvent(event);
+ });
+
+ // Delay the panel UI and Sync initialization.
+ window.addEventListener("UIReadyDelayed", function(aEvent) {
+ window.removeEventListener(aEvent.type, arguments.callee, false);
+
// We unhide the panelUI so the XBL and settings can initialize
Elements.panelUI.hidden = false;
// Init the views
ExtensionsView.init();
DownloadsView.init();
PreferencesView.init();
ConsoleView.init();
@@ -468,17 +476,17 @@ var BrowserUI = {
Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime)
.ensureContentProcess();
#endif
#ifdef MOZ_SERVICES_SYNC
// Init the sync system
WeaveGlue.init();
#endif
- });
+ }, false);
FormHelperUI.init();
FindHelperUI.init();
PageActions.init();
},
uninit: function() {
ExtensionsView.uninit();