Bug 562992 - The names of restartless extensions installed from the web while about:addons is open should appear after they're installed. r=bmcbride
authorDrew Willcoxon <adw@mozilla.com>
Thu, 15 Jul 2010 22:05:52 -0700
changeset 47787 6b22b96b2d6f6a6116f48bf4a7767bba4e3f17c5
parent 47786 574de87782f9eb577678823058c1b208a68113cb
child 47788 06a815baa315e91271eaa5f79701d7b1aa30e1fe
push id14419
push userdwillcoxon@mozilla.com
push dateFri, 16 Jul 2010 05:07:23 +0000
treeherderautoland@6b22b96b2d6f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbmcbride
bugs562992
milestone2.0b2pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 562992 - The names of restartless extensions installed from the web while about:addons is open should appear after they're installed. r=bmcbride
toolkit/mozapps/extensions/content/extensions.xml
toolkit/mozapps/extensions/test/browser/Makefile.in
toolkit/mozapps/extensions/test/browser/browser_bug562992.js
toolkit/mozapps/extensions/test/browser/head.js
--- a/toolkit/mozapps/extensions/content/extensions.xml
+++ b/toolkit/mozapps/extensions/content/extensions.xml
@@ -1173,16 +1173,17 @@
                                                 "install-status");
       </field>
 
       <method name="onInstallCompleted">
         <body><![CDATA[
           this.refreshInfo();
           if (!this.isPending("install")) {
             delete this.mInstall;
+            this.setAttribute("name", this.mAddon.name);
             this.setAttribute("status", "installed");
           }
         ]]></body>
       </method>
 
       <method name="refreshInfo">
         <body><![CDATA[
           this.mAddon = this.mAddon || this.mInstall.addon;
--- a/toolkit/mozapps/extensions/test/browser/Makefile.in
+++ b/toolkit/mozapps/extensions/test/browser/Makefile.in
@@ -51,16 +51,17 @@ include $(DEPTH)/config/autoconf.mk
   browser_bug562899.js \
   browser_bug572561.js \
   browser_dragdrop.js \
   browser_sorting.js \
   browser_updatessl.js \
   browser_updatessl.rdf \
   browser_installssl.js \
   redirect.sjs \
+  browser_bug562992.js \
   $(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
 libs:: $(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir)
 
 libs::
new file mode 100644
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug562992.js
@@ -0,0 +1,105 @@
+/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:set ts=2 sw=2 sts=2 et: */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is the Extension Manager UI.
+ *
+ * The Initial Developer of the Original Code is
+ * the Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Drew Willcoxon <adw@mozilla.com> (Original Author)
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/**
+ * This test ensures that when the extension manager UI is open and a
+ * restartless extension is installed from the web, its correct name appears
+ * when the download and installation complete.  See bug 562992.
+ */
+
+var gManagerWindow;
+var gProvider;
+var gInstall;
+
+const EXTENSION_NAME = "Wunderbar";
+
+function test() {
+  waitForExplicitFinish();
+
+  gProvider = new MockProvider();
+
+  open_manager("addons://list/extension", function (aWindow) {
+    gManagerWindow = aWindow;
+    run_next_test();
+  });
+}
+
+function end_test() {
+  close_manager(gManagerWindow, function () {
+    finish();
+  });
+}
+
+// Create a MockInstall with a MockAddon payload and add it to the provider,
+// causing the onNewInstall event to fire, which in turn will cause a new
+// "installing" item to appear in the list of extensions.
+add_test(function () {
+  let addon = new MockAddon(undefined, EXTENSION_NAME, "extension", true);
+  gInstall = new MockInstall(undefined, undefined, addon);
+  gInstall.addTestListener({
+    onNewInstall: function () {
+      run_next_test();
+    }
+  });
+  gProvider.addInstall(gInstall);
+});
+
+// Finish the install, which will cause the "installing" item to be converted
+// to an "installed" item, which should have the correct add-on name.
+add_test(function () {
+  gInstall.addTestListener({
+    onInstallEnded: function () {
+      let list = gManagerWindow.document.getElementById("addon-list");
+
+      // To help prevent future breakage, don't assume the item is the only one
+      // in the list, or that it's first in the list.  Find it by name.
+      for (let i = 0; i < list.itemCount; i++) {
+        let item = list.getItemAtIndex(i);
+        if (item.getAttribute("name") === EXTENSION_NAME) {
+          ok(true, "Item with correct name found");
+          run_next_test();
+          return;
+        }
+      }
+      ok(false, "Item with correct name was not found");
+      run_next_test();
+    }
+  });
+  gInstall.install();
+});
--- a/toolkit/mozapps/extensions/test/browser/head.js
+++ b/toolkit/mozapps/extensions/test/browser/head.js
@@ -524,32 +524,33 @@ MockAddon.prototype = {
 
   cancelUninstall: function() {
     // To be implemented when needed
   }
 };
 
 /***** Mock AddonInstall object for the Mock Provider *****/
 
-function MockInstall(aName, aType) {
+function MockInstall(aName, aType, aAddonToInstall) {
   this.name = aName || "";
   this.type = aType || "extension";
   this.version = "1.0";
   this.iconURL = "";
   this.infoURL = "";
   this.state = AddonManager.STATE_AVAILABLE;
   this.error = 0;
   this.sourceURI = null;
   this.file = null;
   this.progress = 0;
   this.maxProgress = -1;
   this.certificate = null;
   this.certName = "";
   this.existingAddon = null;
   this.addon = null;
+  this._addonToInstall = aAddonToInstall;
   this.listeners = [];
 
   // Another type of install listener for tests that want to check the results
   // of code run from standard install listeners
   this.testListeners = [];
 }
 
 MockInstall.prototype = {
@@ -563,17 +564,18 @@ MockInstall.prototype = {
         if (!this.callListeners("onInstallStarted")) {
           // Reverting to STATE_DOWNLOADED instead to be implemented when needed
           this.state = AddonManager.STATE_CANCELLED;
           this.callListeners("onInstallCancelled");
           return;
         }
 
         // Adding addon to MockProvider to be implemented when needed
-        this.addon = new MockAddon("", this.name, this.type);
+        this.addon = this._addonToInstall ||
+                     new MockAddon("", this.name, this.type);
         this.state = AddonManager.STATE_INSTALLED;
         this.callListeners("onInstallEnded");
         break;
       case AddonManager.STATE_DOWNLOADING:
       case AddonManager.STATE_CHECKING:
       case AddonManger.STATE_INSTALLING:
         // Installation is already running
         return;