Bug 609661 - Fire ViewChanged event when adding items to addon manager [r=mfinkle]
authorWes Johnston <wjohnston@mozilla.com>
Thu, 04 Nov 2010 16:18:00 -0400
changeset 66968 30c8722a8d686114a596f5b2590c11c82c4eaffd
parent 66967 808cb2bbf55159e08bfdb4641c07aa93bdcd0c27
child 66969 37b95b834e9482a1b27230a75b95125d21b3fee0
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs609661
Bug 609661 - Fire ViewChanged event when adding items to addon manager [r=mfinkle]
mobile/chrome/content/extensions.js
mobile/chrome/tests/browser_addons.js
--- a/mobile/chrome/content/extensions.js
+++ b/mobile/chrome/content/extensions.js
@@ -572,16 +572,20 @@ var ExtensionsView = {
     this.appendSearchResults(aBrowseAddons, true);
 
     let showmore = document.createElement("richlistitem");
     showmore.setAttribute("typeName", "showmore");
     showmore.setAttribute("label", strings.getString("addonsBrowseAll.label"));
 
     showmore.setAttribute("url", browseURL);
     this._list.appendChild(showmore);
+
+    let evt = document.createEvent("Events");
+    evt.initEvent("ViewChanged", true, false);
+    this._list.dispatchEvent(evt);
   },
 
   displaySearchResults: function ev_displaySearchResults(aAddons, aTotalResults, aSelectFirstResult) {
     this.clearSection("repo");
 
     let strings = Elements.browserBundle;
     if (aAddons.length == 0) {
       let msg = strings.getString("addonsSearchNone.search");
--- a/mobile/chrome/tests/browser_addons.js
+++ b/mobile/chrome/tests/browser_addons.js
@@ -160,25 +160,28 @@ function get_addon_element(aId) {
 
 }
 
 function open_manager(aView, aCallback) {
   var panelButton = document.getElementById("tool-panel-open")
   panelButton.click();
   var addonsButton = document.getElementById("tool-addons");
   addonsButton.click();
-  
-  ExtensionsView.init();
-  ExtensionsView._delayedInit();
 
-  // XXX - give the list time to add addons from the repo
-  // find a better way to do this
-  setTimeout(function() {
+  if (!ExtensionsView._list) {
+    window.addEventListener("ViewChanged", function() {
+      window.removeEventListener("ViewChanged", arguments.callee, true);
+      aCallback();
+    }, true);
+    
+    ExtensionsView.init();
+    ExtensionsView._delayedInit();
+  } else {
     aCallback();
-  }, 2000);
+  }
 }
 
 function close_manager(aCallback) {
   var prefsButton = document.getElementById("tool-preferences");
   prefsButton.click();
 
   BrowserUI.hidePanel();
   aCallback();