From e7d2a6945f513ea00da5943a88e77d427bbf7334 Mon Sep 17 00:00:00 2001 From: Dave Townsend Date: Tue, 30 Nov 2010 14:19:10 -0800 Subject: [PATCH] Bug 610764: Get Add-ons tab is not default selection in new profile. r=Unfocused, a=blocks-final --- .../mozapps/extensions/content/extensions.js | 2 +- .../extensions/test/browser/Makefile.in | 1 + .../test/browser/browser_bug557943.js | 20 ++++++----- .../test/browser/browser_bug562797.js | 23 +++++++++++-- .../test/browser/browser_bug581076.js | 26 +++++++------- .../test/browser/browser_bug610764.js | 34 +++++++++++++++++++ .../test/browser/browser_discovery.js | 1 - .../test/browser/browser_install.js | 2 +- .../mozapps/extensions/test/browser/head.js | 3 ++ 9 files changed, 85 insertions(+), 27 deletions(-) create mode 100644 toolkit/mozapps/extensions/test/browser/browser_bug610764.js diff --git a/toolkit/mozapps/extensions/content/extensions.js b/toolkit/mozapps/extensions/content/extensions.js index d3a5a7b3dbf2..df72c3d66f93 100644 --- a/toolkit/mozapps/extensions/content/extensions.js +++ b/toolkit/mozapps/extensions/content/extensions.js @@ -72,7 +72,7 @@ const UPDATES_RELEASENOTES_TRANSFORMFILE = "chrome://mozapps/content/extensions/ 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", diff --git a/toolkit/mozapps/extensions/test/browser/Makefile.in b/toolkit/mozapps/extensions/test/browser/Makefile.in index cc7d76ee92ad..e100e20fee72 100644 --- a/toolkit/mozapps/extensions/test/browser/Makefile.in +++ b/toolkit/mozapps/extensions/test/browser/Makefile.in @@ -61,6 +61,7 @@ _MAIN_TEST_FILES = \ browser_bug591465.js \ browser_bug596336.js \ browser_bug608316.js \ + browser_bug610764.js \ browser_details.js \ browser_discovery.js \ browser_dragdrop.js \ diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug557943.js b/toolkit/mozapps/extensions/test/browser/browser_bug557943.js index e7f60741fa7b..88c62b507e37 100644 --- a/toolkit/mozapps/extensions/test/browser/browser_bug557943.js +++ b/toolkit/mozapps/extensions/test/browser/browser_bug557943.js @@ -41,16 +41,18 @@ function end_test() { 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); } diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug562797.js b/toolkit/mozapps/extensions/test/browser/browser_bug562797.js index 51f19ac1b096..04b1b3b290cb 100644 --- a/toolkit/mozapps/extensions/test/browser/browser_bug562797.js +++ b/toolkit/mozapps/extensions/test/browser/browser_bug562797.js @@ -387,7 +387,7 @@ add_test(function() { 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); @@ -453,7 +453,7 @@ add_test(function() { 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); @@ -530,7 +530,7 @@ add_test(function() { // 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); @@ -574,3 +574,20 @@ add_test(function() { 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); + }); + }); + }); +}); diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug581076.js b/toolkit/mozapps/extensions/test/browser/browser_bug581076.js index ea78b0a73f31..02045c806c32 100644 --- a/toolkit/mozapps/extensions/test/browser/browser_bug581076.js +++ b/toolkit/mozapps/extensions/test/browser/browser_bug581076.js @@ -40,21 +40,23 @@ function end_test() { } 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) { diff --git a/toolkit/mozapps/extensions/test/browser/browser_bug610764.js b/toolkit/mozapps/extensions/test/browser/browser_bug610764.js new file mode 100644 index 000000000000..58de8813040a --- /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); + }); +} diff --git a/toolkit/mozapps/extensions/test/browser/browser_discovery.js b/toolkit/mozapps/extensions/test/browser/browser_discovery.js index f13391245aac..c5586e2fb5d3 100644 --- a/toolkit/mozapps/extensions/test/browser/browser_discovery.js +++ b/toolkit/mozapps/extensions/test/browser/browser_discovery.js @@ -4,7 +4,6 @@ // Tests that the discovery view loads properly -const PREF_DISCOVERURL = "extensions.webservice.discoverURL"; const PREF_BACKGROUND_UPDATE = "extensions.update.enabled"; var gManagerWindow; diff --git a/toolkit/mozapps/extensions/test/browser/browser_install.js b/toolkit/mozapps/extensions/test/browser/browser_install.js index 89177b831858..76065970a505 100644 --- a/toolkit/mozapps/extensions/test/browser/browser_install.js +++ b/toolkit/mozapps/extensions/test/browser/browser_install.js @@ -204,7 +204,7 @@ add_test(function() { 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(); diff --git a/toolkit/mozapps/extensions/test/browser/head.js b/toolkit/mozapps/extensions/test/browser/head.js index de6cbec5121f..0d03a7a858f4 100644 --- a/toolkit/mozapps/extensions/test/browser/head.js +++ b/toolkit/mozapps/extensions/test/browser/head.js @@ -26,6 +26,7 @@ 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; @@ -37,6 +38,8 @@ var gUseInContentUI = !gTestInWindow && ("switchToTabHavingURI" in window); 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 {