From b5120ebfb64154908f1163930568a125d0507ee8 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Thu, 27 Jan 2011 09:36:22 -0800 Subject: [PATCH] Bug 627851 - PreferencesView._delayedInit is not delayed enough [r=mfinkle] --- mobile/chrome/content/browser-ui.js | 8 +++++++- mobile/chrome/content/preferences.js | 6 ++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/mobile/chrome/content/browser-ui.js b/mobile/chrome/content/browser-ui.js index 2acfc827ebc2..2a195bd43a95 100644 --- a/mobile/chrome/content/browser-ui.js +++ b/mobile/chrome/content/browser-ui.js @@ -743,8 +743,14 @@ var BrowserUI = { Elements.panelUI.hidden = false; Elements.contentShowing.setAttribute("disabled", "true"); - if (aPage != undefined) + if (aPage) { this.switchPane(aPage); + } else { + // Fire a "select" event anyway so listeners know when the panel is opened. + let event = document.createEvent("Events"); + event.initEvent("select", true, true); + document.getElementById("panel-items").dispatchEvent(event); + } }, hidePanel: function hidePanel() { diff --git a/mobile/chrome/content/preferences.js b/mobile/chrome/content/preferences.js index 50bfebd0ed2b..359c39cd37b8 100644 --- a/mobile/chrome/content/preferences.js +++ b/mobile/chrome/content/preferences.js @@ -41,7 +41,7 @@ var PreferencesView = { _msg: null, _restartCount: 0, - _messageActions: function ev__messageActions(aData) { + _messageActions: function pv__messageActions(aData) { if (aData == "prefs-restart-app") { // Notify all windows that an application quit has been requested var cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance(Ci.nsISupportsPRBool); @@ -107,13 +107,15 @@ var PreferencesView = { let panels = document.getElementById("panel-items"); panels.addEventListener("select", function(aEvent) { + if (aEvent.target != panels) + return; if (panels.selectedPanel.id == "prefs-container") self._delayedInit(); }, false); }, - _delayedInit: function ev__delayedInit() { + _delayedInit: function pv__delayedInit() { if (this._languages) return;