diff options
author | Matt A. Tobin <email@mattatobin.com> | 2018-02-11 07:03:16 -0500 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2018-02-11 07:03:16 -0500 |
commit | 203eb0f61a09372310a2a8fb57e169cb3f47800b (patch) | |
tree | 8490329d3dae4de3c7ffd127bce1f65fdc009abd /toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository_compatmode.js | |
parent | e45706ca3acbb6530419433212becc61d5953a2d (diff) | |
parent | 8f6d3dab81c7f8f97ef197e26ab9439b09735b8f (diff) | |
download | UXP-ed96a7148c31f5448b81800287c09ce7169223cc.tar UXP-ed96a7148c31f5448b81800287c09ce7169223cc.tar.gz UXP-ed96a7148c31f5448b81800287c09ce7169223cc.tar.lz UXP-ed96a7148c31f5448b81800287c09ce7169223cc.tar.xz UXP-ed96a7148c31f5448b81800287c09ce7169223cc.zip |
Merge branch 'ext-work'FF_Checkpoint_1
Diffstat (limited to 'toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository_compatmode.js')
-rw-r--r-- | toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository_compatmode.js | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository_compatmode.js b/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository_compatmode.js new file mode 100644 index 000000000..6aec96ea1 --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository_compatmode.js @@ -0,0 +1,90 @@ +/* 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"; + +Components.utils.import("resource://testing-common/httpd.js"); +var gServer = new HttpServer(); +gServer.start(-1); +gPort = gServer.identity.primaryPort; +var COMPATIBILITY_PREF; + +// register static files with server and interpolate port numbers in them +mapFile("/data/test_AddonRepository_compatmode_ignore.xml", gServer); +mapFile("/data/test_AddonRepository_compatmode_normal.xml", gServer); +mapFile("/data/test_AddonRepository_compatmode_strict.xml", gServer); + +function run_test() { + do_test_pending(); + createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2"); + + Services.prefs.setCharPref(PREF_GETADDONS_GETSEARCHRESULTS, + "http://localhost:" + gPort + "/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"); + AddonManager.checkCompatibility = 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"); + } + }); +} |