From 1bc713ddbba65c137b43b5d15e6ef32a60d60e58 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Sun, 18 Mar 2018 22:21:46 -0700 Subject: [PATCH] Bug 1446868: Part 2 - Convert remaining update.rdf tests to JSON format. r=aswan MozReview-Commit-ID: 4ZIMdrvP5pJ --HG-- rename : toolkit/mozapps/extensions/test/browser/browser_updatessl.rdf => toolkit/mozapps/extensions/test/browser/browser_updatessl.json rename : toolkit/mozapps/extensions/test/browser/browser_updatessl.rdf^headers^ => toolkit/mozapps/extensions/test/browser/browser_updatessl.json^headers^ rename : toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update1.rdf => toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update1.json rename : toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update2.rdf => toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update2.json rename : toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update3.rdf => toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update3.json rename : toolkit/mozapps/extensions/test/xpcshell/data/test_backgroundupdate.rdf => toolkit/mozapps/extensions/test/xpcshell/data/test_backgroundupdate.json rename : toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_1.rdf => toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_1.json rename : toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_2.rdf => toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_2.json rename : toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_3.rdf => toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_3.json rename : toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_4.rdf => toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_4.json rename : toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_5.rdf => toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_5.json rename : toolkit/mozapps/extensions/test/xpcshell/data/test_bug655254.rdf => toolkit/mozapps/extensions/test/xpcshell/data/test_bug655254.json rename : toolkit/mozapps/extensions/test/xpcshell/data/test_corrupt.rdf => toolkit/mozapps/extensions/test/xpcshell/data/test_corrupt.json rename : toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_complete.rdf => toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_complete_legacy.json rename : toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_defer.rdf => toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_defer_legacy.json rename : toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_ignore.rdf => toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_ignore_legacy.json rename : toolkit/mozapps/extensions/test/xpcshell/data/test_dictionary.rdf => toolkit/mozapps/extensions/test/xpcshell/data/test_dictionary.json rename : toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_ignore.rdf => toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_ignore.json rename : toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_normal.rdf => toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_normal.json rename : toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_strict.rdf => toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_strict.json extra : rebase_source : 1e05503ba170e5df05d66346ba4808fb9259c445 --- .../test/xpcshell/test_ext_privacy_update.js | 2 +- .../extensions/test/browser/browser.ini | 4 +- .../test/browser/browser_install.rdf | 46 +- .../test/browser/browser_updatessl.js | 14 +- .../test/browser/browser_updatessl.json | 17 + ...aders^ => browser_updatessl.json^headers^} | 0 .../test/browser/browser_updatessl.rdf | 25 - .../data/blocklistchange/addon_update1.json | 102 + .../data/blocklistchange/addon_update1.rdf | 144 -- .../data/blocklistchange/addon_update2.json | 102 + .../data/blocklistchange/addon_update2.rdf | 144 -- .../data/blocklistchange/addon_update3.json | 102 + .../data/blocklistchange/addon_update3.rdf | 144 -- .../xpcshell/data/test_backgroundupdate.json | 46 + .../xpcshell/data/test_backgroundupdate.rdf | 70 - .../data/test_bug470377/update_1.json | 18 + .../xpcshell/data/test_bug470377/update_1.rdf | 26 - .../data/test_bug470377/update_2.json | 18 + .../xpcshell/data/test_bug470377/update_2.rdf | 26 - .../data/test_bug470377/update_3.json | 18 + .../xpcshell/data/test_bug470377/update_3.rdf | 26 - .../data/test_bug470377/update_4.json | 18 + .../xpcshell/data/test_bug470377/update_4.rdf | 26 - .../data/test_bug470377/update_5.json | 18 + .../xpcshell/data/test_bug470377/update_5.rdf | 26 - .../test/xpcshell/data/test_bug655254.json | 17 + .../test/xpcshell/data/test_bug655254.rdf | 26 - .../test/xpcshell/data/test_corrupt.json | 30 + .../test/xpcshell/data/test_corrupt.rdf | 44 - .../data/test_delay_updates_complete.rdf | 26 - .../test_delay_updates_complete_legacy.json | 18 + .../data/test_delay_updates_defer.rdf | 26 - .../data/test_delay_updates_defer_legacy.json | 18 + .../data/test_delay_updates_ignore.rdf | 26 - .../test_delay_updates_ignore_legacy.json | 18 + .../test/xpcshell/data/test_dictionary.json | 46 + .../test/xpcshell/data/test_dictionary.rdf | 65 - .../data/test_updatecompatmode_ignore.json | 18 + .../data/test_updatecompatmode_ignore.rdf | 26 - .../data/test_updatecompatmode_normal.json | 18 + .../data/test_updatecompatmode_normal.rdf | 26 - .../data/test_updatecompatmode_strict.json | 18 + .../data/test_updatecompatmode_strict.rdf | 26 - .../test/xpcshell/test_backgroundupdate.js | 8 +- .../test/xpcshell/test_badschema.js | 6 +- .../test/xpcshell/test_blocklistchange.js | 42 +- .../test/xpcshell/test_bug384052.js | 4 +- .../test/xpcshell/test_bug559800.js | 2 +- .../test/xpcshell/test_bug655254.js | 4 +- .../extensions/test/xpcshell/test_corrupt.js | 6 +- .../xpcshell/test_corrupt_strictcompat.js | 6 +- .../test/xpcshell/test_delay_update.js | 12 +- .../test/xpcshell/test_dictionary.js | 8 +- .../extensions/test/xpcshell/test_locked.js | 6 +- .../test/xpcshell/test_locked_strictcompat.js | 6 +- .../test/xpcshell/test_signed_install.js | 30 +- .../extensions/test/xpcshell/test_update.js | 2225 ++++++++--------- .../test/xpcshell/test_updateCancel.js | 8 +- .../test/xpcshell/test_update_compatmode.js | 14 +- .../test/xpcshell/test_update_ignorecompat.js | 143 +- .../test/xpcshell/test_update_strictcompat.js | 1911 +++++++------- .../test/xpcshell/test_updatecheck.js | 264 +- 62 files changed, 3015 insertions(+), 3364 deletions(-) create mode 100644 toolkit/mozapps/extensions/test/browser/browser_updatessl.json rename toolkit/mozapps/extensions/test/browser/{browser_updatessl.rdf^headers^ => browser_updatessl.json^headers^} (100%) delete mode 100644 toolkit/mozapps/extensions/test/browser/browser_updatessl.rdf create mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update1.json delete mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update1.rdf create mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update2.json delete mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update2.rdf create mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update3.json delete mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update3.rdf create mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/test_backgroundupdate.json delete mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/test_backgroundupdate.rdf create mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_1.json delete mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_1.rdf create mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_2.json delete mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_2.rdf create mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_3.json delete mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_3.rdf create mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_4.json delete mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_4.rdf create mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_5.json delete mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_5.rdf create mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/test_bug655254.json delete mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/test_bug655254.rdf create mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/test_corrupt.json delete mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/test_corrupt.rdf delete mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_complete.rdf create mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_complete_legacy.json delete mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_defer.rdf create mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_defer_legacy.json delete mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_ignore.rdf create mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_ignore_legacy.json create mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/test_dictionary.json delete mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/test_dictionary.rdf create mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_ignore.json delete mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_ignore.rdf create mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_normal.json delete mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_normal.rdf create mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_strict.json delete mode 100644 toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_strict.rdf diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_privacy_update.js b/toolkit/components/extensions/test/xpcshell/test_ext_privacy_update.js index f1002e9efa70..5f9563f60da9 100644 --- a/toolkit/components/extensions/test/xpcshell/test_ext_privacy_update.js +++ b/toolkit/components/extensions/test/xpcshell/test_ext_privacy_update.js @@ -26,7 +26,7 @@ AddonTestUtils.init(this); // Allow for unsigned addons. AddonTestUtils.overrideCertDB(); -createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "42"); +createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "42", "42"); add_task(async function test_privacy_update() { // Create a object to hold the values to which we will initialize the prefs. diff --git a/toolkit/mozapps/extensions/test/browser/browser.ini b/toolkit/mozapps/extensions/test/browser/browser.ini index 15cee4fc6198..93658285c72c 100644 --- a/toolkit/mozapps/extensions/test/browser/browser.ini +++ b/toolkit/mozapps/extensions/test/browser/browser.ini @@ -15,8 +15,8 @@ support-files = releaseNotes.xhtml blockNoPlugins.xml blockPluginHard.xml - browser_updatessl.rdf - browser_updatessl.rdf^headers^ + browser_updatessl.json + browser_updatessl.json^headers^ browser_install.rdf browser_install.rdf^headers^ browser_install1_3.xpi diff --git a/toolkit/mozapps/extensions/test/browser/browser_install.rdf b/toolkit/mozapps/extensions/test/browser/browser_install.rdf index 437bf9b85e3f..7d7a10b5a3cf 100644 --- a/toolkit/mozapps/extensions/test/browser/browser_install.rdf +++ b/toolkit/mozapps/extensions/test/browser/browser_install.rdf @@ -1,27 +1,19 @@ - - - - - - - -
  • - - 2.0 - - - toolkit@mozilla.org - 0 - * - https://example.com/browser/toolkit/mozapps/extensions/test/browser/browser_install1_3.xpi - sha1:4f0f4391914e3e036beca50cbac33958e5269643 - - - -
  • -
    -
    -
    - -
    +{ + "addons": { + "install1@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "0", + "advisory_max_version": "*" + } + }, + "version": "2.0", + "update_link": "https://example.com/browser/toolkit/mozapps/extensions/test/browser/browser_install1_3.xpi", + "update_hash": "sha1:4f0f4391914e3e036beca50cbac33958e5269643" + } + ] + } + } +} diff --git a/toolkit/mozapps/extensions/test/browser/browser_updatessl.js b/toolkit/mozapps/extensions/test/browser/browser_updatessl.js index fcaf64562d36..4b2ed9905105 100644 --- a/toolkit/mozapps/extensions/test/browser/browser_updatessl.js +++ b/toolkit/mozapps/extensions/test/browser/browser_updatessl.js @@ -6,7 +6,7 @@ var tempScope = {}; ChromeUtils.import("resource://gre/modules/addons/AddonUpdateChecker.jsm", tempScope); var AddonUpdateChecker = tempScope.AddonUpdateChecker; -const updaterdf = RELATIVE_DIR + "browser_updatessl.rdf"; +const updatejson = RELATIVE_DIR + "browser_updatessl.json"; const redirect = RELATIVE_DIR + "redirect.sjs?"; const SUCCESS = 0; const DOWNLOAD_ERROR = AddonManager.ERROR_DOWNLOAD_ERROR; @@ -78,11 +78,11 @@ function run_update_tests(callback) { let [mainURL, redirectURL, expectedStatus] = gTests.shift(); if (redirectURL) { - var url = mainURL + redirect + redirectURL + updaterdf; + var url = mainURL + redirect + redirectURL + updatejson; var message = "Should have seen the right result for an update check redirected from " + mainURL + " to " + redirectURL; } else { - url = mainURL + updaterdf; + url = mainURL + updatejson; message = "Should have seen the right result for an update check from " + mainURL; } @@ -116,7 +116,7 @@ function addCertOverrides() { // Runs tests with built-in certificates required and no certificate exceptions. add_test(function() { - // Tests that a simple update.rdf retrieval works as expected. + // Tests that a simple update.json retrieval works as expected. add_update_test(HTTP, null, SUCCESS); add_update_test(HTTPS, null, DOWNLOAD_ERROR); add_update_test(NOCERT, null, DOWNLOAD_ERROR); @@ -180,7 +180,7 @@ add_test(function() { add_test(function() { Services.prefs.setBoolPref(PREF_UPDATE_REQUIREBUILTINCERTS, false); - // Tests that a simple update.rdf retrieval works as expected. + // Tests that a simple update.json retrieval works as expected. add_update_test(HTTP, null, SUCCESS); add_update_test(HTTPS, null, SUCCESS); add_update_test(NOCERT, null, DOWNLOAD_ERROR); @@ -244,7 +244,7 @@ add_test(function() { Services.prefs.clearUserPref(PREF_UPDATE_REQUIREBUILTINCERTS); addCertOverrides(); - // Tests that a simple update.rdf retrieval works as expected. + // Tests that a simple update.json retrieval works as expected. add_update_test(HTTP, null, SUCCESS); add_update_test(HTTPS, null, DOWNLOAD_ERROR); add_update_test(NOCERT, null, DOWNLOAD_ERROR); @@ -308,7 +308,7 @@ add_test(function() { add_test(function() { Services.prefs.setBoolPref(PREF_UPDATE_REQUIREBUILTINCERTS, false); - // Tests that a simple update.rdf retrieval works as expected. + // Tests that a simple update.json retrieval works as expected. add_update_test(HTTP, null, SUCCESS); add_update_test(HTTPS, null, SUCCESS); add_update_test(NOCERT, null, SUCCESS); diff --git a/toolkit/mozapps/extensions/test/browser/browser_updatessl.json b/toolkit/mozapps/extensions/test/browser/browser_updatessl.json new file mode 100644 index 000000000000..223d1ef2d3ea --- /dev/null +++ b/toolkit/mozapps/extensions/test/browser/browser_updatessl.json @@ -0,0 +1,17 @@ +{ + "addons": { + "addon1@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "0", + "advisory_max_version": "20" + } + }, + "version": "2.0" + } + ] + } + } +} diff --git a/toolkit/mozapps/extensions/test/browser/browser_updatessl.rdf^headers^ b/toolkit/mozapps/extensions/test/browser/browser_updatessl.json^headers^ similarity index 100% rename from toolkit/mozapps/extensions/test/browser/browser_updatessl.rdf^headers^ rename to toolkit/mozapps/extensions/test/browser/browser_updatessl.json^headers^ diff --git a/toolkit/mozapps/extensions/test/browser/browser_updatessl.rdf b/toolkit/mozapps/extensions/test/browser/browser_updatessl.rdf deleted file mode 100644 index f24573847df8..000000000000 --- a/toolkit/mozapps/extensions/test/browser/browser_updatessl.rdf +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - -
  • - - 2.0 - - - toolkit@mozilla.org - 0 - 20 - - - -
  • -
    -
    -
    - -
    diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update1.json b/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update1.json new file mode 100644 index 000000000000..ddcb4fc7bab3 --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update1.json @@ -0,0 +1,102 @@ +{ + "addons": { + "softblock1@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "0", + "advisory_max_version": "*" + } + }, + "version": "2", + "update_link": "http://localhost:%PORT%/addons/blocklist_soft1_2.xpi" + } + ] + }, + "softblock3@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "0", + "advisory_max_version": "*" + } + }, + "version": "2", + "update_link": "http://localhost:%PORT%/addons/blocklist_soft3_2.xpi" + } + ] + }, + "softblock5@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "0", + "advisory_max_version": "*" + } + }, + "version": "2", + "update_link": "http://localhost:%PORT%/addons/blocklist_soft5_2.xpi" + } + ] + }, + "softblock4@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "0", + "advisory_max_version": "*" + } + }, + "version": "2", + "update_link": "http://localhost:%PORT%/addons/blocklist_soft4_2.xpi" + } + ] + }, + "softblock2@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "0", + "advisory_max_version": "*" + } + }, + "version": "2", + "update_link": "http://localhost:%PORT%/addons/blocklist_soft2_2.xpi" + } + ] + }, + "regexpblock@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "0", + "advisory_max_version": "*" + } + }, + "version": "2", + "update_link": "http://localhost:%PORT%/addons/blocklist_regexp1_2.xpi" + } + ] + }, + "hardblock@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "0", + "advisory_max_version": "*" + } + }, + "version": "2", + "update_link": "http://localhost:%PORT%/addons/blocklist_hard1_2.xpi" + } + ] + } + } +} diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update1.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update1.rdf deleted file mode 100644 index 5882909684f8..000000000000 --- a/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update1.rdf +++ /dev/null @@ -1,144 +0,0 @@ - - - - - - - - - 2 - - - toolkit@mozilla.org - 0 - * - http://localhost:%PORT%/addons/blocklist_soft1_2.xpi - - - - - - - - - - - - - - 2 - - - toolkit@mozilla.org - 0 - * - http://localhost:%PORT%/addons/blocklist_soft2_2.xpi - - - - - - - - - - - - - - 2 - - - toolkit@mozilla.org - 0 - * - http://localhost:%PORT%/addons/blocklist_soft3_2.xpi - - - - - - - - - - - - - - 2 - - - toolkit@mozilla.org - 0 - * - http://localhost:%PORT%/addons/blocklist_soft4_2.xpi - - - - - - - - - - - - - - 2 - - - toolkit@mozilla.org - 0 - * - http://localhost:%PORT%/addons/blocklist_soft5_2.xpi - - - - - - - - - - - - - - 2 - - - toolkit@mozilla.org - 0 - * - http://localhost:%PORT%/addons/blocklist_hard1_2.xpi - - - - - - - - - - - - - - 2 - - - toolkit@mozilla.org - 0 - * - http://localhost:%PORT%/addons/blocklist_regexp1_2.xpi - - - - - - - - diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update2.json b/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update2.json new file mode 100644 index 000000000000..4d3748e77a6e --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update2.json @@ -0,0 +1,102 @@ +{ + "addons": { + "softblock1@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "0", + "advisory_max_version": "*" + } + }, + "version": "3", + "update_link": "http://localhost:%PORT%/addons/blocklist_soft1_3.xpi" + } + ] + }, + "softblock3@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "0", + "advisory_max_version": "*" + } + }, + "version": "3", + "update_link": "http://localhost:%PORT%/addons/blocklist_soft3_3.xpi" + } + ] + }, + "regexpblock@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "0", + "advisory_max_version": "*" + } + }, + "version": "3", + "update_link": "http://localhost:%PORT%/addons/blocklist_regexp1_3.xpi" + } + ] + }, + "hardblock@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "0", + "advisory_max_version": "*" + } + }, + "version": "3", + "update_link": "http://localhost:%PORT%/addons/blocklist_hard1_3.xpi" + } + ] + }, + "softblock5@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "0", + "advisory_max_version": "*" + } + }, + "version": "3", + "update_link": "http://localhost:%PORT%/addons/blocklist_soft5_3.xpi" + } + ] + }, + "softblock4@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "0", + "advisory_max_version": "*" + } + }, + "version": "3", + "update_link": "http://localhost:%PORT%/addons/blocklist_soft4_3.xpi" + } + ] + }, + "softblock2@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "0", + "advisory_max_version": "*" + } + }, + "version": "3", + "update_link": "http://localhost:%PORT%/addons/blocklist_soft2_3.xpi" + } + ] + } + } +} diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update2.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update2.rdf deleted file mode 100644 index 5c3747f5f48b..000000000000 --- a/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update2.rdf +++ /dev/null @@ -1,144 +0,0 @@ - - - - - - - - - 3 - - - toolkit@mozilla.org - 0 - * - http://localhost:%PORT%/addons/blocklist_soft1_3.xpi - - - - - - - - - - - - - - 3 - - - toolkit@mozilla.org - 0 - * - http://localhost:%PORT%/addons/blocklist_soft2_3.xpi - - - - - - - - - - - - - - 3 - - - toolkit@mozilla.org - 0 - * - http://localhost:%PORT%/addons/blocklist_soft3_3.xpi - - - - - - - - - - - - - - 3 - - - toolkit@mozilla.org - 0 - * - http://localhost:%PORT%/addons/blocklist_soft4_3.xpi - - - - - - - - - - - - - - 3 - - - toolkit@mozilla.org - 0 - * - http://localhost:%PORT%/addons/blocklist_soft5_3.xpi - - - - - - - - - - - - - - 3 - - - toolkit@mozilla.org - 0 - * - http://localhost:%PORT%/addons/blocklist_hard1_3.xpi - - - - - - - - - - - - - - 3 - - - toolkit@mozilla.org - 0 - * - http://localhost:%PORT%/addons/blocklist_regexp1_3.xpi - - - - - - - - diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update3.json b/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update3.json new file mode 100644 index 000000000000..97313ef26288 --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update3.json @@ -0,0 +1,102 @@ +{ + "addons": { + "regexpblock@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "0", + "advisory_max_version": "*" + } + }, + "version": "4", + "update_link": "http://localhost:%PORT%/addons/blocklist_regexp1_1.xpi" + } + ] + }, + "hardblock@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "0", + "advisory_max_version": "*" + } + }, + "version": "4", + "update_link": "http://localhost:%PORT%/addons/blocklist_hard1_1.xpi" + } + ] + }, + "softblock5@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "0", + "advisory_max_version": "*" + } + }, + "version": "4", + "update_link": "http://localhost:%PORT%/addons/blocklist_soft5_1.xpi" + } + ] + }, + "softblock4@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "0", + "advisory_max_version": "*" + } + }, + "version": "4", + "update_link": "http://localhost:%PORT%/addons/blocklist_soft4_1.xpi" + } + ] + }, + "softblock3@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "0", + "advisory_max_version": "*" + } + }, + "version": "4", + "update_link": "http://localhost:%PORT%/addons/blocklist_soft3_1.xpi" + } + ] + }, + "softblock2@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "0", + "advisory_max_version": "*" + } + }, + "version": "4", + "update_link": "http://localhost:%PORT%/addons/blocklist_soft2_1.xpi" + } + ] + }, + "softblock1@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "0", + "advisory_max_version": "*" + } + }, + "version": "4", + "update_link": "http://localhost:%PORT%/addons/blocklist_soft1_1.xpi" + } + ] + } + } +} diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update3.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update3.rdf deleted file mode 100644 index d6070841423c..000000000000 --- a/toolkit/mozapps/extensions/test/xpcshell/data/blocklistchange/addon_update3.rdf +++ /dev/null @@ -1,144 +0,0 @@ - - - - - - - - - 4 - - - toolkit@mozilla.org - 0 - * - http://localhost:%PORT%/addons/blocklist_soft1_1.xpi - - - - - - - - - - - - - - 4 - - - toolkit@mozilla.org - 0 - * - http://localhost:%PORT%/addons/blocklist_soft2_1.xpi - - - - - - - - - - - - - - 4 - - - toolkit@mozilla.org - 0 - * - http://localhost:%PORT%/addons/blocklist_soft3_1.xpi - - - - - - - - - - - - - - 4 - - - toolkit@mozilla.org - 0 - * - http://localhost:%PORT%/addons/blocklist_soft4_1.xpi - - - - - - - - - - - - - - 4 - - - toolkit@mozilla.org - 0 - * - http://localhost:%PORT%/addons/blocklist_soft5_1.xpi - - - - - - - - - - - - - - 4 - - - toolkit@mozilla.org - 0 - * - http://localhost:%PORT%/addons/blocklist_hard1_1.xpi - - - - - - - - - - - - - - 4 - - - toolkit@mozilla.org - 0 - * - http://localhost:%PORT%/addons/blocklist_regexp1_1.xpi - - - - - - - - diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_backgroundupdate.json b/toolkit/mozapps/extensions/test/xpcshell/data/test_backgroundupdate.json new file mode 100644 index 000000000000..02dd15a8c415 --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpcshell/data/test_backgroundupdate.json @@ -0,0 +1,46 @@ +{ + "addons": { + "addon2@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "1", + "advisory_max_version": "1" + } + }, + "version": "2", + "update_link": "http://localhost:%PORT%/broken.xpi" + } + ] + }, + "addon3@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "1", + "advisory_max_version": "1" + } + }, + "version": "2", + "update_link": "http://localhost:%PORT%/broken.xpi" + } + ] + }, + "addon1@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "1", + "advisory_max_version": "1" + } + }, + "version": "2", + "update_link": "http://localhost:%PORT%/broken.xpi" + } + ] + } + } +} diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_backgroundupdate.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/test_backgroundupdate.rdf deleted file mode 100644 index ab7cdef3409e..000000000000 --- a/toolkit/mozapps/extensions/test/xpcshell/data/test_backgroundupdate.rdf +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - 2 - - - xpcshell@tests.mozilla.org - 1 - 1 - http://localhost:%PORT%/broken.xpi - - - - - - - - - - - - - - - 2 - - - xpcshell@tests.mozilla.org - 1 - 1 - http://localhost:%PORT%/broken.xpi - - - - - - - - - - - - - - - 2 - - - xpcshell@tests.mozilla.org - 1 - 1 - http://localhost:%PORT%/broken.xpi - - - - - - - - - - diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_1.json b/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_1.json new file mode 100644 index 000000000000..c7335c562ca5 --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_1.json @@ -0,0 +1,18 @@ +{ + "addons": { + "test_bug470377_1@tests.mozilla.org": { + "updates": [ + { + "applications": { + "unknown@tests.mozilla.org": { + "strict_min_version": "1", + "advisory_max_version": "2" + } + }, + "version": "1", + "update_link": "http://localhost:%PORT%/broken.xpi" + } + ] + } + } +} diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_1.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_1.rdf deleted file mode 100644 index e4ad91ae9f30..000000000000 --- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_1.rdf +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - 1 - - - unknown@tests.mozilla.org - 1 - 2 - http://localhost:%PORT%/broken.xpi - - - - - - - - - diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_2.json b/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_2.json new file mode 100644 index 000000000000..d9766532a466 --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_2.json @@ -0,0 +1,18 @@ +{ + "addons": { + "test_bug470377_2@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "1", + "advisory_max_version": "1" + } + }, + "version": "1", + "update_link": "http://localhost:%PORT%/broken.xpi" + } + ] + } + } +} diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_2.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_2.rdf deleted file mode 100644 index 10fcafd391f2..000000000000 --- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_2.rdf +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - 1 - - - toolkit@mozilla.org - 1 - 1 - http://localhost:%PORT%/broken.xpi - - - - - - - - - diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_3.json b/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_3.json new file mode 100644 index 000000000000..4ecbb1639d24 --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_3.json @@ -0,0 +1,18 @@ +{ + "addons": { + "test_bug470377_3@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "1", + "advisory_max_version": "1" + } + }, + "version": "1", + "update_link": "http://localhost:%PORT%/broken.xpi" + } + ] + } + } +} diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_3.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_3.rdf deleted file mode 100644 index 6840024622d9..000000000000 --- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_3.rdf +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - 1 - - - xpcshell@tests.mozilla.org - 1 - 1 - http://localhost:%PORT%/broken.xpi - - - - - - - - - diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_4.json b/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_4.json new file mode 100644 index 000000000000..7698b302ae9d --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_4.json @@ -0,0 +1,18 @@ +{ + "addons": { + "test_bug470377_4@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "1", + "advisory_max_version": "2" + } + }, + "version": "1", + "update_link": "http://localhost:%PORT%/broken.xpi" + } + ] + } + } +} diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_4.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_4.rdf deleted file mode 100644 index 6e71162397b2..000000000000 --- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_4.rdf +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - 1 - - - toolkit@mozilla.org - 1 - 2 - http://localhost:%PORT%/broken.xpi - - - - - - - - - diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_5.json b/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_5.json new file mode 100644 index 000000000000..4fcc32fbbcc8 --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_5.json @@ -0,0 +1,18 @@ +{ + "addons": { + "test_bug470377_5@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "1", + "advisory_max_version": "3" + } + }, + "version": "1", + "update_link": "http://localhost:%PORT%/broken.xpi" + } + ] + } + } +} diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_5.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_5.rdf deleted file mode 100644 index c926af934ff9..000000000000 --- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug470377/update_5.rdf +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - 1 - - - xpcshell@tests.mozilla.org - 1 - 3 - http://localhost:%PORT%/broken.xpi - - - - - - - - - diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug655254.json b/toolkit/mozapps/extensions/test/xpcshell/data/test_bug655254.json new file mode 100644 index 000000000000..3b1dd81dabf6 --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpcshell/data/test_bug655254.json @@ -0,0 +1,17 @@ +{ + "addons": { + "addon1@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "1", + "advisory_max_version": "2" + } + }, + "version": "1" + } + ] + } + } +} diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug655254.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/test_bug655254.rdf deleted file mode 100644 index 9857dcb5555a..000000000000 --- a/toolkit/mozapps/extensions/test/xpcshell/data/test_bug655254.rdf +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - 1 - - - xpcshell@tests.mozilla.org - 1 - 2 - - - - - - - - - - diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_corrupt.json b/toolkit/mozapps/extensions/test/xpcshell/data/test_corrupt.json new file mode 100644 index 000000000000..7cb48d4798fc --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpcshell/data/test_corrupt.json @@ -0,0 +1,30 @@ +{ + "addons": { + "addon3@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "1", + "advisory_max_version": "2" + } + }, + "version": "1.0" + } + ] + }, + "addon4@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "1", + "advisory_max_version": "2" + } + }, + "version": "1.0" + } + ] + } + } +} diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_corrupt.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/test_corrupt.rdf deleted file mode 100644 index f3341bdcfb64..000000000000 --- a/toolkit/mozapps/extensions/test/xpcshell/data/test_corrupt.rdf +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - -
  • - - 1.0 - - - xpcshell@tests.mozilla.org - 1 - 2 - - - -
  • -
    -
    -
    - - - - -
  • - - 1.0 - - - xpcshell@tests.mozilla.org - 1 - 2 - - - -
  • -
    -
    -
    - -
    diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_complete.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_complete.rdf deleted file mode 100644 index 8af39cb0e72d..000000000000 --- a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_complete.rdf +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - -
  • - - 2.0 - - - xpcshell@tests.mozilla.org - 1 - 1 - http://localhost:%PORT%/addons/test_delay_update_complete_v2.xpi - - - -
  • -
    -
    -
    -
    diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_complete_legacy.json b/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_complete_legacy.json new file mode 100644 index 000000000000..12e7718bffbe --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_complete_legacy.json @@ -0,0 +1,18 @@ +{ + "addons": { + "test_delay_update_complete@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "1", + "advisory_max_version": "1" + } + }, + "version": "2.0", + "update_link": "http://localhost:%PORT%/addons/test_delay_update_complete_v2.xpi" + } + ] + } + } +} diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_defer.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_defer.rdf deleted file mode 100644 index d44d4880f11f..000000000000 --- a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_defer.rdf +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - -
  • - - 2.0 - - - xpcshell@tests.mozilla.org - 1 - 1 - http://localhost:%PORT%/addons/test_delay_update_defer_v2.xpi - - - -
  • -
    -
    -
    -
    diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_defer_legacy.json b/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_defer_legacy.json new file mode 100644 index 000000000000..9ec87f17c5fc --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_defer_legacy.json @@ -0,0 +1,18 @@ +{ + "addons": { + "test_delay_update_defer@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "1", + "advisory_max_version": "1" + } + }, + "version": "2.0", + "update_link": "http://localhost:%PORT%/addons/test_delay_update_defer_v2.xpi" + } + ] + } + } +} diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_ignore.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_ignore.rdf deleted file mode 100644 index 866884f8d510..000000000000 --- a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_ignore.rdf +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - -
  • - - 2.0 - - - xpcshell@tests.mozilla.org - 1 - 1 - http://localhost:%PORT%/addons/test_delay_update_ignore_v2.xpi - - - -
  • -
    -
    -
    -
    diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_ignore_legacy.json b/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_ignore_legacy.json new file mode 100644 index 000000000000..d8b09d005a5c --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_ignore_legacy.json @@ -0,0 +1,18 @@ +{ + "addons": { + "test_delay_update_ignore@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "1", + "advisory_max_version": "1" + } + }, + "version": "2.0", + "update_link": "http://localhost:%PORT%/addons/test_delay_update_ignore_v2.xpi" + } + ] + } + } +} diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_dictionary.json b/toolkit/mozapps/extensions/test/xpcshell/data/test_dictionary.json new file mode 100644 index 000000000000..c450fd9b1f71 --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpcshell/data/test_dictionary.json @@ -0,0 +1,46 @@ +{ + "addons": { + "ab-CD@dictionaries.addons.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "1", + "advisory_max_version": "1" + } + }, + "version": "2.0", + "update_link": "http://localhost:%PORT%/addons/test_dictionary_3.xpi" + } + ] + }, + "gh@dictionaries.addons.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "1", + "advisory_max_version": "1" + } + }, + "version": "2.0", + "update_link": "http://localhost:%PORT%/addons/test_dictionary_5.xpi" + } + ] + }, + "ef@dictionaries.addons.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "1", + "advisory_max_version": "1" + } + }, + "version": "2.0", + "update_link": "http://localhost:%PORT%/addons/test_dictionary_4.xpi" + } + ] + } + } +} diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_dictionary.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/test_dictionary.rdf deleted file mode 100644 index 364b3bba1acb..000000000000 --- a/toolkit/mozapps/extensions/test/xpcshell/data/test_dictionary.rdf +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - -
  • - - 2.0 - - - xpcshell@tests.mozilla.org - 1 - 1 - http://localhost:%PORT%/addons/test_dictionary_3.xpi - - - -
  • -
    -
    -
    - - - - -
  • - - 2.0 - - - xpcshell@tests.mozilla.org - 1 - 1 - http://localhost:%PORT%/addons/test_dictionary_4.xpi - - - -
  • -
    -
    -
    - - - - -
  • - - 2.0 - - - xpcshell@tests.mozilla.org - 1 - 1 - http://localhost:%PORT%/addons/test_dictionary_5.xpi - - - -
  • -
    -
    -
    -
    diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_ignore.json b/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_ignore.json new file mode 100644 index 000000000000..c9fadac7cb3f --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_ignore.json @@ -0,0 +1,18 @@ +{ + "addons": { + "compatmode-ignore@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "1", + "advisory_max_version": "2" + } + }, + "version": "2.0", + "update_link": "https://localhost:%PORT%/addons/test1.xpi" + } + ] + } + } +} diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_ignore.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_ignore.rdf deleted file mode 100644 index ec6e88ec485a..000000000000 --- a/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_ignore.rdf +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - -
  • - - 2.0 - - - xpcshell@tests.mozilla.org - 1 - 2 - https://localhost:%PORT%/addons/test1.xpi - - - -
  • -
    -
    -
    -
    diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_normal.json b/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_normal.json new file mode 100644 index 000000000000..ab54ad093fa8 --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_normal.json @@ -0,0 +1,18 @@ +{ + "addons": { + "compatmode-normal@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "1", + "advisory_max_version": "2" + } + }, + "version": "2.0", + "update_link": "https://localhost:%PORT%/addons/test1.xpi" + } + ] + } + } +} diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_normal.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_normal.rdf deleted file mode 100644 index 2ef88860ec97..000000000000 --- a/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_normal.rdf +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - -
  • - - 2.0 - - - xpcshell@tests.mozilla.org - 1 - 2 - https://localhost:%PORT%/addons/test1.xpi - - - -
  • -
    -
    -
    -
    diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_strict.json b/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_strict.json new file mode 100644 index 000000000000..d4c4df513ab5 --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_strict.json @@ -0,0 +1,18 @@ +{ + "addons": { + "compatmode-strict@tests.mozilla.org": { + "updates": [ + { + "applications": { + "gecko": { + "strict_min_version": "1", + "advisory_max_version": "2" + } + }, + "version": "2.0", + "update_link": "https://localhost:%PORT%/addons/test1.xpi" + } + ] + } + } +} diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_strict.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_strict.rdf deleted file mode 100644 index 2f72c181d9e0..000000000000 --- a/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecompatmode_strict.rdf +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - -
  • - - 2.0 - - - xpcshell@tests.mozilla.org - 1 - 2 - https://localhost:%PORT%/addons/test1.xpi - - - -
  • -
    -
    -
    -
    diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_backgroundupdate.js b/toolkit/mozapps/extensions/test/xpcshell/test_backgroundupdate.js index 9c2a6eefbcb5..b1e19a37bfc9 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_backgroundupdate.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_backgroundupdate.js @@ -15,7 +15,7 @@ const profileDir = gProfD.clone(); profileDir.append("extensions"); // register static files with server and interpolate port numbers in them -mapFile("/data/test_backgroundupdate.rdf", testserver); +mapFile("/data/test_backgroundupdate.json", testserver); function run_test() { createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2"); @@ -55,7 +55,7 @@ function run_test_2() { writeInstallRDFForExtension({ id: "addon1@tests.mozilla.org", version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/test_backgroundupdate.rdf", + updateURL: "http://localhost:" + gPort + "/data/test_backgroundupdate.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", @@ -67,7 +67,7 @@ function run_test_2() { writeInstallRDFForExtension({ id: "addon2@tests.mozilla.org", version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/test_backgroundupdate.rdf", + updateURL: "http://localhost:" + gPort + "/data/test_backgroundupdate.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", @@ -92,7 +92,7 @@ function run_test_2() { // Background update uses a different pref, if set Services.prefs.setCharPref("extensions.update.background.url", - "http://localhost:" + gPort + "/data/test_backgroundupdate.rdf"); + "http://localhost:" + gPort + "/data/test_backgroundupdate.json"); restartManager(); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_badschema.js b/toolkit/mozapps/extensions/test/xpcshell/test_badschema.js index 90cb1412a153..dc5ecd43cee4 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_badschema.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_badschema.js @@ -11,7 +11,7 @@ testserver.start(-1); gPort = testserver.identity.primaryPort; // register static files with server and interpolate port numbers in them -mapFile("/data/test_corrupt.rdf", testserver); +mapFile("/data/test_corrupt.json", testserver); // The test extension uses an insecure update url. Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false); @@ -45,7 +45,7 @@ var addon3 = { id: "addon3@tests.mozilla.org", version: "1.0", name: "Test 3", - updateURL: "http://localhost:" + gPort + "/data/test_corrupt.rdf", + updateURL: "http://localhost:" + gPort + "/data/test_corrupt.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", @@ -58,7 +58,7 @@ var addon4 = { id: "addon4@tests.mozilla.org", version: "1.0", name: "Test 4", - updateURL: "http://localhost:" + gPort + "/data/test_corrupt.rdf", + updateURL: "http://localhost:" + gPort + "/data/test_corrupt.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_blocklistchange.js b/toolkit/mozapps/extensions/test/xpcshell/test_blocklistchange.js index d694ad5bac30..e1e0f1750f5a 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_blocklistchange.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_blocklistchange.js @@ -35,9 +35,9 @@ var testserver = createHttpServer(); gPort = testserver.identity.primaryPort; // register static files with server and interpolate port numbers in them -mapFile("/data/blocklistchange/addon_update1.rdf", testserver); -mapFile("/data/blocklistchange/addon_update2.rdf", testserver); -mapFile("/data/blocklistchange/addon_update3.rdf", testserver); +mapFile("/data/blocklistchange/addon_update1.json", testserver); +mapFile("/data/blocklistchange/addon_update2.json", testserver); +mapFile("/data/blocklistchange/addon_update3.json", testserver); mapFile("/data/blocklistchange/addon_change.xml", testserver); mapFile("/data/blocklistchange/app_update.xml", testserver); mapFile("/data/blocklistchange/blocklist_update1.xml", testserver); @@ -51,7 +51,7 @@ var softblock1_1 = { id: "softblock1@tests.mozilla.org", version: "1.0", name: "Softblocked add-on", - updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update1.rdf", + updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update1.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", @@ -63,7 +63,7 @@ var softblock1_2 = { id: "softblock1@tests.mozilla.org", version: "2.0", name: "Softblocked add-on", - updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update2.rdf", + updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update2.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", @@ -75,7 +75,7 @@ var softblock1_3 = { id: "softblock1@tests.mozilla.org", version: "3.0", name: "Softblocked add-on", - updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update3.rdf", + updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update3.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", @@ -87,7 +87,7 @@ var softblock2_1 = { id: "softblock2@tests.mozilla.org", version: "1.0", name: "Softblocked add-on", - updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update1.rdf", + updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update1.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", @@ -99,7 +99,7 @@ var softblock2_2 = { id: "softblock2@tests.mozilla.org", version: "2.0", name: "Softblocked add-on", - updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update2.rdf", + updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update2.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", @@ -111,7 +111,7 @@ var softblock2_3 = { id: "softblock2@tests.mozilla.org", version: "3.0", name: "Softblocked add-on", - updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update3.rdf", + updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update3.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", @@ -123,7 +123,7 @@ var softblock3_1 = { id: "softblock3@tests.mozilla.org", version: "1.0", name: "Softblocked add-on", - updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update1.rdf", + updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update1.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", @@ -135,7 +135,7 @@ var softblock3_2 = { id: "softblock3@tests.mozilla.org", version: "2.0", name: "Softblocked add-on", - updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update2.rdf", + updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update2.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", @@ -147,7 +147,7 @@ var softblock3_3 = { id: "softblock3@tests.mozilla.org", version: "3.0", name: "Softblocked add-on", - updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update3.rdf", + updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update3.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", @@ -159,7 +159,7 @@ var softblock4_1 = { id: "softblock4@tests.mozilla.org", version: "1.0", name: "Softblocked add-on", - updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update1.rdf", + updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update1.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", @@ -171,7 +171,7 @@ var softblock4_2 = { id: "softblock4@tests.mozilla.org", version: "2.0", name: "Softblocked add-on", - updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update2.rdf", + updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update2.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", @@ -183,7 +183,7 @@ var softblock4_3 = { id: "softblock4@tests.mozilla.org", version: "3.0", name: "Softblocked add-on", - updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update3.rdf", + updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update3.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", @@ -195,7 +195,7 @@ var hardblock_1 = { id: "hardblock@tests.mozilla.org", version: "1.0", name: "Hardblocked add-on", - updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update1.rdf", + updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update1.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", @@ -207,7 +207,7 @@ var hardblock_2 = { id: "hardblock@tests.mozilla.org", version: "2.0", name: "Hardblocked add-on", - updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update2.rdf", + updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update2.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", @@ -219,7 +219,7 @@ var hardblock_3 = { id: "hardblock@tests.mozilla.org", version: "3.0", name: "Hardblocked add-on", - updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update3.rdf", + updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update3.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", @@ -231,7 +231,7 @@ var regexpblock_1 = { id: "regexpblock@tests.mozilla.org", version: "1.0", name: "RegExp-blocked add-on", - updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update1.rdf", + updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update1.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", @@ -243,7 +243,7 @@ var regexpblock_2 = { id: "regexpblock@tests.mozilla.org", version: "2.0", name: "RegExp-blocked add-on", - updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update2.rdf", + updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update2.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", @@ -255,7 +255,7 @@ var regexpblock_3 = { id: "regexpblock@tests.mozilla.org", version: "3.0", name: "RegExp-blocked add-on", - updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update3.rdf", + updateURL: "http://localhost:" + gPort + "/data/blocklistchange/addon_update3.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug384052.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug384052.js index 84cbd6918185..3012809e55cc 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_bug384052.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug384052.js @@ -7,7 +7,7 @@ var testserver = new HttpServer(); testserver.start(-1); gPort = testserver.identity.primaryPort; -var gTestURL = "http://127.0.0.1:" + gPort + "/update.rdf?itemID=%ITEM_ID%&custom1=%CUSTOM1%&custom2=%CUSTOM2%"; +var gTestURL = "http://127.0.0.1:" + gPort + "/update.json?itemID=%ITEM_ID%&custom1=%CUSTOM1%&custom2=%CUSTOM2%"; var gExpectedQuery = "itemID=test@mozilla.org&custom1=custom_parameter_1&custom2=custom_parameter_2"; var gSeenExpectedURL = false; @@ -38,7 +38,7 @@ function initTest() { createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9"); // Configure the HTTP server. - testserver.registerPathHandler("/update.rdf", function(aRequest, aResponse) { + testserver.registerPathHandler("/update.json", function(aRequest, aResponse) { gSeenExpectedURL = aRequest.queryString == gExpectedQuery; aResponse.setStatusLine(null, 404, "Not Found"); }); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug559800.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug559800.js index 406d4effe991..4fbd496d94e3 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_bug559800.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug559800.js @@ -20,7 +20,7 @@ function run_test() { writeInstallRDFForExtension({ id: "addon1@tests.mozilla.org", version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/test_update.rdf", + updateURL: "http://localhost:" + gPort + "/data/test_update.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug655254.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug655254.js index 4a8cd242b6c9..45f824b3278c 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_bug655254.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug655254.js @@ -17,7 +17,7 @@ ChromeUtils.import("resource://testing-common/httpd.js"); var testserver = new HttpServer(); testserver.start(-1); gPort = testserver.identity.primaryPort; -mapFile("/data/test_bug655254.rdf", testserver); +mapFile("/data/test_bug655254.json", testserver); var userDir = gProfD.clone(); userDir.append("extensions2"); @@ -40,7 +40,7 @@ var addon1 = { id: "addon1@tests.mozilla.org", version: "1.0", name: "Test 1", - updateURL: "http://localhost:" + gPort + "/data/test_bug655254.rdf", + updateURL: "http://localhost:" + gPort + "/data/test_bug655254.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_corrupt.js b/toolkit/mozapps/extensions/test/xpcshell/test_corrupt.js index 8e8c2e0c52a5..667b314cba5e 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_corrupt.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_corrupt.js @@ -13,7 +13,7 @@ gPort = testserver.identity.primaryPort; // register files with server testserver.registerDirectory("/addons/", do_get_file("addons")); -mapFile("/data/test_corrupt.rdf", testserver); +mapFile("/data/test_corrupt.json", testserver); // The test extension uses an insecure update url. Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false); @@ -48,7 +48,7 @@ var addon3 = { id: "addon3@tests.mozilla.org", version: "1.0", name: "Test 3", - updateURL: "http://localhost:" + gPort + "/data/test_corrupt.rdf", + updateURL: "http://localhost:" + gPort + "/data/test_corrupt.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", @@ -61,7 +61,7 @@ var addon4 = { id: "addon4@tests.mozilla.org", version: "1.0", name: "Test 4", - updateURL: "http://localhost:" + gPort + "/data/test_corrupt.rdf", + updateURL: "http://localhost:" + gPort + "/data/test_corrupt.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_corrupt_strictcompat.js b/toolkit/mozapps/extensions/test/xpcshell/test_corrupt_strictcompat.js index 484b1b54a1db..1e11716162b7 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_corrupt_strictcompat.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_corrupt_strictcompat.js @@ -13,7 +13,7 @@ gPort = testserver.identity.primaryPort; // register files with server testserver.registerDirectory("/addons/", do_get_file("addons")); -mapFile("/data/test_corrupt.rdf", testserver); +mapFile("/data/test_corrupt.json", testserver); // The test extension uses an insecure update url. @@ -49,7 +49,7 @@ var addon3 = { id: "addon3@tests.mozilla.org", version: "1.0", name: "Test 3", - updateURL: "http://localhost:" + gPort + "/data/test_corrupt.rdf", + updateURL: "http://localhost:" + gPort + "/data/test_corrupt.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", @@ -62,7 +62,7 @@ var addon4 = { id: "addon4@tests.mozilla.org", version: "1.0", name: "Test 4", - updateURL: "http://localhost:" + gPort + "/data/test_corrupt.rdf", + updateURL: "http://localhost:" + gPort + "/data/test_corrupt.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_delay_update.js b/toolkit/mozapps/extensions/test/xpcshell/test_delay_update.js index cbf1c05b1c1a..5bd66bbac145 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_delay_update.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_delay_update.js @@ -26,9 +26,9 @@ createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "42"); // Create and configure the HTTP server. let testserver = createHttpServer(); gPort = testserver.identity.primaryPort; -mapFile("/data/test_delay_updates_complete.rdf", testserver); -mapFile("/data/test_delay_updates_ignore.rdf", testserver); -mapFile("/data/test_delay_updates_defer.rdf", testserver); +mapFile("/data/test_delay_updates_complete_legacy.json", testserver); +mapFile("/data/test_delay_updates_ignore_legacy.json", testserver); +mapFile("/data/test_delay_updates_defer_legacy.json", testserver); testserver.registerDirectory("/addons/", do_get_file("addons")); function createIgnoreAddon() { @@ -37,7 +37,7 @@ function createIgnoreAddon() { version: "1.0", bootstrap: true, unpack: true, - updateURL: `http://localhost:${gPort}/data/test_delay_updates_ignore.rdf`, + updateURL: `http://localhost:${gPort}/data/test_delay_updates_ignore_legacy.json`, targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", @@ -58,7 +58,7 @@ function createCompleteAddon() { version: "1.0", bootstrap: true, unpack: true, - updateURL: `http://localhost:${gPort}/data/test_delay_updates_complete.rdf`, + updateURL: `http://localhost:${gPort}/data/test_delay_updates_complete_legacy.json`, targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", @@ -79,7 +79,7 @@ function createDeferAddon() { version: "1.0", bootstrap: true, unpack: true, - updateURL: `http://localhost:${gPort}/data/test_delay_updates_defer.rdf`, + updateURL: `http://localhost:${gPort}/data/test_delay_updates_defer_legacy.json`, targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_dictionary.js b/toolkit/mozapps/extensions/test/xpcshell/test_dictionary.js index 2e613f0592ec..babe99a89b79 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_dictionary.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_dictionary.js @@ -29,7 +29,7 @@ gPort = testserver.identity.primaryPort; // register files with server testserver.registerDirectory("/addons/", do_get_file("addons")); -mapFile("/data/test_dictionary.rdf", testserver); +mapFile("/data/test_dictionary.json", testserver); /** * This object is both a factory and an mozISpellCheckingEngine implementation (so, it @@ -669,7 +669,7 @@ function run_test_27() { writeInstallRDFForExtension({ id: "ab-CD@dictionaries.addons.mozilla.org", version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/test_dictionary.rdf", + updateURL: "http://localhost:" + gPort + "/data/test_dictionary.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", @@ -715,7 +715,7 @@ function run_test_28() { id: "ef@dictionaries.addons.mozilla.org", version: "1.0", type: "64", - updateURL: "http://localhost:" + gPort + "/data/test_dictionary.rdf", + updateURL: "http://localhost:" + gPort + "/data/test_dictionary.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", @@ -761,7 +761,7 @@ function run_test_29() { id: "gh@dictionaries.addons.mozilla.org", version: "1.0", type: "64", - updateURL: "http://localhost:" + gPort + "/data/test_dictionary.rdf", + updateURL: "http://localhost:" + gPort + "/data/test_dictionary.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_locked.js b/toolkit/mozapps/extensions/test/xpcshell/test_locked.js index 936a7b9ee947..91d93d46dddd 100755 --- a/toolkit/mozapps/extensions/test/xpcshell/test_locked.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_locked.js @@ -10,7 +10,7 @@ ChromeUtils.import("resource://gre/modules/osfile.jsm"); var testserver = new HttpServer(); testserver.start(-1); gPort = testserver.identity.primaryPort; -mapFile("/data/test_corrupt.rdf", testserver); +mapFile("/data/test_corrupt.json", testserver); testserver.registerDirectory("/addons/", do_get_file("addons")); // The test extension uses an insecure update url. @@ -46,7 +46,7 @@ var addon3 = { id: "addon3@tests.mozilla.org", version: "1.0", name: "Test 3", - updateURL: "http://localhost:" + gPort + "/data/test_corrupt.rdf", + updateURL: "http://localhost:" + gPort + "/data/test_corrupt.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", @@ -59,7 +59,7 @@ var addon4 = { id: "addon4@tests.mozilla.org", version: "1.0", name: "Test 4", - updateURL: "http://localhost:" + gPort + "/data/test_corrupt.rdf", + updateURL: "http://localhost:" + gPort + "/data/test_corrupt.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_locked_strictcompat.js b/toolkit/mozapps/extensions/test/xpcshell/test_locked_strictcompat.js index 0818ccdc3443..471f2593502e 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_locked_strictcompat.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_locked_strictcompat.js @@ -10,7 +10,7 @@ ChromeUtils.import("resource://gre/modules/osfile.jsm"); var testserver = new HttpServer(); testserver.start(-1); gPort = testserver.identity.primaryPort; -mapFile("/data/test_corrupt.rdf", testserver); +mapFile("/data/test_corrupt.json", testserver); testserver.registerDirectory("/addons/", do_get_file("addons")); // The test extension uses an insecure update url. @@ -46,7 +46,7 @@ var addon3 = { id: "addon3@tests.mozilla.org", version: "1.0", name: "Test 3", - updateURL: "http://localhost:" + gPort + "/data/test_corrupt.rdf", + updateURL: "http://localhost:" + gPort + "/data/test_corrupt.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", @@ -59,7 +59,7 @@ var addon4 = { id: "addon4@tests.mozilla.org", version: "1.0", name: "Test 4", - updateURL: "http://localhost:" + gPort + "/data/test_corrupt.rdf", + updateURL: "http://localhost:" + gPort + "/data/test_corrupt.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_signed_install.js b/toolkit/mozapps/extensions/test/xpcshell/test_signed_install.js index 9f53ecaef5e3..cb03fef25c76 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_signed_install.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_signed_install.js @@ -82,19 +82,25 @@ function createInstall(url) { function serveUpdateRDF(leafName) { gServer.registerPathHandler("/update.rdf", function(request, response) { - let updateData = {}; - updateData[ID] = [{ - version: "2.0", - targetApplications: [{ - id: "xpcshell@tests.mozilla.org", - minVersion: "4", - maxVersion: "6", - updateLink: "http://localhost:4444/" + leafName - }] - }]; - response.setStatusLine(request.httpVersion, 200, "OK"); - response.write(createUpdateRDF(updateData)); + response.write(JSON.stringify({ + addons: { + [ID]: { + updates: [ + { + version: "2.0", + update_link: "http://localhost:4444/" + leafName, + applications: { + gecko: { + strict_min_version: "4", + advisory_max_version: "6", + }, + }, + }, + ], + }, + }, + })); }); } diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_update.js b/toolkit/mozapps/extensions/test/xpcshell/test_update.js index 28e2683e423e..d2d8ed7abd6d 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_update.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_update.js @@ -23,7 +23,6 @@ var gInstallDate; var testserver = createHttpServer(); gPort = testserver.identity.primaryPort; -mapFile("/data/test_update.rdf", testserver); mapFile("/data/test_update.json", testserver); mapFile("/data/test_update_addons.json", testserver); mapFile("/data/test_update_compat.json", testserver); @@ -42,1157 +41,1149 @@ function run_test() { run_next_test(); } -let testParams = [ - { updateFile: "test_update.rdf", - appId: "xpcshell@tests.mozilla.org" }, - { updateFile: "test_update.json", - appId: "toolkit@mozilla.org" }, -]; +const updateFile = "test_update.json"; +const appId = "toolkit@mozilla.org"; -for (let test of testParams) { - let { updateFile, appId } = test; +add_test(function() { + writeInstallRDFForExtension({ + id: "addon1@tests.mozilla.org", + version: "1.0", + updateURL: "http://localhost:" + gPort + "/data/" + updateFile, + targetApplications: [{ + id: appId, + minVersion: "1", + maxVersion: "1" + }], + name: "Test Addon 1", + }, profileDir); - add_test(function() { - writeInstallRDFForExtension({ - id: "addon1@tests.mozilla.org", - version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/" + updateFile, - targetApplications: [{ - id: appId, - minVersion: "1", - maxVersion: "1" - }], - name: "Test Addon 1", - }, profileDir); + writeInstallRDFForExtension({ + id: "addon2@tests.mozilla.org", + version: "1.0", + updateURL: "http://localhost:" + gPort + "/data/" + updateFile, + targetApplications: [{ + id: appId, + minVersion: "0", + maxVersion: "0" + }], + name: "Test Addon 2", + }, profileDir); - writeInstallRDFForExtension({ - id: "addon2@tests.mozilla.org", - version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/" + updateFile, - targetApplications: [{ - id: appId, - minVersion: "0", - maxVersion: "0" - }], - name: "Test Addon 2", - }, profileDir); + writeInstallRDFForExtension({ + id: "addon3@tests.mozilla.org", + version: "1.0", + updateURL: "http://localhost:" + gPort + "/data/" + updateFile, + targetApplications: [{ + id: appId, + minVersion: "5", + maxVersion: "5" + }], + name: "Test Addon 3", + }, profileDir); - writeInstallRDFForExtension({ - id: "addon3@tests.mozilla.org", - version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/" + updateFile, - targetApplications: [{ - id: appId, - minVersion: "5", - maxVersion: "5" - }], - name: "Test Addon 3", - }, profileDir); + startupManager(); - startupManager(); + run_next_test(); +}); - run_next_test(); - }); +// Verify that an update is available and can be installed. +let check_test_1; +add_test(function run_test_1() { + AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) { + Assert.notEqual(a1, null); + Assert.equal(a1.version, "1.0"); + Assert.equal(a1.applyBackgroundUpdates, AddonManager.AUTOUPDATE_DEFAULT); + Assert.equal(a1.releaseNotesURI, null); + Assert.ok(a1.foreignInstall); + Assert.notEqual(a1.syncGUID, null); - // Verify that an update is available and can be installed. - let check_test_1; - add_test(function run_test_1() { - AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) { - Assert.notEqual(a1, null); - Assert.equal(a1.version, "1.0"); - Assert.equal(a1.applyBackgroundUpdates, AddonManager.AUTOUPDATE_DEFAULT); - Assert.equal(a1.releaseNotesURI, null); - Assert.ok(a1.foreignInstall); - Assert.notEqual(a1.syncGUID, null); + originalSyncGUID = a1.syncGUID; + a1.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DEFAULT; - originalSyncGUID = a1.syncGUID; - a1.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DEFAULT; - - prepare_test({ - "addon1@tests.mozilla.org": [ - ["onPropertyChanged", ["applyBackgroundUpdates"]] - ] - }); - a1.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE; - check_test_completed(); - - a1.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE; - - prepare_test({}, [ - "onNewInstall", - ]); - - a1.findUpdates({ - onNoCompatibilityUpdateAvailable(addon) { - ok(false, "Should not have seen onNoCompatibilityUpdateAvailable notification"); - }, - - onUpdateAvailable(addon, install) { - ensure_test_completed(); - - AddonManager.getAllInstalls(function(aInstalls) { - Assert.equal(aInstalls.length, 1); - Assert.equal(aInstalls[0], install); - - Assert.equal(addon, a1); - Assert.equal(install.name, addon.name); - Assert.equal(install.version, "2.0"); - Assert.equal(install.state, AddonManager.STATE_AVAILABLE); - Assert.equal(install.existingAddon, addon); - Assert.equal(install.releaseNotesURI.spec, "http://example.com/updateInfo.xhtml"); - - // Verify that another update check returns the same AddonInstall - a1.findUpdates({ - onNoCompatibilityUpdateAvailable() { - ok(false, "Should not have seen onNoCompatibilityUpdateAvailable notification"); - }, - - onUpdateAvailable(newAddon, newInstall) { - AddonManager.getAllInstalls(function(aInstalls2) { - Assert.equal(aInstalls2.length, 1); - Assert.equal(aInstalls2[0], install); - Assert.equal(newAddon, addon); - Assert.equal(newInstall, install); - - prepare_test({}, [ - "onDownloadStarted", - "onDownloadEnded", - ], check_test_1); - install.install(); - }); - }, - - onNoUpdateAvailable() { - ok(false, "Should not have seen onNoUpdateAvailable notification"); - } - }, AddonManager.UPDATE_WHEN_USER_REQUESTED); - }); - }, - - onNoUpdateAvailable(addon) { - ok(false, "Should not have seen onNoUpdateAvailable notification"); - } - }, AddonManager.UPDATE_WHEN_USER_REQUESTED); + prepare_test({ + "addon1@tests.mozilla.org": [ + ["onPropertyChanged", ["applyBackgroundUpdates"]] + ] }); - }); + a1.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE; + check_test_completed(); - let run_test_2; - check_test_1 = (install) => { - ensure_test_completed(); - Assert.equal(install.state, AddonManager.STATE_DOWNLOADED); - run_test_2(install); - return false; - }; + a1.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE; - // Continue installing the update. - let check_test_2; - run_test_2 = (install) => { - // Verify that another update check returns no new update - install.existingAddon.findUpdates({ + prepare_test({}, [ + "onNewInstall", + ]); + + a1.findUpdates({ onNoCompatibilityUpdateAvailable(addon) { ok(false, "Should not have seen onNoCompatibilityUpdateAvailable notification"); }, - onUpdateAvailable() { - ok(false, "Should find no available update when one is already downloading"); - }, + onUpdateAvailable(addon, install) { + ensure_test_completed(); - onNoUpdateAvailable(addon) { AddonManager.getAllInstalls(function(aInstalls) { Assert.equal(aInstalls.length, 1); Assert.equal(aInstalls[0], install); - prepare_test({ - "addon1@tests.mozilla.org": [ - "onInstalling" - ] - }, [ - "onInstallStarted", - "onInstallEnded", - ], check_test_2); - install.install(); + Assert.equal(addon, a1); + Assert.equal(install.name, addon.name); + Assert.equal(install.version, "2.0"); + Assert.equal(install.state, AddonManager.STATE_AVAILABLE); + Assert.equal(install.existingAddon, addon); + Assert.equal(install.releaseNotesURI.spec, "http://example.com/updateInfo.xhtml"); + + // Verify that another update check returns the same AddonInstall + a1.findUpdates({ + onNoCompatibilityUpdateAvailable() { + ok(false, "Should not have seen onNoCompatibilityUpdateAvailable notification"); + }, + + onUpdateAvailable(newAddon, newInstall) { + AddonManager.getAllInstalls(function(aInstalls2) { + Assert.equal(aInstalls2.length, 1); + Assert.equal(aInstalls2[0], install); + Assert.equal(newAddon, addon); + Assert.equal(newInstall, install); + + prepare_test({}, [ + "onDownloadStarted", + "onDownloadEnded", + ], check_test_1); + install.install(); + }); + }, + + onNoUpdateAvailable() { + ok(false, "Should not have seen onNoUpdateAvailable notification"); + } + }, AddonManager.UPDATE_WHEN_USER_REQUESTED); }); + }, + + onNoUpdateAvailable(addon) { + ok(false, "Should not have seen onNoUpdateAvailable notification"); } }, AddonManager.UPDATE_WHEN_USER_REQUESTED); - }; + }); +}); - check_test_2 = () => { - ensure_test_completed(); +let run_test_2; +check_test_1 = (install) => { + ensure_test_completed(); + Assert.equal(install.state, AddonManager.STATE_DOWNLOADED); + run_test_2(install); + return false; +}; - AddonManager.getAddonByID("addon1@tests.mozilla.org", callback_soon(async function(olda1) { - await AddonTestUtils.loadAddonsList(true); +// Continue installing the update. +let check_test_2; +run_test_2 = (install) => { + // Verify that another update check returns no new update + install.existingAddon.findUpdates({ + onNoCompatibilityUpdateAvailable(addon) { + ok(false, "Should not have seen onNoCompatibilityUpdateAvailable notification"); + }, - Assert.notEqual(olda1, null); - Assert.equal(olda1.version, "1.0"); - Assert.ok(isExtensionInAddonsList(profileDir, olda1.id)); + onUpdateAvailable() { + ok(false, "Should find no available update when one is already downloading"); + }, - shutdownManager(); + onNoUpdateAvailable(addon) { + AddonManager.getAllInstalls(function(aInstalls) { + Assert.equal(aInstalls.length, 1); + Assert.equal(aInstalls[0], install); - await promiseStartupManager(); - - // Grab the current time so we can check the mtime of the add-on below - // without worrying too much about how long other tests take. - let startupTime = Date.now(); - - Assert.ok(isExtensionInAddonsList(profileDir, "addon1@tests.mozilla.org")); - - AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) { - Assert.notEqual(a1, null); - Assert.equal(a1.version, "2.0"); - Assert.ok(isExtensionInAddonsList(profileDir, a1.id)); - Assert.equal(a1.applyBackgroundUpdates, AddonManager.AUTOUPDATE_DISABLE); - Assert.equal(a1.releaseNotesURI.spec, "http://example.com/updateInfo.xhtml"); - Assert.ok(a1.foreignInstall); - Assert.notEqual(a1.syncGUID, null); - Assert.equal(originalSyncGUID, a1.syncGUID); - - // Make sure that the extension lastModifiedTime was updated. - let testURI = a1.getResourceURI(TEST_UNPACKED ? "install.rdf" : ""); - let testFile = testURI.QueryInterface(Ci.nsIFileURL).file; - let difference = testFile.lastModifiedTime - startupTime; - Assert.ok(Math.abs(difference) < MAX_TIME_DIFFERENCE); - - a1.uninstall(); - run_next_test(); + prepare_test({ + "addon1@tests.mozilla.org": [ + "onInstalling" + ] + }, [ + "onInstallStarted", + "onInstallEnded", + ], check_test_2); + install.install(); }); - })); - }; + } + }, AddonManager.UPDATE_WHEN_USER_REQUESTED); +}; - // Check that an update check finds compatibility updates and applies them - let check_test_3; - add_test(function run_test_3() { - restartManager(); +check_test_2 = () => { + ensure_test_completed(); - AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) { - Assert.notEqual(a2, null); - Assert.ok(a2.isActive); - Assert.ok(a2.isCompatible); - Assert.ok(!a2.appDisabled); - Assert.ok(a2.isCompatibleWith("0", "0")); + AddonManager.getAddonByID("addon1@tests.mozilla.org", callback_soon(async function(olda1) { + await AddonTestUtils.loadAddonsList(true); - a2.findUpdates({ - onCompatibilityUpdateAvailable(addon) { - Assert.ok(a2.isCompatible); - Assert.ok(!a2.appDisabled); - Assert.ok(a2.isActive); - }, - - onUpdateAvailable(addon, install) { - ok(false, "Should not have seen an available update"); - }, - - onNoUpdateAvailable(addon) { - Assert.equal(addon, a2); - executeSoon(check_test_3); - } - }, AddonManager.UPDATE_WHEN_USER_REQUESTED); - }); - }); - - check_test_3 = () => { - restartManager(); - AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) { - Assert.notEqual(a2, null); - Assert.ok(a2.isActive); - Assert.ok(a2.isCompatible); - Assert.ok(!a2.appDisabled); - a2.uninstall(); - - run_next_test(); - }); - }; - - // Checks that we see no compatibility information when there is none. - add_test(function run_test_4() { - AddonManager.getAddonByID("addon3@tests.mozilla.org", function(a3) { - Assert.notEqual(a3, null); - Assert.ok(!a3.isActive); - Assert.ok(!a3.isCompatible); - Assert.ok(a3.appDisabled); - Assert.ok(a3.isCompatibleWith("5", "5")); - Assert.ok(!a3.isCompatibleWith("2", "2")); - - a3.findUpdates({ - sawUpdate: false, - onCompatibilityUpdateAvailable(addon) { - ok(false, "Should not have seen compatibility information"); - }, - - onNoCompatibilityUpdateAvailable(addon) { - this.sawUpdate = true; - }, - - onUpdateAvailable(addon, install) { - ok(false, "Should not have seen an available update"); - }, - - onNoUpdateAvailable(addon) { - Assert.ok(this.sawUpdate); - run_next_test(); - } - }, AddonManager.UPDATE_WHEN_USER_REQUESTED); - }); - }); - - // Checks that compatibility info for future apps are detected but don't make - // the item compatibile. - let check_test_5; - add_test(function run_test_5() { - AddonManager.getAddonByID("addon3@tests.mozilla.org", function(a3) { - Assert.notEqual(a3, null); - Assert.ok(!a3.isActive); - Assert.ok(!a3.isCompatible); - Assert.ok(a3.appDisabled); - Assert.ok(a3.isCompatibleWith("5", "5")); - Assert.ok(!a3.isCompatibleWith("2", "2")); - - a3.findUpdates({ - sawUpdate: false, - onCompatibilityUpdateAvailable(addon) { - Assert.ok(!a3.isCompatible); - Assert.ok(a3.appDisabled); - Assert.ok(!a3.isActive); - this.sawUpdate = true; - }, - - onNoCompatibilityUpdateAvailable(addon) { - ok(false, "Should have seen some compatibility information"); - }, - - onUpdateAvailable(addon, install) { - ok(false, "Should not have seen an available update"); - }, - - onNoUpdateAvailable(addon) { - Assert.ok(this.sawUpdate); - executeSoon(check_test_5); - } - }, AddonManager.UPDATE_WHEN_USER_REQUESTED, "3.0", "3.0"); - }); - }); - - check_test_5 = () => { - restartManager(); - AddonManager.getAddonByID("addon3@tests.mozilla.org", function(a3) { - Assert.notEqual(a3, null); - Assert.ok(!a3.isActive); - Assert.ok(!a3.isCompatible); - Assert.ok(a3.appDisabled); - - a3.uninstall(); - run_next_test(); - }); - }; - - // Test that background update checks work - let continue_test_6; - add_test(function run_test_6() { - restartManager(); - - writeInstallRDFForExtension({ - id: "addon1@tests.mozilla.org", - version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/" + updateFile, - targetApplications: [{ - id: appId, - minVersion: "1", - maxVersion: "1" - }], - name: "Test Addon 1", - }, profileDir); - restartManager(); - - prepare_test({}, [ - "onNewInstall", - "onDownloadStarted", - "onDownloadEnded" - ], continue_test_6); - - AddonManagerInternal.backgroundUpdateCheck(); - }); - - let check_test_6; - continue_test_6 = (install) => { - Assert.notEqual(install.existingAddon, null); - Assert.equal(install.existingAddon.id, "addon1@tests.mozilla.org"); - - prepare_test({ - "addon1@tests.mozilla.org": [ - "onInstalling" - ] - }, [ - "onInstallStarted", - "onInstallEnded", - ], callback_soon(check_test_6)); - }; - - check_test_6 = (install) => { - Assert.equal(install.existingAddon.pendingUpgrade.install, install); - - restartManager(); - AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) { - Assert.notEqual(a1, null); - Assert.equal(a1.version, "2.0"); - Assert.equal(a1.releaseNotesURI.spec, "http://example.com/updateInfo.xhtml"); - a1.uninstall(); - run_next_test(); - }); - }; - - // Verify the parameter escaping in update urls. - add_test(function run_test_8() { - restartManager(); - - writeInstallRDFForExtension({ - id: "addon1@tests.mozilla.org", - version: "5.0", - updateURL: "http://localhost:" + gPort + "/data/param_test.rdf" + PARAMS, - targetApplications: [{ - id: appId, - minVersion: "1", - maxVersion: "2" - }], - name: "Test Addon 1", - }, profileDir); - - writeInstallRDFForExtension({ - id: "addon2@tests.mozilla.org", - version: "67.0.5b1", - updateURL: "http://localhost:" + gPort + "/data/param_test.rdf" + PARAMS, - targetApplications: [{ - id: "toolkit@mozilla.org", - minVersion: "0", - maxVersion: "3" - }], - name: "Test Addon 2", - }, profileDir); - - writeInstallRDFForExtension({ - id: "addon3@tests.mozilla.org", - version: "1.3+", - updateURL: "http://localhost:" + gPort + "/data/param_test.rdf" + PARAMS, - targetApplications: [{ - id: appId, - minVersion: "0", - maxVersion: "0" - }, { - id: "toolkit@mozilla.org", - minVersion: "0", - maxVersion: "3" - }], - name: "Test Addon 3", - }, profileDir); - - writeInstallRDFForExtension({ - id: "addon4@tests.mozilla.org", - version: "0.5ab6", - updateURL: "http://localhost:" + gPort + "/data/param_test.rdf" + PARAMS, - targetApplications: [{ - id: appId, - minVersion: "1", - maxVersion: "5" - }], - name: "Test Addon 4", - }, profileDir); - - writeInstallRDFForExtension({ - id: "addon5@tests.mozilla.org", - version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/param_test.rdf" + PARAMS, - targetApplications: [{ - id: appId, - minVersion: "1", - maxVersion: "1" - }], - name: "Test Addon 5", - }, profileDir); - - writeInstallRDFForExtension({ - id: "addon6@tests.mozilla.org", - version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/param_test.rdf" + PARAMS, - targetApplications: [{ - id: appId, - minVersion: "1", - maxVersion: "1" - }], - name: "Test Addon 6", - }, profileDir); - - restartManager(); - - AddonManager.getAddonByID("addon2@tests.mozilla.org", callback_soon(function(a2) { - a2.userDisabled = true; - restartManager(); - - testserver.registerPathHandler("/data/param_test.rdf", function(request, response) { - Assert.notEqual(request.queryString, ""); - let [req_version, item_id, item_version, - item_maxappversion, item_status, - app_id, app_version, current_app_version, - app_os, app_abi, app_locale, update_type] = - request.queryString.split("/").map(a => decodeURIComponent(a)); - - Assert.equal(req_version, "2"); - - switch (item_id) { - case "addon1@tests.mozilla.org": - Assert.equal(item_version, "5.0"); - Assert.equal(item_maxappversion, "2"); - Assert.equal(item_status, "userEnabled"); - Assert.equal(app_version, "1"); - Assert.equal(update_type, "97"); - break; - case "addon2@tests.mozilla.org": - Assert.equal(item_version, "67.0.5b1"); - Assert.equal(item_maxappversion, "3"); - Assert.equal(item_status, "userDisabled"); - Assert.equal(app_version, "1"); - Assert.equal(update_type, "49"); - break; - case "addon3@tests.mozilla.org": - Assert.equal(item_version, "1.3+"); - Assert.equal(item_maxappversion, "0"); - Assert.equal(item_status, "userEnabled"); - Assert.equal(app_version, "1"); - Assert.equal(update_type, "112"); - break; - case "addon4@tests.mozilla.org": - Assert.equal(item_version, "0.5ab6"); - Assert.equal(item_maxappversion, "5"); - Assert.equal(item_status, "userEnabled"); - Assert.equal(app_version, "2"); - Assert.equal(update_type, "98"); - break; - case "addon5@tests.mozilla.org": - Assert.equal(item_version, "1.0"); - Assert.equal(item_maxappversion, "1"); - Assert.equal(item_status, "userEnabled"); - Assert.equal(app_version, "1"); - Assert.equal(update_type, "35"); - break; - case "addon6@tests.mozilla.org": - Assert.equal(item_version, "1.0"); - Assert.equal(item_maxappversion, "1"); - Assert.equal(item_status, "userEnabled"); - Assert.equal(app_version, "1"); - Assert.equal(update_type, "99"); - break; - default: - ok(false, "Update request for unexpected add-on " + item_id); - } - - Assert.equal(app_id, "xpcshell@tests.mozilla.org"); - Assert.equal(current_app_version, "1"); - Assert.equal(app_os, "XPCShell"); - Assert.equal(app_abi, "noarch-spidermonkey"); - Assert.equal(app_locale, "fr-FR"); - - request.setStatusLine(null, 500, "Server Error"); - }); - - AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", - "addon2@tests.mozilla.org", - "addon3@tests.mozilla.org", - "addon4@tests.mozilla.org", - "addon5@tests.mozilla.org", - "addon6@tests.mozilla.org"], - function([a1_2, a2_2, a3_2, a4_2, a5_2, a6_2]) { - let count = 6; - - function next_test() { - a1_2.uninstall(); - a2_2.uninstall(); - a3_2.uninstall(); - a4_2.uninstall(); - a5_2.uninstall(); - a6_2.uninstall(); - - restartManager(); - run_next_test(); - } - - let compatListener = { - onUpdateFinished(addon, error) { - if (--count == 0) - executeSoon(next_test); - } - }; - - let updateListener = { - onUpdateAvailable(addon, update) { - // Dummy so the update checker knows we care about new versions - }, - - onUpdateFinished(addon, error) { - if (--count == 0) - executeSoon(next_test); - } - }; - - a1_2.findUpdates(updateListener, AddonManager.UPDATE_WHEN_USER_REQUESTED); - a2_2.findUpdates(compatListener, AddonManager.UPDATE_WHEN_ADDON_INSTALLED); - a3_2.findUpdates(updateListener, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE); - a4_2.findUpdates(updateListener, AddonManager.UPDATE_WHEN_NEW_APP_DETECTED, "2"); - a5_2.findUpdates(compatListener, AddonManager.UPDATE_WHEN_NEW_APP_INSTALLED); - a6_2.findUpdates(updateListener, AddonManager.UPDATE_WHEN_NEW_APP_INSTALLED); - }); - })); - }); - - // Tests that if an install.rdf claims compatibility then the add-on will be - // seen as compatible regardless of what the update.rdf says. - add_test(function run_test_9() { - writeInstallRDFForExtension({ - id: "addon4@tests.mozilla.org", - version: "5.0", - updateURL: "http://localhost:" + gPort + "/data/" + updateFile, - targetApplications: [{ - id: appId, - minVersion: "0", - maxVersion: "1" - }], - name: "Test Addon 1", - }, profileDir); - - restartManager(); - - AddonManager.getAddonByID("addon4@tests.mozilla.org", function(a4) { - Assert.ok(a4.isActive, "addon4 is active"); - Assert.ok(a4.isCompatible, "addon4 is compatible"); - - run_next_test(); - }); - }); - - // Tests that a normal update check won't decrease a targetApplication's - // maxVersion. - add_test(function run_test_10() { - AddonManager.getAddonByID("addon4@tests.mozilla.org", function(a4) { - a4.findUpdates({ - onUpdateFinished(addon) { - Assert.ok(addon.isCompatible, "addon4 is compatible"); - - run_next_test(); - } - }, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE); - }); - }); - - // Tests that an update check for a new application will decrease a - // targetApplication's maxVersion. - add_test(function run_test_11() { - AddonManager.getAddonByID("addon4@tests.mozilla.org", function(a4) { - a4.findUpdates({ - onUpdateFinished(addon) { - Assert.ok(addon.isCompatible, "addon4 is not compatible"); - - run_next_test(); - } - }, AddonManager.UPDATE_WHEN_NEW_APP_INSTALLED); - }); - }); - - // Check that the decreased maxVersion applied and disables the add-on - add_test(function run_test_12() { - restartManager(); - - AddonManager.getAddonByID("addon4@tests.mozilla.org", function(a4) { - Assert.ok(a4.isActive); - Assert.ok(a4.isCompatible); - - a4.uninstall(); - run_next_test(); - }); - }); - - // Tests that a compatibility update is passed to the listener when there is - // compatibility info for the current version of the app but not for the - // version of the app that the caller requested an update check for, when - // strict compatibility checking is disabled. - let check_test_13; - add_test(function run_test_13() { - restartManager(); - - // Not initially compatible but the update check will make it compatible - writeInstallRDFForExtension({ - id: "addon7@tests.mozilla.org", - version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/" + updateFile, - targetApplications: [{ - id: appId, - minVersion: "0", - maxVersion: "0" - }], - name: "Test Addon 7", - }, profileDir); - restartManager(); - - AddonManager.getAddonByID("addon7@tests.mozilla.org", function(a7) { - Assert.notEqual(a7, null); - Assert.ok(a7.isActive); - Assert.ok(a7.isCompatible); - Assert.ok(!a7.appDisabled); - Assert.ok(a7.isCompatibleWith("0", "0")); - - a7.findUpdates({ - sawUpdate: false, - onNoCompatibilityUpdateAvailable(addon) { - ok(false, "Should have seen compatibility information"); - }, - - onUpdateAvailable(addon, install) { - ok(false, "Should not have seen an available update"); - }, - - onUpdateFinished(addon) { - Assert.ok(addon.isCompatible); - executeSoon(check_test_13); - } - }, AddonManager.UPDATE_WHEN_NEW_APP_DETECTED, "3.0", "3.0"); - }); - }); - - check_test_13 = () => { - restartManager(); - AddonManager.getAddonByID("addon7@tests.mozilla.org", function(a7) { - Assert.notEqual(a7, null); - Assert.ok(a7.isActive); - Assert.ok(a7.isCompatible); - Assert.ok(!a7.appDisabled); - - a7.uninstall(); - run_next_test(); - }); - }; - - // Test that background update checks doesn't update an add-on that isn't - // allowed to update automatically. - let check_test_14; - add_test(function run_test_14() { - restartManager(); - - // Have an add-on there that will be updated so we see some events from it - writeInstallRDFForExtension({ - id: "addon1@tests.mozilla.org", - version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/" + updateFile, - targetApplications: [{ - id: appId, - minVersion: "1", - maxVersion: "1" - }], - name: "Test Addon 1", - }, profileDir); - - writeInstallRDFForExtension({ - id: "addon8@tests.mozilla.org", - version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/" + updateFile, - targetApplications: [{ - id: appId, - minVersion: "1", - maxVersion: "1" - }], - name: "Test Addon 8", - }, profileDir); - restartManager(); - - AddonManager.getAddonByID("addon8@tests.mozilla.org", function(a8) { - a8.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE; - - // The background update check will find updates for both add-ons but only - // proceed to install one of them. - AddonManager.addInstallListener({ - onNewInstall(aInstall) { - let id = aInstall.existingAddon.id; - ok((id == "addon1@tests.mozilla.org" || id == "addon8@tests.mozilla.org"), - "Saw unexpected onNewInstall for " + id); - }, - - onDownloadStarted(aInstall) { - Assert.equal(aInstall.existingAddon.id, "addon1@tests.mozilla.org"); - }, - - onDownloadEnded(aInstall) { - Assert.equal(aInstall.existingAddon.id, "addon1@tests.mozilla.org"); - }, - - onDownloadFailed(aInstall) { - ok(false, "Should not have seen onDownloadFailed event"); - }, - - onDownloadCancelled(aInstall) { - ok(false, "Should not have seen onDownloadCancelled event"); - }, - - onInstallStarted(aInstall) { - Assert.equal(aInstall.existingAddon.id, "addon1@tests.mozilla.org"); - }, - - onInstallEnded(aInstall) { - Assert.equal(aInstall.existingAddon.id, "addon1@tests.mozilla.org"); - Assert.equal(aInstall.existingAddon.pendingUpgrade.install, aInstall); - - executeSoon(check_test_14); - }, - - onInstallFailed(aInstall) { - ok(false, "Should not have seen onInstallFailed event"); - }, - - onInstallCancelled(aInstall) { - ok(false, "Should not have seen onInstallCancelled event"); - }, - }); - - AddonManagerInternal.backgroundUpdateCheck(); - }); - }); - - check_test_14 = () => { - restartManager(); - AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", - "addon8@tests.mozilla.org"], function([a1, a8]) { - Assert.notEqual(a1, null); - Assert.equal(a1.version, "2.0"); - a1.uninstall(); - - Assert.notEqual(a8, null); - Assert.equal(a8.version, "1.0"); - a8.uninstall(); - - run_next_test(); - }); - }; - - // Test that background update checks doesn't update an add-on that is - // pending uninstall - let check_test_15; - add_test(function run_test_15() { - restartManager(); - - // Have an add-on there that will be updated so we see some events from it - writeInstallRDFForExtension({ - id: "addon1@tests.mozilla.org", - version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/" + updateFile, - targetApplications: [{ - id: appId, - minVersion: "1", - maxVersion: "1" - }], - name: "Test Addon 1", - }, profileDir); - - writeInstallRDFForExtension({ - id: "addon8@tests.mozilla.org", - version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/" + updateFile, - targetApplications: [{ - id: appId, - minVersion: "1", - maxVersion: "1" - }], - name: "Test Addon 8", - }, profileDir); - restartManager(); - - AddonManager.getAddonByID("addon8@tests.mozilla.org", function(a8) { - a8.uninstall(); - Assert.ok(!hasFlag(a8.permissions, AddonManager.PERM_CAN_UPGRADE)); - - // The background update check will find updates for both add-ons but only - // proceed to install one of them. - AddonManager.addInstallListener({ - onNewInstall(aInstall) { - let id = aInstall.existingAddon.id; - ok((id == "addon1@tests.mozilla.org" || id == "addon8@tests.mozilla.org"), - "Saw unexpected onNewInstall for " + id); - }, - - onDownloadStarted(aInstall) { - Assert.equal(aInstall.existingAddon.id, "addon1@tests.mozilla.org"); - }, - - onDownloadEnded(aInstall) { - Assert.equal(aInstall.existingAddon.id, "addon1@tests.mozilla.org"); - }, - - onDownloadFailed(aInstall) { - ok(false, "Should not have seen onDownloadFailed event"); - }, - - onDownloadCancelled(aInstall) { - ok(false, "Should not have seen onDownloadCancelled event"); - }, - - onInstallStarted(aInstall) { - Assert.equal(aInstall.existingAddon.id, "addon1@tests.mozilla.org"); - }, - - onInstallEnded(aInstall) { - Assert.equal(aInstall.existingAddon.id, "addon1@tests.mozilla.org"); - executeSoon(check_test_15); - }, - - onInstallFailed(aInstall) { - ok(false, "Should not have seen onInstallFailed event"); - }, - - onInstallCancelled(aInstall) { - ok(false, "Should not have seen onInstallCancelled event"); - }, - }); - - AddonManagerInternal.backgroundUpdateCheck(); - }); - }); - - check_test_15 = () => { - restartManager(); - AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", - "addon8@tests.mozilla.org"], function([a1, a8]) { - Assert.notEqual(a1, null); - Assert.equal(a1.version, "2.0"); - a1.uninstall(); - - Assert.equal(a8, null); - - run_next_test(); - }); - }; - - add_test(function run_test_16() { - restartManager(); - - restartManager(); - - let url = "http://localhost:" + gPort + "/addons/test_install2_1.xpi"; - AddonManager.getInstallForURL(url, function(aInstall) { - aInstall.addListener({ - onInstallEnded() { - executeSoon(function install_2_1_ended() { - restartManager(); - - AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a1) { - Assert.notEqual(a1.syncGUID, null); - let oldGUID = a1.syncGUID; - - let url_2 = "http://localhost:" + gPort + "/addons/test_install2_2.xpi"; - AddonManager.getInstallForURL(url_2, function(aInstall_2) { - aInstall_2.addListener({ - onInstallEnded() { - executeSoon(function install_2_2_ended() { - restartManager(); - - AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) { - Assert.notEqual(a2.syncGUID, null); - Assert.equal(oldGUID, a2.syncGUID); - - a2.uninstall(); - run_next_test(); - }); - }); - } - }); - aInstall_2.install(); - }, "application/x-xpinstall"); - }); - }); - } - }); - aInstall.install(); - }, "application/x-xpinstall"); - }); - - // Test that the update check correctly observes the - // extensions.strictCompatibility pref and compatibility overrides. - add_test(function run_test_17() { - restartManager(); - - writeInstallRDFForExtension({ - id: "addon9@tests.mozilla.org", - version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/" + updateFile, - targetApplications: [{ - id: appId, - minVersion: "0.1", - maxVersion: "0.2" - }], - name: "Test Addon 9", - }, profileDir); - restartManager(); - - AddonManager.addInstallListener({ - onNewInstall(aInstall) { - equal(aInstall.existingAddon.id, "addon9@tests.mozilla.org", - "Saw unexpected onNewInstall for " + aInstall.existingAddon.id); - Assert.equal(aInstall.version, "3.0"); - }, - onDownloadFailed(aInstall) { - AddonManager.getAddonByID("addon9@tests.mozilla.org", function(a9) { - a9.uninstall(); - run_next_test(); - }); - } - }); - - Services.prefs.setCharPref(PREF_GETADDONS_BYIDS, - `http://localhost:${gPort}/data/test_update_addons.json`); - Services.prefs.setCharPref(PREF_COMPAT_OVERRIDES, - `http://localhost:${gPort}/data/test_update_compat.json`); - Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true); - - AddonManagerInternal.backgroundUpdateCheck(); - }); - - // Tests that compatibility updates are applied to addons when the updated - // compatibility data wouldn't match with strict compatibility enabled. - add_test(function run_test_18() { - restartManager(); - writeInstallRDFForExtension({ - id: "addon10@tests.mozilla.org", - version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/" + updateFile, - targetApplications: [{ - id: appId, - minVersion: "0.1", - maxVersion: "0.2" - }], - name: "Test Addon 10", - }, profileDir); - restartManager(); - - AddonManager.getAddonByID("addon10@tests.mozilla.org", function(a10) { - Assert.notEqual(a10, null); - - a10.findUpdates({ - onNoCompatibilityUpdateAvailable() { - ok(false, "Should have seen compatibility information"); - }, - - onUpdateAvailable() { - ok(false, "Should not have seen an available update"); - }, - - onUpdateFinished() { - a10.uninstall(); - run_next_test(); - } - }, AddonManager.UPDATE_WHEN_USER_REQUESTED); - }); - }); - - // Test that the update check correctly observes when an addon opts-in to - // strict compatibility checking. - add_test(function run_test_19() { - restartManager(); - writeInstallRDFForExtension({ - id: "addon11@tests.mozilla.org", - version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/" + updateFile, - targetApplications: [{ - id: appId, - minVersion: "0.1", - maxVersion: "0.2" - }], - name: "Test Addon 11", - }, profileDir); - restartManager(); - - AddonManager.getAddonByID("addon11@tests.mozilla.org", function(a11) { - Assert.notEqual(a11, null); - - a11.findUpdates({ - onCompatibilityUpdateAvailable() { - ok(false, "Should have not have seen compatibility information"); - }, - - onUpdateAvailable() { - ok(false, "Should not have seen an available update"); - }, - - onUpdateFinished() { - a11.uninstall(); - run_next_test(); - } - }, AddonManager.UPDATE_WHEN_USER_REQUESTED); - }); - }); - - // Test that the update succeeds when the update.rdf URN contains a type prefix - // different from the add-on type - let continue_test_20; - add_test(function run_test_20() { - restartManager(); - writeInstallRDFForExtension({ - id: "addon12@tests.mozilla.org", - version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/" + updateFile, - targetApplications: [{ - id: appId, - minVersion: "1", - maxVersion: "1" - }], - name: "Test Addon 12", - }, profileDir); - restartManager(); - - prepare_test({}, [ - "onNewInstall", - "onDownloadStarted", - "onDownloadEnded" - ], continue_test_20); - - AddonManagerPrivate.backgroundUpdateCheck(); - }); - - let check_test_20; - continue_test_20 = (install) => { - Assert.notEqual(install.existingAddon, null); - Assert.equal(install.existingAddon.id, "addon12@tests.mozilla.org"); - - prepare_test({ - "addon12@tests.mozilla.org": [ - "onInstalling" - ] - }, [ - "onInstallStarted", - "onInstallEnded", - ], callback_soon(check_test_20)); - }; - - check_test_20 = (install) => { - Assert.equal(install.existingAddon.pendingUpgrade.install, install); - - restartManager(); - AddonManager.getAddonByID("addon12@tests.mozilla.org", function(a12) { - Assert.notEqual(a12, null); - Assert.equal(a12.version, "2.0"); - Assert.equal(a12.type, "extension"); - a12.uninstall(); - - executeSoon(() => { - restartManager(); - run_next_test(); - }); - }); - }; - - add_task(async function cleanup() { - let addons = await AddonManager.getAddonsByTypes(["extension"]); - - for (let addon of addons) - addon.uninstall(); - - await promiseRestartManager(); + Assert.notEqual(olda1, null); + Assert.equal(olda1.version, "1.0"); + Assert.ok(isExtensionInAddonsList(profileDir, olda1.id)); shutdownManager(); - await new Promise(executeSoon); + await promiseStartupManager(); + + // Grab the current time so we can check the mtime of the add-on below + // without worrying too much about how long other tests take. + let startupTime = Date.now(); + + Assert.ok(isExtensionInAddonsList(profileDir, "addon1@tests.mozilla.org")); + + AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) { + Assert.notEqual(a1, null); + Assert.equal(a1.version, "2.0"); + Assert.ok(isExtensionInAddonsList(profileDir, a1.id)); + Assert.equal(a1.applyBackgroundUpdates, AddonManager.AUTOUPDATE_DISABLE); + Assert.equal(a1.releaseNotesURI.spec, "http://example.com/updateInfo.xhtml"); + Assert.ok(a1.foreignInstall); + Assert.notEqual(a1.syncGUID, null); + Assert.equal(originalSyncGUID, a1.syncGUID); + + // Make sure that the extension lastModifiedTime was updated. + let testURI = a1.getResourceURI(TEST_UNPACKED ? "install.rdf" : ""); + let testFile = testURI.QueryInterface(Ci.nsIFileURL).file; + let difference = testFile.lastModifiedTime - startupTime; + Assert.ok(Math.abs(difference) < MAX_TIME_DIFFERENCE); + + a1.uninstall(); + run_next_test(); + }); + })); +}; + +// Check that an update check finds compatibility updates and applies them +let check_test_3; +add_test(function run_test_3() { + restartManager(); + + AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) { + Assert.notEqual(a2, null); + Assert.ok(a2.isActive); + Assert.ok(a2.isCompatible); + Assert.ok(!a2.appDisabled); + Assert.ok(a2.isCompatibleWith("0", "0")); + + a2.findUpdates({ + onCompatibilityUpdateAvailable(addon) { + Assert.ok(a2.isCompatible); + Assert.ok(!a2.appDisabled); + Assert.ok(a2.isActive); + }, + + onUpdateAvailable(addon, install) { + ok(false, "Should not have seen an available update"); + }, + + onNoUpdateAvailable(addon) { + Assert.equal(addon, a2); + executeSoon(check_test_3); + } + }, AddonManager.UPDATE_WHEN_USER_REQUESTED); }); -} +}); + +check_test_3 = () => { + restartManager(); + AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) { + Assert.notEqual(a2, null); + Assert.ok(a2.isActive); + Assert.ok(a2.isCompatible); + Assert.ok(!a2.appDisabled); + a2.uninstall(); + + run_next_test(); + }); +}; + +// Checks that we see no compatibility information when there is none. +add_test(function run_test_4() { + AddonManager.getAddonByID("addon3@tests.mozilla.org", function(a3) { + Assert.notEqual(a3, null); + Assert.ok(!a3.isActive); + Assert.ok(!a3.isCompatible); + Assert.ok(a3.appDisabled); + Assert.ok(a3.isCompatibleWith("5", "5")); + Assert.ok(!a3.isCompatibleWith("2", "2")); + + a3.findUpdates({ + sawUpdate: false, + onCompatibilityUpdateAvailable(addon) { + ok(false, "Should not have seen compatibility information"); + }, + + onNoCompatibilityUpdateAvailable(addon) { + this.sawUpdate = true; + }, + + onUpdateAvailable(addon, install) { + ok(false, "Should not have seen an available update"); + }, + + onNoUpdateAvailable(addon) { + Assert.ok(this.sawUpdate); + run_next_test(); + } + }, AddonManager.UPDATE_WHEN_USER_REQUESTED); + }); +}); + +// Checks that compatibility info for future apps are detected but don't make +// the item compatibile. +let check_test_5; +add_test(function run_test_5() { + AddonManager.getAddonByID("addon3@tests.mozilla.org", function(a3) { + Assert.notEqual(a3, null); + Assert.ok(!a3.isActive); + Assert.ok(!a3.isCompatible); + Assert.ok(a3.appDisabled); + Assert.ok(a3.isCompatibleWith("5", "5")); + Assert.ok(!a3.isCompatibleWith("2", "2")); + + a3.findUpdates({ + sawUpdate: false, + onCompatibilityUpdateAvailable(addon) { + Assert.ok(!a3.isCompatible); + Assert.ok(a3.appDisabled); + Assert.ok(!a3.isActive); + this.sawUpdate = true; + }, + + onNoCompatibilityUpdateAvailable(addon) { + ok(false, "Should have seen some compatibility information"); + }, + + onUpdateAvailable(addon, install) { + ok(false, "Should not have seen an available update"); + }, + + onNoUpdateAvailable(addon) { + Assert.ok(this.sawUpdate); + executeSoon(check_test_5); + } + }, AddonManager.UPDATE_WHEN_USER_REQUESTED, "3.0", "3.0"); + }); +}); + +check_test_5 = () => { + restartManager(); + AddonManager.getAddonByID("addon3@tests.mozilla.org", function(a3) { + Assert.notEqual(a3, null); + Assert.ok(!a3.isActive); + Assert.ok(!a3.isCompatible); + Assert.ok(a3.appDisabled); + + a3.uninstall(); + run_next_test(); + }); +}; + +// Test that background update checks work +let continue_test_6; +add_test(function run_test_6() { + restartManager(); + + writeInstallRDFForExtension({ + id: "addon1@tests.mozilla.org", + version: "1.0", + updateURL: "http://localhost:" + gPort + "/data/" + updateFile, + targetApplications: [{ + id: appId, + minVersion: "1", + maxVersion: "1" + }], + name: "Test Addon 1", + }, profileDir); + restartManager(); + + prepare_test({}, [ + "onNewInstall", + "onDownloadStarted", + "onDownloadEnded" + ], continue_test_6); + + AddonManagerInternal.backgroundUpdateCheck(); +}); + +let check_test_6; +continue_test_6 = (install) => { + Assert.notEqual(install.existingAddon, null); + Assert.equal(install.existingAddon.id, "addon1@tests.mozilla.org"); + + prepare_test({ + "addon1@tests.mozilla.org": [ + "onInstalling" + ] + }, [ + "onInstallStarted", + "onInstallEnded", + ], callback_soon(check_test_6)); +}; + +check_test_6 = (install) => { + Assert.equal(install.existingAddon.pendingUpgrade.install, install); + + restartManager(); + AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) { + Assert.notEqual(a1, null); + Assert.equal(a1.version, "2.0"); + Assert.equal(a1.releaseNotesURI.spec, "http://example.com/updateInfo.xhtml"); + a1.uninstall(); + run_next_test(); + }); +}; + +// Verify the parameter escaping in update urls. +add_test(function run_test_8() { + restartManager(); + + writeInstallRDFForExtension({ + id: "addon1@tests.mozilla.org", + version: "5.0", + updateURL: "http://localhost:" + gPort + "/data/param_test.json" + PARAMS, + targetApplications: [{ + id: appId, + minVersion: "1", + maxVersion: "2" + }], + name: "Test Addon 1", + }, profileDir); + + writeInstallRDFForExtension({ + id: "addon2@tests.mozilla.org", + version: "67.0.5b1", + updateURL: "http://localhost:" + gPort + "/data/param_test.json" + PARAMS, + targetApplications: [{ + id: "toolkit@mozilla.org", + minVersion: "0", + maxVersion: "3" + }], + name: "Test Addon 2", + }, profileDir); + + writeInstallRDFForExtension({ + id: "addon3@tests.mozilla.org", + version: "1.3+", + updateURL: "http://localhost:" + gPort + "/data/param_test.json" + PARAMS, + targetApplications: [{ + id: appId, + minVersion: "0", + maxVersion: "0" + }, { + id: "toolkit@mozilla.org", + minVersion: "0", + maxVersion: "3" + }], + name: "Test Addon 3", + }, profileDir); + + writeInstallRDFForExtension({ + id: "addon4@tests.mozilla.org", + version: "0.5ab6", + updateURL: "http://localhost:" + gPort + "/data/param_test.json" + PARAMS, + targetApplications: [{ + id: appId, + minVersion: "1", + maxVersion: "5" + }], + name: "Test Addon 4", + }, profileDir); + + writeInstallRDFForExtension({ + id: "addon5@tests.mozilla.org", + version: "1.0", + updateURL: "http://localhost:" + gPort + "/data/param_test.json" + PARAMS, + targetApplications: [{ + id: appId, + minVersion: "1", + maxVersion: "1" + }], + name: "Test Addon 5", + }, profileDir); + + writeInstallRDFForExtension({ + id: "addon6@tests.mozilla.org", + version: "1.0", + updateURL: "http://localhost:" + gPort + "/data/param_test.json" + PARAMS, + targetApplications: [{ + id: appId, + minVersion: "1", + maxVersion: "1" + }], + name: "Test Addon 6", + }, profileDir); + + restartManager(); + + AddonManager.getAddonByID("addon2@tests.mozilla.org", callback_soon(function(a2) { + a2.userDisabled = true; + restartManager(); + + testserver.registerPathHandler("/data/param_test.json", function(request, response) { + Assert.notEqual(request.queryString, ""); + let [req_version, item_id, item_version, + item_maxappversion, item_status, + app_id, app_version, current_app_version, + app_os, app_abi, app_locale, update_type] = + request.queryString.split("/").map(a => decodeURIComponent(a)); + + Assert.equal(req_version, "2"); + + switch (item_id) { + case "addon1@tests.mozilla.org": + Assert.equal(item_version, "5.0"); + Assert.equal(item_maxappversion, "2"); + Assert.equal(item_status, "userEnabled"); + Assert.equal(app_version, "1"); + Assert.equal(update_type, "97"); + break; + case "addon2@tests.mozilla.org": + Assert.equal(item_version, "67.0.5b1"); + Assert.equal(item_maxappversion, "3"); + Assert.equal(item_status, "userDisabled"); + Assert.equal(app_version, "1"); + Assert.equal(update_type, "49"); + break; + case "addon3@tests.mozilla.org": + Assert.equal(item_version, "1.3+"); + Assert.equal(item_maxappversion, "0"); + Assert.equal(item_status, "userEnabled"); + Assert.equal(app_version, "1"); + Assert.equal(update_type, "112"); + break; + case "addon4@tests.mozilla.org": + Assert.equal(item_version, "0.5ab6"); + Assert.equal(item_maxappversion, "5"); + Assert.equal(item_status, "userEnabled"); + Assert.equal(app_version, "2"); + Assert.equal(update_type, "98"); + break; + case "addon5@tests.mozilla.org": + Assert.equal(item_version, "1.0"); + Assert.equal(item_maxappversion, "1"); + Assert.equal(item_status, "userEnabled"); + Assert.equal(app_version, "1"); + Assert.equal(update_type, "35"); + break; + case "addon6@tests.mozilla.org": + Assert.equal(item_version, "1.0"); + Assert.equal(item_maxappversion, "1"); + Assert.equal(item_status, "userEnabled"); + Assert.equal(app_version, "1"); + Assert.equal(update_type, "99"); + break; + default: + ok(false, "Update request for unexpected add-on " + item_id); + } + + Assert.equal(app_id, "xpcshell@tests.mozilla.org"); + Assert.equal(current_app_version, "1"); + Assert.equal(app_os, "XPCShell"); + Assert.equal(app_abi, "noarch-spidermonkey"); + Assert.equal(app_locale, "fr-FR"); + + request.setStatusLine(null, 500, "Server Error"); + }); + + AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", + "addon2@tests.mozilla.org", + "addon3@tests.mozilla.org", + "addon4@tests.mozilla.org", + "addon5@tests.mozilla.org", + "addon6@tests.mozilla.org"], + function([a1_2, a2_2, a3_2, a4_2, a5_2, a6_2]) { + let count = 6; + + function next_test() { + a1_2.uninstall(); + a2_2.uninstall(); + a3_2.uninstall(); + a4_2.uninstall(); + a5_2.uninstall(); + a6_2.uninstall(); + + restartManager(); + run_next_test(); + } + + let compatListener = { + onUpdateFinished(addon, error) { + if (--count == 0) + executeSoon(next_test); + } + }; + + let updateListener = { + onUpdateAvailable(addon, update) { + // Dummy so the update checker knows we care about new versions + }, + + onUpdateFinished(addon, error) { + if (--count == 0) + executeSoon(next_test); + } + }; + + a1_2.findUpdates(updateListener, AddonManager.UPDATE_WHEN_USER_REQUESTED); + a2_2.findUpdates(compatListener, AddonManager.UPDATE_WHEN_ADDON_INSTALLED); + a3_2.findUpdates(updateListener, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE); + a4_2.findUpdates(updateListener, AddonManager.UPDATE_WHEN_NEW_APP_DETECTED, "2"); + a5_2.findUpdates(compatListener, AddonManager.UPDATE_WHEN_NEW_APP_INSTALLED); + a6_2.findUpdates(updateListener, AddonManager.UPDATE_WHEN_NEW_APP_INSTALLED); + }); + })); +}); + +// Tests that if an install.rdf claims compatibility then the add-on will be +// seen as compatible regardless of what the update.rdf says. +add_test(function run_test_9() { + writeInstallRDFForExtension({ + id: "addon4@tests.mozilla.org", + version: "5.0", + updateURL: "http://localhost:" + gPort + "/data/" + updateFile, + targetApplications: [{ + id: appId, + minVersion: "0", + maxVersion: "1" + }], + name: "Test Addon 1", + }, profileDir); + + restartManager(); + + AddonManager.getAddonByID("addon4@tests.mozilla.org", function(a4) { + Assert.ok(a4.isActive, "addon4 is active"); + Assert.ok(a4.isCompatible, "addon4 is compatible"); + + run_next_test(); + }); +}); + +// Tests that a normal update check won't decrease a targetApplication's +// maxVersion. +add_test(function run_test_10() { + AddonManager.getAddonByID("addon4@tests.mozilla.org", function(a4) { + a4.findUpdates({ + onUpdateFinished(addon) { + Assert.ok(addon.isCompatible, "addon4 is compatible"); + + run_next_test(); + } + }, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE); + }); +}); + +// Tests that an update check for a new application will decrease a +// targetApplication's maxVersion. +add_test(function run_test_11() { + AddonManager.getAddonByID("addon4@tests.mozilla.org", function(a4) { + a4.findUpdates({ + onUpdateFinished(addon) { + Assert.ok(addon.isCompatible, "addon4 is not compatible"); + + run_next_test(); + } + }, AddonManager.UPDATE_WHEN_NEW_APP_INSTALLED); + }); +}); + +// Check that the decreased maxVersion applied and disables the add-on +add_test(function run_test_12() { + restartManager(); + + AddonManager.getAddonByID("addon4@tests.mozilla.org", function(a4) { + Assert.ok(a4.isActive); + Assert.ok(a4.isCompatible); + + a4.uninstall(); + run_next_test(); + }); +}); + +// Tests that a compatibility update is passed to the listener when there is +// compatibility info for the current version of the app but not for the +// version of the app that the caller requested an update check for, when +// strict compatibility checking is disabled. +let check_test_13; +add_test(function run_test_13() { + restartManager(); + + // Not initially compatible but the update check will make it compatible + writeInstallRDFForExtension({ + id: "addon7@tests.mozilla.org", + version: "1.0", + updateURL: "http://localhost:" + gPort + "/data/" + updateFile, + targetApplications: [{ + id: appId, + minVersion: "0", + maxVersion: "0" + }], + name: "Test Addon 7", + }, profileDir); + restartManager(); + + AddonManager.getAddonByID("addon7@tests.mozilla.org", function(a7) { + Assert.notEqual(a7, null); + Assert.ok(a7.isActive); + Assert.ok(a7.isCompatible); + Assert.ok(!a7.appDisabled); + Assert.ok(a7.isCompatibleWith("0", "0")); + + a7.findUpdates({ + sawUpdate: false, + onNoCompatibilityUpdateAvailable(addon) { + ok(false, "Should have seen compatibility information"); + }, + + onUpdateAvailable(addon, install) { + ok(false, "Should not have seen an available update"); + }, + + onUpdateFinished(addon) { + Assert.ok(addon.isCompatible); + executeSoon(check_test_13); + } + }, AddonManager.UPDATE_WHEN_NEW_APP_DETECTED, "3.0", "3.0"); + }); +}); + +check_test_13 = () => { + restartManager(); + AddonManager.getAddonByID("addon7@tests.mozilla.org", function(a7) { + Assert.notEqual(a7, null); + Assert.ok(a7.isActive); + Assert.ok(a7.isCompatible); + Assert.ok(!a7.appDisabled); + + a7.uninstall(); + run_next_test(); + }); +}; + +// Test that background update checks doesn't update an add-on that isn't +// allowed to update automatically. +let check_test_14; +add_test(function run_test_14() { + restartManager(); + + // Have an add-on there that will be updated so we see some events from it + writeInstallRDFForExtension({ + id: "addon1@tests.mozilla.org", + version: "1.0", + updateURL: "http://localhost:" + gPort + "/data/" + updateFile, + targetApplications: [{ + id: appId, + minVersion: "1", + maxVersion: "1" + }], + name: "Test Addon 1", + }, profileDir); + + writeInstallRDFForExtension({ + id: "addon8@tests.mozilla.org", + version: "1.0", + updateURL: "http://localhost:" + gPort + "/data/" + updateFile, + targetApplications: [{ + id: appId, + minVersion: "1", + maxVersion: "1" + }], + name: "Test Addon 8", + }, profileDir); + restartManager(); + + AddonManager.getAddonByID("addon8@tests.mozilla.org", function(a8) { + a8.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE; + + // The background update check will find updates for both add-ons but only + // proceed to install one of them. + AddonManager.addInstallListener({ + onNewInstall(aInstall) { + let id = aInstall.existingAddon.id; + ok((id == "addon1@tests.mozilla.org" || id == "addon8@tests.mozilla.org"), + "Saw unexpected onNewInstall for " + id); + }, + + onDownloadStarted(aInstall) { + Assert.equal(aInstall.existingAddon.id, "addon1@tests.mozilla.org"); + }, + + onDownloadEnded(aInstall) { + Assert.equal(aInstall.existingAddon.id, "addon1@tests.mozilla.org"); + }, + + onDownloadFailed(aInstall) { + ok(false, "Should not have seen onDownloadFailed event"); + }, + + onDownloadCancelled(aInstall) { + ok(false, "Should not have seen onDownloadCancelled event"); + }, + + onInstallStarted(aInstall) { + Assert.equal(aInstall.existingAddon.id, "addon1@tests.mozilla.org"); + }, + + onInstallEnded(aInstall) { + Assert.equal(aInstall.existingAddon.id, "addon1@tests.mozilla.org"); + Assert.equal(aInstall.existingAddon.pendingUpgrade.install, aInstall); + + executeSoon(check_test_14); + }, + + onInstallFailed(aInstall) { + ok(false, "Should not have seen onInstallFailed event"); + }, + + onInstallCancelled(aInstall) { + ok(false, "Should not have seen onInstallCancelled event"); + }, + }); + + AddonManagerInternal.backgroundUpdateCheck(); + }); +}); + +check_test_14 = () => { + restartManager(); + AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", + "addon8@tests.mozilla.org"], function([a1, a8]) { + Assert.notEqual(a1, null); + Assert.equal(a1.version, "2.0"); + a1.uninstall(); + + Assert.notEqual(a8, null); + Assert.equal(a8.version, "1.0"); + a8.uninstall(); + + run_next_test(); + }); +}; + +// Test that background update checks doesn't update an add-on that is +// pending uninstall +let check_test_15; +add_test(function run_test_15() { + restartManager(); + + // Have an add-on there that will be updated so we see some events from it + writeInstallRDFForExtension({ + id: "addon1@tests.mozilla.org", + version: "1.0", + updateURL: "http://localhost:" + gPort + "/data/" + updateFile, + targetApplications: [{ + id: appId, + minVersion: "1", + maxVersion: "1" + }], + name: "Test Addon 1", + }, profileDir); + + writeInstallRDFForExtension({ + id: "addon8@tests.mozilla.org", + version: "1.0", + updateURL: "http://localhost:" + gPort + "/data/" + updateFile, + targetApplications: [{ + id: appId, + minVersion: "1", + maxVersion: "1" + }], + name: "Test Addon 8", + }, profileDir); + restartManager(); + + AddonManager.getAddonByID("addon8@tests.mozilla.org", function(a8) { + a8.uninstall(); + Assert.ok(!hasFlag(a8.permissions, AddonManager.PERM_CAN_UPGRADE)); + + // The background update check will find updates for both add-ons but only + // proceed to install one of them. + AddonManager.addInstallListener({ + onNewInstall(aInstall) { + let id = aInstall.existingAddon.id; + ok((id == "addon1@tests.mozilla.org" || id == "addon8@tests.mozilla.org"), + "Saw unexpected onNewInstall for " + id); + }, + + onDownloadStarted(aInstall) { + Assert.equal(aInstall.existingAddon.id, "addon1@tests.mozilla.org"); + }, + + onDownloadEnded(aInstall) { + Assert.equal(aInstall.existingAddon.id, "addon1@tests.mozilla.org"); + }, + + onDownloadFailed(aInstall) { + ok(false, "Should not have seen onDownloadFailed event"); + }, + + onDownloadCancelled(aInstall) { + ok(false, "Should not have seen onDownloadCancelled event"); + }, + + onInstallStarted(aInstall) { + Assert.equal(aInstall.existingAddon.id, "addon1@tests.mozilla.org"); + }, + + onInstallEnded(aInstall) { + Assert.equal(aInstall.existingAddon.id, "addon1@tests.mozilla.org"); + executeSoon(check_test_15); + }, + + onInstallFailed(aInstall) { + ok(false, "Should not have seen onInstallFailed event"); + }, + + onInstallCancelled(aInstall) { + ok(false, "Should not have seen onInstallCancelled event"); + }, + }); + + AddonManagerInternal.backgroundUpdateCheck(); + }); +}); + +check_test_15 = () => { + restartManager(); + AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", + "addon8@tests.mozilla.org"], function([a1, a8]) { + Assert.notEqual(a1, null); + Assert.equal(a1.version, "2.0"); + a1.uninstall(); + + Assert.equal(a8, null); + + run_next_test(); + }); +}; + +add_test(function run_test_16() { + restartManager(); + + restartManager(); + + let url = "http://localhost:" + gPort + "/addons/test_install2_1.xpi"; + AddonManager.getInstallForURL(url, function(aInstall) { + aInstall.addListener({ + onInstallEnded() { + executeSoon(function install_2_1_ended() { + restartManager(); + + AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a1) { + Assert.notEqual(a1.syncGUID, null); + let oldGUID = a1.syncGUID; + + let url_2 = "http://localhost:" + gPort + "/addons/test_install2_2.xpi"; + AddonManager.getInstallForURL(url_2, function(aInstall_2) { + aInstall_2.addListener({ + onInstallEnded() { + executeSoon(function install_2_2_ended() { + restartManager(); + + AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) { + Assert.notEqual(a2.syncGUID, null); + Assert.equal(oldGUID, a2.syncGUID); + + a2.uninstall(); + run_next_test(); + }); + }); + } + }); + aInstall_2.install(); + }, "application/x-xpinstall"); + }); + }); + } + }); + aInstall.install(); + }, "application/x-xpinstall"); +}); + +// Test that the update check correctly observes the +// extensions.strictCompatibility pref and compatibility overrides. +add_test(function run_test_17() { + restartManager(); + + writeInstallRDFForExtension({ + id: "addon9@tests.mozilla.org", + version: "1.0", + updateURL: "http://localhost:" + gPort + "/data/" + updateFile, + targetApplications: [{ + id: appId, + minVersion: "0.1", + maxVersion: "0.2" + }], + name: "Test Addon 9", + }, profileDir); + restartManager(); + + AddonManager.addInstallListener({ + onNewInstall(aInstall) { + equal(aInstall.existingAddon.id, "addon9@tests.mozilla.org", + "Saw unexpected onNewInstall for " + aInstall.existingAddon.id); + Assert.equal(aInstall.version, "3.0"); + }, + onDownloadFailed(aInstall) { + AddonManager.getAddonByID("addon9@tests.mozilla.org", function(a9) { + a9.uninstall(); + run_next_test(); + }); + } + }); + + Services.prefs.setCharPref(PREF_GETADDONS_BYIDS, + `http://localhost:${gPort}/data/test_update_addons.json`); + Services.prefs.setCharPref(PREF_COMPAT_OVERRIDES, + `http://localhost:${gPort}/data/test_update_compat.json`); + Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true); + + AddonManagerInternal.backgroundUpdateCheck(); +}); + +// Tests that compatibility updates are applied to addons when the updated +// compatibility data wouldn't match with strict compatibility enabled. +add_test(function run_test_18() { + restartManager(); + writeInstallRDFForExtension({ + id: "addon10@tests.mozilla.org", + version: "1.0", + updateURL: "http://localhost:" + gPort + "/data/" + updateFile, + targetApplications: [{ + id: appId, + minVersion: "0.1", + maxVersion: "0.2" + }], + name: "Test Addon 10", + }, profileDir); + restartManager(); + + AddonManager.getAddonByID("addon10@tests.mozilla.org", function(a10) { + Assert.notEqual(a10, null); + + a10.findUpdates({ + onNoCompatibilityUpdateAvailable() { + ok(false, "Should have seen compatibility information"); + }, + + onUpdateAvailable() { + ok(false, "Should not have seen an available update"); + }, + + onUpdateFinished() { + a10.uninstall(); + run_next_test(); + } + }, AddonManager.UPDATE_WHEN_USER_REQUESTED); + }); +}); + +// Test that the update check correctly observes when an addon opts-in to +// strict compatibility checking. +add_test(function run_test_19() { + restartManager(); + writeInstallRDFForExtension({ + id: "addon11@tests.mozilla.org", + version: "1.0", + updateURL: "http://localhost:" + gPort + "/data/" + updateFile, + targetApplications: [{ + id: appId, + minVersion: "0.1", + maxVersion: "0.2" + }], + name: "Test Addon 11", + }, profileDir); + restartManager(); + + AddonManager.getAddonByID("addon11@tests.mozilla.org", function(a11) { + Assert.notEqual(a11, null); + + a11.findUpdates({ + onCompatibilityUpdateAvailable() { + ok(false, "Should have not have seen compatibility information"); + }, + + onUpdateAvailable() { + ok(false, "Should not have seen an available update"); + }, + + onUpdateFinished() { + a11.uninstall(); + run_next_test(); + } + }, AddonManager.UPDATE_WHEN_USER_REQUESTED); + }); +}); + +// Test that the update succeeds when the update.rdf URN contains a type prefix +// different from the add-on type +let continue_test_20; +add_test(function run_test_20() { + restartManager(); + writeInstallRDFForExtension({ + id: "addon12@tests.mozilla.org", + version: "1.0", + updateURL: "http://localhost:" + gPort + "/data/" + updateFile, + targetApplications: [{ + id: appId, + minVersion: "1", + maxVersion: "1" + }], + name: "Test Addon 12", + }, profileDir); + restartManager(); + + prepare_test({}, [ + "onNewInstall", + "onDownloadStarted", + "onDownloadEnded" + ], continue_test_20); + + AddonManagerPrivate.backgroundUpdateCheck(); +}); + +let check_test_20; +continue_test_20 = (install) => { + Assert.notEqual(install.existingAddon, null); + Assert.equal(install.existingAddon.id, "addon12@tests.mozilla.org"); + + prepare_test({ + "addon12@tests.mozilla.org": [ + "onInstalling" + ] + }, [ + "onInstallStarted", + "onInstallEnded", + ], callback_soon(check_test_20)); +}; + +check_test_20 = (install) => { + Assert.equal(install.existingAddon.pendingUpgrade.install, install); + + restartManager(); + AddonManager.getAddonByID("addon12@tests.mozilla.org", function(a12) { + Assert.notEqual(a12, null); + Assert.equal(a12.version, "2.0"); + Assert.equal(a12.type, "extension"); + a12.uninstall(); + + executeSoon(() => { + restartManager(); + run_next_test(); + }); + }); +}; + +add_task(async function cleanup() { + let addons = await AddonManager.getAddonsByTypes(["extension"]); + + for (let addon of addons) + addon.uninstall(); + + await promiseRestartManager(); + + shutdownManager(); + + await new Promise(executeSoon); +}); // Test that background update checks work for lightweight themes add_test(function run_test_7() { @@ -1367,7 +1358,7 @@ add_test(async function run_test_locked_install() { writeInstallRDFToXPI({ id: "addon13@tests.mozilla.org", version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/test_update.rdf", + updateURL: "http://localhost:" + gPort + "/data/test_update.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "0.1", diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_updateCancel.js b/toolkit/mozapps/extensions/test/xpcshell/test_updateCancel.js index 9b9e720bbf6c..64f2c0578ad6 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_updateCancel.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_updateCancel.js @@ -51,7 +51,7 @@ function dataHandler(aRequest, aResponse) { } var testserver = new HttpServer(); testserver.registerDirectory("/addons/", do_get_file("addons")); -testserver.registerPathHandler("/data/test_update.rdf", dataHandler); +testserver.registerPathHandler("/data/test_update.json", dataHandler); testserver.start(-1); gPort = testserver.identity.primaryPort; @@ -59,7 +59,7 @@ gPort = testserver.identity.primaryPort; writeInstallRDFForExtension({ id: "addon1@tests.mozilla.org", version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/test_update.rdf", + updateURL: "http://localhost:" + gPort + "/data/test_update.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", @@ -89,7 +89,7 @@ add_task(async function cancel_during_check() { // Now complete the HTTP request let file = do_get_cwd(); file.append("data"); - file.append("test_update.rdf"); + file.append("test_update.json"); let data = loadFile(file); response.write(data); response.finish(); @@ -123,7 +123,7 @@ add_task(async function shutdown_during_check() { // Now complete the HTTP request let file = do_get_cwd(); file.append("data"); - file.append("test_update.rdf"); + file.append("test_update.json"); let data = loadFile(file); response.write(data); response.finish(); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_update_compatmode.js b/toolkit/mozapps/extensions/test/xpcshell/test_update_compatmode.js index 62240642300a..236a114bbe1f 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_update_compatmode.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_update_compatmode.js @@ -13,9 +13,9 @@ ChromeUtils.import("resource://testing-common/httpd.js"); var testserver = new HttpServer(); testserver.start(-1); gPort = testserver.identity.primaryPort; -mapFile("/data/test_updatecompatmode_ignore.rdf", testserver); -mapFile("/data/test_updatecompatmode_normal.rdf", testserver); -mapFile("/data/test_updatecompatmode_strict.rdf", testserver); +mapFile("/data/test_updatecompatmode_ignore.json", testserver); +mapFile("/data/test_updatecompatmode_normal.json", testserver); +mapFile("/data/test_updatecompatmode_strict.json", testserver); testserver.registerDirectory("/addons/", do_get_file("addons")); const profileDir = gProfD.clone(); @@ -28,7 +28,7 @@ function run_test() { writeInstallRDFForExtension({ id: "compatmode-normal@tests.mozilla.org", version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/test_updatecompatmode_%COMPATIBILITY_MODE%.rdf", + updateURL: "http://localhost:" + gPort + "/data/test_updatecompatmode_%COMPATIBILITY_MODE%.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", @@ -40,7 +40,7 @@ function run_test() { writeInstallRDFForExtension({ id: "compatmode-strict@tests.mozilla.org", version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/test_updatecompatmode_%COMPATIBILITY_MODE%.rdf", + updateURL: "http://localhost:" + gPort + "/data/test_updatecompatmode_%COMPATIBILITY_MODE%.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", @@ -52,7 +52,7 @@ function run_test() { writeInstallRDFForExtension({ id: "compatmode-strict-optin@tests.mozilla.org", version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/test_updatecompatmode_%COMPATIBILITY_MODE%.rdf", + updateURL: "http://localhost:" + gPort + "/data/test_updatecompatmode_%COMPATIBILITY_MODE%.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", @@ -65,7 +65,7 @@ function run_test() { writeInstallRDFForExtension({ id: "compatmode-ignore@tests.mozilla.org", version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/test_updatecompatmode_%COMPATIBILITY_MODE%.rdf", + updateURL: "http://localhost:" + gPort + "/data/test_updatecompatmode_%COMPATIBILITY_MODE%.json", targetApplications: [{ id: "xpcshell@tests.mozilla.org", minVersion: "1", diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_update_ignorecompat.js b/toolkit/mozapps/extensions/test/xpcshell/test_update_ignorecompat.js index 4c38cd4fbc53..62f2c93eb502 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_update_ignorecompat.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_update_ignorecompat.js @@ -13,7 +13,6 @@ Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, false); var testserver = createHttpServer(); gPort = testserver.identity.primaryPort; -mapFile("/data/test_update.rdf", testserver); mapFile("/data/test_update.json", testserver); mapFile("/data/test_update_addons.json", testserver); mapFile("/data/test_update_compat.json", testserver); @@ -25,86 +24,78 @@ profileDir.append("extensions"); createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1"); -let testParams = [ - { updateFile: "test_update.rdf", - appId: "xpcshell@tests.mozilla.org" }, - { updateFile: "test_update.json", - appId: "toolkit@mozilla.org" }, -]; +const updateFile = "test_update.json"; +const appId = "toolkit@mozilla.org"; -for (let test of testParams) { - let { updateFile, appId } = test; +// Test that the update check correctly observes the +// extensions.strictCompatibility pref and compatibility overrides. +add_test(function() { + writeInstallRDFForExtension({ + id: "addon9@tests.mozilla.org", + version: "1.0", + updateURL: "http://localhost:" + gPort + "/data/" + updateFile, + targetApplications: [{ + id: appId, + minVersion: "0.1", + maxVersion: "0.2" + }], + name: "Test Addon 9", + }, profileDir); - // Test that the update check correctly observes the - // extensions.strictCompatibility pref and compatibility overrides. - add_test(function() { - writeInstallRDFForExtension({ - id: "addon9@tests.mozilla.org", - version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/" + updateFile, - targetApplications: [{ - id: appId, - minVersion: "0.1", - maxVersion: "0.2" - }], - name: "Test Addon 9", - }, profileDir); + restartManager(); - restartManager(); + AddonManager.addInstallListener({ + onNewInstall(aInstall) { + if (aInstall.existingAddon.id != "addon9@tests.mozilla.org") + do_throw("Saw unexpected onNewInstall for " + aInstall.existingAddon.id); + Assert.equal(aInstall.version, "4.0"); + }, + onDownloadFailed(aInstall) { + run_next_test(); + } + }); - AddonManager.addInstallListener({ - onNewInstall(aInstall) { - if (aInstall.existingAddon.id != "addon9@tests.mozilla.org") - do_throw("Saw unexpected onNewInstall for " + aInstall.existingAddon.id); - Assert.equal(aInstall.version, "4.0"); + Services.prefs.setCharPref(PREF_GETADDONS_BYIDS, + `http://localhost:${gPort}/data/test_update_addons.json`); + Services.prefs.setCharPref(PREF_COMPAT_OVERRIDES, + `http://localhost:${gPort}/data/test_update_compat.json`); + Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true); + + AddonManagerInternal.backgroundUpdateCheck(); +}); + +// Test that the update check correctly observes when an addon opts-in to +// strict compatibility checking. +add_test(function() { + writeInstallRDFForExtension({ + id: "addon11@tests.mozilla.org", + version: "1.0", + updateURL: "http://localhost:" + gPort + "/data/" + updateFile, + targetApplications: [{ + id: appId, + minVersion: "0.1", + maxVersion: "0.2" + }], + name: "Test Addon 11", + }, profileDir); + + restartManager(); + + AddonManager.getAddonByID("addon11@tests.mozilla.org", function(a11) { + Assert.notEqual(a11, null); + + a11.findUpdates({ + onCompatibilityUpdateAvailable() { + do_throw("Should not have seen compatibility information"); }, - onDownloadFailed(aInstall) { + + onUpdateAvailable() { + do_throw("Should not have seen an available update"); + }, + + onUpdateFinished() { run_next_test(); } - }); - - Services.prefs.setCharPref(PREF_GETADDONS_BYIDS, - `http://localhost:${gPort}/data/test_update_addons.json`); - Services.prefs.setCharPref(PREF_COMPAT_OVERRIDES, - `http://localhost:${gPort}/data/test_update_compat.json`); - Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true); - - AddonManagerInternal.backgroundUpdateCheck(); + }, AddonManager.UPDATE_WHEN_USER_REQUESTED); }); - - // Test that the update check correctly observes when an addon opts-in to - // strict compatibility checking. - add_test(function() { - writeInstallRDFForExtension({ - id: "addon11@tests.mozilla.org", - version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/" + updateFile, - targetApplications: [{ - id: appId, - minVersion: "0.1", - maxVersion: "0.2" - }], - name: "Test Addon 11", - }, profileDir); - - restartManager(); - - AddonManager.getAddonByID("addon11@tests.mozilla.org", function(a11) { - Assert.notEqual(a11, null); - - a11.findUpdates({ - onCompatibilityUpdateAvailable() { - do_throw("Should not have seen compatibility information"); - }, - - onUpdateAvailable() { - do_throw("Should not have seen an available update"); - }, - - onUpdateFinished() { - run_next_test(); - } - }, AddonManager.UPDATE_WHEN_USER_REQUESTED); - }); - }); -} +}); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_update_strictcompat.js b/toolkit/mozapps/extensions/test/xpcshell/test_update_strictcompat.js index 87be0fe45de8..75120feaa132 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_update_strictcompat.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_update_strictcompat.js @@ -23,7 +23,6 @@ var gInstallDate; var testserver = createHttpServer(); gPort = testserver.identity.primaryPort; -mapFile("/data/test_update.rdf", testserver); mapFile("/data/test_update.json", testserver); mapFile("/data/test_update_addons.json", testserver); mapFile("/data/test_update_compat.json", testserver); @@ -40,1001 +39,993 @@ function run_test() { run_next_test(); } -let testParams = [ - { updateFile: "test_update.rdf", - appId: "xpcshell@tests.mozilla.org" }, - { updateFile: "test_update.json", - appId: "toolkit@mozilla.org" }, -]; +const updateFile = "test_update.json"; +const appId = "toolkit@mozilla.org"; -for (let test of testParams) { - let { updateFile, appId } = test; +add_test(function() { + writeInstallRDFForExtension({ + id: "addon1@tests.mozilla.org", + version: "1.0", + updateURL: "http://localhost:" + gPort + "/data/" + updateFile, + targetApplications: [{ + id: appId, + minVersion: "1", + maxVersion: "1" + }], + name: "Test Addon 1", + }, profileDir); - add_test(function() { - writeInstallRDFForExtension({ - id: "addon1@tests.mozilla.org", - version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/" + updateFile, - targetApplications: [{ - id: appId, - minVersion: "1", - maxVersion: "1" - }], - name: "Test Addon 1", - }, profileDir); + writeInstallRDFForExtension({ + id: "addon2@tests.mozilla.org", + version: "1.0", + updateURL: "http://localhost:" + gPort + "/data/" + updateFile, + targetApplications: [{ + id: appId, + minVersion: "0", + maxVersion: "0" + }], + name: "Test Addon 2", + }, profileDir); - writeInstallRDFForExtension({ - id: "addon2@tests.mozilla.org", - version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/" + updateFile, - targetApplications: [{ - id: appId, - minVersion: "0", - maxVersion: "0" - }], - name: "Test Addon 2", - }, profileDir); + writeInstallRDFForExtension({ + id: "addon3@tests.mozilla.org", + version: "1.0", + updateURL: "http://localhost:" + gPort + "/data/" + updateFile, + targetApplications: [{ + id: appId, + minVersion: "5", + maxVersion: "5" + }], + name: "Test Addon 3", + }, profileDir); - writeInstallRDFForExtension({ - id: "addon3@tests.mozilla.org", - version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/" + updateFile, - targetApplications: [{ - id: appId, - minVersion: "5", - maxVersion: "5" - }], - name: "Test Addon 3", - }, profileDir); + startupManager(); - startupManager(); + run_next_test(); +}); - run_next_test(); - }); +// Verify that an update is available and can be installed. +let check_test_1; +add_test(function run_test_1() { + AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) { + Assert.notEqual(a1, null); + Assert.equal(a1.version, "1.0"); + Assert.equal(a1.applyBackgroundUpdates, AddonManager.AUTOUPDATE_DEFAULT); + Assert.equal(a1.releaseNotesURI, null); - // Verify that an update is available and can be installed. - let check_test_1; - add_test(function run_test_1() { - AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) { - Assert.notEqual(a1, null); - Assert.equal(a1.version, "1.0"); - Assert.equal(a1.applyBackgroundUpdates, AddonManager.AUTOUPDATE_DEFAULT); - Assert.equal(a1.releaseNotesURI, null); + a1.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DEFAULT; - a1.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DEFAULT; - - prepare_test({ - "addon1@tests.mozilla.org": [ - ["onPropertyChanged", ["applyBackgroundUpdates"]] - ] - }); - a1.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE; - check_test_completed(); - - a1.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE; - - prepare_test({}, [ - "onNewInstall", - ]); - - a1.findUpdates({ - onNoCompatibilityUpdateAvailable(addon) { - ok(false, "Should not have seen onNoCompatibilityUpdateAvailable notification"); - }, - - onUpdateAvailable(addon, install) { - ensure_test_completed(); - - AddonManager.getAllInstalls(function(aInstalls) { - Assert.equal(aInstalls.length, 1); - Assert.equal(aInstalls[0], install); - - Assert.equal(addon, a1); - Assert.equal(install.name, addon.name); - Assert.equal(install.version, "2.0"); - Assert.equal(install.state, AddonManager.STATE_AVAILABLE); - Assert.equal(install.existingAddon, addon); - Assert.equal(install.releaseNotesURI.spec, "http://example.com/updateInfo.xhtml"); - - // Verify that another update check returns the same AddonInstall - a1.findUpdates({ - onNoCompatibilityUpdateAvailable() { - ok(false, "Should not have seen onNoCompatibilityUpdateAvailable notification"); - }, - - onUpdateAvailable(newAddon, newInstall) { - AddonManager.getAllInstalls(function(aInstalls2) { - Assert.equal(aInstalls2.length, 1); - Assert.equal(aInstalls2[0], install); - Assert.equal(newAddon, addon); - Assert.equal(newInstall, install); - - prepare_test({}, [ - "onDownloadStarted", - "onDownloadEnded", - ], check_test_1); - install.install(); - }); - }, - - onNoUpdateAvailable() { - ok(false, "Should not have seen onNoUpdateAvailable notification"); - } - }, AddonManager.UPDATE_WHEN_USER_REQUESTED); - }); - }, - - onNoUpdateAvailable(addon) { - ok(false, "Should not have seen onNoUpdateAvailable notification"); - } - }, AddonManager.UPDATE_WHEN_USER_REQUESTED); + prepare_test({ + "addon1@tests.mozilla.org": [ + ["onPropertyChanged", ["applyBackgroundUpdates"]] + ] }); - }); + a1.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE; + check_test_completed(); - let run_test_2; - check_test_1 = (install) => { - ensure_test_completed(); - Assert.equal(install.state, AddonManager.STATE_DOWNLOADED); - run_test_2(install); - return false; - }; + a1.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE; - // Continue installing the update. - let check_test_2; - run_test_2 = (install) => { - // Verify that another update check returns no new update - install.existingAddon.findUpdates({ + prepare_test({}, [ + "onNewInstall", + ]); + + a1.findUpdates({ onNoCompatibilityUpdateAvailable(addon) { ok(false, "Should not have seen onNoCompatibilityUpdateAvailable notification"); }, - onUpdateAvailable() { - ok(false, "Should find no available update when one is already downloading"); - }, + onUpdateAvailable(addon, install) { + ensure_test_completed(); - onNoUpdateAvailable(addon) { AddonManager.getAllInstalls(function(aInstalls) { Assert.equal(aInstalls.length, 1); Assert.equal(aInstalls[0], install); - prepare_test({ - "addon1@tests.mozilla.org": [ - "onInstalling" - ] - }, [ - "onInstallStarted", - "onInstallEnded", - ], check_test_2); - install.install(); + Assert.equal(addon, a1); + Assert.equal(install.name, addon.name); + Assert.equal(install.version, "2.0"); + Assert.equal(install.state, AddonManager.STATE_AVAILABLE); + Assert.equal(install.existingAddon, addon); + Assert.equal(install.releaseNotesURI.spec, "http://example.com/updateInfo.xhtml"); + + // Verify that another update check returns the same AddonInstall + a1.findUpdates({ + onNoCompatibilityUpdateAvailable() { + ok(false, "Should not have seen onNoCompatibilityUpdateAvailable notification"); + }, + + onUpdateAvailable(newAddon, newInstall) { + AddonManager.getAllInstalls(function(aInstalls2) { + Assert.equal(aInstalls2.length, 1); + Assert.equal(aInstalls2[0], install); + Assert.equal(newAddon, addon); + Assert.equal(newInstall, install); + + prepare_test({}, [ + "onDownloadStarted", + "onDownloadEnded", + ], check_test_1); + install.install(); + }); + }, + + onNoUpdateAvailable() { + ok(false, "Should not have seen onNoUpdateAvailable notification"); + } + }, AddonManager.UPDATE_WHEN_USER_REQUESTED); }); + }, + + onNoUpdateAvailable(addon) { + ok(false, "Should not have seen onNoUpdateAvailable notification"); } }, AddonManager.UPDATE_WHEN_USER_REQUESTED); - }; + }); +}); - check_test_2 = () => { - ensure_test_completed(); +let run_test_2; +check_test_1 = (install) => { + ensure_test_completed(); + Assert.equal(install.state, AddonManager.STATE_DOWNLOADED); + run_test_2(install); + return false; +}; - AddonManager.getAddonByID("addon1@tests.mozilla.org", callback_soon(async function(olda1) { - await AddonTestUtils.loadAddonsList(true); +// Continue installing the update. +let check_test_2; +run_test_2 = (install) => { + // Verify that another update check returns no new update + install.existingAddon.findUpdates({ + onNoCompatibilityUpdateAvailable(addon) { + ok(false, "Should not have seen onNoCompatibilityUpdateAvailable notification"); + }, - Assert.notEqual(olda1, null); - Assert.equal(olda1.version, "1.0"); - Assert.ok(isExtensionInAddonsList(profileDir, olda1.id)); + onUpdateAvailable() { + ok(false, "Should find no available update when one is already downloading"); + }, - shutdownManager(); + onNoUpdateAvailable(addon) { + AddonManager.getAllInstalls(function(aInstalls) { + Assert.equal(aInstalls.length, 1); + Assert.equal(aInstalls[0], install); - await promiseStartupManager(); - - Assert.ok(isExtensionInAddonsList(profileDir, "addon1@tests.mozilla.org")); - - AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) { - Assert.notEqual(a1, null); - Assert.equal(a1.version, "2.0"); - Assert.ok(isExtensionInAddonsList(profileDir, a1.id)); - Assert.equal(a1.applyBackgroundUpdates, AddonManager.AUTOUPDATE_DISABLE); - Assert.equal(a1.releaseNotesURI.spec, "http://example.com/updateInfo.xhtml"); - - a1.uninstall(); - run_next_test(); + prepare_test({ + "addon1@tests.mozilla.org": [ + "onInstalling" + ] + }, [ + "onInstallStarted", + "onInstallEnded", + ], check_test_2); + install.install(); }); - })); - }; + } + }, AddonManager.UPDATE_WHEN_USER_REQUESTED); +}; +check_test_2 = () => { + ensure_test_completed(); - // Check that an update check finds compatibility updates and applies them - let check_test_3; - add_test(function run_test_3() { - restartManager(); + AddonManager.getAddonByID("addon1@tests.mozilla.org", callback_soon(async function(olda1) { + await AddonTestUtils.loadAddonsList(true); - AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) { - Assert.notEqual(a2, null); - Assert.ok(!a2.isActive); - Assert.ok(!a2.isCompatible); - Assert.ok(a2.appDisabled); - Assert.ok(a2.isCompatibleWith("0", "0")); - - a2.findUpdates({ - onCompatibilityUpdateAvailable(addon) { - Assert.ok(a2.isCompatible); - Assert.ok(!a2.appDisabled); - Assert.ok(!a2.isActive); - }, - - onUpdateAvailable(addon, install) { - ok(false, "Should not have seen an available update"); - }, - - onNoUpdateAvailable(addon) { - Assert.equal(addon, a2); - executeSoon(check_test_3); - } - }, AddonManager.UPDATE_WHEN_USER_REQUESTED); - }); - }); - - check_test_3 = () => { - restartManager(); - AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) { - Assert.notEqual(a2, null); - Assert.ok(a2.isActive); - Assert.ok(a2.isCompatible); - Assert.ok(!a2.appDisabled); - a2.uninstall(); - - run_next_test(); - }); - }; - - // Checks that we see no compatibility information when there is none. - add_test(function run_test_4() { - AddonManager.getAddonByID("addon3@tests.mozilla.org", function(a3) { - Assert.notEqual(a3, null); - Assert.ok(!a3.isActive); - Assert.ok(!a3.isCompatible); - Assert.ok(a3.appDisabled); - Assert.ok(a3.isCompatibleWith("5", "5")); - Assert.ok(!a3.isCompatibleWith("2", "2")); - - a3.findUpdates({ - sawUpdate: false, - onCompatibilityUpdateAvailable(addon) { - ok(false, "Should not have seen compatibility information"); - }, - - onNoCompatibilityUpdateAvailable(addon) { - this.sawUpdate = true; - }, - - onUpdateAvailable(addon, install) { - ok(false, "Should not have seen an available update"); - }, - - onNoUpdateAvailable(addon) { - Assert.ok(this.sawUpdate); - run_next_test(); - } - }, AddonManager.UPDATE_WHEN_USER_REQUESTED); - }); - }); - - // Checks that compatibility info for future apps are detected but don't make - // the item compatibile. - let check_test_5; - add_test(function run_test_5() { - AddonManager.getAddonByID("addon3@tests.mozilla.org", function(a3) { - Assert.notEqual(a3, null); - Assert.ok(!a3.isActive); - Assert.ok(!a3.isCompatible); - Assert.ok(a3.appDisabled); - Assert.ok(a3.isCompatibleWith("5", "5")); - Assert.ok(!a3.isCompatibleWith("2", "2")); - - a3.findUpdates({ - sawUpdate: false, - onCompatibilityUpdateAvailable(addon) { - Assert.ok(!a3.isCompatible); - Assert.ok(a3.appDisabled); - Assert.ok(!a3.isActive); - this.sawUpdate = true; - }, - - onNoCompatibilityUpdateAvailable(addon) { - ok(false, "Should have seen some compatibility information"); - }, - - onUpdateAvailable(addon, install) { - ok(false, "Should not have seen an available update"); - }, - - onNoUpdateAvailable(addon) { - Assert.ok(this.sawUpdate); - executeSoon(check_test_5); - } - }, AddonManager.UPDATE_WHEN_USER_REQUESTED, "3.0", "3.0"); - }); - }); - - check_test_5 = () => { - restartManager(); - AddonManager.getAddonByID("addon3@tests.mozilla.org", function(a3) { - Assert.notEqual(a3, null); - Assert.ok(!a3.isActive); - Assert.ok(!a3.isCompatible); - Assert.ok(a3.appDisabled); - - a3.uninstall(); - run_next_test(); - }); - }; - - // Test that background update checks work - let continue_test_6; - add_test(function run_test_6() { - restartManager(); - - writeInstallRDFForExtension({ - id: "addon1@tests.mozilla.org", - version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/" + updateFile, - targetApplications: [{ - id: appId, - minVersion: "1", - maxVersion: "1" - }], - name: "Test Addon 1", - }, profileDir); - restartManager(); - - prepare_test({}, [ - "onNewInstall", - "onDownloadStarted", - "onDownloadEnded" - ], continue_test_6); - - AddonManagerInternal.backgroundUpdateCheck(); - }); - - let check_test_6; - continue_test_6 = (install) => { - Assert.notEqual(install.existingAddon, null); - Assert.equal(install.existingAddon.id, "addon1@tests.mozilla.org"); - - prepare_test({ - "addon1@tests.mozilla.org": [ - "onInstalling" - ] - }, [ - "onInstallStarted", - "onInstallEnded", - ], callback_soon(check_test_6)); - }; - - check_test_6 = (install) => { - Assert.equal(install.existingAddon.pendingUpgrade.install, install); - - restartManager(); - AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) { - Assert.notEqual(a1, null); - Assert.equal(a1.version, "2.0"); - Assert.equal(a1.releaseNotesURI.spec, "http://example.com/updateInfo.xhtml"); - a1.uninstall(); - run_next_test(); - }); - }; - - // Verify the parameter escaping in update urls. - add_test(function run_test_8() { - restartManager(); - - writeInstallRDFForExtension({ - id: "addon1@tests.mozilla.org", - version: "5.0", - updateURL: "http://localhost:" + gPort + "/data/param_test.rdf" + PARAMS, - targetApplications: [{ - id: appId, - minVersion: "1", - maxVersion: "2" - }], - name: "Test Addon 1", - }, profileDir); - - writeInstallRDFForExtension({ - id: "addon2@tests.mozilla.org", - version: "67.0.5b1", - updateURL: "http://localhost:" + gPort + "/data/param_test.rdf" + PARAMS, - targetApplications: [{ - id: "toolkit@mozilla.org", - minVersion: "0", - maxVersion: "3" - }], - name: "Test Addon 2", - }, profileDir); - - writeInstallRDFForExtension({ - id: "addon3@tests.mozilla.org", - version: "1.3+", - updateURL: "http://localhost:" + gPort + "/data/param_test.rdf" + PARAMS, - targetApplications: [{ - id: appId, - minVersion: "0", - maxVersion: "0" - }, { - id: "toolkit@mozilla.org", - minVersion: "0", - maxVersion: "3" - }], - name: "Test Addon 3", - }, profileDir); - - writeInstallRDFForExtension({ - id: "addon4@tests.mozilla.org", - version: "0.5ab6", - updateURL: "http://localhost:" + gPort + "/data/param_test.rdf" + PARAMS, - targetApplications: [{ - id: appId, - minVersion: "1", - maxVersion: "5" - }], - name: "Test Addon 4", - }, profileDir); - - writeInstallRDFForExtension({ - id: "addon5@tests.mozilla.org", - version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/param_test.rdf" + PARAMS, - targetApplications: [{ - id: appId, - minVersion: "1", - maxVersion: "1" - }], - name: "Test Addon 5", - }, profileDir); - - writeInstallRDFForExtension({ - id: "addon6@tests.mozilla.org", - version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/param_test.rdf" + PARAMS, - targetApplications: [{ - id: appId, - minVersion: "1", - maxVersion: "1" - }], - name: "Test Addon 6", - }, profileDir); - - restartManager(); - - AddonManager.getAddonByID("addon2@tests.mozilla.org", callback_soon(function(a2) { - a2.userDisabled = true; - restartManager(); - - testserver.registerPathHandler("/data/param_test.rdf", function(request, response) { - Assert.notEqual(request.queryString, ""); - let [req_version, item_id, item_version, - item_maxappversion, item_status, - app_id, app_version, current_app_version, - app_os, app_abi, app_locale, update_type] = - request.queryString.split("/").map(a => decodeURIComponent(a)); - - Assert.equal(req_version, "2"); - - switch (item_id) { - case "addon1@tests.mozilla.org": - Assert.equal(item_version, "5.0"); - Assert.equal(item_maxappversion, "2"); - Assert.equal(item_status, "userEnabled"); - Assert.equal(app_version, "1"); - Assert.equal(update_type, "97"); - break; - case "addon2@tests.mozilla.org": - Assert.equal(item_version, "67.0.5b1"); - Assert.equal(item_maxappversion, "3"); - Assert.equal(item_status, "userDisabled"); - Assert.equal(app_version, "1"); - Assert.equal(update_type, "49"); - break; - case "addon3@tests.mozilla.org": - Assert.equal(item_version, "1.3+"); - Assert.equal(item_maxappversion, "0"); - Assert.equal(item_status, "userEnabled,incompatible"); - Assert.equal(app_version, "1"); - Assert.equal(update_type, "112"); - break; - case "addon4@tests.mozilla.org": - Assert.equal(item_version, "0.5ab6"); - Assert.equal(item_maxappversion, "5"); - Assert.equal(item_status, "userEnabled"); - Assert.equal(app_version, "2"); - Assert.equal(update_type, "98"); - break; - case "addon5@tests.mozilla.org": - Assert.equal(item_version, "1.0"); - Assert.equal(item_maxappversion, "1"); - Assert.equal(item_status, "userEnabled"); - Assert.equal(app_version, "1"); - Assert.equal(update_type, "35"); - break; - case "addon6@tests.mozilla.org": - Assert.equal(item_version, "1.0"); - Assert.equal(item_maxappversion, "1"); - Assert.equal(item_status, "userEnabled"); - Assert.equal(app_version, "1"); - Assert.equal(update_type, "99"); - break; - default: - ok(false, "Update request for unexpected add-on " + item_id); - } - - Assert.equal(app_id, "xpcshell@tests.mozilla.org"); - Assert.equal(current_app_version, "1"); - Assert.equal(app_os, "XPCShell"); - Assert.equal(app_abi, "noarch-spidermonkey"); - Assert.equal(app_locale, "fr-FR"); - - request.setStatusLine(null, 500, "Server Error"); - }); - - AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", - "addon2@tests.mozilla.org", - "addon3@tests.mozilla.org", - "addon4@tests.mozilla.org", - "addon5@tests.mozilla.org", - "addon6@tests.mozilla.org"], - function([a1_2, a2_2, a3_2, a4_2, a5_2, a6_2]) { - let count = 6; - - function next_test() { - a1_2.uninstall(); - a2_2.uninstall(); - a3_2.uninstall(); - a4_2.uninstall(); - a5_2.uninstall(); - a6_2.uninstall(); - - restartManager(); - run_next_test(); - } - - let compatListener = { - onUpdateFinished(addon, error) { - if (--count == 0) - executeSoon(next_test); - } - }; - - let updateListener = { - onUpdateAvailable(addon, update) { - // Dummy so the update checker knows we care about new versions - }, - - onUpdateFinished(addon, error) { - if (--count == 0) - executeSoon(next_test); - } - }; - - a1_2.findUpdates(updateListener, AddonManager.UPDATE_WHEN_USER_REQUESTED); - a2_2.findUpdates(compatListener, AddonManager.UPDATE_WHEN_ADDON_INSTALLED); - a3_2.findUpdates(updateListener, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE); - a4_2.findUpdates(updateListener, AddonManager.UPDATE_WHEN_NEW_APP_DETECTED, "2"); - a5_2.findUpdates(compatListener, AddonManager.UPDATE_WHEN_NEW_APP_INSTALLED); - a6_2.findUpdates(updateListener, AddonManager.UPDATE_WHEN_NEW_APP_INSTALLED); - }); - })); - }); - - // Tests that if an install.rdf claims compatibility then the add-on will be - // seen as compatible regardless of what the update.rdf says. - add_test(function run_test_9() { - writeInstallRDFForExtension({ - id: "addon4@tests.mozilla.org", - version: "5.0", - updateURL: "http://localhost:" + gPort + "/data/" + updateFile, - targetApplications: [{ - id: appId, - minVersion: "0", - maxVersion: "1" - }], - name: "Test Addon 1", - }, profileDir); - - restartManager(); - - AddonManager.getAddonByID("addon4@tests.mozilla.org", function(a4) { - Assert.ok(a4.isActive, "addon4 is active"); - Assert.ok(a4.isCompatible, "addon4 is compatible"); - - run_next_test(); - }); - }); - - // Tests that a normal update check won't decrease a targetApplication's - // maxVersion. - add_test(function run_test_10() { - AddonManager.getAddonByID("addon4@tests.mozilla.org", function(a4) { - a4.findUpdates({ - onUpdateFinished(addon) { - Assert.ok(addon.isCompatible, "addon4 is compatible"); - - run_next_test(); - } - }, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE); - }); - }); - - // Tests that an update check for a new application will decrease a - // targetApplication's maxVersion. - add_test(function run_test_11() { - AddonManager.getAddonByID("addon4@tests.mozilla.org", function(a4) { - a4.findUpdates({ - onUpdateFinished(addon) { - Assert.ok(!addon.isCompatible, "addon4 is compatible"); - - run_next_test(); - } - }, AddonManager.UPDATE_WHEN_NEW_APP_INSTALLED); - }); - }); - - // Check that the decreased maxVersion applied and disables the add-on - add_test(function run_test_12() { - restartManager(); - - AddonManager.getAddonByID("addon4@tests.mozilla.org", function(a4) { - Assert.ok(!a4.isActive, "addon4 is active"); - Assert.ok(!a4.isCompatible, "addon4 is compatible"); - - a4.uninstall(); - run_next_test(); - }); - }); - - // Tests that no compatibility update is passed to the listener when there is - // compatibility info for the current version of the app but not for the - // version of the app that the caller requested an update check for. - let check_test_13; - add_test(function run_test_13() { - restartManager(); - - // Not initially compatible but the update check will make it compatible - writeInstallRDFForExtension({ - id: "addon7@tests.mozilla.org", - version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/" + updateFile, - targetApplications: [{ - id: appId, - minVersion: "0", - maxVersion: "0" - }], - name: "Test Addon 7", - }, profileDir); - restartManager(); - - AddonManager.getAddonByID("addon7@tests.mozilla.org", function(a7) { - Assert.notEqual(a7, null); - Assert.ok(!a7.isActive); - Assert.ok(!a7.isCompatible); - Assert.ok(a7.appDisabled); - Assert.ok(a7.isCompatibleWith("0", "0")); - - a7.findUpdates({ - sawUpdate: false, - onCompatibilityUpdateAvailable(addon) { - ok(false, "Should not have seen compatibility information"); - }, - - onUpdateAvailable(addon, install) { - ok(false, "Should not have seen an available update"); - }, - - onUpdateFinished(addon) { - Assert.ok(addon.isCompatible); - executeSoon(check_test_13); - } - }, AddonManager.UPDATE_WHEN_NEW_APP_DETECTED, "3.0", "3.0"); - }); - }); - - check_test_13 = () => { - restartManager(); - AddonManager.getAddonByID("addon7@tests.mozilla.org", function(a7) { - Assert.notEqual(a7, null); - Assert.ok(a7.isActive); - Assert.ok(a7.isCompatible); - Assert.ok(!a7.appDisabled); - - a7.uninstall(); - run_next_test(); - }); - }; - - // Test that background update checks doesn't update an add-on that isn't - // allowed to update automatically. - let check_test_14; - add_test(function run_test_14() { - restartManager(); - - // Have an add-on there that will be updated so we see some events from it - writeInstallRDFForExtension({ - id: "addon1@tests.mozilla.org", - version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/" + updateFile, - targetApplications: [{ - id: appId, - minVersion: "1", - maxVersion: "1" - }], - name: "Test Addon 1", - }, profileDir); - - writeInstallRDFForExtension({ - id: "addon8@tests.mozilla.org", - version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/" + updateFile, - targetApplications: [{ - id: appId, - minVersion: "1", - maxVersion: "1" - }], - name: "Test Addon 8", - }, profileDir); - restartManager(); - - AddonManager.getAddonByID("addon8@tests.mozilla.org", function(a8) { - a8.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE; - - // The background update check will find updates for both add-ons but only - // proceed to install one of them. - AddonManager.addInstallListener({ - onNewInstall(aInstall) { - let id = aInstall.existingAddon.id; - ok((id == "addon1@tests.mozilla.org" || id == "addon8@tests.mozilla.org"), - "Saw unexpected onNewInstall for " + id); - }, - - onDownloadStarted(aInstall) { - Assert.equal(aInstall.existingAddon.id, "addon1@tests.mozilla.org"); - }, - - onDownloadEnded(aInstall) { - Assert.equal(aInstall.existingAddon.id, "addon1@tests.mozilla.org"); - }, - - onDownloadFailed(aInstall) { - ok(false, "Should not have seen onDownloadFailed event"); - }, - - onDownloadCancelled(aInstall) { - ok(false, "Should not have seen onDownloadCancelled event"); - }, - - onInstallStarted(aInstall) { - Assert.equal(aInstall.existingAddon.id, "addon1@tests.mozilla.org"); - }, - - onInstallEnded(aInstall) { - Assert.equal(aInstall.existingAddon.id, "addon1@tests.mozilla.org"); - Assert.equal(aInstall.existingAddon.pendingUpgrade.install, aInstall); - - executeSoon(check_test_14); - }, - - onInstallFailed(aInstall) { - ok(false, "Should not have seen onInstallFailed event"); - }, - - onInstallCancelled(aInstall) { - ok(false, "Should not have seen onInstallCancelled event"); - }, - }); - - AddonManagerInternal.backgroundUpdateCheck(); - }); - }); - - check_test_14 = () => { - restartManager(); - AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", - "addon8@tests.mozilla.org"], function([a1, a8]) { - Assert.notEqual(a1, null); - Assert.equal(a1.version, "2.0"); - a1.uninstall(); - - Assert.notEqual(a8, null); - Assert.equal(a8.version, "1.0"); - a8.uninstall(); - - run_next_test(); - }); - }; - - // Test that background update checks doesn't update an add-on that is - // pending uninstall - let check_test_15; - add_test(function run_test_15() { - restartManager(); - - // Have an add-on there that will be updated so we see some events from it - writeInstallRDFForExtension({ - id: "addon1@tests.mozilla.org", - version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/" + updateFile, - targetApplications: [{ - id: appId, - minVersion: "1", - maxVersion: "1" - }], - name: "Test Addon 1", - }, profileDir); - - writeInstallRDFForExtension({ - id: "addon8@tests.mozilla.org", - version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/" + updateFile, - targetApplications: [{ - id: appId, - minVersion: "1", - maxVersion: "1" - }], - name: "Test Addon 8", - }, profileDir); - restartManager(); - - AddonManager.getAddonByID("addon8@tests.mozilla.org", function(a8) { - a8.uninstall(); - Assert.ok(!hasFlag(a8.permissions, AddonManager.PERM_CAN_UPGRADE)); - - // The background update check will find updates for both add-ons but only - // proceed to install one of them. - AddonManager.addInstallListener({ - onNewInstall(aInstall) { - let id = aInstall.existingAddon.id; - ok((id == "addon1@tests.mozilla.org" || id == "addon8@tests.mozilla.org"), - "Saw unexpected onNewInstall for " + id); - }, - - onDownloadStarted(aInstall) { - Assert.equal(aInstall.existingAddon.id, "addon1@tests.mozilla.org"); - }, - - onDownloadEnded(aInstall) { - Assert.equal(aInstall.existingAddon.id, "addon1@tests.mozilla.org"); - }, - - onDownloadFailed(aInstall) { - ok(false, "Should not have seen onDownloadFailed event"); - }, - - onDownloadCancelled(aInstall) { - ok(false, "Should not have seen onDownloadCancelled event"); - }, - - onInstallStarted(aInstall) { - Assert.equal(aInstall.existingAddon.id, "addon1@tests.mozilla.org"); - }, - - onInstallEnded(aInstall) { - Assert.equal(aInstall.existingAddon.id, "addon1@tests.mozilla.org"); - executeSoon(check_test_15); - }, - - onInstallFailed(aInstall) { - ok(false, "Should not have seen onInstallFailed event"); - }, - - onInstallCancelled(aInstall) { - ok(false, "Should not have seen onInstallCancelled event"); - }, - }); - - AddonManagerInternal.backgroundUpdateCheck(); - }); - }); - - check_test_15 = () => { - restartManager(); - AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", - "addon8@tests.mozilla.org"], function([a1, a8]) { - Assert.notEqual(a1, null); - Assert.equal(a1.version, "2.0"); - a1.uninstall(); - - Assert.equal(a8, null); - - run_next_test(); - }); - }; - - // Test that the update check correctly observes the - // extensions.strictCompatibility pref and compatibility overrides. - add_test(function run_test_17() { - restartManager(); - - writeInstallRDFForExtension({ - id: "addon9@tests.mozilla.org", - version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/" + updateFile, - targetApplications: [{ - id: appId, - minVersion: "0.1", - maxVersion: "0.2" - }], - name: "Test Addon 9", - }, profileDir); - restartManager(); - - AddonManager.addInstallListener({ - onNewInstall(aInstall) { - equal(aInstall.existingAddon.id, "addon9@tests.mozilla.org", - "Saw unexpected onNewInstall for " + aInstall.existingAddon.id); - Assert.equal(aInstall.version, "2.0"); - }, - onDownloadFailed(aInstall) { - AddonManager.getAddonByID("addon9@tests.mozilla.org", function(a9) { - a9.uninstall(); - run_next_test(); - }); - } - }); - - Services.prefs.setCharPref(PREF_GETADDONS_BYIDS, - `http://localhost:${gPort}/data/test_update_addons.json`); - Services.prefs.setCharPref(PREF_COMPAT_OVERRIDES, - `http://localhost:${gPort}/data/test_update_compat.json`); - Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true); - - AddonManagerInternal.backgroundUpdateCheck(); - }); - - // Test that the update check correctly observes when an addon opts-in to - // strict compatibility checking. - add_test(function run_test_19() { - restartManager(); - writeInstallRDFForExtension({ - id: "addon11@tests.mozilla.org", - version: "1.0", - updateURL: "http://localhost:" + gPort + "/data/" + updateFile, - targetApplications: [{ - id: appId, - minVersion: "0.1", - maxVersion: "0.2" - }], - name: "Test Addon 11", - }, profileDir); - restartManager(); - - AddonManager.getAddonByID("addon11@tests.mozilla.org", function(a11) { - Assert.notEqual(a11, null); - - a11.findUpdates({ - onCompatibilityUpdateAvailable() { - ok(false, "Should have not have seen compatibility information"); - }, - - onUpdateAvailable() { - ok(false, "Should not have seen an available update"); - }, - - onUpdateFinished() { - run_next_test(); - } - }, AddonManager.UPDATE_WHEN_USER_REQUESTED); - }); - }); - - add_task(async function cleanup() { - let addons = await AddonManager.getAddonsByTypes(["extension"]); - - for (let addon of addons) - addon.uninstall(); - - await promiseRestartManager(); + Assert.notEqual(olda1, null); + Assert.equal(olda1.version, "1.0"); + Assert.ok(isExtensionInAddonsList(profileDir, olda1.id)); shutdownManager(); - await new Promise(executeSoon); + await promiseStartupManager(); + + Assert.ok(isExtensionInAddonsList(profileDir, "addon1@tests.mozilla.org")); + + AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) { + Assert.notEqual(a1, null); + Assert.equal(a1.version, "2.0"); + Assert.ok(isExtensionInAddonsList(profileDir, a1.id)); + Assert.equal(a1.applyBackgroundUpdates, AddonManager.AUTOUPDATE_DISABLE); + Assert.equal(a1.releaseNotesURI.spec, "http://example.com/updateInfo.xhtml"); + + a1.uninstall(); + run_next_test(); + }); + })); +}; + + +// Check that an update check finds compatibility updates and applies them +let check_test_3; +add_test(function run_test_3() { + restartManager(); + + AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) { + Assert.notEqual(a2, null); + Assert.ok(!a2.isActive); + Assert.ok(!a2.isCompatible); + Assert.ok(a2.appDisabled); + Assert.ok(a2.isCompatibleWith("0", "0")); + + a2.findUpdates({ + onCompatibilityUpdateAvailable(addon) { + Assert.ok(a2.isCompatible); + Assert.ok(!a2.appDisabled); + Assert.ok(!a2.isActive); + }, + + onUpdateAvailable(addon, install) { + ok(false, "Should not have seen an available update"); + }, + + onNoUpdateAvailable(addon) { + Assert.equal(addon, a2); + executeSoon(check_test_3); + } + }, AddonManager.UPDATE_WHEN_USER_REQUESTED); }); -} +}); + +check_test_3 = () => { + restartManager(); + AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) { + Assert.notEqual(a2, null); + Assert.ok(a2.isActive); + Assert.ok(a2.isCompatible); + Assert.ok(!a2.appDisabled); + a2.uninstall(); + + run_next_test(); + }); +}; + +// Checks that we see no compatibility information when there is none. +add_test(function run_test_4() { + AddonManager.getAddonByID("addon3@tests.mozilla.org", function(a3) { + Assert.notEqual(a3, null); + Assert.ok(!a3.isActive); + Assert.ok(!a3.isCompatible); + Assert.ok(a3.appDisabled); + Assert.ok(a3.isCompatibleWith("5", "5")); + Assert.ok(!a3.isCompatibleWith("2", "2")); + + a3.findUpdates({ + sawUpdate: false, + onCompatibilityUpdateAvailable(addon) { + ok(false, "Should not have seen compatibility information"); + }, + + onNoCompatibilityUpdateAvailable(addon) { + this.sawUpdate = true; + }, + + onUpdateAvailable(addon, install) { + ok(false, "Should not have seen an available update"); + }, + + onNoUpdateAvailable(addon) { + Assert.ok(this.sawUpdate); + run_next_test(); + } + }, AddonManager.UPDATE_WHEN_USER_REQUESTED); + }); +}); + +// Checks that compatibility info for future apps are detected but don't make +// the item compatibile. +let check_test_5; +add_test(function run_test_5() { + AddonManager.getAddonByID("addon3@tests.mozilla.org", function(a3) { + Assert.notEqual(a3, null); + Assert.ok(!a3.isActive); + Assert.ok(!a3.isCompatible); + Assert.ok(a3.appDisabled); + Assert.ok(a3.isCompatibleWith("5", "5")); + Assert.ok(!a3.isCompatibleWith("2", "2")); + + a3.findUpdates({ + sawUpdate: false, + onCompatibilityUpdateAvailable(addon) { + Assert.ok(!a3.isCompatible); + Assert.ok(a3.appDisabled); + Assert.ok(!a3.isActive); + this.sawUpdate = true; + }, + + onNoCompatibilityUpdateAvailable(addon) { + ok(false, "Should have seen some compatibility information"); + }, + + onUpdateAvailable(addon, install) { + ok(false, "Should not have seen an available update"); + }, + + onNoUpdateAvailable(addon) { + Assert.ok(this.sawUpdate); + executeSoon(check_test_5); + } + }, AddonManager.UPDATE_WHEN_USER_REQUESTED, "3.0", "3.0"); + }); +}); + +check_test_5 = () => { + restartManager(); + AddonManager.getAddonByID("addon3@tests.mozilla.org", function(a3) { + Assert.notEqual(a3, null); + Assert.ok(!a3.isActive); + Assert.ok(!a3.isCompatible); + Assert.ok(a3.appDisabled); + + a3.uninstall(); + run_next_test(); + }); +}; + +// Test that background update checks work +let continue_test_6; +add_test(function run_test_6() { + restartManager(); + + writeInstallRDFForExtension({ + id: "addon1@tests.mozilla.org", + version: "1.0", + updateURL: "http://localhost:" + gPort + "/data/" + updateFile, + targetApplications: [{ + id: appId, + minVersion: "1", + maxVersion: "1" + }], + name: "Test Addon 1", + }, profileDir); + restartManager(); + + prepare_test({}, [ + "onNewInstall", + "onDownloadStarted", + "onDownloadEnded" + ], continue_test_6); + + AddonManagerInternal.backgroundUpdateCheck(); +}); + +let check_test_6; +continue_test_6 = (install) => { + Assert.notEqual(install.existingAddon, null); + Assert.equal(install.existingAddon.id, "addon1@tests.mozilla.org"); + + prepare_test({ + "addon1@tests.mozilla.org": [ + "onInstalling" + ] + }, [ + "onInstallStarted", + "onInstallEnded", + ], callback_soon(check_test_6)); +}; + +check_test_6 = (install) => { + Assert.equal(install.existingAddon.pendingUpgrade.install, install); + + restartManager(); + AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) { + Assert.notEqual(a1, null); + Assert.equal(a1.version, "2.0"); + Assert.equal(a1.releaseNotesURI.spec, "http://example.com/updateInfo.xhtml"); + a1.uninstall(); + run_next_test(); + }); +}; + +// Verify the parameter escaping in update urls. +add_test(function run_test_8() { + restartManager(); + + writeInstallRDFForExtension({ + id: "addon1@tests.mozilla.org", + version: "5.0", + updateURL: "http://localhost:" + gPort + "/data/param_test.json" + PARAMS, + targetApplications: [{ + id: appId, + minVersion: "1", + maxVersion: "2" + }], + name: "Test Addon 1", + }, profileDir); + + writeInstallRDFForExtension({ + id: "addon2@tests.mozilla.org", + version: "67.0.5b1", + updateURL: "http://localhost:" + gPort + "/data/param_test.json" + PARAMS, + targetApplications: [{ + id: "toolkit@mozilla.org", + minVersion: "0", + maxVersion: "3" + }], + name: "Test Addon 2", + }, profileDir); + + writeInstallRDFForExtension({ + id: "addon3@tests.mozilla.org", + version: "1.3+", + updateURL: "http://localhost:" + gPort + "/data/param_test.json" + PARAMS, + targetApplications: [{ + id: appId, + minVersion: "0", + maxVersion: "0" + }, { + id: "toolkit@mozilla.org", + minVersion: "0", + maxVersion: "3" + }], + name: "Test Addon 3", + }, profileDir); + + writeInstallRDFForExtension({ + id: "addon4@tests.mozilla.org", + version: "0.5ab6", + updateURL: "http://localhost:" + gPort + "/data/param_test.json" + PARAMS, + targetApplications: [{ + id: appId, + minVersion: "1", + maxVersion: "5" + }], + name: "Test Addon 4", + }, profileDir); + + writeInstallRDFForExtension({ + id: "addon5@tests.mozilla.org", + version: "1.0", + updateURL: "http://localhost:" + gPort + "/data/param_test.json" + PARAMS, + targetApplications: [{ + id: appId, + minVersion: "1", + maxVersion: "1" + }], + name: "Test Addon 5", + }, profileDir); + + writeInstallRDFForExtension({ + id: "addon6@tests.mozilla.org", + version: "1.0", + updateURL: "http://localhost:" + gPort + "/data/param_test.json" + PARAMS, + targetApplications: [{ + id: appId, + minVersion: "1", + maxVersion: "1" + }], + name: "Test Addon 6", + }, profileDir); + + restartManager(); + + AddonManager.getAddonByID("addon2@tests.mozilla.org", callback_soon(function(a2) { + a2.userDisabled = true; + restartManager(); + + testserver.registerPathHandler("/data/param_test.json", function(request, response) { + Assert.notEqual(request.queryString, ""); + let [req_version, item_id, item_version, + item_maxappversion, item_status, + app_id, app_version, current_app_version, + app_os, app_abi, app_locale, update_type] = + request.queryString.split("/").map(a => decodeURIComponent(a)); + + Assert.equal(req_version, "2"); + + switch (item_id) { + case "addon1@tests.mozilla.org": + Assert.equal(item_version, "5.0"); + Assert.equal(item_maxappversion, "2"); + Assert.equal(item_status, "userEnabled"); + Assert.equal(app_version, "1"); + Assert.equal(update_type, "97"); + break; + case "addon2@tests.mozilla.org": + Assert.equal(item_version, "67.0.5b1"); + Assert.equal(item_maxappversion, "3"); + Assert.equal(item_status, "userDisabled"); + Assert.equal(app_version, "1"); + Assert.equal(update_type, "49"); + break; + case "addon3@tests.mozilla.org": + Assert.equal(item_version, "1.3+"); + Assert.equal(item_maxappversion, "0"); + Assert.equal(item_status, "userEnabled,incompatible"); + Assert.equal(app_version, "1"); + Assert.equal(update_type, "112"); + break; + case "addon4@tests.mozilla.org": + Assert.equal(item_version, "0.5ab6"); + Assert.equal(item_maxappversion, "5"); + Assert.equal(item_status, "userEnabled"); + Assert.equal(app_version, "2"); + Assert.equal(update_type, "98"); + break; + case "addon5@tests.mozilla.org": + Assert.equal(item_version, "1.0"); + Assert.equal(item_maxappversion, "1"); + Assert.equal(item_status, "userEnabled"); + Assert.equal(app_version, "1"); + Assert.equal(update_type, "35"); + break; + case "addon6@tests.mozilla.org": + Assert.equal(item_version, "1.0"); + Assert.equal(item_maxappversion, "1"); + Assert.equal(item_status, "userEnabled"); + Assert.equal(app_version, "1"); + Assert.equal(update_type, "99"); + break; + default: + ok(false, "Update request for unexpected add-on " + item_id); + } + + Assert.equal(app_id, "xpcshell@tests.mozilla.org"); + Assert.equal(current_app_version, "1"); + Assert.equal(app_os, "XPCShell"); + Assert.equal(app_abi, "noarch-spidermonkey"); + Assert.equal(app_locale, "fr-FR"); + + request.setStatusLine(null, 500, "Server Error"); + }); + + AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", + "addon2@tests.mozilla.org", + "addon3@tests.mozilla.org", + "addon4@tests.mozilla.org", + "addon5@tests.mozilla.org", + "addon6@tests.mozilla.org"], + function([a1_2, a2_2, a3_2, a4_2, a5_2, a6_2]) { + let count = 6; + + function next_test() { + a1_2.uninstall(); + a2_2.uninstall(); + a3_2.uninstall(); + a4_2.uninstall(); + a5_2.uninstall(); + a6_2.uninstall(); + + restartManager(); + run_next_test(); + } + + let compatListener = { + onUpdateFinished(addon, error) { + if (--count == 0) + executeSoon(next_test); + } + }; + + let updateListener = { + onUpdateAvailable(addon, update) { + // Dummy so the update checker knows we care about new versions + }, + + onUpdateFinished(addon, error) { + if (--count == 0) + executeSoon(next_test); + } + }; + + a1_2.findUpdates(updateListener, AddonManager.UPDATE_WHEN_USER_REQUESTED); + a2_2.findUpdates(compatListener, AddonManager.UPDATE_WHEN_ADDON_INSTALLED); + a3_2.findUpdates(updateListener, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE); + a4_2.findUpdates(updateListener, AddonManager.UPDATE_WHEN_NEW_APP_DETECTED, "2"); + a5_2.findUpdates(compatListener, AddonManager.UPDATE_WHEN_NEW_APP_INSTALLED); + a6_2.findUpdates(updateListener, AddonManager.UPDATE_WHEN_NEW_APP_INSTALLED); + }); + })); +}); + +// Tests that if an install.rdf claims compatibility then the add-on will be +// seen as compatible regardless of what the update.json says. +add_test(function run_test_9() { + writeInstallRDFForExtension({ + id: "addon4@tests.mozilla.org", + version: "5.0", + updateURL: "http://localhost:" + gPort + "/data/" + updateFile, + targetApplications: [{ + id: appId, + minVersion: "0", + maxVersion: "1" + }], + name: "Test Addon 1", + }, profileDir); + + restartManager(); + + AddonManager.getAddonByID("addon4@tests.mozilla.org", function(a4) { + Assert.ok(a4.isActive, "addon4 is active"); + Assert.ok(a4.isCompatible, "addon4 is compatible"); + + run_next_test(); + }); +}); + +// Tests that a normal update check won't decrease a targetApplication's +// maxVersion. +add_test(function run_test_10() { + AddonManager.getAddonByID("addon4@tests.mozilla.org", function(a4) { + a4.findUpdates({ + onUpdateFinished(addon) { + Assert.ok(addon.isCompatible, "addon4 is compatible"); + + run_next_test(); + } + }, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE); + }); +}); + +// Tests that an update check for a new application will decrease a +// targetApplication's maxVersion. +add_test(function run_test_11() { + AddonManager.getAddonByID("addon4@tests.mozilla.org", function(a4) { + a4.findUpdates({ + onUpdateFinished(addon) { + Assert.ok(!addon.isCompatible, "addon4 is compatible"); + + run_next_test(); + } + }, AddonManager.UPDATE_WHEN_NEW_APP_INSTALLED); + }); +}); + +// Check that the decreased maxVersion applied and disables the add-on +add_test(function run_test_12() { + restartManager(); + + AddonManager.getAddonByID("addon4@tests.mozilla.org", function(a4) { + Assert.ok(!a4.isActive, "addon4 is active"); + Assert.ok(!a4.isCompatible, "addon4 is compatible"); + + a4.uninstall(); + run_next_test(); + }); +}); + +// Tests that no compatibility update is passed to the listener when there is +// compatibility info for the current version of the app but not for the +// version of the app that the caller requested an update check for. +let check_test_13; +add_test(function run_test_13() { + restartManager(); + + // Not initially compatible but the update check will make it compatible + writeInstallRDFForExtension({ + id: "addon7@tests.mozilla.org", + version: "1.0", + updateURL: "http://localhost:" + gPort + "/data/" + updateFile, + targetApplications: [{ + id: appId, + minVersion: "0", + maxVersion: "0" + }], + name: "Test Addon 7", + }, profileDir); + restartManager(); + + AddonManager.getAddonByID("addon7@tests.mozilla.org", function(a7) { + Assert.notEqual(a7, null); + Assert.ok(!a7.isActive); + Assert.ok(!a7.isCompatible); + Assert.ok(a7.appDisabled); + Assert.ok(a7.isCompatibleWith("0", "0")); + + a7.findUpdates({ + sawUpdate: false, + onCompatibilityUpdateAvailable(addon) { + ok(false, "Should not have seen compatibility information"); + }, + + onUpdateAvailable(addon, install) { + ok(false, "Should not have seen an available update"); + }, + + onUpdateFinished(addon) { + Assert.ok(addon.isCompatible); + executeSoon(check_test_13); + } + }, AddonManager.UPDATE_WHEN_NEW_APP_DETECTED, "3.0", "3.0"); + }); +}); + +check_test_13 = () => { + restartManager(); + AddonManager.getAddonByID("addon7@tests.mozilla.org", function(a7) { + Assert.notEqual(a7, null); + Assert.ok(a7.isActive); + Assert.ok(a7.isCompatible); + Assert.ok(!a7.appDisabled); + + a7.uninstall(); + run_next_test(); + }); +}; + +// Test that background update checks doesn't update an add-on that isn't +// allowed to update automatically. +let check_test_14; +add_test(function run_test_14() { + restartManager(); + + // Have an add-on there that will be updated so we see some events from it + writeInstallRDFForExtension({ + id: "addon1@tests.mozilla.org", + version: "1.0", + updateURL: "http://localhost:" + gPort + "/data/" + updateFile, + targetApplications: [{ + id: appId, + minVersion: "1", + maxVersion: "1" + }], + name: "Test Addon 1", + }, profileDir); + + writeInstallRDFForExtension({ + id: "addon8@tests.mozilla.org", + version: "1.0", + updateURL: "http://localhost:" + gPort + "/data/" + updateFile, + targetApplications: [{ + id: appId, + minVersion: "1", + maxVersion: "1" + }], + name: "Test Addon 8", + }, profileDir); + restartManager(); + + AddonManager.getAddonByID("addon8@tests.mozilla.org", function(a8) { + a8.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE; + + // The background update check will find updates for both add-ons but only + // proceed to install one of them. + AddonManager.addInstallListener({ + onNewInstall(aInstall) { + let id = aInstall.existingAddon.id; + ok((id == "addon1@tests.mozilla.org" || id == "addon8@tests.mozilla.org"), + "Saw unexpected onNewInstall for " + id); + }, + + onDownloadStarted(aInstall) { + Assert.equal(aInstall.existingAddon.id, "addon1@tests.mozilla.org"); + }, + + onDownloadEnded(aInstall) { + Assert.equal(aInstall.existingAddon.id, "addon1@tests.mozilla.org"); + }, + + onDownloadFailed(aInstall) { + ok(false, "Should not have seen onDownloadFailed event"); + }, + + onDownloadCancelled(aInstall) { + ok(false, "Should not have seen onDownloadCancelled event"); + }, + + onInstallStarted(aInstall) { + Assert.equal(aInstall.existingAddon.id, "addon1@tests.mozilla.org"); + }, + + onInstallEnded(aInstall) { + Assert.equal(aInstall.existingAddon.id, "addon1@tests.mozilla.org"); + Assert.equal(aInstall.existingAddon.pendingUpgrade.install, aInstall); + + executeSoon(check_test_14); + }, + + onInstallFailed(aInstall) { + ok(false, "Should not have seen onInstallFailed event"); + }, + + onInstallCancelled(aInstall) { + ok(false, "Should not have seen onInstallCancelled event"); + }, + }); + + AddonManagerInternal.backgroundUpdateCheck(); + }); +}); + +check_test_14 = () => { + restartManager(); + AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", + "addon8@tests.mozilla.org"], function([a1, a8]) { + Assert.notEqual(a1, null); + Assert.equal(a1.version, "2.0"); + a1.uninstall(); + + Assert.notEqual(a8, null); + Assert.equal(a8.version, "1.0"); + a8.uninstall(); + + run_next_test(); + }); +}; + +// Test that background update checks doesn't update an add-on that is +// pending uninstall +let check_test_15; +add_test(function run_test_15() { + restartManager(); + + // Have an add-on there that will be updated so we see some events from it + writeInstallRDFForExtension({ + id: "addon1@tests.mozilla.org", + version: "1.0", + updateURL: "http://localhost:" + gPort + "/data/" + updateFile, + targetApplications: [{ + id: appId, + minVersion: "1", + maxVersion: "1" + }], + name: "Test Addon 1", + }, profileDir); + + writeInstallRDFForExtension({ + id: "addon8@tests.mozilla.org", + version: "1.0", + updateURL: "http://localhost:" + gPort + "/data/" + updateFile, + targetApplications: [{ + id: appId, + minVersion: "1", + maxVersion: "1" + }], + name: "Test Addon 8", + }, profileDir); + restartManager(); + + AddonManager.getAddonByID("addon8@tests.mozilla.org", function(a8) { + a8.uninstall(); + Assert.ok(!hasFlag(a8.permissions, AddonManager.PERM_CAN_UPGRADE)); + + // The background update check will find updates for both add-ons but only + // proceed to install one of them. + AddonManager.addInstallListener({ + onNewInstall(aInstall) { + let id = aInstall.existingAddon.id; + ok((id == "addon1@tests.mozilla.org" || id == "addon8@tests.mozilla.org"), + "Saw unexpected onNewInstall for " + id); + }, + + onDownloadStarted(aInstall) { + Assert.equal(aInstall.existingAddon.id, "addon1@tests.mozilla.org"); + }, + + onDownloadEnded(aInstall) { + Assert.equal(aInstall.existingAddon.id, "addon1@tests.mozilla.org"); + }, + + onDownloadFailed(aInstall) { + ok(false, "Should not have seen onDownloadFailed event"); + }, + + onDownloadCancelled(aInstall) { + ok(false, "Should not have seen onDownloadCancelled event"); + }, + + onInstallStarted(aInstall) { + Assert.equal(aInstall.existingAddon.id, "addon1@tests.mozilla.org"); + }, + + onInstallEnded(aInstall) { + Assert.equal(aInstall.existingAddon.id, "addon1@tests.mozilla.org"); + executeSoon(check_test_15); + }, + + onInstallFailed(aInstall) { + ok(false, "Should not have seen onInstallFailed event"); + }, + + onInstallCancelled(aInstall) { + ok(false, "Should not have seen onInstallCancelled event"); + }, + }); + + AddonManagerInternal.backgroundUpdateCheck(); + }); +}); + +check_test_15 = () => { + restartManager(); + AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org", + "addon8@tests.mozilla.org"], function([a1, a8]) { + Assert.notEqual(a1, null); + Assert.equal(a1.version, "2.0"); + a1.uninstall(); + + Assert.equal(a8, null); + + run_next_test(); + }); +}; + +// Test that the update check correctly observes the +// extensions.strictCompatibility pref and compatibility overrides. +add_test(function run_test_17() { + restartManager(); + + writeInstallRDFForExtension({ + id: "addon9@tests.mozilla.org", + version: "1.0", + updateURL: "http://localhost:" + gPort + "/data/" + updateFile, + targetApplications: [{ + id: appId, + minVersion: "0.1", + maxVersion: "0.2" + }], + name: "Test Addon 9", + }, profileDir); + restartManager(); + + AddonManager.addInstallListener({ + onNewInstall(aInstall) { + equal(aInstall.existingAddon.id, "addon9@tests.mozilla.org", + "Saw unexpected onNewInstall for " + aInstall.existingAddon.id); + Assert.equal(aInstall.version, "2.0"); + }, + onDownloadFailed(aInstall) { + AddonManager.getAddonByID("addon9@tests.mozilla.org", function(a9) { + a9.uninstall(); + run_next_test(); + }); + } + }); + + Services.prefs.setCharPref(PREF_GETADDONS_BYIDS, + `http://localhost:${gPort}/data/test_update_addons.json`); + Services.prefs.setCharPref(PREF_COMPAT_OVERRIDES, + `http://localhost:${gPort}/data/test_update_compat.json`); + Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true); + + AddonManagerInternal.backgroundUpdateCheck(); +}); + +// Test that the update check correctly observes when an addon opts-in to +// strict compatibility checking. +add_test(function run_test_19() { + restartManager(); + writeInstallRDFForExtension({ + id: "addon11@tests.mozilla.org", + version: "1.0", + updateURL: "http://localhost:" + gPort + "/data/" + updateFile, + targetApplications: [{ + id: appId, + minVersion: "0.1", + maxVersion: "0.2" + }], + name: "Test Addon 11", + }, profileDir); + restartManager(); + + AddonManager.getAddonByID("addon11@tests.mozilla.org", function(a11) { + Assert.notEqual(a11, null); + + a11.findUpdates({ + onCompatibilityUpdateAvailable() { + ok(false, "Should have not have seen compatibility information"); + }, + + onUpdateAvailable() { + ok(false, "Should not have seen an available update"); + }, + + onUpdateFinished() { + run_next_test(); + } + }, AddonManager.UPDATE_WHEN_USER_REQUESTED); + }); +}); + +add_task(async function cleanup() { + let addons = await AddonManager.getAddonsByTypes(["extension"]); + + for (let addon of addons) + addon.uninstall(); + + await promiseRestartManager(); + + shutdownManager(); + + await new Promise(executeSoon); +}); // Test that background update checks work for lightweight themes add_test(function run_test_7() { diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_updatecheck.js b/toolkit/mozapps/extensions/test/xpcshell/test_updatecheck.js index 2faa7383d4a7..8d2535947861 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_updatecheck.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_updatecheck.js @@ -32,21 +32,21 @@ function run_test() { run_next_test(); } +const UPDATE_FILE = "test_updatecheck.json"; + // Test that a basic update check returns the expected available updates add_task(async function() { - for (let file of ["test_updatecheck.rdf", "test_updatecheck.json"]) { - let updates = await checkUpdates("updatecheck1@tests.mozilla.org", file); + let updates = await checkUpdates("updatecheck1@tests.mozilla.org", UPDATE_FILE); - equal(updates.length, 5); - let update = AddonUpdateChecker.getNewestCompatibleUpdate(updates); - notEqual(update, null); - equal(update.version, "3.0"); - update = AddonUpdateChecker.getCompatibilityUpdate(updates, "2"); - notEqual(update, null); - equal(update.version, "2.0"); - equal(update.targetApplications[0].minVersion, "1"); - equal(update.targetApplications[0].maxVersion, "2"); - } + equal(updates.length, 5); + let update = AddonUpdateChecker.getNewestCompatibleUpdate(updates); + notEqual(update, null); + equal(update.version, "3.0"); + update = AddonUpdateChecker.getCompatibilityUpdate(updates, "2"); + notEqual(update, null); + equal(update.version, "2.0"); + equal(update.targetApplications[0].minVersion, "1"); + equal(update.targetApplications[0].maxVersion, "2"); }); /* @@ -65,24 +65,20 @@ add_task(async function() { */ add_task(async function() { - for (let file of ["test_updatecheck.rdf", "test_updatecheck.json"]) { - try { - await checkUpdates("test_bug378216_5@tests.mozilla.org", - file); - throw "Expected the update check to fail"; - } catch (e) {} - } + try { + await checkUpdates("test_bug378216_5@tests.mozilla.org", + UPDATE_FILE); + throw "Expected the update check to fail"; + } catch (e) {} }); add_task(async function() { - for (let file of ["test_updatecheck.rdf", "test_updatecheck.json"]) { - try { - await checkUpdates("test_bug378216_7@tests.mozilla.org", - file); + try { + await checkUpdates("test_bug378216_7@tests.mozilla.org", + UPDATE_FILE); - throw "Expected the update check to fail"; - } catch (e) {} - } + throw "Expected the update check to fail"; + } catch (e) {} }); add_task(async function() { @@ -97,136 +93,108 @@ add_task(async function() { throw "Expected the update check to fail"; } catch (e) {} - for (let file of ["test_updatecheck.rdf", - "test_updatecheck.json"]) { - let updates = await checkUpdates("test_bug378216_8@tests.mozilla.org", - file); - equal(updates.length, 1); - ok(!("updateURL" in updates[0])); + let updates = await checkUpdates("test_bug378216_8@tests.mozilla.org", + UPDATE_FILE); + equal(updates.length, 1); + ok(!("updateURL" in updates[0])); +}); + +add_task(async function() { + let updates = await checkUpdates("test_bug378216_9@tests.mozilla.org", + UPDATE_FILE); + equal(updates.length, 1); + equal(updates[0].version, "2.0"); + ok("updateURL" in updates[0]); +}); + +add_task(async function() { + let updates = await checkUpdates("test_bug378216_10@tests.mozilla.org", + UPDATE_FILE); + equal(updates.length, 1); + equal(updates[0].version, "2.0"); + ok("updateURL" in updates[0]); +}); + +add_task(async function() { + let updates = await checkUpdates("test_bug378216_11@tests.mozilla.org", + UPDATE_FILE); + equal(updates.length, 1); + equal(updates[0].version, "2.0"); + ok("updateURL" in updates[0]); +}); + +add_task(async function() { + let updates = await checkUpdates("test_bug378216_12@tests.mozilla.org", + UPDATE_FILE); + equal(updates.length, 1); + Assert.equal(false, "updateURL" in updates[0]); +}); + +add_task(async function() { + let updates = await checkUpdates("test_bug378216_13@tests.mozilla.org", + UPDATE_FILE); + equal(updates.length, 1); + equal(updates[0].version, "2.0"); + ok("updateURL" in updates[0]); +}); + +add_task(async function() { + let updates = await checkUpdates("test_bug378216_14@tests.mozilla.org", + UPDATE_FILE); + equal(updates.length, 0); +}); + +add_task(async function() { + try { + await checkUpdates("test_bug378216_15@tests.mozilla.org", + UPDATE_FILE); + + throw "Update check should have failed"; + } catch (e) { + equal(e.status, AddonManager.ERROR_PARSE_ERROR); } }); add_task(async function() { - for (let file of ["test_updatecheck.rdf", - "test_updatecheck.json"]) { - let updates = await checkUpdates("test_bug378216_9@tests.mozilla.org", - file); - equal(updates.length, 1); - equal(updates[0].version, "2.0"); - ok("updateURL" in updates[0]); - } + let updates = await checkUpdates("ignore-compat@tests.mozilla.org", + UPDATE_FILE); + equal(updates.length, 3); + let update = AddonUpdateChecker.getNewestCompatibleUpdate( + updates, null, null, true); + notEqual(update, null); + equal(update.version, 2); }); add_task(async function() { - for (let file of ["test_updatecheck.rdf", - "test_updatecheck.json"]) { - let updates = await checkUpdates("test_bug378216_10@tests.mozilla.org", - file); - equal(updates.length, 1); - equal(updates[0].version, "2.0"); - ok("updateURL" in updates[0]); - } + let updates = await checkUpdates("compat-override@tests.mozilla.org", + UPDATE_FILE); + equal(updates.length, 3); + let overrides = [{ + type: "incompatible", + minVersion: 1, + maxVersion: 2, + appID: "xpcshell@tests.mozilla.org", + appMinVersion: 0.1, + appMaxVersion: 0.2 + }, { + type: "incompatible", + minVersion: 2, + maxVersion: 2, + appID: "xpcshell@tests.mozilla.org", + appMinVersion: 1, + appMaxVersion: 2 + }]; + let update = AddonUpdateChecker.getNewestCompatibleUpdate( + updates, null, null, true, false, overrides); + notEqual(update, null); + equal(update.version, 1); }); add_task(async function() { - for (let file of ["test_updatecheck.rdf", - "test_updatecheck.json"]) { - let updates = await checkUpdates("test_bug378216_11@tests.mozilla.org", - file); - equal(updates.length, 1); - equal(updates[0].version, "2.0"); - ok("updateURL" in updates[0]); - } -}); - -add_task(async function() { - for (let file of ["test_updatecheck.rdf", - "test_updatecheck.json"]) { - let updates = await checkUpdates("test_bug378216_12@tests.mozilla.org", - file); - equal(updates.length, 1); - Assert.equal(false, "updateURL" in updates[0]); - } -}); - -add_task(async function() { - for (let file of ["test_updatecheck.rdf", - "test_updatecheck.json"]) { - let updates = await checkUpdates("test_bug378216_13@tests.mozilla.org", - file); - equal(updates.length, 1); - equal(updates[0].version, "2.0"); - ok("updateURL" in updates[0]); - } -}); - -add_task(async function() { - for (let file of ["test_updatecheck.rdf", "test_updatecheck.json"]) { - let updates = await checkUpdates("test_bug378216_14@tests.mozilla.org", - file); - equal(updates.length, 0); - } -}); - -add_task(async function() { - for (let file of ["test_updatecheck.json"]) { - try { - await checkUpdates("test_bug378216_15@tests.mozilla.org", - file); - - throw "Update check should have failed"; - } catch (e) { - equal(e.status, AddonManager.ERROR_PARSE_ERROR); - } - } -}); - -add_task(async function() { - for (let file of ["test_updatecheck.rdf", "test_updatecheck.json"]) { - let updates = await checkUpdates("ignore-compat@tests.mozilla.org", - file); - equal(updates.length, 3); - let update = AddonUpdateChecker.getNewestCompatibleUpdate( - updates, null, null, true); - notEqual(update, null); - equal(update.version, 2); - } -}); - -add_task(async function() { - for (let file of ["test_updatecheck.rdf", "test_updatecheck.json"]) { - let updates = await checkUpdates("compat-override@tests.mozilla.org", - file); - equal(updates.length, 3); - let overrides = [{ - type: "incompatible", - minVersion: 1, - maxVersion: 2, - appID: "xpcshell@tests.mozilla.org", - appMinVersion: 0.1, - appMaxVersion: 0.2 - }, { - type: "incompatible", - minVersion: 2, - maxVersion: 2, - appID: "xpcshell@tests.mozilla.org", - appMinVersion: 1, - appMaxVersion: 2 - }]; - let update = AddonUpdateChecker.getNewestCompatibleUpdate( - updates, null, null, true, false, overrides); - notEqual(update, null); - equal(update.version, 1); - } -}); - -add_task(async function() { - for (let file of ["test_updatecheck.rdf", "test_updatecheck.json"]) { - let updates = await checkUpdates("compat-strict-optin@tests.mozilla.org", - file); - equal(updates.length, 1); - let update = AddonUpdateChecker.getNewestCompatibleUpdate( - updates, null, null, true, false); - equal(update, null); - } + let updates = await checkUpdates("compat-strict-optin@tests.mozilla.org", + UPDATE_FILE); + equal(updates.length, 1); + let update = AddonUpdateChecker.getNewestCompatibleUpdate( + updates, null, null, true, false); + equal(update, null); });