From c165842c746642fc2d5fc6f545c125ad8bfa4353 Mon Sep 17 00:00:00 2001 From: Gijs Kruitbosch Date: Tue, 22 Oct 2013 13:07:30 +0200 Subject: [PATCH] Bug 890319 - about:customize doesn't work if we try to enter before the window has loaded, r=mikedeboer --- browser/base/content/browser.js | 3 + .../customizableui/src/CustomizeMode.jsm | 85 +++++++++++-------- 2 files changed, 52 insertions(+), 36 deletions(-) diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 880330d5cf1..66e947fb2bb 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -736,6 +736,8 @@ const gFormSubmitObserver = { }; var gBrowserInit = { + delayedStartupFinished: false, + onLoad: function() { gMultiProcessBrowser = gPrefService.getBoolPref("browser.tabs.remote"); @@ -1185,6 +1187,7 @@ var gBrowserInit = { setTimeout(function () { BrowserChromeTest.markAsReady(); }, 0); }); + this.delayedStartupFinished = true; Services.obs.notifyObservers(window, "browser-delayed-startup-finished", ""); TelemetryTimestamps.add("delayedStartupFinished"); diff --git a/browser/components/customizableui/src/CustomizeMode.jsm b/browser/components/customizableui/src/CustomizeMode.jsm index a2aa320a813..5fdd6568f66 100644 --- a/browser/components/customizableui/src/CustomizeMode.jsm +++ b/browser/components/customizableui/src/CustomizeMode.jsm @@ -93,43 +93,56 @@ CustomizeMode.prototype = { return; } - // Disable lightweight themes while in customization mode since - // they don't have large enough images to pad the full browser window. - LightweightThemeManager.temporarilyToggleTheme(false); - - this.dispatchToolboxEvent("beforecustomization"); - - let window = this.window; - let document = this.document; - - CustomizableUI.addListener(this); - - // Add a keypress listener and mousedown listener to the tab-view-deck so that - // we can quickly exit customization mode when pressing ESC or clicking on - // the blueprint outside the customization container. - let deck = document.getElementById("tab-view-deck"); - deck.addEventListener("keypress", this); - deck.addEventListener("mousedown", this); - - // Same goes for the menu button - if we're customizing, a mousedown to the - // menu button means a quick exit from customization mode. - window.PanelUI.hide(); - window.PanelUI.menuButton.addEventListener("mousedown", this); - window.PanelUI.menuButton.open = true; - window.PanelUI.beginBatchUpdate(); - - // Move the mainView in the panel to the holder so that we can see it - // while customizing. - let panelHolder = document.getElementById("customization-panelHolder"); - panelHolder.appendChild(window.PanelUI.mainView); - - this._transitioning = true; - - let customizer = document.getElementById("customization-container"); - customizer.parentNode.selectedPanel = customizer; - customizer.hidden = false; - Task.spawn(function() { + // We shouldn't start customize mode until after browser-delayed-startup has finished: + if (!this.window.gBrowserInit.delayedStartupFinished) { + let delayedStartupDeferred = Promise.defer(); + let delayedStartupObserver = function(aSubject) { + if (aSubject == this.window) { + Services.obs.removeObserver(delayedStartupObserver, "browser-delayed-startup-finished"); + delayedStartupDeferred.resolve(); + } + }.bind(this); + Services.obs.addObserver(delayedStartupObserver, "browser-delayed-startup-finished", false); + yield delayedStartupDeferred.promise; + } + + // Disable lightweight themes while in customization mode since + // they don't have large enough images to pad the full browser window. + LightweightThemeManager.temporarilyToggleTheme(false); + + this.dispatchToolboxEvent("beforecustomization"); + + let window = this.window; + let document = this.document; + + CustomizableUI.addListener(this); + + // Add a keypress listener and mousedown listener to the tab-view-deck so that + // we can quickly exit customization mode when pressing ESC or clicking on + // the blueprint outside the customization container. + let deck = document.getElementById("tab-view-deck"); + deck.addEventListener("keypress", this); + deck.addEventListener("mousedown", this); + + // Same goes for the menu button - if we're customizing, a mousedown to the + // menu button means a quick exit from customization mode. + window.PanelUI.hide(); + window.PanelUI.menuButton.addEventListener("mousedown", this); + window.PanelUI.menuButton.open = true; + window.PanelUI.beginBatchUpdate(); + + // Move the mainView in the panel to the holder so that we can see it + // while customizing. + let panelHolder = document.getElementById("customization-panelHolder"); + panelHolder.appendChild(window.PanelUI.mainView); + + this._transitioning = true; + + let customizer = document.getElementById("customization-container"); + customizer.parentNode.selectedPanel = customizer; + customizer.hidden = false; + yield this._doTransition(true); // Let everybody in this window know that we're about to customize.