Bug 677646 - Install Add-on from file no longer works. r=dtownsend
authorBlair McBride <bmcbride@mozilla.com>
Tue, 16 Aug 2011 18:16:37 +1200
changeset 75361 67142b6a15ab393573e477981a089ad6ea59057a
parent 75360 f9a0435281d32ac2f76eb93c2ba30fa77f5fe342
child 75362 32d45b1d060d51d1d7e9d9f33d98db849402274f
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
reviewersdtownsend
bugs677646
milestone8.0a1
Bug 677646 - Install Add-on from file no longer works. r=dtownsend
toolkit/mozapps/extensions/content/extensions.js
toolkit/mozapps/extensions/test/browser/browser_bug567127.js
--- a/toolkit/mozapps/extensions/content/extensions.js
+++ b/toolkit/mozapps/extensions/content/extensions.js
@@ -1101,17 +1101,17 @@ var gViewController = {
         var files = fp.files;
         var installs = [];
 
         function buildNextInstall() {
           if (!files.hasMoreElements()) {
             if (installs.length > 0) {
               // Display the normal install confirmation for the installs
               AddonManager.installAddonsFromWebpage("application/x-xpinstall",
-                                                    this, null, installs);
+                                                    window, null, installs);
             }
             return;
           }
 
           var file = files.getNext();
           AddonManager.getInstallForFile(file, function(aInstall) {
             installs.push(aInstall);
             buildNextInstall();
--- a/toolkit/mozapps/extensions/test/browser/browser_bug567127.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug567127.js
@@ -4,16 +4,17 @@
 
 // Tests bug 567127 - Add install button to the add-ons manager
 
 
 var gFilePickerFiles = [];
 var gMockFilePickerFactory;
 var gMockFilePickerFactoryCID;
 var gManagerWindow;
+var gSawInstallNotification = false;
 
 function MockFilePicker() { }
 
 MockFilePicker.prototype = {
   QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIFilePicker]),
   init: function(aParent, aTitle, aMode) { },
   appendFilters: function(aFilterMask) { },
   appendFilter: function(aTitle, aFilter) { },
@@ -92,16 +93,26 @@ WindowOpenListener.prototype = {
 
     // Let the window close complete
     executeSoon(this.closecallback);
     this.closecallback = null;
   }
 };
 
 
+var gInstallNotificationObserver = {
+  observe: function(aSubject, aTopic, aData) {
+    var installInfo = aSubject.QueryInterface(Ci.amIWebInstallInfo);
+    isnot(installInfo.originatingWindow, null, "Notification should have non-null originatingWindow");
+    gSawInstallNotification = true;
+    Services.obs.removeObserver(this, "addon-install-started");
+  }
+};
+
+
 function test_confirmation(aWindow, aExpectedURLs) {
   var list = aWindow.document.getElementById("itemList");
   is(list.childNodes.length, aExpectedURLs.length, "Should be the right number of installs");
 
   aExpectedURLs.forEach(function(aURL) {
     var node = list.firstChild;
     while (node) {
       if (node.url == aURL) {
@@ -130,30 +141,35 @@ function test() {
 
   open_manager("addons://list/extension", function(aWindow) {
     gManagerWindow = aWindow;
     run_next_test();
   });
 }
 
 function end_test() {
+  is(gSawInstallNotification, true, "Should have seen addon-install-started notification.");
+
   var compReg = Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar);
   compReg.unregisterFactory(gMockFilePickerFactoryCID,
                             gMockFilePickerFactory);
   close_manager(gManagerWindow, function() {
     finish();
   });
 }
 
 
 add_test(function() {
   var filePaths = [
                    get_addon_file_url("browser_bug567127_1.xpi"),
                    get_addon_file_url("browser_bug567127_2.xpi")
                   ];
   gFilePickerFiles = filePaths.map(function(aPath) aPath.file);
   
+  Services.obs.addObserver(gInstallNotificationObserver,
+                           "addon-install-started", false);
+
   new WindowOpenListener(INSTALL_URI, function(aWindow) {
     test_confirmation(aWindow, filePaths.map(function(aPath) aPath.spec));
   }, run_next_test);
-  
+
   gManagerWindow.gViewController.doCommand("cmd_installFromFile");
 });