mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 706387 - Send the compatibility mode when using AMO Search API. r=dtownsend a=khuey
This commit is contained in:
parent
3d1a40bcf2
commit
b7b78d24ac
@ -66,7 +66,7 @@ pref("extensions.getAddons.cache.enabled", true);
|
||||
pref("extensions.getAddons.maxResults", 15);
|
||||
pref("extensions.getAddons.get.url", "https://services.addons.mozilla.org/%LOCALE%/firefox/api/%API_VERSION%/search/guid:%IDS%?src=firefox&appOS=%OS%&appVersion=%VERSION%");
|
||||
pref("extensions.getAddons.search.browseURL", "https://addons.mozilla.org/%LOCALE%/firefox/search?q=%TERMS%");
|
||||
pref("extensions.getAddons.search.url", "https://services.addons.mozilla.org/%LOCALE%/firefox/api/%API_VERSION%/search/%TERMS%/all/%MAX_RESULTS%/%OS%/%VERSION%?src=firefox");
|
||||
pref("extensions.getAddons.search.url", "https://services.addons.mozilla.org/%LOCALE%/firefox/api/%API_VERSION%/search/%TERMS%/all/%MAX_RESULTS%/%OS%/%VERSION%/%COMPATIBILITY_MODE%?src=firefox");
|
||||
pref("extensions.webservice.discoverURL", "https://services.addons.mozilla.org/%LOCALE%/firefox/discovery/pane/%VERSION%/%OS%");
|
||||
|
||||
// Blocklist preferences
|
||||
|
@ -841,21 +841,28 @@ var AddonRepository = {
|
||||
* The callback to pass results to
|
||||
*/
|
||||
searchAddons: function(aSearchTerms, aMaxResults, aCallback) {
|
||||
let substitutions = {
|
||||
API_VERSION : API_VERSION,
|
||||
TERMS : encodeURIComponent(aSearchTerms),
|
||||
|
||||
// Get twice as many results to account for potential filtering
|
||||
MAX_RESULTS : 2 * aMaxResults
|
||||
};
|
||||
|
||||
let checkCompatibility = true;
|
||||
try {
|
||||
checkCompatibility = Services.prefs.getBoolPref(PREF_CHECK_COMPATIBILITY);
|
||||
} catch(e) { }
|
||||
let strictCompatibility = STRICT_COMPATIBILITY_DEFAULT;
|
||||
try {
|
||||
strictCompatibility = Services.prefs.getBoolPref(PREF_EM_STRICT_COMPATIBILITY);
|
||||
} catch(e) { }
|
||||
|
||||
let compatMode = "normal";
|
||||
if (!checkCompatibility)
|
||||
substitutions.VERSION = "";
|
||||
compatMode = "ignore";
|
||||
else if (strictCompatibility)
|
||||
compatMode = "strict";
|
||||
|
||||
let substitutions = {
|
||||
API_VERSION : API_VERSION,
|
||||
TERMS : encodeURIComponent(aSearchTerms),
|
||||
// Get twice as many results to account for potential filtering
|
||||
MAX_RESULTS : 2 * aMaxResults,
|
||||
COMPATIBILITY_MODE : compatMode,
|
||||
};
|
||||
|
||||
let url = this._formatURLPref(PREF_GETADDONS_GETSEARCHRESULTS, substitutions);
|
||||
|
||||
|
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<searchresults total_results="123">
|
||||
<addon>
|
||||
<name>Test Repo Add-on - ignore</name>
|
||||
<type id="1">Extension</type>
|
||||
<guid>compatmode-ignore@tests.mozilla.org</guid>
|
||||
<version>1.1</version>
|
||||
<authors>
|
||||
<author>
|
||||
<name>Test Creator 1</name>
|
||||
<link>http://localhost:4444/creator1.html</link>
|
||||
</author>
|
||||
</authors>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<install>http://localhost:4444/test1.xpi</install>
|
||||
</addon>
|
||||
</searchresults>
|
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<searchresults total_results="123">
|
||||
<addon>
|
||||
<name>Test Repo Add-on - normal</name>
|
||||
<type id="1">Extension</type>
|
||||
<guid>compatmode-normal@tests.mozilla.org</guid>
|
||||
<version>1.1</version>
|
||||
<authors>
|
||||
<author>
|
||||
<name>Test Creator 1</name>
|
||||
<link>http://localhost:4444/creator1.html</link>
|
||||
</author>
|
||||
</authors>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<install>http://localhost:4444/test1.xpi</install>
|
||||
</addon>
|
||||
</searchresults>
|
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<searchresults total_results="123">
|
||||
<addon>
|
||||
<name>Test Repo Add-on - strict</name>
|
||||
<type id="1">Extension</type>
|
||||
<guid>compatmode-strict@tests.mozilla.org</guid>
|
||||
<version>1.1</version>
|
||||
<authors>
|
||||
<author>
|
||||
<name>Test Creator 1</name>
|
||||
<link>http://localhost:4444/creator1.html</link>
|
||||
</author>
|
||||
</authors>
|
||||
<compatible_applications>
|
||||
<application>
|
||||
<appID>xpcshell@tests.mozilla.org</appID>
|
||||
<min_version>1</min_version>
|
||||
<max_version>1</max_version>
|
||||
</application>
|
||||
</compatible_applications>
|
||||
<install>http://localhost:4444/test1.xpi</install>
|
||||
</addon>
|
||||
</searchresults>
|
@ -0,0 +1,101 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// This verifies that AddonRepository correctly fills in the
|
||||
// %COMPATIBILITY_MODE% token in the Search API URL.
|
||||
|
||||
const PREF_GETADDONS_GETSEARCHRESULTS = "extensions.getAddons.search.url";
|
||||
|
||||
do_load_httpd_js();
|
||||
var gServer;
|
||||
var COMPATIBILITY_PREF;
|
||||
|
||||
function run_test() {
|
||||
do_test_pending();
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
|
||||
|
||||
var channel = "default";
|
||||
try {
|
||||
channel = Services.prefs.getCharPref("app.update.channel");
|
||||
} catch (e) { }
|
||||
if (channel != "aurora" &&
|
||||
channel != "beta" &&
|
||||
channel != "release") {
|
||||
var version = "nightly";
|
||||
} else {
|
||||
version = Services.appinfo.version.replace(/^([^\.]+\.[0-9]+[a-z]*).*/gi, "$1");
|
||||
}
|
||||
COMPATIBILITY_PREF = "extensions.checkCompatibility." + version;
|
||||
|
||||
// Create and configure the HTTP server.
|
||||
gServer = new nsHttpServer();
|
||||
gServer.registerDirectory("/data/", do_get_file("data"));
|
||||
gServer.start(4444);
|
||||
|
||||
Services.prefs.setCharPref(PREF_GETADDONS_GETSEARCHRESULTS,
|
||||
"http://localhost:4444/data/test_AddonRepository_compatmode_%COMPATIBILITY_MODE%.xml");
|
||||
startupManager();
|
||||
run_test_1();
|
||||
}
|
||||
|
||||
function end_test() {
|
||||
gServer.stop(do_test_finished);
|
||||
}
|
||||
|
||||
// Strict compatibility checking disabled.
|
||||
function run_test_1() {
|
||||
do_print("Testing with strict compatibility checking disabled");
|
||||
Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, false);
|
||||
|
||||
AddonRepository.searchAddons("test", 6, {
|
||||
searchSucceeded: function(aAddons) {
|
||||
do_check_neq(aAddons, null);
|
||||
do_check_eq(aAddons.length, 1);
|
||||
do_check_eq(aAddons[0].id, "compatmode-normal@tests.mozilla.org");
|
||||
|
||||
run_test_2();
|
||||
},
|
||||
searchFailed: function() {
|
||||
do_throw("Search should not have failed");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Strict compatibility checking enabled.
|
||||
function run_test_2() {
|
||||
do_print("Testing with strict compatibility checking enabled");
|
||||
Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, true);
|
||||
|
||||
AddonRepository.searchAddons("test", 6, {
|
||||
searchSucceeded: function(aAddons) {
|
||||
do_check_neq(aAddons, null);
|
||||
do_check_eq(aAddons.length, 1);
|
||||
do_check_eq(aAddons[0].id, "compatmode-strict@tests.mozilla.org");
|
||||
|
||||
run_test_3();
|
||||
},
|
||||
searchFailed: function() {
|
||||
do_throw("Search should not have failed");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Compatibility checking disabled.
|
||||
function run_test_3() {
|
||||
do_print("Testing with all compatibility checking disabled");
|
||||
Services.prefs.setBoolPref(COMPATIBILITY_PREF, false);
|
||||
|
||||
AddonRepository.searchAddons("test", 6, {
|
||||
searchSucceeded: function(aAddons) {
|
||||
do_check_neq(aAddons, null);
|
||||
do_check_eq(aAddons.length, 1);
|
||||
do_check_eq(aAddons[0].id, "compatmode-ignore@tests.mozilla.org");
|
||||
|
||||
end_test();
|
||||
},
|
||||
searchFailed: function() {
|
||||
do_throw("Search should not have failed");
|
||||
}
|
||||
});
|
||||
}
|
@ -8,6 +8,9 @@ skip-if = os == "android"
|
||||
[test_AddonRepository_cache.js]
|
||||
# Bug 676992: test consistently hangs on Android
|
||||
skip-if = os == "android"
|
||||
[test_AddonRepository_compatmode.js]
|
||||
# Bug 676992: test consistently hangs on Android
|
||||
skip-if = os == "android"
|
||||
[test_LightweightThemeManager.js]
|
||||
[test_backgroundupdate.js]
|
||||
[test_badschema.js]
|
||||
|
Loading…
Reference in New Issue
Block a user