Bug 589954: addon install blocked notification should replace dismissed notification, r=dtownsend, a=blocking
authorGavin Sharp <gavin@gavinsharp.com>
Thu, 26 Aug 2010 19:01:28 -0400
changeset 51644 1c0313114a8f1cb2410dadbea8b26b0f721cf04f
parent 51643 f0184863691ea5b21e87d3c2e4386b58c986ccd9
child 51645 cba5d93947b9dfc04bc56bd1d85b4932e2f91db9
push id15377
push usergsharp@mozilla.com
push dateSat, 28 Aug 2010 01:26:18 +0000
treeherdermozilla-central@1688aa462b49 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdtownsend, blocking
bugs589954
milestone2.0b5pre
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 589954: addon install blocked notification should replace dismissed notification, r=dtownsend, a=blocking
browser/base/content/browser.js
browser/base/content/test/browser_bug553455.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -677,18 +677,16 @@ const gXPInstallObserver = {
       try {
         enabled = gPrefService.getBoolPref("xpinstall.enabled");
       }
       catch (e) {
       }
 
       if (!enabled) {
         notificationID = "xpinstall-disabled"
-        if (PopupNotifications.getNotification(notificationID, browser))
-          return;
 
         if (gPrefService.prefIsLocked("xpinstall.enabled")) {
           messageString = gNavigatorBundle.getString("xpinstallDisabledMessageLocked");
           buttons = [];
         }
         else {
           messageString = gNavigatorBundle.getString("xpinstallDisabledMessage");
 
@@ -697,19 +695,16 @@ const gXPInstallObserver = {
             accessKey: gNavigatorBundle.getString("xpinstallDisabledButton.accesskey"),
             callback: function editPrefs() {
               gPrefService.setBoolPref("xpinstall.enabled", true);
             }
           };
         }
       }
       else {
-        if (PopupNotifications.getNotification(notificationID, browser))
-          return;
-
         messageString = gNavigatorBundle.getFormattedString("xpinstallPromptWarning",
                           [brandShortName, installInfo.originatingURI.host]);
 
         action = {
           label: gNavigatorBundle.getString("xpinstallPromptAllowButton"),
           accessKey: gNavigatorBundle.getString("xpinstallPromptAllowButton.accesskey"),
           callback: function() {
             installInfo.install();
@@ -744,20 +739,16 @@ const gXPInstallObserver = {
         messageString = messageString.replace("#3", brandShortName);
         messageString = messageString.replace("#4", Services.appinfo.version);
 
         PopupNotifications.show(browser, notificationID, messageString, anchorID,
                                 action, null, options);
       });
       break;
     case "addon-install-complete":
-      var notification = PopupNotifications.getNotification(notificationID, browser);
-      if (notification)
-        PopupNotifications.remove(notification);
-
       var needsRestart = installInfo.installs.some(function(i) {
         return i.addon.pendingOperations != AddonManager.PENDING_NONE;
       });
 
       if (needsRestart) {
         messageString = gNavigatorBundle.getString("addonsInstalledNeedsRestart");
         action = {
           label: gNavigatorBundle.getString("addonInstallRestartButton"),
--- a/browser/base/content/test/browser_bug553455.js
+++ b/browser/base/content/test/browser_bug553455.js
@@ -431,16 +431,115 @@ function test_theme() {
          "Theme Test will be installed after you restart " + gApp + ".",
          "Should have seen the right message");
 
       gBrowser.removeTab(gBrowser.selectedTab);
       Services.perms.remove("example.com", "install");
       runNextTest();
     });
   });
+},
+
+function test_renotify_blocked() {
+  var triggers = encodeURIComponent(JSON.stringify({
+    "XPI": "unsigned.xpi"
+  }));
+  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
+
+  // Wait for the blocked notification
+  wait_for_notification(function(aPanel) {
+    let notification = aPanel.childNodes[0];
+    is(notification.id, "addon-install-blocked", "Should have seen the install blocked");
+
+    aPanel.addEventListener("popuphidden", function () {
+      aPanel.removeEventListener("popuphidden", arguments.callee, false);
+      info("Timeouts after this probably mean bug 589954 regressed");
+      executeSoon(function () {
+        gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
+
+        wait_for_notification(function(aPanel) {
+          let notification = aPanel.childNodes[0];
+          is(notification.id, "addon-install-blocked",
+             "Should have seen the install blocked - 2nd time");
+
+          AddonManager.getAllInstalls(function(aInstalls) {
+          is(aInstalls.length, 2, "Should be two pending installs");
+            aInstalls[0].cancel();
+            aInstalls[1].cancel();
+
+            info("Closing browser tab");
+            gBrowser.removeTab(gBrowser.selectedTab);
+            runNextTest();
+          });
+        });
+
+      });
+    }, false);
+
+    // hide the panel (this simulates the user dismissing it)
+    aPanel.hidePopup();
+  });
+},
+
+function test_renotify_installed() {
+  var pm = Services.perms;
+  pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
+
+  var triggers = encodeURIComponent(JSON.stringify({
+    "XPI": "unsigned.xpi"
+  }));
+  gBrowser.selectedTab = gBrowser.addTab();
+  gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
+
+  // Wait for the install confirmation dialog
+  wait_for_install_dialog(function(aWindow) {
+    aWindow.document.documentElement.acceptDialog();
+
+    // Wait for the complete notification
+    wait_for_notification(function(aPanel) {
+      let notification = aPanel.childNodes[0];
+      is(notification.id, "addon-install-complete", "Should have seen the install complete");
+
+      // Dismiss the notification
+      aPanel.addEventListener("popuphidden", function () {
+        aPanel.removeEventListener("popuphidden", arguments.callee, false);
+
+        // Install another
+        executeSoon(function () {
+          gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
+
+          // Wait for the install confirmation dialog
+          wait_for_install_dialog(function(aWindow) {
+            aWindow.document.documentElement.acceptDialog();
+            info("Timeouts after this probably mean bug 589954 regressed");
+
+            // Wait for the complete notification
+            wait_for_notification(function(aPanel) {
+              let notification = aPanel.childNodes[0];
+              is(notification.id, "addon-install-complete", "Should have seen the second install complete");
+
+              AddonManager.getAllInstalls(function(aInstalls) {
+              is(aInstalls.length, 2, "Should be two pending installs");
+                aInstalls[0].cancel();
+                aInstalls[1].cancel();
+
+                gBrowser.removeTab(gBrowser.selectedTab);
+                runNextTest();
+              });
+            });
+          });
+
+        });
+      }, false);
+  
+      // hide the panel (this simulates the user dismissing it)
+      aPanel.hidePopup();
+    });
+  });
 }
 ];
 
 function runNextTest() {
   AddonManager.getAllInstalls(function(aInstalls) {
     is(aInstalls.length, 0, "Should be no active installs");
 
     if (TESTS.length == 0) {