Test for Bug 680113 - Select Add-ons dialog lists distribution add-ons as installed by the user. r=Unfocused
authorJustin Wood <Callek@gmail.com>
Tue, 13 Sep 2011 01:18:01 -0400
changeset 76939 0159e317b73568c1fbb9c2d85f9ec6e10365f061
parent 76938 f794c079cf86d1ca1a7f78de8aa4c7fa7d5e257d
child 76940 20d65201c7ff0850940de1b9f1bd268a32eb6438
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersUnfocused
bugs680113
milestone9.0a1
Test for Bug 680113 - Select Add-ons dialog lists distribution add-ons as installed by the user. r=Unfocused
toolkit/mozapps/extensions/test/browser/browser_select_selection.js
--- a/toolkit/mozapps/extensions/test/browser/browser_select_selection.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_select_selection.js
@@ -67,21 +67,41 @@ function waitForView(aView, aCallback) {
 function getString(aName) {
   if (!aName)
     return "";
 
   var strings = Services.strings.createBundle("chrome://mozapps/locale/extensions/selectAddons.properties");
   return strings.GetStringFromName("action." + aName);
 }
 
+function getSourceString(aSource) {
+  if (!aSource)
+    return "";
+
+  var strings = Services.strings.createBundle("chrome://mozapps/locale/extensions/selectAddons.properties");
+  switch (aSource) {
+    case AddonManager.SCOPE_APPLICATION:
+      return strings.GetStringFromName("source.bundled");
+    case AddonManager.SCOPE_PROFILE:
+      return strings.GetStringFromName("source.profile");
+    default:
+      return strings.GetStringFromName("source.other");
+  }
+}
+
 function test() {
   waitForExplicitFinish();
 
   gProvider = new MockProvider();
 
+  // Set prefs for Distributed Extension Source tests.
+  Services.prefs.setBoolPref("extensions.installedDistroAddon.test3@tests.mozilla.org", true);
+  Services.prefs.setBoolPref("extensions.installedDistroAddon.test12@tests.mozilla.org", true);
+  Services.prefs.setBoolPref("extensions.installedDistroAddon.test15@tests.mozilla.org", true);
+
   ADDONS.forEach(function(aAddon, aPos) {
     var addon = new MockAddon("test" + aPos + "@tests.mozilla.org",
                               "Test Add-on " + aPos, "extension");
     addon.version = "1.0";
     addon.userDisabled = aAddon[0];
     addon.appDisabled = aAddon[1];
     addon.isActive = aAddon[3];
     addon.applyBackgroundUpdates = aAddon[5] ? AddonManager.AUTOUPDATE_ENABLE
@@ -203,16 +223,24 @@ add_test(function selection_test() {
     var id = parseInt(row.id.substring(4, row.id.length - 18));
     var addon = ADDONS[id];
 
     info("Testing add-on " + id);
     scrollBoxObject.ensureElementIsVisible(row);
     var keep = gWin.document.getAnonymousElementByAttribute(row, "anonid", "keep");
     var action = gWin.document.getAnonymousElementByAttribute(row, "class", "addon-action-message");
     var update = gWin.document.getAnonymousElementByAttribute(row, "anonid", "update");
+    var source = gWin.document.getAnonymousElementByAttribute(row, "class", "addon-source");
+
+    if (id == 3 || id == 12 || id == 15) {
+      // Distro Installed To Profile
+      is(source.textContent, getSourceString(APP), "Source message should have the right text for Distributed Addons");
+    } else {
+      is(source.textContent, getSourceString(addon[6]), "Source message should have the right text");
+    }
 
     // Non-profile add-ons don't appear to have updates since we won't install
     // them
     var hasUpdate = addon[4] && addon[6] == PROFILE;
 
     is(pos, addon[8], "Should have been in the right position");
     is(keep.checked, addon[7], "Keep checkbox should be in the right state");