зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1263313 Remove tests of old about:addons search r=rhelmer
Also consolidated the two .ini files in toolkit/mozapps/extension/test/browser since we only run these tests in tabs now. MozReview-Commit-ID: HHwM4Q1K5C8 --HG-- extra : rebase_source : 6db3527ee6973946d188fa70dc8af1c008094d49
This commit is contained in:
Родитель
58e2ec3e04
Коммит
755fde92c8
|
@ -16,12 +16,10 @@ support-files =
|
|||
browser_webext_update_origins1.xpi
|
||||
browser_webext_update_origins2.xpi
|
||||
browser_webext_update.json
|
||||
browser_webext_search.xml
|
||||
|
||||
[browser_extension_sideloading.js]
|
||||
[browser_extension_update_background.js]
|
||||
[browser_extension_update_background_noprompt.js]
|
||||
[browser_permissions_addons_search.js]
|
||||
[browser_permissions_installTrigger.js]
|
||||
[browser_permissions_local_file.js]
|
||||
[browser_permissions_mozAddonManager.js]
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
async function installSearch(filename) {
|
||||
await SpecialPowers.pushPrefEnv({set: [
|
||||
["extensions.getAddons.maxResults", 10],
|
||||
["extensions.getAddons.search.url", `${BASE}/browser_webext_search.xml`],
|
||||
]});
|
||||
|
||||
let win = await BrowserOpenAddonsMgr("addons://list/extension");
|
||||
|
||||
let searchResultsPromise = new Promise(resolve => {
|
||||
win.document.addEventListener("ViewChanged", resolve, {once: true});
|
||||
});
|
||||
let search = win.document.getElementById("header-search");
|
||||
search.focus();
|
||||
search.value = "search text";
|
||||
EventUtils.synthesizeKey("VK_RETURN", {}, win);
|
||||
|
||||
await searchResultsPromise;
|
||||
ok(win.gViewController.currentViewId.startsWith("addons://search"),
|
||||
"about:addons is displaying search results");
|
||||
|
||||
let list = win.document.getElementById("search-list");
|
||||
let item = null;
|
||||
for (let child of list.childNodes) {
|
||||
if (child.nodeName == "richlistitem" &&
|
||||
child.mAddon.install.sourceURI.pathQueryRef.endsWith(filename)) {
|
||||
item = child;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ok(item, `Found ${filename} in search results`);
|
||||
|
||||
// abracadabara XBL
|
||||
item.clientTop;
|
||||
|
||||
let install = win.document.getAnonymousElementByAttribute(item, "anonid", "install-status");
|
||||
let button = win.document.getAnonymousElementByAttribute(install, "anonid", "install-remote-btn");
|
||||
EventUtils.synthesizeMouseAtCenter(button, {}, win);
|
||||
}
|
||||
|
||||
add_task(() => testInstallMethod(installSearch, "installAmo"));
|
|
@ -1,51 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<searchresults total_results="2">
|
||||
<addon>
|
||||
<name>permissions test</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>permissions@tests.mozilla.org</guid>
|
||||
<version>1.1</version>
|
||||
<authors>
|
||||
<author>
|
||||
<name>Test Creator</name>
|
||||
<link>http://example.com/creator.html</link>
|
||||
</author>
|
||||
</authors>
|
||||
<status id='4'>Public</status>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>Firefox</name>
|
||||
<appID>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<compatible_os>ALL</compatible_os>
|
||||
<install size="1">https://example.com/browser/browser/base/content/test/webextensions/browser_webext_permissions.xpi</install>
|
||||
</addon>
|
||||
|
||||
<addon>
|
||||
<name>no permissions</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>nopermissions@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<authors>
|
||||
<author>
|
||||
<name>Test Creator</name>
|
||||
<link>http://example.com/creator.html</link>
|
||||
</author>
|
||||
</authors>
|
||||
<status id='4'>Public</status>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>Firefox</name>
|
||||
<appID>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<compatible_os>ALL</compatible_os>
|
||||
<install size="1">https://example.com/browser/browser/base/content/test/webextensions/browser_webext_nopermissions.xpi</install>
|
||||
</addon>
|
||||
</searchresults>
|
||||
|
Двоичный файл не отображается.
|
@ -1,10 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
/* exported startup, shutdown, install, uninstall */
|
||||
|
||||
function install(data, reason) {}
|
||||
function startup(data, reason) {}
|
||||
function shutdown(data, reason) {}
|
||||
function uninstall(data, reason) {}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
|
||||
|
||||
<Description about="urn:mozilla:install-manifest">
|
||||
<em:id>remote1@tests.mozilla.org</em:id>
|
||||
<em:version>1.0</em:version>
|
||||
<em:type>2</em:type>
|
||||
<em:bootstrap>true</em:bootstrap>
|
||||
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
|
||||
<em:minVersion>0.3</em:minVersion>
|
||||
<em:maxVersion>*</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
|
||||
<!-- Front End MetaData -->
|
||||
<em:name>PASS - b - installed</em:name>
|
||||
<em:description>Test sumary - SEARCH SEARCH</em:description>
|
||||
|
||||
</Description>
|
||||
</RDF>
|
|
@ -1,61 +0,0 @@
|
|||
[browser_about.js]
|
||||
skip-if = os == 'linux' || os == 'win' # bug 632290
|
||||
[browser_bug523784.js]
|
||||
[browser_bug557943.js]
|
||||
[browser_bug562797.js]
|
||||
[browser_bug562854.js]
|
||||
[browser_bug562890.js]
|
||||
skip-if = os == 'win' && !debug # Disabled on Windows opt/PGO builds due to intermittent failures (bug 1135866)
|
||||
[browser_bug562899.js]
|
||||
skip-if = buildapp == 'mulet'
|
||||
[browser_bug562992.js]
|
||||
[browser_bug567127.js]
|
||||
[browser_bug567137.js]
|
||||
[browser_bug570760.js]
|
||||
[browser_bug572561.js]
|
||||
[browser_bug573062.js]
|
||||
[browser_bug577990.js]
|
||||
[browser_bug580298.js]
|
||||
[browser_bug581076.js]
|
||||
[browser_bug586574.js]
|
||||
[browser_bug587970.js]
|
||||
[browser_bug591465.js]
|
||||
skip-if = os == "linux" && !debug # Bug 1395539 - fails on multi-core
|
||||
[browser_bug591663.js]
|
||||
[browser_bug593535.js]
|
||||
skip-if = true # Bug 1093190 - Disabled due to leak
|
||||
[browser_bug596336.js]
|
||||
[browser_bug608316.js]
|
||||
[browser_bug610764.js]
|
||||
[browser_bug618502.js]
|
||||
[browser_bug679604.js]
|
||||
[browser_bug590347.js]
|
||||
[browser_details.js]
|
||||
[browser_discovery.js]
|
||||
[browser_dragdrop.js]
|
||||
skip-if = buildapp == 'mulet'
|
||||
[browser_dragdrop_incompat.js]
|
||||
[browser_experiments.js]
|
||||
[browser_list.js]
|
||||
[browser_sorting.js]
|
||||
[browser_sorting_plugins.js]
|
||||
[browser_plugin_enabled_state_locked.js]
|
||||
[browser_uninstalling.js]
|
||||
[browser_recentupdates.js]
|
||||
[browser_manualupdates.js]
|
||||
[browser_globalwarnings.js]
|
||||
[browser_updateid.js]
|
||||
[browser_purchase.js]
|
||||
[browser_types.js]
|
||||
[browser_inlinesettings_browser.js]
|
||||
[browser_tabsettings.js]
|
||||
[browser_pluginprefs.js]
|
||||
[browser_pluginprefs_is_not_disabled.js]
|
||||
skip-if = buildapp == 'mulet'
|
||||
[browser_CTP_plugins.js]
|
||||
tags = blocklist
|
||||
skip-if = buildapp == 'mulet'
|
||||
[browser_webext_options.js]
|
||||
tags = webextensions
|
||||
[browser_webext_options_addon_reload.js]
|
||||
tags = webextensions
|
|
@ -15,18 +15,11 @@ support-files =
|
|||
releaseNotes.xhtml
|
||||
blockNoPlugins.xml
|
||||
blockPluginHard.xml
|
||||
browser_bug591465.xml
|
||||
browser_bug593535.xml
|
||||
browser_searching.xml
|
||||
browser_searching_empty.xml
|
||||
browser_updatessl.rdf
|
||||
browser_updatessl.rdf^headers^
|
||||
browser_install.rdf
|
||||
browser_install.rdf^headers^
|
||||
browser_install.xml
|
||||
browser_install1_3.xpi
|
||||
browser_eula.xml
|
||||
browser_purchase.xml
|
||||
webapi_addon_listener.html
|
||||
webapi_checkavailable.html
|
||||
webapi_checkchromeframe.xul
|
||||
|
@ -40,27 +33,75 @@ support-files =
|
|||
!/toolkit/mozapps/extensions/test/xpinstall/unsigned.xpi
|
||||
!/toolkit/mozapps/extensions/test/xpinstall/amosigned.xpi
|
||||
|
||||
[browser_addonrepository_performance.js]
|
||||
[browser_bug616841.js]
|
||||
[browser_checkAddonCompatibility.js]
|
||||
[browser_discovery_install.js]
|
||||
[browser_eula.js]
|
||||
[browser_CTP_plugins.js]
|
||||
tags = blocklist
|
||||
skip-if = buildapp == 'mulet'
|
||||
[browser_about.js]
|
||||
skip-if = os == 'linux' || os == 'win' # bug 632290
|
||||
[browser_addonrepository_performance.js]
|
||||
[browser_bug523784.js]
|
||||
[browser_bug562797.js]
|
||||
[browser_bug562854.js]
|
||||
[browser_bug562890.js]
|
||||
skip-if = os == 'win' && !debug # Disabled on Windows opt/PGO builds due to intermittent failures (bug 1135866)
|
||||
[browser_bug562899.js]
|
||||
skip-if = buildapp == 'mulet'
|
||||
[browser_bug562992.js]
|
||||
[browser_bug567127.js]
|
||||
[browser_bug567137.js]
|
||||
[browser_bug570760.js]
|
||||
[browser_bug572561.js]
|
||||
[browser_bug573062.js]
|
||||
[browser_bug577990.js]
|
||||
[browser_bug580298.js]
|
||||
[browser_bug586574.js]
|
||||
[browser_bug587970.js]
|
||||
[browser_bug591465.js]
|
||||
skip-if = os == "linux" && !debug # Bug 1395539 - fails on multi-core
|
||||
[browser_bug591663.js]
|
||||
[browser_bug596336.js]
|
||||
[browser_bug608316.js]
|
||||
[browser_bug616841.js]
|
||||
[browser_bug618502.js]
|
||||
[browser_bug679604.js]
|
||||
[browser_bug590347.js]
|
||||
[browser_checkAddonCompatibility.js]
|
||||
[browser_details.js]
|
||||
[browser_discovery.js]
|
||||
[browser_discovery_install.js]
|
||||
[browser_dragdrop.js]
|
||||
skip-if = buildapp == 'mulet'
|
||||
[browser_dragdrop_incompat.js]
|
||||
[browser_experiments.js]
|
||||
[browser_file_xpi_no_process_switch.js]
|
||||
[browser_getmorethemes.js]
|
||||
[browser_globalwarnings.js]
|
||||
[browser_gmpProvider.js]
|
||||
skip-if = os == 'linux' && !debug # Bug 1398766
|
||||
[browser_inlinesettings_browser.js]
|
||||
[browser_install.js]
|
||||
[browser_installssl.js]
|
||||
[browser_legacy.js]
|
||||
[browser_legacy_pre57.js]
|
||||
[browser_legacy_themes.js]
|
||||
[browser_list.js]
|
||||
[browser_manualupdates.js]
|
||||
[browser_newaddon.js]
|
||||
[browser_non_mpc.js]
|
||||
[browser_searching.js]
|
||||
[browser_pluginprefs.js]
|
||||
[browser_pluginprefs_is_not_disabled.js]
|
||||
skip-if = buildapp == 'mulet'
|
||||
[browser_plugin_enabled_state_locked.js]
|
||||
[browser_recentupdates.js]
|
||||
[browser_sorting.js]
|
||||
[browser_sorting_plugins.js]
|
||||
[browser_system_addons_are_e10s.js]
|
||||
[browser_tabsettings.js]
|
||||
[browser_task_next_test.js]
|
||||
[browser_types.js]
|
||||
[browser_uninstalling.js]
|
||||
[browser_update.js]
|
||||
[browser_updateid.js]
|
||||
[browser_updatessl.js]
|
||||
[browser_webapi.js]
|
||||
[browser_webapi_access.js]
|
||||
|
@ -68,5 +109,8 @@ skip-if = os == 'linux' && !debug # Bug 1398766
|
|||
[browser_webapi_enable.js]
|
||||
[browser_webapi_install.js]
|
||||
[browser_webapi_uninstall.js]
|
||||
[browser_webext_options.js]
|
||||
tags = webextensions
|
||||
[browser_webext_options_addon_reload.js]
|
||||
tags = webextensions
|
||||
|
||||
[include:browser-common.ini]
|
||||
|
|
|
@ -1,80 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// Bug 557943 - Searching for addons can result in wrong results
|
||||
|
||||
var gManagerWindow;
|
||||
var gProvider;
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
gProvider = new MockProvider();
|
||||
|
||||
gProvider.createAddons([{
|
||||
id: "addon1@tests.mozilla.org",
|
||||
name: "Microsoft .NET Framework Assistant",
|
||||
description: "",
|
||||
version: "6.66"
|
||||
}, {
|
||||
id: "addon2@tests.mozilla.org",
|
||||
name: "AwesomeNet Addon",
|
||||
description: ""
|
||||
}, {
|
||||
id: "addon3@tests.mozilla.org",
|
||||
name: "Dictionnaire MySpell en Francais (réforme 1990)",
|
||||
description: ""
|
||||
}]);
|
||||
|
||||
open_manager("addons://list/extension", function(aWindow) {
|
||||
gManagerWindow = aWindow;
|
||||
run_next_test();
|
||||
});
|
||||
}
|
||||
|
||||
function end_test() {
|
||||
close_manager(gManagerWindow, function() {
|
||||
finish();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function perform_search(aQuery, aCallback) {
|
||||
waitForFocus(function() {
|
||||
var searchBox = gManagerWindow.document.getElementById("header-search");
|
||||
searchBox.value = aQuery;
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(searchBox, { }, 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();
|
||||
});
|
||||
});
|
||||
|
||||
add_test(function() {
|
||||
perform_search("réf", function(aRows) {
|
||||
is(aRows.length, 1, "Should only get one result");
|
||||
is(aRows[0].mAddon.id, "addon3@tests.mozilla.org", "Should get expected addon as only result");
|
||||
run_next_test();
|
||||
});
|
||||
});
|
||||
|
||||
add_test(function() {
|
||||
perform_search("javascript:void()", function(aRows) {
|
||||
is(aRows.length, 0, "Should not get any results");
|
||||
run_next_test();
|
||||
});
|
||||
});
|
|
@ -120,16 +120,6 @@ function is_in_list(aManager, view, canGoBack, canGoForward) {
|
|||
check_state(canGoBack, canGoForward);
|
||||
}
|
||||
|
||||
function is_in_search(aManager, query, canGoBack, canGoForward) {
|
||||
var doc = aManager.document;
|
||||
|
||||
is(doc.getElementById("categories").selectedItem.value, "addons://search/", "Should be on the right category");
|
||||
is(get_current_view(aManager).id, "search-view", "Should be on the right view");
|
||||
is(doc.getElementById("header-search").value, query, "Should have used the right query");
|
||||
|
||||
check_state(canGoBack, canGoForward);
|
||||
}
|
||||
|
||||
function is_in_detail(aManager, view, canGoBack, canGoForward) {
|
||||
var doc = aManager.document;
|
||||
|
||||
|
@ -459,128 +449,6 @@ add_test(function() {
|
|||
});
|
||||
});
|
||||
|
||||
// Tests that going back to search results works
|
||||
add_test(function() {
|
||||
// Before we open the add-ons manager, we should make sure that no filter
|
||||
// has been set. If one is set, we remove it.
|
||||
// This is for the check below, from bug 611459.
|
||||
let store = Cc["@mozilla.org/xul/xulstore;1"].getService(Ci.nsIXULStore);
|
||||
store.removeValue("about:addons", "search-filter-radiogroup", "value");
|
||||
|
||||
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", {}, aManager);
|
||||
|
||||
wait_for_view_load(aManager, function(aManager) {
|
||||
// Remote search is meant to be checked by default (bug 611459), so we
|
||||
// confirm that and then switch to a local search.
|
||||
var localFilter = aManager.document.getElementById("search-filter-local");
|
||||
var remoteFilter = aManager.document.getElementById("search-filter-remote");
|
||||
|
||||
is(remoteFilter.selected, true, "Remote filter should be set by default");
|
||||
|
||||
var list = aManager.document.getElementById("search-list");
|
||||
list.ensureElementIsVisible(localFilter);
|
||||
EventUtils.synthesizeMouseAtCenter(localFilter, { }, aManager);
|
||||
|
||||
is(localFilter.selected, true, "Should have changed to local filter");
|
||||
|
||||
// Now we continue with the normal test.
|
||||
|
||||
info("Part 2");
|
||||
is_in_search(aManager, "bar", true, false);
|
||||
// force layout flush
|
||||
aManager.document.documentElement.clientTop;
|
||||
check_all_in_list(aManager, ["test2@tests.mozilla.org", "test3@tests.mozilla.org"]);
|
||||
|
||||
double_click_addon_element(aManager, "test2@tests.mozilla.org");
|
||||
|
||||
wait_for_view_load(aManager, function(aManager) {
|
||||
info("Part 3");
|
||||
is_in_detail(aManager, "addons://search/", true, false);
|
||||
|
||||
go_back();
|
||||
wait_for_view_load(aManager, function(aManager) {
|
||||
info("Part 4");
|
||||
is_in_search(aManager, "bar", true, true);
|
||||
check_all_in_list(aManager, ["test2@tests.mozilla.org", "test3@tests.mozilla.org"]);
|
||||
|
||||
go_forward();
|
||||
wait_for_view_load(aManager, function(aManager) {
|
||||
info("Part 5");
|
||||
is_in_detail(aManager, "addons://search/", true, false);
|
||||
|
||||
close_manager(aManager, run_next_test);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Tests that going back from a webpage to a detail view loaded from a search
|
||||
// result works
|
||||
add_test(function() {
|
||||
|
||||
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", {});
|
||||
|
||||
wait_for_view_load(aManager, function(aManager) {
|
||||
info("Part 2");
|
||||
is_in_search(aManager, "bar", true, false);
|
||||
check_all_in_list(aManager, ["test2@tests.mozilla.org", "test3@tests.mozilla.org"]);
|
||||
|
||||
double_click_addon_element(aManager, "test2@tests.mozilla.org");
|
||||
|
||||
wait_for_view_load(aManager, function(aManager) {
|
||||
info("Part 3");
|
||||
is_in_detail(aManager, "addons://search/", true, false);
|
||||
|
||||
gBrowser.loadURI("http://example.com/");
|
||||
wait_for_page_show(gBrowser.selectedBrowser).then(() => {
|
||||
info("Part 4");
|
||||
executeSoon(function() {
|
||||
ok(gBrowser.canGoBack, "Should be able to go back");
|
||||
ok(!gBrowser.canGoForward, "Should not be able to go forward");
|
||||
|
||||
go_back();
|
||||
gBrowser.addEventListener("pageshow", function listener(event) {
|
||||
if (event.target.location != "about:addons")
|
||||
return;
|
||||
gBrowser.removeEventListener("pageshow", listener);
|
||||
|
||||
wait_for_view_load(gBrowser.contentWindow.wrappedJSObject, function(aManager) {
|
||||
info("Part 5");
|
||||
is_in_detail(aManager, "addons://search/", true, true);
|
||||
|
||||
go_back();
|
||||
wait_for_view_load(aManager, function(aManager) {
|
||||
info("Part 6");
|
||||
is_in_search(aManager, "bar", true, true);
|
||||
check_all_in_list(aManager, ["test2@tests.mozilla.org", "test3@tests.mozilla.org"]);
|
||||
|
||||
close_manager(aManager, run_next_test);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Tests that refreshing a list view does not affect the history
|
||||
add_test(function() {
|
||||
|
||||
|
|
|
@ -1,130 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// Bug 581076 - No "See all results" link present when searching for add-ons and not all are displayed (extensions.getAddons.maxResults)
|
||||
|
||||
const PREF_GETADDONS_GETSEARCHRESULTS = "extensions.getAddons.search.url";
|
||||
const PREF_GETADDONS_MAXRESULTS = "extensions.getAddons.maxResults";
|
||||
const SEARCH_URL = TESTROOT + "browser_searching.xml";
|
||||
const SEARCH_EXPECTED_TOTAL = 100;
|
||||
const SEARCH_QUERY = "search";
|
||||
|
||||
const SEARCHABLE_PAGE = "addons://list/extension";
|
||||
|
||||
var gManagerWindow;
|
||||
|
||||
|
||||
function test() {
|
||||
Services.prefs.setCharPref(PREF_GETADDONS_GETSEARCHRESULTS, SEARCH_URL);
|
||||
Services.prefs.setIntPref(PREF_SEARCH_MAXRESULTS, 15);
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
open_manager(SEARCHABLE_PAGE, function(aWindow) {
|
||||
gManagerWindow = aWindow;
|
||||
run_next_test();
|
||||
});
|
||||
}
|
||||
|
||||
function end_test() {
|
||||
// Test generates a lot of available installs so just cancel them all
|
||||
AddonManager.getAllInstalls(function(aInstalls) {
|
||||
for (let install of aInstalls)
|
||||
install.cancel();
|
||||
|
||||
close_manager(gManagerWindow, finish);
|
||||
});
|
||||
}
|
||||
|
||||
function search(aRemoteSearch, aCallback) {
|
||||
waitForFocus(function() {
|
||||
var searchBox = gManagerWindow.document.getElementById("header-search");
|
||||
searchBox.value = SEARCH_QUERY;
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow);
|
||||
EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow);
|
||||
|
||||
wait_for_view_load(gManagerWindow, function() {
|
||||
let filter;
|
||||
if (aRemoteSearch)
|
||||
filter = gManagerWindow.document.getElementById("search-filter-remote");
|
||||
else
|
||||
filter = gManagerWindow.document.getElementById("search-filter-local");
|
||||
EventUtils.synthesizeMouseAtCenter(filter, { }, gManagerWindow);
|
||||
|
||||
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");
|
||||
is(link.value, "See all " + SEARCH_EXPECTED_TOTAL + " results", "All Results link should show the correct message");
|
||||
var scope = {};
|
||||
Components.utils.import("resource://gre/modules/addons/AddonRepository.jsm", scope);
|
||||
is(link.href, scope.AddonRepository.getSearchURL(SEARCH_QUERY), "All Results link should have the correct href");
|
||||
} else {
|
||||
is_element_hidden(link, "All Results link should be hidden");
|
||||
}
|
||||
}
|
||||
|
||||
add_test(function() {
|
||||
info("Searching locally");
|
||||
search(false, function() {
|
||||
check_allresultslink(false);
|
||||
restart_manager(gManagerWindow, SEARCHABLE_PAGE, function(aManager) {
|
||||
gManagerWindow = aManager;
|
||||
run_next_test();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
add_test(function() {
|
||||
info("Searching remotely - more results than cap");
|
||||
Services.prefs.setIntPref(PREF_GETADDONS_MAXRESULTS, 3);
|
||||
search(true, function() {
|
||||
check_allresultslink(true);
|
||||
restart_manager(gManagerWindow, SEARCHABLE_PAGE, function(aManager) {
|
||||
gManagerWindow = aManager;
|
||||
run_next_test();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
add_test(function() {
|
||||
info("Searching remotely - less results than cap");
|
||||
Services.prefs.setIntPref(PREF_GETADDONS_MAXRESULTS, 200);
|
||||
search(true, function() {
|
||||
check_allresultslink(false);
|
||||
restart_manager(gManagerWindow, SEARCHABLE_PAGE, function(aManager) {
|
||||
gManagerWindow = aManager;
|
||||
run_next_test();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
add_test(function() {
|
||||
info("Searching remotely - more results than cap");
|
||||
Services.prefs.setIntPref(PREF_GETADDONS_MAXRESULTS, 3);
|
||||
search(true, function() {
|
||||
check_allresultslink(true);
|
||||
run_next_test();
|
||||
});
|
||||
});
|
||||
|
||||
add_test(function() {
|
||||
info("Switching views");
|
||||
gManagerWindow.loadView("addons://list/extension");
|
||||
wait_for_view_load(gManagerWindow, function() {
|
||||
info("Re-loading previous search");
|
||||
search(true, function() {
|
||||
check_allresultslink(true);
|
||||
run_next_test();
|
||||
});
|
||||
});
|
||||
});
|
|
@ -10,10 +10,6 @@ Components.utils.import("resource://gre/modules/LightweightThemeManager.jsm", te
|
|||
var LightweightThemeManager = tempScope.LightweightThemeManager;
|
||||
|
||||
|
||||
const PREF_GETADDONS_GETSEARCHRESULTS = "extensions.getAddons.search.url";
|
||||
const SEARCH_URL = TESTROOT + "browser_bug591465.xml";
|
||||
const SEARCH_QUERY = "SEARCH";
|
||||
|
||||
var gManagerWindow;
|
||||
var gProvider;
|
||||
var gContextMenu;
|
||||
|
@ -413,64 +409,3 @@ add_test(function() {
|
|||
EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow);
|
||||
});
|
||||
});
|
||||
|
||||
add_test(function() {
|
||||
info("Searching for remote addons");
|
||||
|
||||
Services.prefs.setCharPref(PREF_GETADDONS_GETSEARCHRESULTS, SEARCH_URL);
|
||||
Services.prefs.setIntPref(PREF_SEARCH_MAXRESULTS, 15);
|
||||
|
||||
var searchBox = gManagerWindow.document.getElementById("header-search");
|
||||
searchBox.value = SEARCH_QUERY;
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow);
|
||||
EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow);
|
||||
|
||||
wait_for_view_load(gManagerWindow, function() {
|
||||
var filter = gManagerWindow.document.getElementById("search-filter-remote");
|
||||
EventUtils.synthesizeMouseAtCenter(filter, { }, gManagerWindow);
|
||||
executeSoon(function() {
|
||||
|
||||
var el = get_addon_element(gManagerWindow, "remote1@tests.mozilla.org");
|
||||
|
||||
gContextMenu.addEventListener("popupshown", function() {
|
||||
check_contextmenu(false, false, true, false, false);
|
||||
|
||||
gContextMenu.hidePopup();
|
||||
run_next_test();
|
||||
}, {once: true});
|
||||
|
||||
info("Opening context menu on remote extension item");
|
||||
el.parentNode.ensureElementIsVisible(el);
|
||||
EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow);
|
||||
EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow);
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
add_test(function() {
|
||||
gManagerWindow.loadView("addons://detail/remote1@tests.mozilla.org");
|
||||
wait_for_view_load(gManagerWindow, function() {
|
||||
|
||||
gContextMenu.addEventListener("popupshown", function() {
|
||||
check_contextmenu(false, false, true, true, false);
|
||||
|
||||
gContextMenu.hidePopup();
|
||||
|
||||
// Delete the created install
|
||||
AddonManager.getAllInstalls(function(aInstalls) {
|
||||
is(aInstalls.length, 1, "Should be one available install");
|
||||
aInstalls[0].cancel();
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
}, {once: true});
|
||||
|
||||
info("Opening context menu on remote extension, in detail view");
|
||||
var el = gManagerWindow.document.querySelector("#detail-view .detail-view-container");
|
||||
EventUtils.synthesizeMouse(el, 4, 4, { }, gManagerWindow);
|
||||
EventUtils.synthesizeMouse(el, 4, 4, { type: "contextmenu", button: 2 }, gManagerWindow);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<searchresults total_results="100">
|
||||
<addon>
|
||||
<name>MAGICAL SEARCH RESULT</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>remote1@tests.mozilla.org</guid>
|
||||
<version>3.0</version>
|
||||
<authors>
|
||||
<author>
|
||||
<name>Test Creator</name>
|
||||
<link>http://example.com/creator.html</link>
|
||||
</author>
|
||||
</authors>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Test summary - SEARCH SEARCH</summary>
|
||||
<description>Test description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>Firefox</name>
|
||||
<appID>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
<application>
|
||||
<name>SeaMonkey</name>
|
||||
<appID>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<compatible_os>ALL</compatible_os>
|
||||
<install size="2">http://example.com/browser/toolkit/mozapps/extensions/test/browser/addons/browser_searching.xpi</install>
|
||||
</addon>
|
||||
</searchresults>
|
||||
|
|
@ -1,118 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// Bug 593535 - Failure to download extension causes about:addons to list the
|
||||
// addon with no way to restart the download
|
||||
|
||||
const PREF_GETADDONS_GETSEARCHRESULTS = "extensions.getAddons.search.url";
|
||||
const SEARCH_URL = TESTROOT + "browser_bug593535.xml";
|
||||
const QUERY = "NOTFOUND";
|
||||
|
||||
var gManagerWindow;
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
// Turn on searching for this test
|
||||
Services.prefs.setIntPref(PREF_SEARCH_MAXRESULTS, 15);
|
||||
|
||||
open_manager("addons://list/extension", function(aWindow) {
|
||||
gManagerWindow = aWindow;
|
||||
run_next_test();
|
||||
});
|
||||
}
|
||||
|
||||
function end_test() {
|
||||
close_manager(gManagerWindow, function() {
|
||||
AddonManager.getAllInstalls(function(aInstallsList) {
|
||||
for (var install of aInstallsList) {
|
||||
var sourceURI = install.sourceURI.spec;
|
||||
if (sourceURI.match(/^http:\/\/example\.com\/(.+)\.xpi$/) != null)
|
||||
install.cancel();
|
||||
}
|
||||
|
||||
finish();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function search(aQuery, aCallback) {
|
||||
// Point search to the correct xml test file
|
||||
Services.prefs.setCharPref(PREF_GETADDONS_GETSEARCHRESULTS, SEARCH_URL);
|
||||
|
||||
var searchBox = gManagerWindow.document.getElementById("header-search");
|
||||
searchBox.value = aQuery;
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow);
|
||||
EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow);
|
||||
|
||||
wait_for_view_load(gManagerWindow, function() {
|
||||
var remoteFilter = gManagerWindow.document.getElementById("search-filter-remote");
|
||||
EventUtils.synthesizeMouseAtCenter(remoteFilter, { }, gManagerWindow);
|
||||
|
||||
aCallback();
|
||||
});
|
||||
}
|
||||
|
||||
function get_addon_item(aName) {
|
||||
var id = aName + "@tests.mozilla.org";
|
||||
var list = gManagerWindow.document.getElementById("search-list");
|
||||
var rows = list.getElementsByTagName("richlistitem");
|
||||
for (let row of rows) {
|
||||
if (row.mAddon && row.mAddon.id == id)
|
||||
return row;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function get_install_button(aItem) {
|
||||
isnot(aItem, null, "Item should not be null when checking state of install button");
|
||||
var installStatus = getAnonymousElementByAttribute(aItem, "anonid", "install-status");
|
||||
return getAnonymousElementByAttribute(installStatus, "anonid", "install-remote-btn");
|
||||
}
|
||||
|
||||
|
||||
function getAnonymousElementByAttribute(aElement, aName, aValue) {
|
||||
return gManagerWindow.document.getAnonymousElementByAttribute(aElement,
|
||||
aName,
|
||||
aValue);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Tests that a failed install for a remote add-on will ask to retry the install
|
||||
add_test(function() {
|
||||
var remoteItem;
|
||||
|
||||
var listener = {
|
||||
onDownloadFailed(aInstall) {
|
||||
aInstall.removeListener(this);
|
||||
ok(true, "Install failed as expected");
|
||||
|
||||
executeSoon(function() {
|
||||
is(remoteItem.getAttribute("notification"), "warning", "Item should have notification attribute set to 'warning'");
|
||||
is_element_visible(remoteItem._warning, "Warning text should be visible");
|
||||
is(remoteItem._warning.textContent, "There was an error downloading NOTFOUND.", "Warning should show correct message");
|
||||
is_element_visible(remoteItem._warningLink, "Retry button should be visible");
|
||||
run_next_test();
|
||||
});
|
||||
},
|
||||
|
||||
onInstallEnded() {
|
||||
ok(false, "Install should have failed");
|
||||
}
|
||||
};
|
||||
|
||||
search(QUERY, function() {
|
||||
var list = gManagerWindow.document.getElementById("search-list");
|
||||
remoteItem = get_addon_item("notfound1");
|
||||
list.ensureElementIsVisible(remoteItem);
|
||||
|
||||
remoteItem.mAddon.install.addListener(listener);
|
||||
|
||||
var installBtn = get_install_button(remoteItem);
|
||||
EventUtils.synthesizeMouseAtCenter(installBtn, { }, gManagerWindow);
|
||||
});
|
||||
});
|
|
@ -1,34 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<searchresults total_results="100">
|
||||
<addon>
|
||||
<name>NOTFOUND</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>notfound1@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<authors>
|
||||
<author>
|
||||
<name>Test Creator</name>
|
||||
<link>http://example.com/creator.html</link>
|
||||
</author>
|
||||
</authors>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Install file not found - NOTFOUND</summary>
|
||||
<description>Test description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>Firefox</name>
|
||||
<appID>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
<application>
|
||||
<name>SeaMonkey</name>
|
||||
<appID>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<compatible_os>ALL</compatible_os>
|
||||
<install size="1">http://example.com/file_not_found.xpi</install>
|
||||
</addon>
|
||||
</searchresults>
|
|
@ -1,34 +0,0 @@
|
|||
/* 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);
|
||||
});
|
||||
}
|
|
@ -7,8 +7,6 @@
|
|||
Components.utils.import("resource://gre/modules/AppConstants.jsm");
|
||||
|
||||
const PREF_AUTOUPDATE_DEFAULT = "extensions.update.autoUpdateDefault";
|
||||
const PREF_GETADDONS_GETSEARCHRESULTS = "extensions.getAddons.search.url";
|
||||
const SEARCH_URL = TESTROOT + "browser_details.xml";
|
||||
const PREF_EM_HOTFIX_ID = "extensions.hotfix.id";
|
||||
|
||||
var gManagerWindow;
|
||||
|
@ -46,9 +44,6 @@ function get(aId) {
|
|||
|
||||
function test() {
|
||||
requestLongerTimeout(2);
|
||||
// Turn on searching for this test
|
||||
Services.prefs.setIntPref(PREF_SEARCH_MAXRESULTS, 15);
|
||||
Services.prefs.setCharPref(PREF_GETADDONS_GETSEARCHRESULTS, SEARCH_URL);
|
||||
Services.prefs.setCharPref(PREF_EM_HOTFIX_ID, "hotfix@tests.mozilla.org");
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
|
|
@ -1,82 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// Tests that the eula is shown correctly for search results
|
||||
|
||||
var gManagerWindow;
|
||||
|
||||
var gSearchCount = 0;
|
||||
|
||||
function test() {
|
||||
requestLongerTimeout(2);
|
||||
waitForExplicitFinish();
|
||||
|
||||
// Turn on searching for this test
|
||||
Services.prefs.setIntPref(PREF_SEARCH_MAXRESULTS, 15);
|
||||
Services.prefs.setCharPref("extensions.getAddons.search.url", TESTROOT + "browser_eula.xml");
|
||||
|
||||
open_manager("addons://list/extension", function(aWindow) {
|
||||
gManagerWindow = aWindow;
|
||||
run_next_test();
|
||||
});
|
||||
}
|
||||
|
||||
function end_test() {
|
||||
close_manager(gManagerWindow, finish);
|
||||
}
|
||||
|
||||
function get_node(parent, anonid) {
|
||||
return parent.ownerDocument.getAnonymousElementByAttribute(parent, "anonid", anonid);
|
||||
}
|
||||
|
||||
function installSearchResult(aCallback) {
|
||||
var searchBox = gManagerWindow.document.getElementById("header-search");
|
||||
// Search for something different each time
|
||||
searchBox.value = "foo" + gSearchCount;
|
||||
gSearchCount++;
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow);
|
||||
EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow);
|
||||
|
||||
wait_for_view_load(gManagerWindow, function() {
|
||||
let remote = gManagerWindow.document.getElementById("search-filter-remote");
|
||||
EventUtils.synthesizeMouseAtCenter(remote, { }, gManagerWindow);
|
||||
|
||||
let item = get_addon_element(gManagerWindow, "addon1@tests.mozilla.org");
|
||||
ok(!!item, "Should see the search result in the list");
|
||||
|
||||
let status = get_node(item, "install-status");
|
||||
EventUtils.synthesizeMouseAtCenter(get_node(status, "install-remote-btn"), {}, gManagerWindow);
|
||||
|
||||
item.mInstall.addListener({
|
||||
onInstallEnded() {
|
||||
executeSoon(aCallback);
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Install an add-on through the search page, accept the EULA and then undo it
|
||||
add_test(function() {
|
||||
// Accept the EULA when it appears
|
||||
let sawEULA = false;
|
||||
wait_for_window_open(function(aWindow) {
|
||||
sawEULA = true;
|
||||
is(aWindow.location.href, "chrome://mozapps/content/extensions/eula.xul", "Window opened should be correct");
|
||||
is(aWindow.document.getElementById("eula").value, "This is the EULA for this add-on", "EULA should be correct");
|
||||
|
||||
aWindow.document.documentElement.acceptDialog();
|
||||
});
|
||||
|
||||
installSearchResult(function() {
|
||||
ok(sawEULA, "Should have seen the EULA");
|
||||
|
||||
AddonManager.getAllInstalls(function(aInstalls) {
|
||||
is(aInstalls.length, 1, "Should be one pending install");
|
||||
aInstalls[0].cancel();
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,35 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<searchresults total_results="1">
|
||||
<addon>
|
||||
<name>Install Tests</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>addon1@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<authors>
|
||||
<author>
|
||||
<name>Test Creator</name>
|
||||
<link>http://example.com/creator.html</link>
|
||||
</author>
|
||||
</authors>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Test add-on</summary>
|
||||
<description>Test add-on</description>
|
||||
<eula>This is the EULA for this add-on</eula>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>Firefox</name>
|
||||
<appID>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
<application>
|
||||
<name>SeaMonkey</name>
|
||||
<appID>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<compatible_os>ALL</compatible_os>
|
||||
<install size="2">http://example.com/browser/toolkit/mozapps/extensions/test/browser/addons/browser_install1_2.xpi</install>
|
||||
</addon>
|
||||
</searchresults>
|
|
@ -8,15 +8,11 @@ var gManagerWindow;
|
|||
var gCategoryUtilities;
|
||||
|
||||
var gApp = document.getElementById("bundle_brand").getString("brandShortName");
|
||||
var gSearchCount = 0;
|
||||
|
||||
function test() {
|
||||
requestLongerTimeout(2);
|
||||
waitForExplicitFinish();
|
||||
|
||||
// Turn on searching for this test
|
||||
Services.prefs.setIntPref(PREF_SEARCH_MAXRESULTS, 15);
|
||||
Services.prefs.setCharPref("extensions.getAddons.search.url", TESTROOT + "browser_install.xml");
|
||||
// Allow http update checks
|
||||
Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
|
||||
|
||||
|
@ -90,33 +86,6 @@ function cancelInstall(aCallback) {
|
|||
}, "application/x-xpinstall");
|
||||
}
|
||||
|
||||
function installSearchResult(aCallback) {
|
||||
var searchBox = gManagerWindow.document.getElementById("header-search");
|
||||
// Search for something different each time
|
||||
searchBox.value = "foo" + gSearchCount;
|
||||
gSearchCount++;
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow);
|
||||
EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow);
|
||||
|
||||
wait_for_view_load(gManagerWindow, function() {
|
||||
let remote = gManagerWindow.document.getElementById("search-filter-remote");
|
||||
EventUtils.synthesizeMouseAtCenter(remote, { }, gManagerWindow);
|
||||
|
||||
let item = get_addon_element(gManagerWindow, "install1@tests.mozilla.org");
|
||||
ok(!!item, "Should see the search result in the list");
|
||||
|
||||
let status = get_node(item, "install-status");
|
||||
EventUtils.synthesizeMouseAtCenter(get_node(status, "install-remote-btn"), {}, gManagerWindow);
|
||||
|
||||
item.mInstall.addListener({
|
||||
onInstallEnded() {
|
||||
executeSoon(aCallback);
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function get_list_item_count() {
|
||||
return get_test_items_in_list(gManagerWindow).length;
|
||||
}
|
||||
|
@ -182,40 +151,6 @@ add_test(function() {
|
|||
});
|
||||
});
|
||||
|
||||
// Install an add-on through the search page and then undo it
|
||||
add_test(function() {
|
||||
installSearchResult(function() {
|
||||
check_undo_install();
|
||||
run_next_test();
|
||||
});
|
||||
});
|
||||
|
||||
// Install an add-on through the search page then switch to the extensions page
|
||||
// and then undo it
|
||||
add_test(function() {
|
||||
installSearchResult(function() {
|
||||
gCategoryUtilities.openType("extension", function() {
|
||||
check_undo_install();
|
||||
run_next_test();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// 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("addons://list/extension", function(aWindow) {
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
check_undo_install();
|
||||
run_next_test();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Cancel an install after download with the manager open
|
||||
add_test(function() {
|
||||
cancelInstall(function() {
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<searchresults total_results="1">
|
||||
<addon>
|
||||
<name>Install Tests</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>install1@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<authors>
|
||||
<author>
|
||||
<name>Test Creator</name>
|
||||
<link>http://example.com/creator.html</link>
|
||||
</author>
|
||||
</authors>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Test add-on</summary>
|
||||
<description>Test add-on</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>Firefox</name>
|
||||
<appID>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
<application>
|
||||
<name>SeaMonkey</name>
|
||||
<appID>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<compatible_os>ALL</compatible_os>
|
||||
<install size="2">http://example.com/browser/toolkit/mozapps/extensions/test/browser/addons/browser_install1_2.xpi</install>
|
||||
</addon>
|
||||
</searchresults>
|
|
@ -1,185 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// Tests that marketplace results show up in searches, are sorted right and
|
||||
// attempting to buy links through to the right webpage
|
||||
|
||||
const PREF_GETADDONS_GETSEARCHRESULTS = "extensions.getAddons.search.url";
|
||||
const SEARCH_URL = TESTROOT + "browser_purchase.xml";
|
||||
|
||||
var gManagerWindow;
|
||||
|
||||
function test() {
|
||||
// Turn on searching for this test
|
||||
Services.prefs.setIntPref(PREF_SEARCH_MAXRESULTS, 15);
|
||||
Services.prefs.setCharPref(PREF_GETADDONS_GETSEARCHRESULTS, SEARCH_URL);
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
open_manager("addons://list/extension", function(aWindow) {
|
||||
gManagerWindow = aWindow;
|
||||
|
||||
waitForFocus(function() {
|
||||
var searchBox = gManagerWindow.document.getElementById("header-search");
|
||||
searchBox.value = "foo";
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow);
|
||||
EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow);
|
||||
|
||||
wait_for_view_load(gManagerWindow, function() {
|
||||
var remoteFilter = gManagerWindow.document.getElementById("search-filter-remote");
|
||||
EventUtils.synthesizeMouseAtCenter(remoteFilter, { }, gManagerWindow);
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
}, aWindow);
|
||||
});
|
||||
}
|
||||
|
||||
function end_test() {
|
||||
close_manager(gManagerWindow, function() {
|
||||
// Will have created an install so cancel it
|
||||
AddonManager.getAllInstalls(function(aInstalls) {
|
||||
is(aInstalls.length, 1, "Should have been one install created");
|
||||
aInstalls[0].cancel();
|
||||
|
||||
finish();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function get_node(parent, anonid) {
|
||||
return parent.ownerDocument.getAnonymousElementByAttribute(parent, "anonid", anonid);
|
||||
}
|
||||
|
||||
function get_install_btn(parent) {
|
||||
var installStatus = get_node(parent, "install-status");
|
||||
return get_node(installStatus, "install-remote-btn");
|
||||
}
|
||||
|
||||
function get_purchase_btn(parent) {
|
||||
var installStatus = get_node(parent, "install-status");
|
||||
return get_node(installStatus, "purchase-remote-btn");
|
||||
}
|
||||
|
||||
// Tests that the expected results appeared
|
||||
add_test(function() {
|
||||
var list = gManagerWindow.document.getElementById("search-list");
|
||||
var items = Array.filter(list.childNodes, function(e) {
|
||||
return e.tagName == "richlistitem";
|
||||
});
|
||||
|
||||
is(items.length, 5, "Should be 5 results");
|
||||
|
||||
is(get_node(items[0], "name").value, "Ludicrously Expensive Add-on", "Add-on 0 should be in expected position");
|
||||
is_element_hidden(get_install_btn(items[0]), "Add-on 0 install button should be hidden");
|
||||
is_element_visible(get_purchase_btn(items[0]), "Add-on 0 purchase button should be visible");
|
||||
is(get_purchase_btn(items[0]).label, "Purchase for $101\u2026", "Add-on 0 should have the right price");
|
||||
|
||||
is(get_node(items[1], "name").value, "Cheap Add-on", "Add-on 1 should be in expected position");
|
||||
is_element_hidden(get_install_btn(items[1]), "Add-on 1 install button should be hidden");
|
||||
is_element_visible(get_purchase_btn(items[1]), "Add-on 1 purchase button should be visible");
|
||||
is(get_purchase_btn(items[1]).label, "Purchase for $0.99\u2026", "Add-on 2 should have the right price");
|
||||
|
||||
is(get_node(items[2], "name").value, "Reasonable Add-on", "Add-on 2 should be in expected position");
|
||||
is_element_hidden(get_install_btn(items[2]), "Add-on 2 install button should be hidden");
|
||||
is_element_visible(get_purchase_btn(items[2]), "Add-on 2 purchase button should be visible");
|
||||
is(get_purchase_btn(items[2]).label, "Purchase for $1\u2026", "Add-on 3 should have the right price");
|
||||
|
||||
is(get_node(items[3], "name").value, "Free Add-on", "Add-on 3 should be in expected position");
|
||||
is_element_visible(get_install_btn(items[3]), "Add-on 3 install button should be visible");
|
||||
is_element_hidden(get_purchase_btn(items[3]), "Add-on 3 purchase button should be hidden");
|
||||
|
||||
is(get_node(items[4], "name").value, "More Expensive Add-on", "Add-on 4 should be in expected position");
|
||||
is_element_hidden(get_install_btn(items[4]), "Add-on 4 install button should be hidden");
|
||||
is_element_visible(get_purchase_btn(items[4]), "Add-on 4 purchase button should be visible");
|
||||
is(get_purchase_btn(items[4]).label, "Purchase for $1.01\u2026", "Add-on 4 should have the right price");
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
// Tests that sorting by price works
|
||||
add_test(function() {
|
||||
var list = gManagerWindow.document.getElementById("search-list");
|
||||
|
||||
var sorters = gManagerWindow.document.getElementById("search-sorters");
|
||||
var priceSorter = get_node(sorters, "price-btn");
|
||||
info("Changing sort order");
|
||||
EventUtils.synthesizeMouseAtCenter(priceSorter, { }, gManagerWindow);
|
||||
|
||||
var items = Array.filter(list.childNodes, function(e) {
|
||||
return e.tagName == "richlistitem";
|
||||
});
|
||||
|
||||
is(get_node(items[0], "name").value, "Free Add-on", "Add-on 0 should be in expected position");
|
||||
is(get_node(items[1], "name").value, "Cheap Add-on", "Add-on 1 should be in expected position");
|
||||
is(get_node(items[2], "name").value, "Reasonable Add-on", "Add-on 2 should be in expected position");
|
||||
is(get_node(items[3], "name").value, "More Expensive Add-on", "Add-on 3 should be in expected position");
|
||||
is(get_node(items[4], "name").value, "Ludicrously Expensive Add-on", "Add-on 4 should be in expected position");
|
||||
|
||||
info("Changing sort order");
|
||||
EventUtils.synthesizeMouseAtCenter(priceSorter, { }, gManagerWindow);
|
||||
|
||||
items = Array.filter(list.childNodes, function(e) {
|
||||
return e.tagName == "richlistitem";
|
||||
});
|
||||
|
||||
is(get_node(items[0], "name").value, "Ludicrously Expensive Add-on", "Add-on 0 should be in expected position");
|
||||
is(get_node(items[1], "name").value, "More Expensive Add-on", "Add-on 1 should be in expected position");
|
||||
is(get_node(items[2], "name").value, "Reasonable Add-on", "Add-on 2 should be in expected position");
|
||||
is(get_node(items[3], "name").value, "Cheap Add-on", "Add-on 3 should be in expected position");
|
||||
is(get_node(items[4], "name").value, "Free Add-on", "Add-on 4 should be in expected position");
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
|
||||
// Tests that clicking the buy button works from the list
|
||||
add_test(function() {
|
||||
gBrowser.tabContainer.addEventListener("TabOpen", function(event) {
|
||||
function wantLoad(url) {
|
||||
return url != "about:blank";
|
||||
}
|
||||
BrowserTestUtils.browserLoaded(event.target.linkedBrowser, false, wantLoad).then(() => {
|
||||
is(gBrowser.currentURI.spec, TESTROOT + "releaseNotes.xhtml?addon5", "Should have loaded the right page");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
|
||||
is(gBrowser.currentURI.spec, "about:addons", "Should be back to the add-ons manager");
|
||||
run_next_test();
|
||||
});
|
||||
}, {capture: true, once: true});
|
||||
|
||||
var list = gManagerWindow.document.getElementById("search-list");
|
||||
EventUtils.synthesizeMouseAtCenter(get_purchase_btn(list.firstChild), { }, gManagerWindow);
|
||||
});
|
||||
|
||||
// Tests that clicking the buy button from the details view works
|
||||
add_test(function() {
|
||||
gBrowser.tabContainer.addEventListener("TabOpen", function(event) {
|
||||
function wantLoad(url) {
|
||||
return url != "about:blank";
|
||||
}
|
||||
BrowserTestUtils.browserLoaded(event.target.linkedBrowser, false, wantLoad).then(() => {
|
||||
is(gBrowser.currentURI.spec, TESTROOT + "releaseNotes.xhtml?addon4", "Should have loaded the right page");
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
|
||||
is(gBrowser.currentURI.spec, "about:addons", "Should be back to the add-ons manager");
|
||||
run_next_test();
|
||||
});
|
||||
}, {capture: true, once: true});
|
||||
|
||||
var list = gManagerWindow.document.getElementById("search-list");
|
||||
var item = list.firstChild.nextSibling;
|
||||
list.ensureElementIsVisible(item);
|
||||
EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, gManagerWindow);
|
||||
EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, gManagerWindow);
|
||||
|
||||
wait_for_view_load(gManagerWindow, function() {
|
||||
var btn = gManagerWindow.document.getElementById("detail-purchase-btn");
|
||||
is_element_visible(btn, "Purchase button should be visible");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(btn, { }, gManagerWindow);
|
||||
});
|
||||
});
|
|
@ -1,180 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<searchresults total_results="100">
|
||||
<addon>
|
||||
<name>Ludicrously Expensive Add-on</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>addon5@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<authors>
|
||||
<author>
|
||||
<name>Test Creator</name>
|
||||
<link>http://example.com/creator.html</link>
|
||||
</author>
|
||||
</authors>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Test summary</summary>
|
||||
<description>Test description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>Firefox</name>
|
||||
<appID>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
<application>
|
||||
<name>SeaMonkey</name>
|
||||
<appID>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<all_compatible_os>
|
||||
<os>ALL</os>
|
||||
</all_compatible_os>
|
||||
<payment_data>
|
||||
<link>http://example.com/browser/toolkit/mozapps/extensions/test/browser/releaseNotes.xhtml?addon5</link>
|
||||
<amount amount="101">$101</amount>
|
||||
</payment_data>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>Cheap Add-on</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>addon2@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<authors>
|
||||
<author>
|
||||
<name>Test Creator</name>
|
||||
<link>http://example.com/creator.html</link>
|
||||
</author>
|
||||
</authors>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Test summary</summary>
|
||||
<description>Test description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>Firefox</name>
|
||||
<appID>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
<application>
|
||||
<name>SeaMonkey</name>
|
||||
<appID>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<all_compatible_os>
|
||||
<os>ALL</os>
|
||||
</all_compatible_os>
|
||||
<payment_data>
|
||||
<link>http://example.com/browser/toolkit/mozapps/extensions/test/browser/releaseNotes.xhtml?addon2</link>
|
||||
<amount amount="0.99">$0.99</amount>
|
||||
</payment_data>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>Reasonable Add-on</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>addon3@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<authors>
|
||||
<author>
|
||||
<name>Test Creator</name>
|
||||
<link>http://example.com/creator.html</link>
|
||||
</author>
|
||||
</authors>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Test summary</summary>
|
||||
<description>Test description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>Firefox</name>
|
||||
<appID>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
<application>
|
||||
<name>SeaMonkey</name>
|
||||
<appID>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<all_compatible_os>
|
||||
<os>ALL</os>
|
||||
</all_compatible_os>
|
||||
<payment_data>
|
||||
<link>http://example.com/browser/toolkit/mozapps/extensions/test/browser/releaseNotes.xhtml?addon3</link>
|
||||
<amount amount="1">$1</amount>
|
||||
</payment_data>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>Free Add-on</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>addon1@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<authors>
|
||||
<author>
|
||||
<name>Test Creator</name>
|
||||
<link>http://example.com/creator.html</link>
|
||||
</author>
|
||||
</authors>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Test summary</summary>
|
||||
<description>Test description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>Firefox</name>
|
||||
<appID>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
<application>
|
||||
<name>SeaMonkey</name>
|
||||
<appID>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<all_compatible_os>
|
||||
<os>ALL</os>
|
||||
</all_compatible_os>
|
||||
<install size="1">http://example.com/addon1.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>More Expensive Add-on</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>addon4@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<authors>
|
||||
<author>
|
||||
<name>Test Creator</name>
|
||||
<link>http://example.com/creator.html</link>
|
||||
</author>
|
||||
</authors>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Test summary</summary>
|
||||
<description>Test description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>Firefox</name>
|
||||
<appID>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
<application>
|
||||
<name>SeaMonkey</name>
|
||||
<appID>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<all_compatible_os>
|
||||
<os>ALL</os>
|
||||
</all_compatible_os>
|
||||
<payment_data>
|
||||
<link>http://example.com/browser/toolkit/mozapps/extensions/test/browser/releaseNotes.xhtml?addon4</link>
|
||||
<amount amount="1.01">$1.01</amount>
|
||||
</payment_data>
|
||||
</addon>
|
||||
</searchresults>
|
|
@ -1,672 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// Tests that searching for add-ons works correctly
|
||||
|
||||
const PREF_GETADDONS_GETSEARCHRESULTS = "extensions.getAddons.search.url";
|
||||
const SEARCH_URL = TESTROOT + "browser_searching.xml";
|
||||
const NO_MATCH_URL = TESTROOT + "browser_searching_empty.xml";
|
||||
|
||||
const QUERY = "SEARCH";
|
||||
const NO_MATCH_QUERY = "NOMATCHQUERY";
|
||||
const REMOTE_TO_INSTALL = "remote1";
|
||||
const REMOTE_INSTALL_URL = TESTROOT + "addons/browser_searching.xpi";
|
||||
|
||||
var gManagerWindow;
|
||||
var gCategoryUtilities;
|
||||
var gProvider;
|
||||
var gAddonInstalled = false;
|
||||
|
||||
function test() {
|
||||
requestLongerTimeout(2);
|
||||
// Turn on searching for this test
|
||||
Services.prefs.setIntPref(PREF_SEARCH_MAXRESULTS, 15);
|
||||
Services.prefs.setBoolPref(PREF_STRICT_COMPAT, true);
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
gProvider = new MockProvider();
|
||||
|
||||
gProvider.createAddons([{
|
||||
id: "addon1@tests.mozilla.org",
|
||||
name: "PASS - f",
|
||||
description: "Test description - SEARCH",
|
||||
size: 3,
|
||||
version: "1.0",
|
||||
updateDate: new Date(2010, 4, 2, 0, 0, 1)
|
||||
}, {
|
||||
id: "fail-addon1@tests.mozilla.org",
|
||||
name: "FAIL",
|
||||
description: "Does not match query"
|
||||
}, {
|
||||
id: "addon2@tests.mozilla.org",
|
||||
name: "PASS - c",
|
||||
description: "Test description - reSEARCHing SEARCH SEARCH",
|
||||
size: 6,
|
||||
version: "2.0",
|
||||
updateDate: new Date(2010, 4, 2, 0, 0, 0)
|
||||
}]);
|
||||
|
||||
var installs = gProvider.createInstalls([{
|
||||
name: "PASS - a - SEARCHing",
|
||||
sourceURI: "http://example.com/install1.xpi"
|
||||
}, {
|
||||
name: "PASS - g - reSEARCHing SEARCH",
|
||||
sourceURI: "http://example.com/install2.xpi"
|
||||
}, {
|
||||
// Does not match query
|
||||
name: "FAIL",
|
||||
sourceURI: "http://example.com/fail-install1.xpi"
|
||||
}]);
|
||||
|
||||
for (let install of installs )
|
||||
install.install();
|
||||
|
||||
open_manager("addons://list/extension", function(aWindow) {
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
run_next_test();
|
||||
});
|
||||
}
|
||||
|
||||
function end_test() {
|
||||
close_manager(gManagerWindow, function() {
|
||||
var installedAddon = get_addon_item(REMOTE_TO_INSTALL).mAddon;
|
||||
installedAddon.uninstall();
|
||||
|
||||
AddonManager.getAllInstalls(function(aInstallsList) {
|
||||
for (var install of aInstallsList) {
|
||||
var sourceURI = install.sourceURI.spec;
|
||||
if (sourceURI == REMOTE_INSTALL_URL ||
|
||||
sourceURI.match(/^http:\/\/example\.com\/(.+)\.xpi$/) != null)
|
||||
install.cancel();
|
||||
}
|
||||
|
||||
finish();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function getAnonymousElementByAttribute(aElement, aName, aValue) {
|
||||
return gManagerWindow.document.getAnonymousElementByAttribute(aElement,
|
||||
aName,
|
||||
aValue);
|
||||
}
|
||||
|
||||
/*
|
||||
* Checks whether or not the Add-ons Manager is currently searching
|
||||
*
|
||||
* @param aExpectedSearching
|
||||
* The expected isSearching state
|
||||
*/
|
||||
function check_is_searching(aExpectedSearching) {
|
||||
var loading = gManagerWindow.document.getElementById("search-loading");
|
||||
is(!is_hidden(loading), aExpectedSearching,
|
||||
"Search throbber should be showing iff currently searching");
|
||||
}
|
||||
|
||||
/*
|
||||
* Completes a search
|
||||
*
|
||||
* @param aQuery
|
||||
* The query to search for
|
||||
* @param aFinishImmediately
|
||||
* Boolean representing whether or not the search is expected to
|
||||
* finish immediately
|
||||
* @param aCallback
|
||||
* The callback to call when the search is done
|
||||
* @param aCategoryType
|
||||
* The expected selected category after the search is done.
|
||||
* Optional and defaults to "search"
|
||||
*/
|
||||
function search(aQuery, aFinishImmediately, aCallback, aCategoryType) {
|
||||
// Point search to the correct xml test file
|
||||
var url = (aQuery == NO_MATCH_QUERY) ? NO_MATCH_URL : SEARCH_URL;
|
||||
Services.prefs.setCharPref(PREF_GETADDONS_GETSEARCHRESULTS, url);
|
||||
|
||||
aCategoryType = aCategoryType ? aCategoryType : "search";
|
||||
|
||||
var searchBox = gManagerWindow.document.getElementById("header-search");
|
||||
searchBox.value = aQuery;
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow);
|
||||
EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow);
|
||||
|
||||
var finishImmediately = true;
|
||||
wait_for_view_load(gManagerWindow, function() {
|
||||
is(gCategoryUtilities.selectedCategory, aCategoryType, "Expected category view should be selected");
|
||||
is(gCategoryUtilities.isTypeVisible("search"), aCategoryType == "search",
|
||||
"Search category should only be visible if it is the current view");
|
||||
check_is_searching(false);
|
||||
is(finishImmediately, aFinishImmediately, "Search should finish immediately only if expected");
|
||||
|
||||
aCallback();
|
||||
});
|
||||
|
||||
finishImmediately = false;
|
||||
if (!aFinishImmediately)
|
||||
check_is_searching(true);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return results of a search
|
||||
*
|
||||
* @return Array of objects, each containing the name and item of a specific
|
||||
* result
|
||||
*/
|
||||
function get_actual_results() {
|
||||
var list = gManagerWindow.document.getElementById("search-list");
|
||||
var rows = list.getElementsByTagName("richlistitem");
|
||||
|
||||
var results = [];
|
||||
for (var item of rows) {
|
||||
|
||||
// Only consider items that are currently showing
|
||||
var style = gManagerWindow.document.defaultView.getComputedStyle(item);
|
||||
if (style.display == "none" || style.visibility != "visible")
|
||||
continue;
|
||||
|
||||
if (item.mInstall || item.isPending("install")) {
|
||||
var sourceURI = item.mInstall.sourceURI.spec;
|
||||
if (sourceURI == REMOTE_INSTALL_URL) {
|
||||
results.push({name: REMOTE_TO_INSTALL, item});
|
||||
continue;
|
||||
}
|
||||
|
||||
let result = sourceURI.match(/^http:\/\/example\.com\/(.+)\.xpi$/);
|
||||
if (result != null) {
|
||||
is(item.mInstall.name.indexOf("PASS"), 0, "Install name should start with PASS");
|
||||
results.push({name: result[1], item});
|
||||
continue;
|
||||
}
|
||||
} else if (item.mAddon) {
|
||||
let result = item.mAddon.id.match(/^(.+)@tests\.mozilla\.org$/);
|
||||
if (result != null) {
|
||||
is(item.mAddon.name.indexOf("PASS"), 0, "Addon name should start with PASS");
|
||||
results.push({name: result[1], item});
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
ok(false, "Found an item in the list that was neither installing or installed");
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns expected results when searching for QUERY with default ordering
|
||||
*
|
||||
* @param aSortBy
|
||||
* How the results are sorted (e.g. "name")
|
||||
* @param aLocalExpected
|
||||
* Boolean representing if local results are expected
|
||||
* @return A pair: [array of results with an expected order,
|
||||
* array of results with unknown order]
|
||||
*/
|
||||
function get_expected_results(aSortBy, aLocalExpected) {
|
||||
var expectedOrder = null, unknownOrder = null;
|
||||
switch (aSortBy) {
|
||||
case "relevancescore":
|
||||
expectedOrder = [ "addon2", "remote1", "install2", "addon1",
|
||||
"install1", "remote2", "remote3", "remote4" ];
|
||||
unknownOrder = [];
|
||||
break;
|
||||
case "name":
|
||||
// Defaults to ascending order
|
||||
expectedOrder = [ "install1", "remote1", "addon2", "remote2",
|
||||
"remote3", "addon1", "install2", "remote4" ];
|
||||
unknownOrder = [];
|
||||
break;
|
||||
case "dateUpdated":
|
||||
expectedOrder = [ "addon1", "addon2" ];
|
||||
// Updated date not available for installs and remote add-ons
|
||||
unknownOrder = [ "install1", "install2", "remote1",
|
||||
"remote2", "remote3", "remote4" ];
|
||||
break;
|
||||
default:
|
||||
ok(false, "Should recognize sortBy when checking the order of items");
|
||||
}
|
||||
|
||||
// Only keep expected results
|
||||
function filterResults(aId) {
|
||||
// Include REMOTE_TO_INSTALL as a local add-on if it has been installed
|
||||
if (gAddonInstalled && aId == REMOTE_TO_INSTALL)
|
||||
return aLocalExpected;
|
||||
|
||||
if (aId.indexOf("addon") == 0 || aId.indexOf("install") == 0)
|
||||
return aLocalExpected;
|
||||
if (aId.indexOf("remote") == 0)
|
||||
return !aLocalExpected;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return [expectedOrder.filter(filterResults),
|
||||
unknownOrder.filter(filterResults)];
|
||||
}
|
||||
|
||||
/*
|
||||
* Check that the actual and expected results are the same
|
||||
*
|
||||
* @param aQuery
|
||||
* The search query used
|
||||
* @param aSortBy
|
||||
* How the results are sorted (e.g. "name")
|
||||
* @param aReverseOrder
|
||||
* Boolean representing if the results are in reverse default order
|
||||
* @param aShowLocal
|
||||
* Boolean representing if local results are being shown
|
||||
*/
|
||||
function check_results(aQuery, aSortBy, aReverseOrder, aShowLocal) {
|
||||
|
||||
var xpinstall_enabled = Services.prefs.getBoolPref(PREF_XPI_ENABLED, true);
|
||||
|
||||
// When XPI Instalation is disabled, those buttons are hidden and unused
|
||||
if (xpinstall_enabled) {
|
||||
var localFilterSelected = gManagerWindow.document.getElementById("search-filter-local").selected;
|
||||
var remoteFilterSelected = gManagerWindow.document.getElementById("search-filter-remote").selected;
|
||||
is(localFilterSelected, aShowLocal, "Local filter should be selected if showing local items");
|
||||
is(remoteFilterSelected, !aShowLocal, "Remote filter should be selected if showing remote items");
|
||||
}
|
||||
|
||||
// Get expected order assuming default order
|
||||
var expectedOrder = [], unknownOrder = [];
|
||||
if (aQuery == QUERY)
|
||||
[expectedOrder, unknownOrder] = get_expected_results(aSortBy, aShowLocal);
|
||||
|
||||
// Get actual order of results
|
||||
var actualResults = get_actual_results();
|
||||
var actualOrder = actualResults.map(result => result.name);
|
||||
|
||||
// Reverse array of actual results if supposed to be in reverse order.
|
||||
// Reverse actualOrder instead of expectedOrder so can always check
|
||||
// expectedOrder before unknownOrder
|
||||
if (aReverseOrder)
|
||||
actualOrder.reverse();
|
||||
|
||||
// Check actual vs. expected list of results
|
||||
var totalExpectedResults = expectedOrder.length + unknownOrder.length;
|
||||
is(actualOrder.length, totalExpectedResults, "Should get correct number of results");
|
||||
|
||||
// Check the "first" and "last" attributes are set correctly
|
||||
for (let i = 0; i < actualResults.length; i++) {
|
||||
if (i == 0) {
|
||||
is(actualResults[0].item.hasAttribute("first"), true,
|
||||
"First item should have 'first' attribute set");
|
||||
is(actualResults[0].item.hasAttribute("last"), false,
|
||||
"First item should not have 'last' attribute set");
|
||||
} else if (i == (actualResults.length - 1)) {
|
||||
is(actualResults[actualResults.length - 1].item.hasAttribute("first"), false,
|
||||
"Last item should not have 'first' attribute set");
|
||||
is(actualResults[actualResults.length - 1].item.hasAttribute("last"), true,
|
||||
"Last item should have 'last' attribute set");
|
||||
} else {
|
||||
is(actualResults[i].item.hasAttribute("first"), false,
|
||||
"Item " + i + " should not have 'first' attribute set");
|
||||
is(actualResults[i].item.hasAttribute("last"), false,
|
||||
"Item " + i + " should not have 'last' attribute set");
|
||||
}
|
||||
}
|
||||
|
||||
var i = 0;
|
||||
for (; i < expectedOrder.length; i++)
|
||||
is(actualOrder[i], expectedOrder[i], "Should have seen expected item");
|
||||
|
||||
// Items with data that is unknown can appear in any order among themselves,
|
||||
// so just check that these items exist
|
||||
for (; i < actualOrder.length; i++) {
|
||||
var unknownOrderIndex = unknownOrder.indexOf(actualOrder[i]);
|
||||
ok(unknownOrderIndex >= 0, "Should expect to see item with data that is unknown");
|
||||
unknownOrder[unknownOrderIndex] = null;
|
||||
}
|
||||
|
||||
// Check status of empty notice
|
||||
var emptyNotice = gManagerWindow.document.getElementById("search-list-empty");
|
||||
is(emptyNotice.hidden, totalExpectedResults > 0,
|
||||
"Empty notice should be hidden only if expecting shown items");
|
||||
}
|
||||
|
||||
/*
|
||||
* Check results of a search with different filterings
|
||||
*
|
||||
* @param aQuery
|
||||
* The search query used
|
||||
* @param aSortBy
|
||||
* How the results are sorted (e.g. "name")
|
||||
* @param aReverseOrder
|
||||
* Boolean representing if the results are in reverse default order
|
||||
* @param aLocalOnly
|
||||
* Boolean representing if the results are local only, can be undefined
|
||||
*/
|
||||
function check_filtered_results(aQuery, aSortBy, aReverseOrder, aLocalOnly) {
|
||||
var localFilter = gManagerWindow.document.getElementById("search-filter-local");
|
||||
var remoteFilter = gManagerWindow.document.getElementById("search-filter-remote");
|
||||
|
||||
var list = gManagerWindow.document.getElementById("search-list");
|
||||
list.ensureElementIsVisible(localFilter);
|
||||
|
||||
// Check with showing local add-ons
|
||||
EventUtils.synthesizeMouseAtCenter(localFilter, { }, gManagerWindow);
|
||||
check_results(aQuery, aSortBy, aReverseOrder, true);
|
||||
|
||||
// Check with showing remote add-ons
|
||||
aLocalOnly = aLocalOnly || false;
|
||||
EventUtils.synthesizeMouseAtCenter(remoteFilter, { }, gManagerWindow);
|
||||
check_results(aQuery, aSortBy, aReverseOrder, aLocalOnly);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get item for a specific add-on by name
|
||||
*
|
||||
* @param aName
|
||||
* The name of the add-on to search for
|
||||
* @return Row of add-on if found, null otherwise
|
||||
*/
|
||||
function get_addon_item(aName) {
|
||||
var id = aName + "@tests.mozilla.org";
|
||||
var list = gManagerWindow.document.getElementById("search-list");
|
||||
var rows = list.getElementsByTagName("richlistitem");
|
||||
for (var row of rows) {
|
||||
if (row.mAddon && row.mAddon.id == id)
|
||||
return row;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* Gets the install button for a specific item
|
||||
*
|
||||
* @param aItem
|
||||
* The item to get the install button for
|
||||
* @return The install button for aItem
|
||||
*/
|
||||
function get_install_button(aItem) {
|
||||
isnot(aItem, null, "Item should not be null when checking state of install button");
|
||||
var installStatus = getAnonymousElementByAttribute(aItem, "anonid", "install-status");
|
||||
return getAnonymousElementByAttribute(installStatus, "anonid", "install-remote-btn");
|
||||
}
|
||||
|
||||
|
||||
// Tests that searching for the empty string does nothing when not in the search view
|
||||
add_test(function() {
|
||||
is(gCategoryUtilities.isTypeVisible("search"), false, "Search category should initially be hidden");
|
||||
|
||||
var selectedCategory = gCategoryUtilities.selectedCategory;
|
||||
isnot(selectedCategory, "search", "Selected type should not initially be the search view");
|
||||
search("", true, run_next_test, selectedCategory);
|
||||
});
|
||||
|
||||
// Tests that the results from a query are sorted by relevancescore in descending order.
|
||||
// Also test that double clicking non-install items goes to the detail view, and that
|
||||
// only remote items have install buttons showing
|
||||
add_test(function() {
|
||||
search(QUERY, false, function() {
|
||||
check_filtered_results(QUERY, "relevancescore", false);
|
||||
|
||||
var list = gManagerWindow.document.getElementById("search-list");
|
||||
var results = get_actual_results();
|
||||
for (var result of results) {
|
||||
var installBtn = get_install_button(result.item);
|
||||
is(installBtn.hidden, result.name.indexOf("remote") != 0,
|
||||
"Install button should only be showing for remote items");
|
||||
}
|
||||
|
||||
var currentIndex = -1;
|
||||
function run_next_double_click_test() {
|
||||
currentIndex++;
|
||||
if (currentIndex >= results.length) {
|
||||
run_next_test();
|
||||
return;
|
||||
}
|
||||
|
||||
var result = results[currentIndex];
|
||||
if (result.name.indexOf("install") == 0) {
|
||||
run_next_double_click_test();
|
||||
return;
|
||||
}
|
||||
|
||||
var item = result.item;
|
||||
list.ensureElementIsVisible(item);
|
||||
EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, gManagerWindow);
|
||||
EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, gManagerWindow);
|
||||
wait_for_view_load(gManagerWindow, function() {
|
||||
var name = gManagerWindow.document.getElementById("detail-name").textContent;
|
||||
is(name, item.mAddon.name, "Name in detail view should be correct");
|
||||
var version = gManagerWindow.document.getElementById("detail-version").value;
|
||||
is(version, item.mAddon.version, "Version in detail view should be correct");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(gManagerWindow.document.getElementById("category-search"),
|
||||
{ }, gManagerWindow);
|
||||
wait_for_view_load(gManagerWindow, run_next_double_click_test);
|
||||
});
|
||||
}
|
||||
|
||||
run_next_double_click_test();
|
||||
});
|
||||
});
|
||||
|
||||
// Tests that the sorters and filters correctly manipulate the results
|
||||
add_test(function() {
|
||||
var sorters = gManagerWindow.document.getElementById("search-sorters");
|
||||
var originalHandler = sorters.handler;
|
||||
|
||||
var sorterNames = ["name", "dateUpdated"];
|
||||
var buttonIds = ["name-btn", "date-btn"];
|
||||
var currentIndex = 0;
|
||||
var currentReversed = false;
|
||||
|
||||
function run_sort_test() {
|
||||
if (currentIndex >= sorterNames.length) {
|
||||
sorters.handler = originalHandler;
|
||||
run_next_test();
|
||||
return;
|
||||
}
|
||||
|
||||
// Simulate clicking on a specific sorter
|
||||
var buttonId = buttonIds[currentIndex];
|
||||
var sorter = getAnonymousElementByAttribute(sorters, "anonid", buttonId);
|
||||
is_element_visible(sorter);
|
||||
EventUtils.synthesizeMouseAtCenter(sorter, { }, gManagerWindow);
|
||||
}
|
||||
|
||||
sorters.handler = {
|
||||
onSortChanged(aSortBy, aAscending) {
|
||||
if (originalHandler && "onSortChanged" in originalHandler)
|
||||
originalHandler.onSortChanged(aSortBy, aAscending);
|
||||
|
||||
check_filtered_results(QUERY, sorterNames[currentIndex], currentReversed);
|
||||
|
||||
if (currentReversed)
|
||||
currentIndex++;
|
||||
currentReversed = !currentReversed;
|
||||
|
||||
run_sort_test();
|
||||
}
|
||||
};
|
||||
|
||||
check_filtered_results(QUERY, "relevancescore", false);
|
||||
run_sort_test();
|
||||
});
|
||||
|
||||
// Tests that searching for the empty string does nothing when in search view
|
||||
add_test(function() {
|
||||
search("", true, function() {
|
||||
check_filtered_results(QUERY, "dateUpdated", true);
|
||||
run_next_test();
|
||||
});
|
||||
});
|
||||
|
||||
// Tests that clicking a different category hides the search query
|
||||
add_test(function() {
|
||||
gCategoryUtilities.openType("extension", function() {
|
||||
is(gCategoryUtilities.isTypeVisible("search"), false, "Search category should be hidden");
|
||||
is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
|
||||
run_next_test();
|
||||
});
|
||||
});
|
||||
|
||||
// Tests that re-searching for query doesn't actually complete a new search,
|
||||
// and the last sort is still used
|
||||
add_test(function() {
|
||||
search(QUERY, true, function() {
|
||||
check_filtered_results(QUERY, "dateUpdated", true);
|
||||
run_next_test();
|
||||
});
|
||||
});
|
||||
|
||||
// Tests that getting zero results works correctly
|
||||
add_test(function() {
|
||||
search(NO_MATCH_QUERY, false, function() {
|
||||
check_filtered_results(NO_MATCH_QUERY, "relevancescore", false);
|
||||
run_next_test();
|
||||
});
|
||||
});
|
||||
|
||||
// Tests that installing a remote add-on works
|
||||
add_test(function() {
|
||||
var installBtn = null;
|
||||
|
||||
var listener = {
|
||||
onInstallEnded(aInstall, aAddon) {
|
||||
// Don't immediately consider the installed add-on as local because
|
||||
// if the user was filtering out local add-ons, the installed add-on
|
||||
// would vanish. Only consider add-on as local on new searches.
|
||||
|
||||
aInstall.removeListener(this);
|
||||
|
||||
is(installBtn.hidden, true, "Install button should be hidden after install ended");
|
||||
check_filtered_results(QUERY, "relevancescore", false);
|
||||
run_next_test();
|
||||
}
|
||||
};
|
||||
|
||||
search(QUERY, false, function() {
|
||||
var list = gManagerWindow.document.getElementById("search-list");
|
||||
var remoteItem = get_addon_item(REMOTE_TO_INSTALL);
|
||||
list.ensureElementIsVisible(remoteItem);
|
||||
|
||||
installBtn = get_install_button(remoteItem);
|
||||
is(installBtn.hidden, false, "Install button should be showing before install");
|
||||
remoteItem.mAddon.install.addListener(listener);
|
||||
EventUtils.synthesizeMouseAtCenter(installBtn, { }, gManagerWindow);
|
||||
});
|
||||
});
|
||||
|
||||
// Tests that re-searching for query results in correct results
|
||||
add_test(function() {
|
||||
// Select a different category
|
||||
gCategoryUtilities.openType("extension", function() {
|
||||
is(gCategoryUtilities.isTypeVisible("search"), false, "Search category should be hidden");
|
||||
is(gCategoryUtilities.selectedCategory, "extension", "View should have changed to extension");
|
||||
|
||||
var installBtn = get_install_button(get_addon_item(REMOTE_TO_INSTALL));
|
||||
is(installBtn.hidden, true, "Install button should be hidden for installed item");
|
||||
|
||||
search(QUERY, true, function() {
|
||||
check_filtered_results(QUERY, "relevancescore", false);
|
||||
run_next_test();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Tests that incompatible add-ons are shown with a warning if compatibility checking is disabled
|
||||
add_test(function() {
|
||||
AddonManager.checkCompatibility = false;
|
||||
search("incompatible", false, function() {
|
||||
var item = get_addon_item("remote5");
|
||||
is_element_visible(item, "Incompatible addon should be visible");
|
||||
is(item.getAttribute("notification"), "warning", "Compatibility warning should be shown");
|
||||
|
||||
item = get_addon_item("remote6");
|
||||
is(item, null, "Addon incompatible with the product should not be visible");
|
||||
|
||||
AddonManager.checkCompatibility = true;
|
||||
run_next_test();
|
||||
});
|
||||
});
|
||||
|
||||
// Tests that compatible-by-default addons are shown if strict compatibility checking is disabled
|
||||
add_test(function() {
|
||||
restart_manager(gManagerWindow, "addons://list/extension", function(aWindow) {
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
|
||||
Services.prefs.setBoolPref(PREF_STRICT_COMPAT, false);
|
||||
search("incompatible", false, function() {
|
||||
var item = get_addon_item("remote5");
|
||||
is_element_visible(item, "Incompatible addon should be visible");
|
||||
isnot(item.getAttribute("notification"), "warning", "Compatibility warning should not be shown");
|
||||
|
||||
item = get_addon_item("remote6");
|
||||
is(item, null, "Addon incompatible with the product should not be visible");
|
||||
|
||||
Services.prefs.setBoolPref(PREF_STRICT_COMPAT, true);
|
||||
run_next_test();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// Tests that restarting the manager doesn't change search results
|
||||
add_test(function() {
|
||||
restart_manager(gManagerWindow, null, function(aWindow) {
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
|
||||
// We never restore to the search pane
|
||||
is(gCategoryUtilities.selectedCategory, "discover", "View should have changed to discover");
|
||||
|
||||
// Installed add-on is considered local on new search
|
||||
gAddonInstalled = true;
|
||||
|
||||
// Switch over to extensions list so we can do a new search
|
||||
gCategoryUtilities.openType("extension", function() {
|
||||
search(QUERY, false, function() {
|
||||
check_filtered_results(QUERY, "relevancescore", false);
|
||||
|
||||
var installBtn = get_install_button(get_addon_item(REMOTE_TO_INSTALL));
|
||||
is(installBtn.hidden, true, "Install button should be hidden for installed item");
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function bug_815120_test_search(aLocalOnly) {
|
||||
restart_manager(gManagerWindow, "addons://list/extension", function(aWindow) {
|
||||
gManagerWindow = aWindow;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
|
||||
// Installed add-on is considered local on new search
|
||||
gAddonInstalled = true;
|
||||
|
||||
// The search buttons should be hidden in the LocalOnly setup
|
||||
var localFilterButton = aWindow.document.getElementById("search-filter-local");
|
||||
is(aLocalOnly, is_hidden(localFilterButton), "Local filter button visibility does not match, aLocalOnly = " + aLocalOnly);
|
||||
|
||||
var remoteFilterButton = aWindow.document.getElementById("search-filter-remote");
|
||||
is(aLocalOnly, is_hidden(remoteFilterButton), "Remote filter button visibility does not match, aLocalOnly = " + aLocalOnly);
|
||||
|
||||
search(QUERY, false, function() {
|
||||
check_filtered_results(QUERY, "relevancescore", false, aLocalOnly);
|
||||
run_next_test();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Tests for Bug 815120
|
||||
add_test(function() {
|
||||
Services.prefs.setBoolPref(PREF_XPI_ENABLED, false);
|
||||
bug_815120_test_search(true);
|
||||
});
|
||||
|
||||
add_test(function() {
|
||||
Services.prefs.setBoolPref(PREF_XPI_ENABLED, true);
|
||||
bug_815120_test_search(false);
|
||||
});
|
||||
|
|
@ -1,277 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<searchresults total_results="100">
|
||||
<addon>
|
||||
<name>FAIL</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>addon1@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<authors>
|
||||
<author>
|
||||
<name>Test Creator</name>
|
||||
<link>http://example.com/creator.html</link>
|
||||
</author>
|
||||
</authors>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Addon already installed - SEARCH</summary>
|
||||
<description>Test description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>Firefox</name>
|
||||
<appID>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
<application>
|
||||
<name>SeaMonkey</name>
|
||||
<appID>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<compatible_os>ALL</compatible_os>
|
||||
<install size="1">http://example.com/addon1.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>FAIL</name>
|
||||
<type id='9'>lightweight theme</type>
|
||||
<guid>addon12345@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<authors>
|
||||
<author>
|
||||
<name>Test Creator</name>
|
||||
<link>http://example.com/creator.html</link>
|
||||
</author>
|
||||
</authors>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Addon with uninstallable type shouldn't be visible in search</summary>
|
||||
<description>Test description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>Firefox</name>
|
||||
<appID>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
<application>
|
||||
<name>SeaMonkey</name>
|
||||
<appID>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<compatible_os>ALL</compatible_os>
|
||||
<install size="1">http://example.com/addon1.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>FAIL</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>install1@tests.mozilla.org</guid>
|
||||
<version>1.0</version>
|
||||
<authors>
|
||||
<author>
|
||||
<name>Test Creator</name>
|
||||
<link>http://example.com/creator.html</link>
|
||||
</author>
|
||||
</authors>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Install already exists - SEARCH</summary>
|
||||
<description>Test description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>Firefox</name>
|
||||
<appID>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
<application>
|
||||
<name>SeaMonkey</name>
|
||||
<appID>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<compatible_os>ALL</compatible_os>
|
||||
<install size="1">http://example.com/install1.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>PASS - b</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>remote1@tests.mozilla.org</guid>
|
||||
<version>3.0</version>
|
||||
<authors>
|
||||
<author>
|
||||
<name>Test Creator</name>
|
||||
<link>http://example.com/creator.html</link>
|
||||
</author>
|
||||
</authors>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Test summary - SEARCH SEARCH</summary>
|
||||
<description>Test description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>Firefox</name>
|
||||
<appID>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
<application>
|
||||
<name>SeaMonkey</name>
|
||||
<appID>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<compatible_os>ALL</compatible_os>
|
||||
<install size="2">http://example.com/browser/toolkit/mozapps/extensions/test/browser/addons/browser_searching.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>PASS - d</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>remote2@tests.mozilla.org</guid>
|
||||
<version>4.0</version>
|
||||
<authors>
|
||||
<author>
|
||||
<name>Test Creator</name>
|
||||
<link>http://example.com/creator.html</link>
|
||||
</author>
|
||||
</authors>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Test summary - SEARCHing SEARCH</summary>
|
||||
<description>Test description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>Firefox</name>
|
||||
<appID>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
<application>
|
||||
<name>SeaMonkey</name>
|
||||
<appID>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<compatible_os>ALL</compatible_os>
|
||||
<install size="5">http://example.com/remote2.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>PASS - e</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>remote3@tests.mozilla.org</guid>
|
||||
<version>5.0</version>
|
||||
<authors>
|
||||
<author>
|
||||
<name>Test Creator</name>
|
||||
<link>http://example.com/creator.html</link>
|
||||
</author>
|
||||
</authors>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Test summary - Does not match query</summary>
|
||||
<description>Test description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>Firefox</name>
|
||||
<appID>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
<application>
|
||||
<name>SeaMonkey</name>
|
||||
<appID>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<compatible_os>ALL</compatible_os>
|
||||
<install size="1">http://example.com/remote3.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>PASS - h</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>remote4@tests.mozilla.org</guid>
|
||||
<version>6.0</version>
|
||||
<authors>
|
||||
<author>
|
||||
<name>Test Creator</name>
|
||||
<link>http://example.com/creator.html</link>
|
||||
</author>
|
||||
</authors>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Test summary - SEARCHing SEARCH SEARCH</summary>
|
||||
<description>Test description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>Firefox</name>
|
||||
<appID>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
<application>
|
||||
<name>SeaMonkey</name>
|
||||
<appID>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>*</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<compatible_os>ALL</compatible_os>
|
||||
<install size="4">http://example.com/remote4.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>PASS - i</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>remote5@tests.mozilla.org</guid>
|
||||
<version>6.0</version>
|
||||
<authors>
|
||||
<author>
|
||||
<name>Test Creator</name>
|
||||
<link>http://example.com/creator.html</link>
|
||||
</author>
|
||||
</authors>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Incompatible test</summary>
|
||||
<description>Test description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>Firefox</name>
|
||||
<appID>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
<application>
|
||||
<name>SeaMonkey</name>
|
||||
<appID>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<compatible_os>ALL</compatible_os>
|
||||
<install size="1">http://example.com/addon1.xpi</install>
|
||||
</addon>
|
||||
<addon>
|
||||
<name>FAIL - j</name>
|
||||
<type id='1'>Extension</type>
|
||||
<guid>remote6@tests.mozilla.org</guid>
|
||||
<version>6.0</version>
|
||||
<authors>
|
||||
<author>
|
||||
<name>Test Creator</name>
|
||||
<link>http://example.com/creator.html</link>
|
||||
</author>
|
||||
</authors>
|
||||
<status id='4'>Public</status>
|
||||
<summary>Incompatible test</summary>
|
||||
<description>Test description</description>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<name>Fake Product</name>
|
||||
<appID>fakeproduct@mozilla.org</appID>
|
||||
<min_version>0</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<compatible_os>ALL</compatible_os>
|
||||
<install size="1">http://example.com/addon1.xpi</install>
|
||||
</addon>
|
||||
</searchresults>
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<searchresults total_results="100" />
|
||||
|
|
@ -2,8 +2,6 @@
|
|||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// Tests that searching for add-ons works correctly
|
||||
|
||||
var gManagerWindow;
|
||||
var gDocument;
|
||||
var gCategoryUtilities;
|
||||
|
@ -248,190 +246,6 @@ add_test(function() {
|
|||
});
|
||||
});
|
||||
|
||||
// Tests that uninstalling a normal add-on from the search view can be undone
|
||||
add_test(function() {
|
||||
var ID = "addon1@tests.mozilla.org";
|
||||
var list = gDocument.getElementById("search-list");
|
||||
|
||||
var searchBox = gManagerWindow.document.getElementById("header-search");
|
||||
searchBox.value = "Uninstall";
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow);
|
||||
EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow);
|
||||
|
||||
wait_for_view_load(gManagerWindow, function() {
|
||||
is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search");
|
||||
|
||||
// Make sure to show local add-ons
|
||||
EventUtils.synthesizeMouseAtCenter(gDocument.getElementById("search-filter-local"), { }, gManagerWindow);
|
||||
|
||||
AddonManager.getAddonByID(ID, function(aAddon) {
|
||||
ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
|
||||
ok(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL, "Add-on should require a restart to uninstall");
|
||||
|
||||
var item = get_item_in_list(ID, list);
|
||||
isnot(item, null, "Should have found the add-on in the list");
|
||||
|
||||
var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
|
||||
isnot(button, null, "Should have a remove button");
|
||||
ok(!button.disabled, "Button should not be disabled");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
|
||||
|
||||
// Force XBL to apply
|
||||
item.clientTop;
|
||||
|
||||
is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling");
|
||||
|
||||
ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall");
|
||||
|
||||
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn");
|
||||
isnot(button, null, "Should have a restart button");
|
||||
ok(!button.hidden, "Restart button should not be hidden");
|
||||
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
|
||||
isnot(button, null, "Should have an undo button");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
|
||||
|
||||
// Force XBL to apply
|
||||
item.clientTop;
|
||||
|
||||
ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
|
||||
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
|
||||
isnot(button, null, "Should have a remove button");
|
||||
ok(!button.disabled, "Button should not be disabled");
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Tests that uninstalling a restartless add-on from the search view can be undone
|
||||
add_test(function() {
|
||||
var ID = "addon2@tests.mozilla.org";
|
||||
var list = gDocument.getElementById("search-list");
|
||||
|
||||
var searchBox = gManagerWindow.document.getElementById("header-search");
|
||||
searchBox.value = "Uninstall";
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow);
|
||||
EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow);
|
||||
|
||||
wait_for_view_load(gManagerWindow, function() {
|
||||
is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search");
|
||||
|
||||
// Make sure to show local add-ons
|
||||
EventUtils.synthesizeMouseAtCenter(gDocument.getElementById("search-filter-local"), { }, gManagerWindow);
|
||||
|
||||
AddonManager.getAddonByID(ID, function(aAddon) {
|
||||
ok(aAddon.isActive, "Add-on should be active");
|
||||
ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall");
|
||||
ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
|
||||
|
||||
var item = get_item_in_list(ID, list);
|
||||
isnot(item, null, "Should have found the add-on in the list");
|
||||
|
||||
var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
|
||||
isnot(button, null, "Should have a remove button");
|
||||
ok(!button.disabled, "Button should not be disabled");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
|
||||
|
||||
// Force XBL to apply
|
||||
item.clientTop;
|
||||
|
||||
is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling");
|
||||
|
||||
ok(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL, "Add-on should be pending uninstall");
|
||||
ok(!aAddon.isActive, "Add-on should be inactive");
|
||||
|
||||
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn");
|
||||
isnot(button, null, "Should have a restart button");
|
||||
ok(button.hidden, "Restart button should be hidden");
|
||||
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
|
||||
isnot(button, null, "Should have an undo button");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
|
||||
|
||||
// Force XBL to apply
|
||||
item.clientTop;
|
||||
|
||||
ok(aAddon.isActive, "Add-on should be active");
|
||||
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
|
||||
isnot(button, null, "Should have a remove button");
|
||||
ok(!button.disabled, "Button should not be disabled");
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Tests that uninstalling a disabled restartless add-on from the search view can
|
||||
// be undone and doesn't re-enable
|
||||
add_test(function() {
|
||||
var ID = "addon2@tests.mozilla.org";
|
||||
var list = gDocument.getElementById("search-list");
|
||||
|
||||
var searchBox = gManagerWindow.document.getElementById("header-search");
|
||||
searchBox.value = "Uninstall";
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow);
|
||||
EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow);
|
||||
|
||||
wait_for_view_load(gManagerWindow, function() {
|
||||
is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search");
|
||||
|
||||
// Make sure to show local add-ons
|
||||
EventUtils.synthesizeMouseAtCenter(gDocument.getElementById("search-filter-local"), { }, gManagerWindow);
|
||||
|
||||
AddonManager.getAddonByID(ID, function(aAddon) {
|
||||
aAddon.userDisabled = true;
|
||||
|
||||
ok(!aAddon.isActive, "Add-on should be inactive");
|
||||
ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall");
|
||||
ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
|
||||
|
||||
var item = get_item_in_list(ID, list);
|
||||
isnot(item, null, "Should have found the add-on in the list");
|
||||
|
||||
var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
|
||||
isnot(button, null, "Should have a remove button");
|
||||
ok(!button.disabled, "Button should not be disabled");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
|
||||
|
||||
// Force XBL to apply
|
||||
item.clientTop;
|
||||
|
||||
is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling");
|
||||
|
||||
ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall");
|
||||
ok(!aAddon.isActive, "Add-on should be inactive");
|
||||
|
||||
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn");
|
||||
isnot(button, null, "Should have a restart button");
|
||||
ok(button.hidden, "Restart button should be hidden");
|
||||
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
|
||||
isnot(button, null, "Should have an undo button");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
|
||||
|
||||
// Force XBL to apply
|
||||
item.clientTop;
|
||||
|
||||
ok(!aAddon.isActive, "Add-on should be inactive");
|
||||
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
|
||||
isnot(button, null, "Should have a remove button");
|
||||
ok(!button.disabled, "Button should not be disabled");
|
||||
|
||||
aAddon.userDisabled = false;
|
||||
ok(aAddon.isActive, "Add-on should be active");
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Tests that uninstalling a normal add-on from the details view switches back
|
||||
// to the list view and can be undone
|
||||
add_test(function() {
|
||||
|
@ -698,87 +512,6 @@ add_test(function() {
|
|||
});
|
||||
});
|
||||
|
||||
// Tests that a normal add-on pending uninstall shows up in the search view
|
||||
add_test(function() {
|
||||
var ID = "addon1@tests.mozilla.org";
|
||||
var list = gDocument.getElementById("search-list");
|
||||
|
||||
var searchBox = gManagerWindow.document.getElementById("header-search");
|
||||
searchBox.value = "Uninstall";
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow);
|
||||
EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow);
|
||||
|
||||
wait_for_view_load(gManagerWindow, function() {
|
||||
is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search");
|
||||
|
||||
// Make sure to show local add-ons
|
||||
EventUtils.synthesizeMouseAtCenter(gDocument.getElementById("search-filter-local"), { }, gManagerWindow);
|
||||
|
||||
AddonManager.getAddonByID(ID, function(aAddon) {
|
||||
ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
|
||||
ok(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL, "Add-on should require a restart to uninstall");
|
||||
|
||||
var item = get_item_in_list(ID, list);
|
||||
isnot(item, null, "Should have found the add-on in the list");
|
||||
|
||||
var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
|
||||
isnot(button, null, "Should have a remove button");
|
||||
ok(!button.disabled, "Button should not be disabled");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
|
||||
|
||||
// Force XBL to apply
|
||||
item.clientTop;
|
||||
|
||||
is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling");
|
||||
|
||||
ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall");
|
||||
|
||||
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn");
|
||||
isnot(button, null, "Should have a restart button");
|
||||
ok(!button.hidden, "Restart button should not be hidden");
|
||||
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
|
||||
isnot(button, null, "Should have an undo button");
|
||||
|
||||
gCategoryUtilities.openType("plugin", function() {
|
||||
is(gCategoryUtilities.selectedCategory, "plugin", "View should have changed to plugin");
|
||||
searchBox.value = "Uninstall";
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow);
|
||||
EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow);
|
||||
|
||||
wait_for_view_load(gManagerWindow, function() {
|
||||
is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search");
|
||||
|
||||
var item = get_item_in_list(ID, list);
|
||||
isnot(item, null, "Should have found the add-on in the list");
|
||||
is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling");
|
||||
|
||||
ok(!!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should be pending uninstall");
|
||||
|
||||
var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn");
|
||||
isnot(button, null, "Should have a restart button");
|
||||
ok(!button.hidden, "Restart button should not be hidden");
|
||||
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
|
||||
isnot(button, null, "Should have an undo button");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
|
||||
|
||||
// Force XBL to apply
|
||||
item.clientTop;
|
||||
ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
|
||||
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
|
||||
isnot(button, null, "Should have a remove button");
|
||||
ok(!button.disabled, "Button should not be disabled");
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Tests that switching away from the list view finalises the uninstall of
|
||||
// multiple restartless add-ons
|
||||
add_test(function() {
|
||||
|
@ -849,90 +582,6 @@ add_test(function() {
|
|||
});
|
||||
});
|
||||
|
||||
// Tests that switching away from the search view finalises the uninstall of
|
||||
// multiple restartless add-ons
|
||||
add_test(function() {
|
||||
var ID = "addon3@tests.mozilla.org";
|
||||
var ID2 = "addon7@tests.mozilla.org";
|
||||
var list = gDocument.getElementById("search-list");
|
||||
|
||||
var searchBox = gManagerWindow.document.getElementById("header-search");
|
||||
searchBox.value = "Uninstall";
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow);
|
||||
EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow);
|
||||
|
||||
wait_for_view_load(gManagerWindow, function() {
|
||||
is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search");
|
||||
|
||||
// Make sure to show local add-ons
|
||||
EventUtils.synthesizeMouseAtCenter(gDocument.getElementById("search-filter-local"), { }, gManagerWindow);
|
||||
|
||||
AddonManager.getAddonByID(ID, function(aAddon) {
|
||||
ok(aAddon.isActive, "Add-on should be active");
|
||||
ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall");
|
||||
ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
|
||||
|
||||
var item = get_item_in_list(ID, list);
|
||||
isnot(item, null, "Should have found the add-on in the list");
|
||||
|
||||
var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
|
||||
isnot(button, null, "Should have a remove button");
|
||||
ok(!button.disabled, "Button should not be disabled");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
|
||||
|
||||
// Force XBL to apply
|
||||
item.clientTop;
|
||||
|
||||
is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling");
|
||||
|
||||
ok(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL, "Add-on should be pending uninstall");
|
||||
ok(!aAddon.isActive, "Add-on should be inactive");
|
||||
|
||||
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn");
|
||||
isnot(button, null, "Should have a restart button");
|
||||
ok(button.hidden, "Restart button should be hidden");
|
||||
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
|
||||
isnot(button, null, "Should have an undo button");
|
||||
|
||||
item = get_item_in_list(ID2, list);
|
||||
isnot(item, null, "Should have found the add-on in the list");
|
||||
|
||||
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
|
||||
isnot(button, null, "Should have a remove button");
|
||||
ok(!button.disabled, "Button should not be disabled");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
|
||||
|
||||
gCategoryUtilities.openType("plugin", function() {
|
||||
is(gCategoryUtilities.selectedCategory, "plugin", "View should have changed to extension");
|
||||
|
||||
AddonManager.getAddonsByIDs([ID, ID2], function([aAddon, aAddon2]) {
|
||||
is(aAddon, null, "Add-on should no longer be installed");
|
||||
is(aAddon2, null, "Second add-on should no longer be installed");
|
||||
|
||||
searchBox.value = "Uninstall";
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow);
|
||||
EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow);
|
||||
|
||||
wait_for_view_load(gManagerWindow, function() {
|
||||
is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search");
|
||||
|
||||
var item = get_item_in_list(ID, list);
|
||||
is(item, null, "Should not have found the add-on in the list");
|
||||
item = get_item_in_list(ID2, list);
|
||||
is(item, null, "Should not have found the second add-on in the list");
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Tests that closing the manager from the list view finalises the uninstall of
|
||||
// multiple restartless add-ons
|
||||
add_test(function() {
|
||||
|
@ -1006,93 +655,3 @@ add_test(function() {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Tests that closing the manager from the search view finalises the uninstall
|
||||
// of multiple restartless add-ons
|
||||
add_test(function() {
|
||||
var ID = "addon5@tests.mozilla.org";
|
||||
var ID2 = "addon9@tests.mozilla.org";
|
||||
var list = gDocument.getElementById("search-list");
|
||||
|
||||
var searchBox = gManagerWindow.document.getElementById("header-search");
|
||||
searchBox.value = "Uninstall";
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow);
|
||||
EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow);
|
||||
|
||||
wait_for_view_load(gManagerWindow, function() {
|
||||
is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search");
|
||||
|
||||
// Make sure to show local add-ons
|
||||
EventUtils.synthesizeMouseAtCenter(gDocument.getElementById("search-filter-local"), { }, gManagerWindow);
|
||||
|
||||
AddonManager.getAddonByID(ID, function(aAddon) {
|
||||
ok(aAddon.isActive, "Add-on should be active");
|
||||
ok(!(aAddon.operationsRequiringRestart & AddonManager.OP_NEEDS_RESTART_UNINSTALL), "Add-on should not require a restart to uninstall");
|
||||
ok(!(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL), "Add-on should not be pending uninstall");
|
||||
|
||||
var item = get_item_in_list(ID, list);
|
||||
isnot(item, null, "Should have found the add-on in the list");
|
||||
|
||||
var button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
|
||||
isnot(button, null, "Should have a remove button");
|
||||
ok(!button.disabled, "Button should not be disabled");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
|
||||
|
||||
// Force XBL to apply
|
||||
item.clientTop;
|
||||
|
||||
is(item.getAttribute("pending"), "uninstall", "Add-on should be uninstalling");
|
||||
|
||||
ok(aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL, "Add-on should be pending uninstall");
|
||||
ok(!aAddon.isActive, "Add-on should be inactive");
|
||||
|
||||
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "restart-btn");
|
||||
isnot(button, null, "Should have a restart button");
|
||||
ok(button.hidden, "Restart button should be hidden");
|
||||
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "undo-btn");
|
||||
isnot(button, null, "Should have an undo button");
|
||||
|
||||
item = get_item_in_list(ID2, list);
|
||||
isnot(item, null, "Should have found the add-on in the list");
|
||||
|
||||
button = gDocument.getAnonymousElementByAttribute(item, "anonid", "remove-btn");
|
||||
isnot(button, null, "Should have a remove button");
|
||||
ok(!button.disabled, "Button should not be disabled");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(button, { }, gManagerWindow);
|
||||
|
||||
close_manager(gManagerWindow, function() {
|
||||
AddonManager.getAddonsByIDs([ID, ID2], function([aAddon, aAddon2]) {
|
||||
is(aAddon, null, "Add-on should no longer be installed");
|
||||
is(aAddon2, null, "Second add-on should no longer be installed");
|
||||
|
||||
open_manager("addons://list/extension", function(aWindow) {
|
||||
gManagerWindow = aWindow;
|
||||
gDocument = gManagerWindow.document;
|
||||
gCategoryUtilities = new CategoryUtilities(gManagerWindow);
|
||||
var list = gDocument.getElementById("search-list");
|
||||
var searchBox = gManagerWindow.document.getElementById("header-search");
|
||||
|
||||
searchBox.value = "Uninstall";
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(searchBox, { }, gManagerWindow);
|
||||
EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow);
|
||||
|
||||
wait_for_view_load(gManagerWindow, function() {
|
||||
is(gCategoryUtilities.selectedCategory, "search", "View should have changed to search");
|
||||
|
||||
var item = get_item_in_list(ID, list);
|
||||
is(item, null, "Should not have found the add-on in the list");
|
||||
item = get_item_in_list(ID2, list);
|
||||
is(item, null, "Should not have found the second add-on in the list");
|
||||
|
||||
run_next_test();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -36,7 +36,6 @@ const PREF_UI_LASTCATEGORY = "extensions.ui.lastCategory";
|
|||
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_STRICT_COMPAT = "extensions.strictCompatibility";
|
||||
|
||||
var PREF_CHECK_COMPATIBILITY;
|
||||
|
@ -66,11 +65,8 @@ var gRestorePrefs = [{name: PREF_LOGGING_ENABLED},
|
|||
{name: "extensions.update.autoUpdateDefault"},
|
||||
{name: "extensions.getAddons.get.url"},
|
||||
{name: "extensions.getAddons.getWithPerformance.url"},
|
||||
{name: "extensions.getAddons.search.browseURL"},
|
||||
{name: "extensions.getAddons.search.url"},
|
||||
{name: "extensions.getAddons.cache.enabled"},
|
||||
{name: "devtools.chrome.enabled"},
|
||||
{name: PREF_SEARCH_MAXRESULTS},
|
||||
{name: PREF_STRICT_COMPAT},
|
||||
{name: PREF_CHECK_COMPATIBILITY}];
|
||||
|
||||
|
@ -283,9 +279,7 @@ function get_current_view(aManager) {
|
|||
function get_test_items_in_list(aManager) {
|
||||
var tests = "@tests.mozilla.org";
|
||||
|
||||
let view = get_current_view(aManager);
|
||||
let listid = view.id == "search-view" ? "search-list" : "addon-list";
|
||||
let item = aManager.document.getElementById(listid).firstChild;
|
||||
let item = aManager.document.getElementById("addon-list").firstChild;
|
||||
let items = [];
|
||||
|
||||
while (item) {
|
||||
|
@ -304,9 +298,7 @@ function get_test_items_in_list(aManager) {
|
|||
|
||||
function check_all_in_list(aManager, aIds, aIgnoreExtras) {
|
||||
var doc = aManager.document;
|
||||
var view = get_current_view(aManager);
|
||||
var listid = view.id == "search-view" ? "search-list" : "addon-list";
|
||||
var list = doc.getElementById(listid);
|
||||
var list = doc.getElementById("addon-list");
|
||||
|
||||
var inlist = [];
|
||||
var node = list.firstChild;
|
||||
|
@ -334,9 +326,7 @@ function get_addon_element(aManager, aId) {
|
|||
var doc = aManager.document;
|
||||
var view = get_current_view(aManager);
|
||||
var listid = "addon-list";
|
||||
if (view.id == "search-view")
|
||||
listid = "search-list";
|
||||
else if (view.id == "updates-view")
|
||||
if (view.id == "updates-view")
|
||||
listid = "updates-list";
|
||||
var list = doc.getElementById(listid);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче