Bug 610764: Get Add-ons tab is not default selection in new profile. r=Unfocused, a=blocks-final
authorDave Townsend <dtownsend@oxymoronical.com>
Tue, 30 Nov 2010 14:19:10 -0800
changeset 58576 24685c64a5c891e0bb4e6785b73007caa91b77e8
parent 58575 61deb05747d68346dc8c5cc058d28cc4df9bf2e9
child 58577 cb897c736451fafe99bb7165df81c0119fedbb2f
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersUnfocused, blocks-final
bugs610764
milestone2.0b8pre
Bug 610764: Get Add-ons tab is not default selection in new profile. r=Unfocused, a=blocks-final
toolkit/mozapps/extensions/content/extensions.js
toolkit/mozapps/extensions/test/browser/Makefile.in
toolkit/mozapps/extensions/test/browser/browser_bug557943.js
toolkit/mozapps/extensions/test/browser/browser_bug562797.js
toolkit/mozapps/extensions/test/browser/browser_bug581076.js
toolkit/mozapps/extensions/test/browser/browser_bug610764.js
toolkit/mozapps/extensions/test/browser/browser_discovery.js
toolkit/mozapps/extensions/test/browser/browser_install.js
toolkit/mozapps/extensions/test/browser/head.js
--- a/toolkit/mozapps/extensions/content/extensions.js
+++ b/toolkit/mozapps/extensions/content/extensions.js
@@ -67,17 +67,17 @@ const SEARCH_SCORE_MATCH_WHOLEWORD = 10;
 const SEARCH_SCORE_MATCH_WORDBOUNDRY = 6;
 const SEARCH_SCORE_MATCH_SUBSTRING = 3;
 
 const UPDATES_RECENT_TIMESPAN = 2 * 24 * 3600000; // 2 days (in milliseconds)
 const UPDATES_RELEASENOTES_TRANSFORMFILE = "chrome://mozapps/content/extensions/updateinfo.xsl";
 
 const XMLURI_PARSE_ERROR = "http://www.mozilla.org/newlayout/xml/parsererror.xml"
 
-const VIEW_DEFAULT = "addons://list/extension";
+const VIEW_DEFAULT = "addons://discover/";
 
 var gStrings = {};
 XPCOMUtils.defineLazyServiceGetter(gStrings, "bundleSvc",
                                    "@mozilla.org/intl/stringbundle;1",
                                    "nsIStringBundleService");
 
 XPCOMUtils.defineLazyGetter(gStrings, "brand", function() {
   return this.bundleSvc.createBundle("chrome://branding/locale/brand.properties");
--- a/toolkit/mozapps/extensions/test/browser/Makefile.in
+++ b/toolkit/mozapps/extensions/test/browser/Makefile.in
@@ -56,16 +56,17 @@ include $(DEPTH)/config/autoconf.mk
   browser_bug567137.js \
   browser_bug572561.js \
   browser_bug577990.js \
   browser_bug581076.js \
   browser_bug587970.js \
   browser_bug591465.js \
   browser_bug596336.js \
   browser_bug608316.js \
+  browser_bug610764.js \
   browser_details.js \
   browser_discovery.js \
   browser_dragdrop.js \
   browser_list.js \
   browser_searching.js \
   browser_sorting.js \
   browser_uninstalling.js \
   browser_install.js \
--- a/toolkit/mozapps/extensions/test/browser/browser_bug557943.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug557943.js
@@ -36,26 +36,28 @@ function test() {
 function end_test() {
   close_manager(gManagerWindow, function() {
     finish();
   });
 }
 
 
 function perform_search(aQuery, aCallback) {
-  var searchBox = gManagerWindow.document.getElementById("header-search");
-  searchBox.value = aQuery;
+  waitForFocus(function() {
+    var searchBox = gManagerWindow.document.getElementById("header-search");
+    searchBox.value = aQuery;
 
-  EventUtils.synthesizeMouse(searchBox, 2, 2, { }, gManagerWindow);
-  EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow);
-  wait_for_view_load(gManagerWindow, function() {
-    var list = gManagerWindow.document.getElementById("search-list");
-    var rows = list.getElementsByTagName("richlistitem");
-    aCallback(rows);
-  });
+    EventUtils.synthesizeMouse(searchBox, 2, 2, { }, gManagerWindow);
+    EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow);
+    wait_for_view_load(gManagerWindow, function() {
+      var list = gManagerWindow.document.getElementById("search-list");
+      var rows = list.getElementsByTagName("richlistitem");
+      aCallback(rows);
+    });
+  }, gManagerWindow);
 }
 
 
 add_test(function() {
   perform_search(".net", function(aRows) {
     is(aRows.length, 1, "Should only get one result");
     is(aRows[0].mAddon.id, "addon1@tests.mozilla.org", "Should get expected addon as only result");
     run_next_test();
--- a/toolkit/mozapps/extensions/test/browser/browser_bug562797.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug562797.js
@@ -382,17 +382,17 @@ add_test(function() {
 // result works
 // Only relevant for in-content UI
 add_test(function() {
   if (!gUseInContentUI) {
     run_next_test();
     return;
   }
 
-  open_manager(null, function(aManager) {
+  open_manager("addons://list/extension", function(aManager) {
     info("Part 1");
     is_in_list(aManager, "addons://list/extension", false, false);
 
     var search = aManager.document.getElementById("header-search");
     search.focus();
     search.value = "bar";
     EventUtils.synthesizeKey("VK_RETURN", {});
 
@@ -448,17 +448,17 @@ add_test(function() {
 // Tests that refreshing a list view does not affect the history
 // Only relevant for in-content UI
 add_test(function() {
   if (!gUseInContentUI) {
     run_next_test();
     return;
   }
 
-  open_manager(null, function(aManager) {
+  open_manager("addons://list/extension", function(aManager) {
     info("Part 1");
     is_in_list(aManager, "addons://list/extension", false, false);
 
     EventUtils.synthesizeMouseAtCenter(aManager.document.getElementById("category-plugins"), { }, aManager);
 
     wait_for_view_load(aManager, function(aManager) {
       info("Part 2");
       is_in_list(aManager, "addons://list/plugin", true, false);
@@ -525,17 +525,17 @@ add_test(function() {
       }, false);
     });
   });
 });
 
 // Tests that removing an extension from the detail view goes back and doesn't
 // allow you to go forward again.
 add_test(function() {
-  open_manager(null, function(aManager) {
+  open_manager("addons://list/extension", function(aManager) {
     info("Part 1");
     is_in_list(aManager, "addons://list/extension", false, false);
 
     double_click_addon_element(aManager, "test1@tests.mozilla.org");
 
     wait_for_view_load(aManager, function(aManager) {
       info("Part 2");
       is_in_detail(aManager, "addons://list/extension", true, false);
@@ -569,8 +569,25 @@ add_test(function() {
     } else {
       is_element_visible(doc.getElementById("back-btn"), "Back button should not be hidden");
       is_element_visible(doc.getElementById("forward-btn"), "Forward button should not be hidden");
     }
 
     close_manager(aManager, run_next_test);
   });
 });
+
+// Tests that opening the manager opens the last view
+add_test(function() {
+  open_manager("addons://list/plugin", function(aManager) {
+    info("Part 1");
+    is_in_list(aManager, "addons://list/plugin", false, false);
+
+    close_manager(aManager, function() {
+      open_manager(null, function(aManager) {
+        info("Part 1");
+        is_in_list(aManager, "addons://list/plugin", false, false);
+
+        close_manager(aManager, run_next_test);
+      });
+    });
+  });
+});
--- a/toolkit/mozapps/extensions/test/browser/browser_bug581076.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug581076.js
@@ -35,31 +35,33 @@ function end_test() {
       aInstall.cancel();
     });
 
     close_manager(gManagerWindow, finish);
   });
 }
 
 function search(aRemoteSearch, aCallback) {
-  var searchBox = gManagerWindow.document.getElementById("header-search");
-  searchBox.value = SEARCH_QUERY;
+  waitForFocus(function() {
+    var searchBox = gManagerWindow.document.getElementById("header-search");
+    searchBox.value = SEARCH_QUERY;
 
-  EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow);
-  EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow);
+    EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow);
+    EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow);
 
-  wait_for_view_load(gManagerWindow, function() {
-    if (aRemoteSearch)
-      var filter = gManagerWindow.document.getElementById("search-filter-remote");
-    else
-      var filter = gManagerWindow.document.getElementById("search-filter-local");
-    EventUtils.synthesizeMouseAtCenter(filter, { }, gManagerWindow);
+    wait_for_view_load(gManagerWindow, function() {
+      if (aRemoteSearch)
+        var filter = gManagerWindow.document.getElementById("search-filter-remote");
+      else
+        var filter = gManagerWindow.document.getElementById("search-filter-local");
+      EventUtils.synthesizeMouseAtCenter(filter, { }, gManagerWindow);
 
-    executeSoon(aCallback);
-  });
+      executeSoon(aCallback);
+    });
+  }, gManagerWindow);
 }
 
 function check_allresultslink(aShouldShow) {
   var list = gManagerWindow.document.getElementById("search-list");
   var link = gManagerWindow.document.getElementById("search-allresults-link");
   is(link.parentNode, list.lastChild, "Footer should be at the end of the richlistbox");
   if (aShouldShow) {
     is_element_visible(link, "All Results link should be visible");
new file mode 100644
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/browser/browser_bug610764.js
@@ -0,0 +1,34 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+// Tests that the discovery view is the default
+
+var gCategoryUtilities;
+
+function test() {
+  waitForExplicitFinish();
+
+  open_manager(null, function(aWindow) {
+    waitForFocus(function() {
+      // The last view is cached except when it is the search view so switch to
+      // that and reopen to ensure we see the default view
+      var searchBox = aWindow.document.getElementById("header-search");
+      searchBox.value = "bar";
+
+      EventUtils.synthesizeMouseAtCenter(searchBox, { }, aWindow);
+      EventUtils.synthesizeKey("VK_RETURN", { }, aWindow);
+
+      wait_for_view_load(aWindow, function() {
+        close_manager(aWindow, function() {
+          open_manager(null, function(aWindow) {
+            gCategoryUtilities = new CategoryUtilities(aWindow);
+            is(gCategoryUtilities.selectedCategory, "discover", "Should show the discovery pane by default");
+
+            close_manager(aWindow, finish);
+          });
+        });
+      });
+    }, aWindow);
+  });
+}
--- a/toolkit/mozapps/extensions/test/browser/browser_discovery.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_discovery.js
@@ -1,15 +1,14 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
 // Tests that the discovery view loads properly
 
-const PREF_DISCOVERURL = "extensions.webservice.discoverURL";
 const PREF_BACKGROUND_UPDATE = "extensions.update.enabled";
 
 var gManagerWindow;
 var gCategoryUtilities;
 var gProvider;
 
 function test() {
   // Switch to a known url
--- a/toolkit/mozapps/extensions/test/browser/browser_install.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_install.js
@@ -199,17 +199,17 @@ add_test(function() {
   });
 });
 
 // Install an add-on through the search page then re-open the manager and then
 // undo it
 add_test(function() {
   installSearchResult(function() {
     close_manager(gManagerWindow, function() {
-      open_manager(null, function(aWindow) {
+        open_manager("addons://list/extension", function(aWindow) {
         gManagerWindow = aWindow;
         gCategoryUtilities = new CategoryUtilities(gManagerWindow);
         check_undo_install();
         run_next_test();
       });
     });
   });
 });
--- a/toolkit/mozapps/extensions/test/browser/head.js
+++ b/toolkit/mozapps/extensions/test/browser/head.js
@@ -21,27 +21,30 @@ const RELATIVE_DIR = pathParts.slice(4).
 const TESTROOT = "http://example.com/" + RELATIVE_DIR;
 const TESTROOT2 = "http://example.org/" + RELATIVE_DIR;
 const CHROMEROOT = pathParts.join("/") + "/";
 
 const MANAGER_URI = "about:addons";
 const INSTALL_URI = "chrome://mozapps/content/xpinstall/xpinstallConfirm.xul";
 const PREF_LOGGING_ENABLED = "extensions.logging.enabled";
 const PREF_SEARCH_MAXRESULTS = "extensions.getAddons.maxResults";
+const PREF_DISCOVERURL = "extensions.webservice.discoverURL";
 
 var gPendingTests = [];
 var gTestsRun = 0;
 var gTestStart = null;
 
 var gUseInContentUI = !gTestInWindow && ("switchToTabHavingURI" in window);
 
 // Turn logging on for all tests
 Services.prefs.setBoolPref(PREF_LOGGING_ENABLED, true);
 // Turn off remote results in searches
 Services.prefs.setIntPref(PREF_SEARCH_MAXRESULTS, 0);
+// Default to a local discovery pane
+Services.prefs.setCharPref(PREF_DISCOVERURL, "http://127.0.0.1/extensions-dummy/discoveryURL");
 registerCleanupFunction(function() {
   Services.prefs.clearUserPref(PREF_LOGGING_ENABLED);
   try {
     Services.prefs.clearUserPref(PREF_SEARCH_MAXRESULTS);
   }
   catch (e) {
   }