summaryrefslogtreecommitdiffstats
path: root/toolkit/mozapps/extensions/test/xpcshell
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/mozapps/extensions/test/xpcshell')
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/.eslintrc.js7
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/BootstrapMonitor.jsm30
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/from_sources/bootstrap.js1
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/from_sources/install.rdf28
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/pluginInfoURL_block.xml24
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/productaddons/bad.txt1
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/productaddons/bad.xml3
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/productaddons/bad2.xml3
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/productaddons/empty.xml5
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/productaddons/good.xml11
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/productaddons/missing.xml3
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/productaddons/unsigned.xpibin452 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_1/bootstrap.js29
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_1/install.rdf24
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_1/test.txt1
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_2/bootstrap.js29
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_2/install.rdf24
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_2/test.txt1
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/hotfix_badid.xpibin5151 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/hotfix_broken.xpibin5298 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/hotfix_good.xpibin5158 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_63_hash.xpibin4471 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_63_plain.xpibin4433 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_64_hash.xpibin4474 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_64_plain.xpibin4436 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_65_hash.xpibin4487 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/multi_badid.xpibin6443 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/multi_broken.xpibin6563 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/multi_signed.xpibin6425 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/multi_unsigned.xpibin2436 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/nonbootstrap_1/install.rdf23
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/nonbootstrap_1/test.txt1
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/nonbootstrap_2/install.rdf23
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/nonbootstrap_2/test.txt1
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/preliminary_bootstrap_2.xpibin5161 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_bootstrap_1.xpibin5150 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_bootstrap_2.xpibin5149 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_bootstrap_badid_2.xpibin5155 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_nonbootstrap_2.xpibin4627 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_nonbootstrap_badid_2.xpibin4634 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/unsigned_bootstrap_2.xpibin1156 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/unsigned_nonbootstrap_2.xpibin691 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/system_addons/bootstrap.js1
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system1_1.xpibin4692 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system1_1_badcert.xpibin4808 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system1_2.xpibin4695 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system2_1.xpibin4692 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system2_2.xpibin4695 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system2_3.xpibin4697 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system3_1.xpibin4689 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system3_2.xpibin4691 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system3_3.xpibin4693 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system4_1.xpibin4692 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system5_1.xpibin4691 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system6_1_unpack.xpibin4708 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system6_2_notBootstrap.xpibin4682 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system6_3_notMultiprocess.xpibin4675 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_complete.xpibin5090 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_complete_2.xpibin4706 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_defer.xpibin5095 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_defer_2.xpibin4701 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_defer_also.xpibin5117 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_defer_also_2.xpibin4716 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_ignore.xpibin5098 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_ignore_2.xpibin4707 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_failed_update.xpibin735 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/test_delay_update_complete/bootstrap.js24
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/test_delay_update_defer/bootstrap.js34
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/test_delay_update_ignore/bootstrap.js26
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_complete.json11
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_complete.rdf26
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_defer.json11
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_defer.rdf26
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_ignore.json11
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_ignore.rdf26
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/test_gfxBlacklist.xml158
-rw-r--r--[-rwxr-xr-x]toolkit/mozapps/extensions/test/xpcshell/data/test_gfxBlacklist_AllOS.xml763
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/test_gfxBlacklist_OSVersion.xml2
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/test_hotfix_1.rdf26
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/test_hotfix_2.rdf26
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/test_hotfix_3.rdf26
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/test_install.xml2
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/test_no_update.json7
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/test_proxy/bootstrap.js1
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/test_softblocked1.xml9
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/test_temporary/bootstrap.js1
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/test_update.json215
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/test_update_multi.rdf26
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/test_updatecheck.json327
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/test_updatecheck.rdf2
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/test_updateid.rdf62
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/data/webext-implicit-id.xpibin4182 -> 0 bytes
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/head_addons.js1372
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/head_unpack.js1
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository.js8
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository_cache.js22
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_ChromeManifestParser.js216
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_DeferredSave.js33
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_LightweightThemeManager.js160
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_ProductAddonChecker.js244
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_XPIStates.js6
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_XPIcancel.js4
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_addon_path_service.js2
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_asyncBlocklistLoad.js2
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_backgroundupdate.js4
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_blocklist_gfx.js157
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_blocklist_metadata_filters.js24
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_blocklist_prefs.js23
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_blocklist_regexp.js239
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_blocklistchange.js34
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bootstrap.js707
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bootstrap_const.js17
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bootstrap_globals.js2
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug1180901.js35
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug1180901_2.js60
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug299716.js13
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug324121.js8
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug335238.js20
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug371495.js8
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug393285.js27
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug406118.js28
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug430120.js15
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug449027.js43
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug455906.js73
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug465190.js2
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug468528.js2
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug470377_1.js2
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug470377_1_strictcompat.js2
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug470377_2.js2
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3.js10
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3_strictcompat.js10
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug470377_4.js10
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug514327_1.js4
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug514327_2.js11
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug514327_3.js57
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug541420.js2
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug542391.js50
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug559800.js2
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug563256.js34
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug564030.js14
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug570173.js93
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug576735.js6
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug587088.js26
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug594058.js21
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug596343.js86
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug596607.js37
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug619730.js8
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug655254.js52
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug659772.js102
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug675371.js2
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_bug757663.js224
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_cache_certdb.js82
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_cacheflush.js7
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_checkCompatibility_themeOverride.js186
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_compatoverrides.js2
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_corrupt.js211
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_corrupt_strictcompat.js211
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_dataDirectory.js8
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_delay_update.js260
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_delay_update_webextension.js344
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_dependencies.js144
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_dictionary.js60
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_distribution.js21
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_dss.js2
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_duplicateplugins.js58
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_e10s_restartless.js429
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_error.js6
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_experiment.js203
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_ext_management.js137
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_filepointer.js36
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_fuel.js5
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_getresource.js4
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Device.js21
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_DriverNew.js16
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverNew.js50
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverOld.js16
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_OK.js16
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_DriverOld.js16
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_OK.js16
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_No_Comparison.js34
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OK.js18
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OS.js19
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_match.js21
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_mismatch_DriverVersion.js20
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_mismatch_OSVersion.js21
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Vendor.js18
-rwxr-xr-xtoolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Version.js145
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_prefs.js7
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_gmpProvider.js122
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_hasbinarycomponents.js2
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_hotfix.js309
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_hotfix_cert.js167
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_install.js190
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_install_from_sources.js80
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_install_strictcompat.js184
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_isDebuggable.js2
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_json_updatecheck.js372
-rw-r--r--[-rwxr-xr-x]toolkit/mozapps/extensions/test/xpcshell/test_locked.js19
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_locked2.js11
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_locked_strictcompat.js22
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_manifest.js8
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_mapURIToAddonID.js63
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_metadata_update.js39
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_migrate1.js45
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_migrate2.js8
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_migrate3.js40
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_migrate4.js34
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_migrate5.js278
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_migrateAddonRepository.js40
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_migrate_max_version.js2
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_multiprocessCompatible.js12
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_no_addons.js12
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_nodisable_hidden.js107
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_overrideblocklist.js8
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_pass_symbol.js43
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_permissions.js172
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_permissions_prefs.js148
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_pluginBlocklistCtp.js1
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_pluginInfoURL.js14
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_pluginchange.js575
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_plugins.js50
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_pref_properties.js15
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_provider_markSafe.js8
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_provider_shutdown.js6
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_provider_unsafe_access_shutdown.js11
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_provider_unsafe_access_startup.js10
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_proxies.js240
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_proxy.js106
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_registry.js73
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_reload.js235
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_schema_change.js317
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_seen.js211
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_seen_newprofile.js41
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_shutdown.js28
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_signed_inject.js382
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_signed_install.js265
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_signed_long.js49
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_signed_migrate.js194
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_signed_multi.js55
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_signed_updatepref.js136
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_signed_verify.js234
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_softblocked.js109
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_sourceURI.js8
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_startup.js83
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_strictcompatibility.js406
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_switch_os.js52
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_syncGUID.js6
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_system_delay_update.js461
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_system_reset.js418
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_system_update.js788
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_temporary.js760
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_theme.js119
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_undothemeuninstall.js10
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_undouninstall.js12
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_update.js2140
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_updateCancel.js10
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_update_compatmode.js8
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_update_ignorecompat.js151
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_update_strictcompat.js1845
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_update_webextensions.js248
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_updatecheck.js472
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_updateid.js448
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_upgrade.js2
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_upgrade_strictcompat.js2
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_webextension.js421
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_webextension_embedded.js306
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_webextension_icons.js169
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js478
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/test_webextension_paths.js55
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini65
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/xpcshell-unpack.ini6
-rw-r--r--toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini26
272 files changed, 6952 insertions, 18396 deletions
diff --git a/toolkit/mozapps/extensions/test/xpcshell/.eslintrc.js b/toolkit/mozapps/extensions/test/xpcshell/.eslintrc.js
deleted file mode 100644
index ba65517f9..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/.eslintrc.js
+++ /dev/null
@@ -1,7 +0,0 @@
-"use strict";
-
-module.exports = { // eslint-disable-line no-undef
- "extends": [
- "../../../../../testing/xpcshell/xpcshell.eslintrc.js"
- ]
-};
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/BootstrapMonitor.jsm b/toolkit/mozapps/extensions/test/xpcshell/data/BootstrapMonitor.jsm
deleted file mode 100644
index 7c1e4aa9d..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/BootstrapMonitor.jsm
+++ /dev/null
@@ -1,30 +0,0 @@
-Components.utils.import("resource://gre/modules/Services.jsm");
-
-this.EXPORTED_SYMBOLS = [ "monitor" ];
-
-function notify(event, originalMethod, data, reason) {
- let info = {
- event,
- data: Object.assign({}, data, {
- installPath: data.installPath.path,
- resourceURI: data.resourceURI.spec,
- }),
- reason
- };
-
- let subject = {wrappedJSObject: {data}};
-
- Services.obs.notifyObservers(subject, "bootstrapmonitor-event", JSON.stringify(info));
-
- // If the bootstrap scope already declares a method call it
- if (originalMethod)
- originalMethod(data, reason);
-}
-
-// Allows a simple one-line bootstrap script:
-// Components.utils.import("resource://xpcshelldata/bootstrapmonitor.jsm").monitor(this);
-this.monitor = function(scope) {
- for (let event of ["install", "startup", "shutdown", "uninstall"]) {
- scope[event] = notify.bind(null, event, scope[event]);
- }
-}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/from_sources/bootstrap.js b/toolkit/mozapps/extensions/test/xpcshell/data/from_sources/bootstrap.js
deleted file mode 100644
index 1666f2972..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/from_sources/bootstrap.js
+++ /dev/null
@@ -1 +0,0 @@
-Components.utils.import("resource://xpcshell-data/BootstrapMonitor.jsm").monitor(this);
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/from_sources/install.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/from_sources/install.rdf
deleted file mode 100644
index f02a3869c..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/from_sources/install.rdf
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0"?>
-
-<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:em="http://www.mozilla.org/2004/em-rdf#">
-
- <Description about="urn:mozilla:install-manifest">
- <em:id>bootstrap1@tests.mozilla.org</em:id>
- <em:version>1.0</em:version>
- <em:bootstrap>true</em:bootstrap>
-
- <!-- Front End MetaData -->
- <em:name>Test Bootstrap 1</em:name>
- <em:description>Test Description</em:description>
-
- <em:iconURL>chrome://foo/skin/icon.png</em:iconURL>
- <em:aboutURL>chrome://foo/content/about.xul</em:aboutURL>
- <em:optionsURL>chrome://foo/content/options.xul</em:optionsURL>
-
- <em:targetApplication>
- <Description>
- <em:id>xpcshell@tests.mozilla.org</em:id>
- <em:minVersion>1</em:minVersion>
- <em:maxVersion>1</em:maxVersion>
- </Description>
- </em:targetApplication>
-
- </Description>
-</RDF>
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/pluginInfoURL_block.xml b/toolkit/mozapps/extensions/test/xpcshell/data/pluginInfoURL_block.xml
index 75e252a46..6c6ce90ef 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/pluginInfoURL_block.xml
+++ b/toolkit/mozapps/extensions/test/xpcshell/data/pluginInfoURL_block.xml
@@ -7,39 +7,15 @@
<pluginItem blockID="test_plugin_wInfoURL">
<match name="name" exp="^test_with_infoURL"/>
<match name="version" exp="^5"/>
- <versionRange>
- <targetApplication id="xpcshell@tests.mozilla.org">
- <versionRange minVersion="1" maxVersion="*"/>
- </targetApplication>
- </versionRange>
<infoURL>http://test.url.com/</infoURL>
</pluginItem>
<pluginItem blockID="test_plugin_wAltInfoURL">
<match name="name" exp="^test_with_altInfoURL"/>
<match name="version" exp="^5"/>
- <versionRange>
- <targetApplication id="xpcshell@tests.mozilla.org">
- <versionRange minVersion="1" maxVersion="*"/>
- </targetApplication>
- </versionRange>
<infoURL>http://alt.test.url.com/</infoURL>
</pluginItem>
<pluginItem blockID="test_plugin_noInfoURL">
<match name="name" exp="^test_no_infoURL"/>
- <versionRange>
- <targetApplication id="xpcshell@tests.mozilla.org">
- <versionRange minVersion="1" maxVersion="*"/>
- </targetApplication>
- </versionRange>
- </pluginItem>
- <pluginItem blockID="test_plugin_newVersion">
- <match name="name" exp="^test_newVersion"/>
- <infoURL>http://test.url2.com/</infoURL>
- <versionRange minVersion="1" maxVersion="2">
- <targetApplication id="xpcshell@tests.mozilla.org">
- <versionRange minVersion="1" maxVersion="*"/>
- </targetApplication>
- </versionRange>
</pluginItem>
</pluginItems>
</blocklist>
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/bad.txt b/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/bad.txt
deleted file mode 100644
index f17f98b15..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/bad.txt
+++ /dev/null
@@ -1 +0,0 @@
-Not an xml file! \ No newline at end of file
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/bad.xml b/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/bad.xml
deleted file mode 100644
index 0e3d415c4..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/bad.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<foobar></barfoo> \ No newline at end of file
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/bad2.xml b/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/bad2.xml
deleted file mode 100644
index 55ad1c7d5..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/bad2.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<test></test>
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/empty.xml b/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/empty.xml
deleted file mode 100644
index 42cb20bd0..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/empty.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<updates>
- <addons></addons>
-</updates>
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/good.xml b/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/good.xml
deleted file mode 100644
index e1da86fa5..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/good.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<updates>
- <addons>
- <addon id="test1" URL="http://example.com/test1.xpi"/>
- <addon id="test2" URL="http://example.com/test2.xpi" hashFunction="md5" hashValue="djhfgsjdhf"/>
- <addon id="test3" URL="http://example.com/test3.xpi" version="1.0" size="45"/>
- <addon id="test4"/>
- <addon URL="http://example.com/test5.xpi"/>
- </addons>
-</updates>
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/missing.xml b/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/missing.xml
deleted file mode 100644
index 8c9501478..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/missing.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<updates></updates>
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/unsigned.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/unsigned.xpi
deleted file mode 100644
index 51b00475a..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/productaddons/unsigned.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_1/bootstrap.js b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_1/bootstrap.js
deleted file mode 100644
index 0cf01d319..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_1/bootstrap.js
+++ /dev/null
@@ -1,29 +0,0 @@
-Components.utils.import("resource://gre/modules/Services.jsm");
-
-const VERSION = 1;
-
-// Test steps chain from pref observers on *_reason,
-// so always set that last
-function install(data, reason) {
- Services.prefs.setIntPref("bootstraptest.installed_version", VERSION);
- Services.prefs.setIntPref("bootstraptest.install_oldversion", data.oldVersion);
- Services.prefs.setIntPref("bootstraptest.install_reason", reason);
-}
-
-function startup(data, reason) {
- Services.prefs.setIntPref("bootstraptest.active_version", VERSION);
- Services.prefs.setIntPref("bootstraptest.startup_oldversion", data.oldVersion);
- Services.prefs.setIntPref("bootstraptest.startup_reason", reason);
-}
-
-function shutdown(data, reason) {
- Services.prefs.setIntPref("bootstraptest.active_version", 0);
- Services.prefs.setIntPref("bootstraptest.shutdown_newversion", data.newVersion);
- Services.prefs.setIntPref("bootstraptest.shutdown_reason", reason);
-}
-
-function uninstall(data, reason) {
- Services.prefs.setIntPref("bootstraptest.installed_version", 0);
- Services.prefs.setIntPref("bootstraptest.uninstall_newversion", data.newVersion);
- Services.prefs.setIntPref("bootstraptest.uninstall_reason", reason);
-}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_1/install.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_1/install.rdf
deleted file mode 100644
index 9d08c357c..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_1/install.rdf
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0"?>
-
-<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:em="http://www.mozilla.org/2004/em-rdf#">
-
- <Description about="urn:mozilla:install-manifest">
- <em:id>test@tests.mozilla.org</em:id>
- <em:version>1.0</em:version>
- <em:bootstrap>true</em:bootstrap>
-
- <!-- Front End MetaData -->
- <em:name>Test Add-on</em:name>
- <em:updateURL>http://localhost:4444/update.rdf</em:updateURL>
-
- <em:targetApplication>
- <Description>
- <em:id>xpcshell@tests.mozilla.org</em:id>
- <em:minVersion>2</em:minVersion>
- <em:maxVersion>5</em:maxVersion>
- </Description>
- </em:targetApplication>
-
- </Description>
-</RDF>
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_1/test.txt b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_1/test.txt
deleted file mode 100644
index 11686f61c..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_1/test.txt
+++ /dev/null
@@ -1 +0,0 @@
-This test file can be altered to break signing checks.
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_2/bootstrap.js b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_2/bootstrap.js
deleted file mode 100644
index 718c82be4..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_2/bootstrap.js
+++ /dev/null
@@ -1,29 +0,0 @@
-Components.utils.import("resource://gre/modules/Services.jsm");
-
-const VERSION = 2;
-
-// Test steps chain from pref observers on *_reason,
-// so always set that last
-function install(data, reason) {
- Services.prefs.setIntPref("bootstraptest.installed_version", VERSION);
- Services.prefs.setIntPref("bootstraptest.install_oldversion", data.oldVersion);
- Services.prefs.setIntPref("bootstraptest.install_reason", reason);
-}
-
-function startup(data, reason) {
- Services.prefs.setIntPref("bootstraptest.active_version", VERSION);
- Services.prefs.setIntPref("bootstraptest.startup_oldversion", data.oldVersion);
- Services.prefs.setIntPref("bootstraptest.startup_reason", reason);
-}
-
-function shutdown(data, reason) {
- Services.prefs.setIntPref("bootstraptest.active_version", 0);
- Services.prefs.setIntPref("bootstraptest.shutdown_newversion", data.newVersion);
- Services.prefs.setIntPref("bootstraptest.shutdown_reason", reason);
-}
-
-function uninstall(data, reason) {
- Services.prefs.setIntPref("bootstraptest.installed_version", 0);
- Services.prefs.setIntPref("bootstraptest.uninstall_newversion", data.newVersion);
- Services.prefs.setIntPref("bootstraptest.uninstall_reason", reason);
-}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_2/install.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_2/install.rdf
deleted file mode 100644
index 0a345dd92..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_2/install.rdf
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0"?>
-
-<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:em="http://www.mozilla.org/2004/em-rdf#">
-
- <Description about="urn:mozilla:install-manifest">
- <em:id>test@tests.mozilla.org</em:id>
- <em:version>2.0</em:version>
- <em:bootstrap>true</em:bootstrap>
-
- <!-- Front End MetaData -->
- <em:name>Test Add-on</em:name>
- <em:updateURL>http://localhost:4444/update.rdf</em:updateURL>
-
- <em:targetApplication>
- <Description>
- <em:id>xpcshell@tests.mozilla.org</em:id>
- <em:minVersion>4</em:minVersion>
- <em:maxVersion>6</em:maxVersion>
- </Description>
- </em:targetApplication>
-
- </Description>
-</RDF>
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_2/test.txt b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_2/test.txt
deleted file mode 100644
index 11686f61c..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/bootstrap_2/test.txt
+++ /dev/null
@@ -1 +0,0 @@
-This test file can be altered to break signing checks.
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/hotfix_badid.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/hotfix_badid.xpi
deleted file mode 100644
index 9d6f0c708..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/hotfix_badid.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/hotfix_broken.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/hotfix_broken.xpi
deleted file mode 100644
index 4496a90cf..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/hotfix_broken.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/hotfix_good.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/hotfix_good.xpi
deleted file mode 100644
index e61e3c721..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/hotfix_good.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_63_hash.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_63_hash.xpi
deleted file mode 100644
index 1682a7506..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_63_hash.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_63_plain.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_63_plain.xpi
deleted file mode 100644
index cd67e25fc..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_63_plain.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_64_hash.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_64_hash.xpi
deleted file mode 100644
index e4040a274..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_64_hash.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_64_plain.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_64_plain.xpi
deleted file mode 100644
index ca453b9d5..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_64_plain.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_65_hash.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_65_hash.xpi
deleted file mode 100644
index 69579d2dc..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/long_65_hash.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/multi_badid.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/multi_badid.xpi
deleted file mode 100644
index 6e23eb214..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/multi_badid.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/multi_broken.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/multi_broken.xpi
deleted file mode 100644
index 0ba0f30d1..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/multi_broken.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/multi_signed.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/multi_signed.xpi
deleted file mode 100644
index 33101f63c..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/multi_signed.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/multi_unsigned.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/multi_unsigned.xpi
deleted file mode 100644
index 3146870d8..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/multi_unsigned.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/nonbootstrap_1/install.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/nonbootstrap_1/install.rdf
deleted file mode 100644
index 97ae60988..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/nonbootstrap_1/install.rdf
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0"?>
-
-<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:em="http://www.mozilla.org/2004/em-rdf#">
-
- <Description about="urn:mozilla:install-manifest">
- <em:id>test@tests.mozilla.org</em:id>
- <em:version>1.0</em:version>
-
- <!-- Front End MetaData -->
- <em:name>Test Add-on</em:name>
- <em:updateURL>http://localhost:4444/update.rdf</em:updateURL>
-
- <em:targetApplication>
- <Description>
- <em:id>xpcshell@tests.mozilla.org</em:id>
- <em:minVersion>2</em:minVersion>
- <em:maxVersion>5</em:maxVersion>
- </Description>
- </em:targetApplication>
-
- </Description>
-</RDF>
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/nonbootstrap_1/test.txt b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/nonbootstrap_1/test.txt
deleted file mode 100644
index 11686f61c..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/nonbootstrap_1/test.txt
+++ /dev/null
@@ -1 +0,0 @@
-This test file can be altered to break signing checks.
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/nonbootstrap_2/install.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/nonbootstrap_2/install.rdf
deleted file mode 100644
index df2fd8081..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/nonbootstrap_2/install.rdf
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0"?>
-
-<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:em="http://www.mozilla.org/2004/em-rdf#">
-
- <Description about="urn:mozilla:install-manifest">
- <em:id>test@tests.mozilla.org</em:id>
- <em:version>2.0</em:version>
-
- <!-- Front End MetaData -->
- <em:name>Test Add-on</em:name>
- <em:updateURL>http://localhost:4444/update.rdf</em:updateURL>
-
- <em:targetApplication>
- <Description>
- <em:id>xpcshell@tests.mozilla.org</em:id>
- <em:minVersion>4</em:minVersion>
- <em:maxVersion>6</em:maxVersion>
- </Description>
- </em:targetApplication>
-
- </Description>
-</RDF>
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/nonbootstrap_2/test.txt b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/nonbootstrap_2/test.txt
deleted file mode 100644
index 11686f61c..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/nonbootstrap_2/test.txt
+++ /dev/null
@@ -1 +0,0 @@
-This test file can be altered to break signing checks.
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/preliminary_bootstrap_2.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/preliminary_bootstrap_2.xpi
deleted file mode 100644
index ec38fcc65..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/preliminary_bootstrap_2.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_bootstrap_1.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_bootstrap_1.xpi
deleted file mode 100644
index fc2842399..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_bootstrap_1.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_bootstrap_2.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_bootstrap_2.xpi
deleted file mode 100644
index 327c8a187..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_bootstrap_2.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_bootstrap_badid_2.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_bootstrap_badid_2.xpi
deleted file mode 100644
index efad21d1b..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_bootstrap_badid_2.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_nonbootstrap_2.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_nonbootstrap_2.xpi
deleted file mode 100644
index d6ddbcec3..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_nonbootstrap_2.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_nonbootstrap_badid_2.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_nonbootstrap_badid_2.xpi
deleted file mode 100644
index 5898d83e4..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/signed_nonbootstrap_badid_2.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/unsigned_bootstrap_2.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/unsigned_bootstrap_2.xpi
deleted file mode 100644
index 9d50f0825..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/unsigned_bootstrap_2.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/unsigned_nonbootstrap_2.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/unsigned_nonbootstrap_2.xpi
deleted file mode 100644
index 6ba1efd72..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/signing_checks/unsigned_nonbootstrap_2.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/bootstrap.js b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/bootstrap.js
deleted file mode 100644
index 1666f2972..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/bootstrap.js
+++ /dev/null
@@ -1 +0,0 @@
-Components.utils.import("resource://xpcshell-data/BootstrapMonitor.jsm").monitor(this);
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system1_1.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system1_1.xpi
deleted file mode 100644
index 2fc2fd189..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system1_1.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system1_1_badcert.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system1_1_badcert.xpi
deleted file mode 100644
index e7e50c8ea..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system1_1_badcert.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system1_2.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system1_2.xpi
deleted file mode 100644
index a858cf74a..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system1_2.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system2_1.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system2_1.xpi
deleted file mode 100644
index 911632e49..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system2_1.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system2_2.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system2_2.xpi
deleted file mode 100644
index 102a053bb..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system2_2.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system2_3.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system2_3.xpi
deleted file mode 100644
index 295e77611..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system2_3.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system3_1.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system3_1.xpi
deleted file mode 100644
index 954995619..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system3_1.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system3_2.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system3_2.xpi
deleted file mode 100644
index dc8632aef..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system3_2.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system3_3.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system3_3.xpi
deleted file mode 100644
index 3f818172a..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system3_3.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system4_1.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system4_1.xpi
deleted file mode 100644
index 1f70b1a75..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system4_1.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system5_1.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system5_1.xpi
deleted file mode 100644
index fc636e97f..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system5_1.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system6_1_unpack.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system6_1_unpack.xpi
deleted file mode 100644
index ff620966d..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system6_1_unpack.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system6_2_notBootstrap.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system6_2_notBootstrap.xpi
deleted file mode 100644
index e474dbd59..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system6_2_notBootstrap.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system6_3_notMultiprocess.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system6_3_notMultiprocess.xpi
deleted file mode 100644
index 1ccde90c5..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system6_3_notMultiprocess.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_complete.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_complete.xpi
deleted file mode 100644
index 94d9e47d2..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_complete.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_complete_2.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_complete_2.xpi
deleted file mode 100644
index 28c8561c6..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_complete_2.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_defer.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_defer.xpi
deleted file mode 100644
index daf55c0d4..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_defer.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_defer_2.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_defer_2.xpi
deleted file mode 100644
index 75cacbbc8..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_defer_2.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_defer_also.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_defer_also.xpi
deleted file mode 100644
index 2eb6b7fc9..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_defer_also.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_defer_also_2.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_defer_also_2.xpi
deleted file mode 100644
index fb588b3e0..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_defer_also_2.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_ignore.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_ignore.xpi
deleted file mode 100644
index 7a5eb265d..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_ignore.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_ignore_2.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_ignore_2.xpi
deleted file mode 100644
index dc6749355..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_delay_ignore_2.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_failed_update.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_failed_update.xpi
deleted file mode 100644
index 3c673ac2e..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/system_addons/system_failed_update.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_update_complete/bootstrap.js b/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_update_complete/bootstrap.js
deleted file mode 100644
index a81c90bf0..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_update_complete/bootstrap.js
+++ /dev/null
@@ -1,24 +0,0 @@
-Components.utils.import("resource://gre/modules/Services.jsm");
-Components.utils.import("resource://gre/modules/AddonManager.jsm");
-
-const ADDON_ID = "test_delay_update_complete@tests.mozilla.org";
-const INSTALL_COMPLETE_PREF = "bootstraptest.install_complete_done";
-
-function install(data, reason) {}
-
-// normally we would use BootstrapMonitor here, but we need a reference to
-// the symbol inside `XPIProvider.jsm`.
-function startup(data, reason) {
- // apply update immediately
- if (data.hasOwnProperty("instanceID") && data.instanceID) {
- AddonManager.addUpgradeListener(data.instanceID, (upgrade) => {
- upgrade.install();
- });
- } else {
- throw Error("no instanceID passed to bootstrap startup");
- }
-}
-
-function shutdown(data, reason) {}
-
-function uninstall(data, reason) {}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_update_defer/bootstrap.js b/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_update_defer/bootstrap.js
deleted file mode 100644
index 25ffd8565..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_update_defer/bootstrap.js
+++ /dev/null
@@ -1,34 +0,0 @@
-Components.utils.import("resource://gre/modules/Services.jsm");
-Components.utils.import("resource://gre/modules/AddonManager.jsm");
-
-const ADDON_ID = "test_delay_update_complete@tests.mozilla.org";
-const INSTALL_COMPLETE_PREF = "bootstraptest.install_complete_done";
-
-// global reference to hold upgrade object
-let gUpgrade;
-
-function install(data, reason) {}
-
-// normally we would use BootstrapMonitor here, but we need a reference to
-// the symbol inside `XPIProvider.jsm`.
-function startup(data, reason) {
- // do not apply update immediately, hold on to for later
- if (data.hasOwnProperty("instanceID") && data.instanceID) {
- AddonManager.addUpgradeListener(data.instanceID, (upgrade) => {
- gUpgrade = upgrade;
- });
- } else {
- throw Error("no instanceID passed to bootstrap startup");
- }
-
- // add a listener so the test can pass control back
- AddonManager.addAddonListener({
- onFakeEvent: () => {
- gUpgrade.install();
- }
- })
-}
-
-function shutdown(data, reason) {}
-
-function uninstall(data, reason) {}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_update_ignore/bootstrap.js b/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_update_ignore/bootstrap.js
deleted file mode 100644
index 7693c9c2d..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_update_ignore/bootstrap.js
+++ /dev/null
@@ -1,26 +0,0 @@
-Components.utils.import("resource://gre/modules/Services.jsm");
-Components.utils.import("resource://gre/modules/AddonManager.jsm");
-
-const ADDON_ID = "test_delay_update_ignore@tests.mozilla.org";
-const TEST_IGNORE_PREF = "delaytest.ignore";
-
-function install(data, reason) {}
-
-// normally we would use BootstrapMonitor here, but we need a reference to
-// the symbol inside `XPIProvider.jsm`.
-function startup(data, reason) {
- Services.prefs.setBoolPref(TEST_IGNORE_PREF, false);
-
- // explicitly ignore update, will be queued for next restart
- if (data.hasOwnProperty("instanceID") && data.instanceID) {
- AddonManager.addUpgradeListener(data.instanceID, (upgrade) => {
- Services.prefs.setBoolPref(TEST_IGNORE_PREF, true);
- });
- } else {
- throw Error("no instanceID passed to bootstrap startup");
- }
-}
-
-function shutdown(data, reason) {}
-
-function uninstall(data, reason) {}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_complete.json b/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_complete.json
deleted file mode 100644
index cf3defdc7..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_complete.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "addons": {
- "test_delay_update_complete_webext@tests.mozilla.org": {
- "updates": [
- { "version": "2.0",
- "update_link": "http://localhost:%PORT%/addons/test_delay_update_complete_webextension_v2.xpi"
- }
- ]
- }
- }
-}
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 8af39cb0e..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_complete.rdf
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:em="http://www.mozilla.org/2004/em-rdf#">
-
- <Description about="urn:mozilla:extension:test_delay_update_complete@tests.mozilla.org">
- <em:updates>
- <Seq>
- <!-- app id compatible update available -->
- <li>
- <Description>
- <em:version>2.0</em:version>
- <em:targetApplication>
- <Description>
- <em:id>xpcshell@tests.mozilla.org</em:id>
- <em:minVersion>1</em:minVersion>
- <em:maxVersion>1</em:maxVersion>
- <em:updateLink>http://localhost:%PORT%/addons/test_delay_update_complete_v2.xpi</em:updateLink>
- </Description>
- </em:targetApplication>
- </Description>
- </li>
- </Seq>
- </em:updates>
- </Description>
-</RDF>
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_defer.json b/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_defer.json
deleted file mode 100644
index 2fcab10b5..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_defer.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "addons": {
- "test_delay_update_defer_webext@tests.mozilla.org": {
- "updates": [
- { "version": "2.0",
- "update_link": "http://localhost:%PORT%/addons/test_delay_update_defer_webextension_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 d44d4880f..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_defer.rdf
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:em="http://www.mozilla.org/2004/em-rdf#">
-
- <Description about="urn:mozilla:extension:test_delay_update_defer@tests.mozilla.org">
- <em:updates>
- <Seq>
- <!-- app id compatible update available -->
- <li>
- <Description>
- <em:version>2.0</em:version>
- <em:targetApplication>
- <Description>
- <em:id>xpcshell@tests.mozilla.org</em:id>
- <em:minVersion>1</em:minVersion>
- <em:maxVersion>1</em:maxVersion>
- <em:updateLink>http://localhost:%PORT%/addons/test_delay_update_defer_v2.xpi</em:updateLink>
- </Description>
- </em:targetApplication>
- </Description>
- </li>
- </Seq>
- </em:updates>
- </Description>
-</RDF>
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_ignore.json b/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_ignore.json
deleted file mode 100644
index b7f48149d..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_ignore.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "addons": {
- "test_delay_update_ignore_webext@tests.mozilla.org": {
- "updates": [
- { "version": "2.0",
- "update_link": "http://localhost:%PORT%/addons/test_delay_update_ignore_webextension_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 866884f8d..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_delay_updates_ignore.rdf
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:em="http://www.mozilla.org/2004/em-rdf#">
-
- <Description about="urn:mozilla:extension:test_delay_update_ignore@tests.mozilla.org">
- <em:updates>
- <Seq>
- <!-- app id compatible update available -->
- <li>
- <Description>
- <em:version>2.0</em:version>
- <em:targetApplication>
- <Description>
- <em:id>xpcshell@tests.mozilla.org</em:id>
- <em:minVersion>1</em:minVersion>
- <em:maxVersion>1</em:maxVersion>
- <em:updateLink>http://localhost:%PORT%/addons/test_delay_update_ignore_v2.xpi</em:updateLink>
- </Description>
- </em:targetApplication>
- </Description>
- </li>
- </Seq>
- </em:updates>
- </Description>
-</RDF>
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_gfxBlacklist.xml b/toolkit/mozapps/extensions/test/xpcshell/data/test_gfxBlacklist.xml
index d535d2c3f..639f2d20f 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_gfxBlacklist.xml
+++ b/toolkit/mozapps/extensions/test/xpcshell/data/test_gfxBlacklist.xml
@@ -2,7 +2,7 @@
<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist">
<gfxItems>
- <gfxBlacklistEntry blockID="g35">
+ <gfxBlacklistEntry>
<os>WINNT 6.1</os>
<vendor>0xabcd</vendor>
<devices>
@@ -28,7 +28,7 @@
<driverVersion> 8.52.322.2202 </driverVersion>
<driverVersionComparator> LESS_THAN </driverVersionComparator>
</gfxBlacklistEntry>
- <gfxBlacklistEntry blockID="g36">
+ <gfxBlacklistEntry>
<os>WINNT 6.1</os>
<vendor>0xabab</vendor>
<devices>
@@ -55,7 +55,7 @@
<driverVersionComparator> EQUAL </driverVersionComparator>
</gfxBlacklistEntry>
<gfxBlacklistEntry>
- <os>Darwin 13</os>
+ <os>Darwin 9</os>
<vendor>0xabcd</vendor>
<devices>
<device>0x2783</device>
@@ -124,7 +124,7 @@
<featureStatus> BLOCKED_DEVICE </featureStatus>
</gfxBlacklistEntry>
<gfxBlacklistEntry>
- <os>Darwin 13</os>
+ <os>Darwin 9</os>
<vendor>0xabcd</vendor>
<devices>
<device>0x6666</device>
@@ -150,155 +150,5 @@
<feature> DIRECT2D </feature>
<featureStatus> BLOCKED_DEVICE </featureStatus>
</gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>All</os>
- <vendor>0xdcdc</vendor>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> DIRECT3D_11_LAYERS </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- <driverVersion> 8.52.322.1112 </driverVersion>
- <driverVersionMax> 8.52.323.1000 </driverVersionMax>
- <driverVersionComparator> BETWEEN_EXCLUSIVE </driverVersionComparator>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>All</os>
- <vendor>0xdcdc</vendor>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> OPENGL_LAYERS </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- <driverVersion> 8.50.322.1000 </driverVersion>
- <driverVersionMax> 8.52.322.1112 </driverVersionMax>
- <driverVersionComparator> BETWEEN_EXCLUSIVE </driverVersionComparator>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>All</os>
- <vendor>0xdcdc</vendor>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> DIRECT3D_11_ANGLE </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- <driverVersion> 8.52.322.1000 </driverVersion>
- <driverVersionMax> 9.52.322.1000 </driverVersionMax>
- <driverVersionComparator> BETWEEN_EXCLUSIVE </driverVersionComparator>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>All</os>
- <vendor>0xdcdc</vendor>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> HARDWARE_VIDEO_DECODING </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- <driverVersion> 7.82.322.1000 </driverVersion>
- <driverVersionMax> 9.25.322.1001 </driverVersionMax>
- <driverVersionComparator> BETWEEN_INCLUSIVE </driverVersionComparator>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>All</os>
- <vendor>0xdcdc</vendor>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> WEBRTC_HW_ACCELERATION </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- <driverVersion> 8.52.322.1112 </driverVersion>
- <driverVersionMax> 9.52.322.1300 </driverVersionMax>
- <driverVersionComparator> BETWEEN_INCLUSIVE </driverVersionComparator>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>All</os>
- <vendor>0xdcdc</vendor>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> WEBRTC_HW_ACCELERATION_DECODE </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- <driverVersion> 8.52.322.1000 </driverVersion>
- <driverVersionMax> 8.52.322.1112 </driverVersionMax>
- <driverVersionComparator> BETWEEN_INCLUSIVE </driverVersionComparator>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>All</os>
- <vendor>0xdcdc</vendor>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> WEBRTC_HW_ACCELERATION_ENCODE </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- <driverVersion> 8.52.322.1112 </driverVersion>
- <driverVersionMax> 8.52.322.1200 </driverVersionMax>
- <driverVersionComparator> BETWEEN_INCLUSIVE_START </driverVersionComparator>
- </gfxBlacklistEntry>
- <gfxBlacklistEntry>
- <os>All</os>
- <vendor>0xdcdc</vendor>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> WEBGL_MSAA </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- <driverVersion> 8.52.322.1000 </driverVersion>
- <driverVersionMax> 8.52.322.1200 </driverVersionMax>
- <driverVersionComparator> BETWEEN_INCLUSIVE_START </driverVersionComparator>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>All</os>
- <vendor>0xdcdc</vendor>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> WEBGL_ANGLE </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- <driverVersion> 8.52.322.1000 </driverVersion>
- <driverVersionMax> 8.52.322.1112 </driverVersionMax>
- <driverVersionComparator> BETWEEN_INCLUSIVE_START </driverVersionComparator>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>All</os>
- <vendor>0xdcdc</vendor>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> CANVAS2D_ACCELERATION </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- <driverVersion> 8.52.322.1000 </driverVersion>
- <driverVersionMax> 9.52.322.1000 </driverVersionMax>
- <driverVersionComparator> BETWEEN_EXCLUSIVE </driverVersionComparator>
- </gfxBlacklistEntry>
-
</gfxItems>
</blocklist>
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_gfxBlacklist_AllOS.xml b/toolkit/mozapps/extensions/test/xpcshell/data/test_gfxBlacklist_AllOS.xml
index f64676355..22af6f712 100755..100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_gfxBlacklist_AllOS.xml
+++ b/toolkit/mozapps/extensions/test/xpcshell/data/test_gfxBlacklist_AllOS.xml
@@ -2,399 +2,9 @@
<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist">
<gfxItems>
-
- <gfxBlacklistEntry blockID="g1">
- <os>All</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="15.0" maxVersion="15.0"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> DIRECT2D </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry blockID="g2">
- <os>All</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="15.0" maxVersion="22.0a1"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> DIRECT3D_9_LAYERS </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>All</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="16.0a1"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> DIRECT3D_10_LAYERS</feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>All</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="16.0a1" maxVersion="22.0"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> DIRECT3D_10_1_LAYERS </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>All</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="12.0" maxVersion="16.0"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> OPENGL_LAYERS </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry blockID="g11">
- <os>All</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="14.0b2" maxVersion="15.0"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> WEBGL_OPENGL </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>All</os>
- <vendor>0xabcd</vendor>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> WEBGL_ANGLE </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>All</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="12.0" maxVersion="16.0"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> WEBGL_MSAA </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>All</os>
- <vendor>0xabcd</vendor>
- <versionRange maxVersion="13.0"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> STAGEFRIGHT </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>All</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="42.0" maxVersion="13.0b2"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> WEBRTC_HW_ACCELERATION </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>All</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="42.0" maxVersion="13.0b2"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> WEBRTC_HW_ACCELERATION_ENCODE </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>All</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="42.0" maxVersion="13.0b2"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> WEBRTC_HW_ACCELERATION_DECODE </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>All</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="17.2a2" maxVersion="15.0"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> DIRECT3D_11_LAYERS </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>All</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="15.0" maxVersion="13.2"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> HARDWARE_VIDEO_DECODING </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
<gfxBlacklistEntry>
<os>All</os>
<vendor>0xabcd</vendor>
- <versionRange minVersion="10.5" maxVersion="13.0"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> DIRECT3D_11_ANGLE </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry blockID="g1">
- <os>Darwin 13</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="15.0" maxVersion="15.0"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> DIRECT2D </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry blockID="g2">
- <os>Darwin 13</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="15.0" maxVersion="22.0a1"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> DIRECT3D_9_LAYERS </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Darwin 13</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="16.0a1"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> DIRECT3D_10_LAYERS</feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Darwin 13</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="16.0a1" maxVersion="22.0"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> DIRECT3D_10_1_LAYERS </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Darwin 13</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="12.0" maxVersion="16.0"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> OPENGL_LAYERS </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry blockID="g11">
- <os>Darwin 13</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="14.0b2" maxVersion="15.0"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> WEBGL_OPENGL </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Darwin 13</os>
- <vendor>0xabcd</vendor>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> WEBGL_ANGLE </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Darwin 13</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="12.0" maxVersion="16.0"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> WEBGL_MSAA </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Darwin 13</os>
- <vendor>0xabcd</vendor>
- <versionRange maxVersion="13.0"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> STAGEFRIGHT </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Darwin 13</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="42.0" maxVersion="13.0b2"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> WEBRTC_HW_ACCELERATION </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Darwin 13</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="42.0" maxVersion="13.0b2"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> WEBRTC_HW_ACCELERATION_ENCODE </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Darwin 13</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="42.0" maxVersion="13.0b2"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> WEBRTC_HW_ACCELERATION_DECODE </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Darwin 13</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="17.2a2" maxVersion="15.0"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> DIRECT3D_11_LAYERS </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Darwin 13</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="15.0" maxVersion="13.2"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> HARDWARE_VIDEO_DECODING </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Darwin 13</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="10.5" maxVersion="13.0"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> DIRECT3D_11_ANGLE </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry blockID="g1">
- <os>Linux</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="15.0" maxVersion="15.0"/>
<devices>
<device>0x2783</device>
<device>0x1234</device>
@@ -402,206 +12,12 @@
</devices>
<feature> DIRECT2D </feature>
<featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
+ <driverVersion> 8.52.322.2202 </driverVersion>
+ <driverVersionComparator> LESS_THAN </driverVersionComparator>
</gfxBlacklistEntry>
-
- <gfxBlacklistEntry blockID="g2">
- <os>Linux</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="15.0" maxVersion="22.0a1"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> DIRECT3D_9_LAYERS </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Linux</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="16.0a1"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> DIRECT3D_10_LAYERS</feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Linux</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="16.0a1" maxVersion="22.0"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> DIRECT3D_10_1_LAYERS </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Linux</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="12.0" maxVersion="16.0"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> OPENGL_LAYERS </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry blockID="g11">
- <os>Linux</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="14.0b2" maxVersion="15.0"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> WEBGL_OPENGL </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Linux</os>
- <vendor>0xabcd</vendor>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> WEBGL_ANGLE </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Linux</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="12.0" maxVersion="16.0"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> WEBGL_MSAA </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Linux</os>
- <vendor>0xabcd</vendor>
- <versionRange maxVersion="13.0"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> STAGEFRIGHT </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Linux</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="42.0" maxVersion="13.0b2"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> WEBRTC_HW_ACCELERATION </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Linux</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="42.0" maxVersion="13.0b2"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> WEBRTC_HW_ACCELERATION_ENCODE </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
<gfxBlacklistEntry>
- <os>Linux</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="42.0" maxVersion="13.0b2"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> WEBRTC_HW_ACCELERATION_DECODE </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Linux</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="17.2a2" maxVersion="15.0"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> DIRECT3D_11_LAYERS </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Linux</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="15.0" maxVersion="13.2"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> HARDWARE_VIDEO_DECODING </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Linux</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="10.5" maxVersion="13.0"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> DIRECT3D_11_ANGLE </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry blockID="g1">
- <os>Android</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="15.0" maxVersion="15.0"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> DIRECT2D </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry blockID="g2">
- <os>Android</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="15.0" maxVersion="22.0a1"/>
+ <os>WINNT 6.0</os>
+ <vendor>0xdcba</vendor>
<devices>
<device>0x2783</device>
<device>0x1234</device>
@@ -609,175 +25,8 @@
</devices>
<feature> DIRECT3D_9_LAYERS </feature>
<featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
+ <driverVersion> 8.52.322.2202 </driverVersion>
+ <driverVersionComparator> LESS_THAN </driverVersionComparator>
</gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Android</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="16.0a1"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> DIRECT3D_10_LAYERS</feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Android</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="16.0a1" maxVersion="22.0"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> DIRECT3D_10_1_LAYERS </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Android</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="12.0" maxVersion="16.0"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> OPENGL_LAYERS </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry blockID="g11">
- <os>Android</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="14.0b2" maxVersion="15.0"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> WEBGL_OPENGL </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Android</os>
- <vendor>0xabcd</vendor>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> WEBGL_ANGLE </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Android</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="12.0" maxVersion="16.0"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> WEBGL_MSAA </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Android</os>
- <vendor>0xabcd</vendor>
- <versionRange maxVersion="13.0"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> STAGEFRIGHT </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Android</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="42.0" maxVersion="13.0b2"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> WEBRTC_HW_ACCELERATION </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Android</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="42.0" maxVersion="13.0b2"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> WEBRTC_HW_ACCELERATION_ENCODE </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Android</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="42.0" maxVersion="13.0b2"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> WEBRTC_HW_ACCELERATION_DECODE </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Android</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="17.2a2" maxVersion="15.0"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> DIRECT3D_11_LAYERS </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Android</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="15.0" maxVersion="13.2"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> HARDWARE_VIDEO_DECODING </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
- <gfxBlacklistEntry>
- <os>Android</os>
- <vendor>0xabcd</vendor>
- <versionRange minVersion="10.5" maxVersion="13.0"/>
- <devices>
- <device>0x2783</device>
- <device>0x1234</device>
- <device>0x2782</device>
- </devices>
- <feature> DIRECT3D_11_ANGLE </feature>
- <featureStatus> BLOCKED_DRIVER_VERSION </featureStatus>
- </gfxBlacklistEntry>
-
</gfxItems>
</blocklist>
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_gfxBlacklist_OSVersion.xml b/toolkit/mozapps/extensions/test/xpcshell/data/test_gfxBlacklist_OSVersion.xml
index 248868a2e..463207d14 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_gfxBlacklist_OSVersion.xml
+++ b/toolkit/mozapps/extensions/test/xpcshell/data/test_gfxBlacklist_OSVersion.xml
@@ -16,7 +16,7 @@
<driverVersionComparator> LESS_THAN </driverVersionComparator>
</gfxBlacklistEntry>
<gfxBlacklistEntry>
- <os>Darwin 13</os>
+ <os>Darwin 12</os>
<vendor>0xabcd</vendor>
<devices>
<device>0x2783</device>
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_hotfix_1.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/test_hotfix_1.rdf
deleted file mode 100644
index 016726021..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_hotfix_1.rdf
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-
-<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:em="http://www.mozilla.org/2004/em-rdf#">
-
- <Description about="urn:mozilla:extension:hotfix@tests.mozilla.org">
- <em:updates>
- <Seq>
- <li>
- <Description>
- <em:version>1.0</em:version>
- <em:targetApplication>
- <Description>
- <em:id>xpcshell@tests.mozilla.org</em:id>
- <em:minVersion>1</em:minVersion>
- <em:maxVersion>1</em:maxVersion>
- <em:updateLink>http://localhost:%PORT%/addons/test_hotfix_1.xpi</em:updateLink>
- </Description>
- </em:targetApplication>
- </Description>
- </li>
- </Seq>
- </em:updates>
- </Description>
-
-</RDF>
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_hotfix_2.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/test_hotfix_2.rdf
deleted file mode 100644
index 35a2befee..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_hotfix_2.rdf
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-
-<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:em="http://www.mozilla.org/2004/em-rdf#">
-
- <Description about="urn:mozilla:extension:hotfix@tests.mozilla.org">
- <em:updates>
- <Seq>
- <li>
- <Description>
- <em:version>2.0</em:version>
- <em:targetApplication>
- <Description>
- <em:id>xpcshell@tests.mozilla.org</em:id>
- <em:minVersion>1</em:minVersion>
- <em:maxVersion>1</em:maxVersion>
- <em:updateLink>http://localhost:%PORT%/addons/test_hotfix_2.xpi</em:updateLink>
- </Description>
- </em:targetApplication>
- </Description>
- </li>
- </Seq>
- </em:updates>
- </Description>
-
-</RDF>
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_hotfix_3.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/test_hotfix_3.rdf
deleted file mode 100644
index 7180da143..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_hotfix_3.rdf
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-
-<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:em="http://www.mozilla.org/2004/em-rdf#">
-
- <Description about="urn:mozilla:extension:hotfix@tests.mozilla.org">
- <em:updates>
- <Seq>
- <li>
- <Description>
- <em:version>3.0</em:version>
- <em:targetApplication>
- <Description>
- <em:id>xpcshell@tests.mozilla.org</em:id>
- <em:minVersion>2</em:minVersion>
- <em:maxVersion>2</em:maxVersion>
- <em:updateLink>http://localhost:%PORT%/addons/test_hotfix_3.xpi</em:updateLink>
- </Description>
- </em:targetApplication>
- </Description>
- </li>
- </Seq>
- </em:updates>
- </Description>
-
-</RDF>
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_install.xml b/toolkit/mozapps/extensions/test/xpcshell/data/test_install.xml
index 33f14a2fd..5f0aab75f 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_install.xml
+++ b/toolkit/mozapps/extensions/test/xpcshell/data/test_install.xml
@@ -17,7 +17,7 @@
<compatible_applications>
<application>
<name>Firefox</name>
- <appID>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</appID>
+ <appID>{8de7fcbb-c55c-4fbe-bfc5-fc555c87dbc4}</appID>
<min_version>0</min_version>
<max_version>*</max_version>
</application>
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_no_update.json b/toolkit/mozapps/extensions/test/xpcshell/data/test_no_update.json
deleted file mode 100644
index 2773c7f98..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_no_update.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "addons": {
- "test_no_update_webext@tests.mozilla.org": {
- "updates": []
- }
- }
-}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_proxy/bootstrap.js b/toolkit/mozapps/extensions/test/xpcshell/data/test_proxy/bootstrap.js
deleted file mode 100644
index 1666f2972..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_proxy/bootstrap.js
+++ /dev/null
@@ -1 +0,0 @@
-Components.utils.import("resource://xpcshell-data/BootstrapMonitor.jsm").monitor(this);
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_softblocked1.xml b/toolkit/mozapps/extensions/test/xpcshell/data/test_softblocked1.xml
deleted file mode 100644
index a1d18470c..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_softblocked1.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist">
- <emItems>
- <emItem id="softblock1@tests.mozilla.org">
- <versionRange severity="1"/>
- </emItem>
- </emItems>
-</blocklist>
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_temporary/bootstrap.js b/toolkit/mozapps/extensions/test/xpcshell/data/test_temporary/bootstrap.js
deleted file mode 100644
index 1666f2972..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_temporary/bootstrap.js
+++ /dev/null
@@ -1 +0,0 @@
-Components.utils.import("resource://xpcshell-data/BootstrapMonitor.jsm").monitor(this);
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_update.json b/toolkit/mozapps/extensions/test/xpcshell/data/test_update.json
deleted file mode 100644
index 027a9b233..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_update.json
+++ /dev/null
@@ -1,215 +0,0 @@
-{
- "addons": {
- "addon1@tests.mozilla.org": {
- "updates": [
- {
- "version": "1.0",
- "applications": {
- "gecko": {
- "strict_min_version": "1",
- "strict_min_version": "1"
- }
- }
- },
- {
- "version": "1.0",
- "applications": {
- "gecko": {
- "strict_min_version": "2",
- "strict_min_version": "2"
- }
- }
- },
- {
- "version": "2.0",
- "update_link": "http://localhost:%PORT%/addons/test_update.xpi",
- "update_info_url": "http://example.com/updateInfo.xhtml",
- "applications": {
- "gecko": {
- "strict_min_version": "1",
- "strict_min_version": "1"
- }
- }
- }
- ]
- },
-
- "addon2@tests.mozilla.org": {
- "updates": [
- {
- "version": "1.0",
- "applications": {
- "gecko": {
- "strict_min_version": "0",
- "advisory_max_version": "1"
- }
- }
- }
- ]
- },
-
- "addon2@tests.mozilla.org": {
- "updates": [
- {
- "version": "1.0",
- "applications": {
- "gecko": {
- "strict_min_version": "0",
- "advisory_max_version": "1"
- }
- }
- }
- ]
- },
-
- "addon3@tests.mozilla.org": {
- "updates": [
- {
- "version": "1.0",
- "applications": {
- "gecko": {
- "strict_min_version": "3",
- "advisory_max_version": "3"
- }
- }
- }
- ]
- },
-
- "addon4@tests.mozilla.org": {
- "updates": [
- {
- "version": "5.0",
- "applications": {
- "gecko": {
- "strict_min_version": "0",
- "advisory_max_version": "0"
- }
- }
- }
- ]
- },
-
- "addon7@tests.mozilla.org": {
- "updates": [
- {
- "version": "1.0",
- "applications": {
- "gecko": {
- "strict_min_version": "0",
- "advisory_max_version": "1"
- }
- }
- }
- ]
- },
-
- "addon8@tests.mozilla.org": {
- "updates": [
- {
- "version": "2.0",
- "update_link": "http://localhost:%PORT%/addons/test_update8.xpi",
- "applications": {
- "gecko": {
- "strict_min_version": "1",
- "advisory_max_version": "1"
- }
- }
- }
- ]
- },
-
- "addon9@tests.mozilla.org": {
- "updates": [
- {
- "version": "2.0",
- "update_link": "http://localhost:%PORT%/addons/test_update9_2.xpi",
- "applications": {
- "gecko": {
- "strict_min_version": "1",
- "advisory_max_version": "1"
- }
- }
- },
- {
- "_comment_": "Incompatible when strict compatibility is enabled",
- "version": "3.0",
- "update_link": "http://localhost:%PORT%/addons/test_update9_3.xpi",
- "applications": {
- "gecko": {
- "strict_min_version": "0.9",
- "advisory_max_version": "0.9"
- }
- }
- },
- {
- "_comment_": "Incompatible due to compatibility override",
- "version": "4.0",
- "update_link": "http://localhost:%PORT%/addons/test_update9_4.xpi",
- "applications": {
- "gecko": {
- "strict_min_version": "0.9",
- "advisory_max_version": "0.9"
- }
- }
- },
- {
- "_comment_": "Addon for future version of app",
- "version": "4.0",
- "update_link": "http://localhost:%PORT%/addons/test_update9_5.xpi",
- "applications": {
- "gecko": {
- "strict_min_version": "5",
- "advisory_max_version": "6"
- }
- }
- }
- ]
- },
-
- "addon10@tests.mozilla.org": {
- "updates": [
- {
- "version": "1.0",
- "update_link": "http://localhost:%PORT%/addons/test_update10.xpi",
- "applications": {
- "gecko": {
- "strict_min_version": "0.1",
- "advisory_max_version": "0.4"
- }
- }
- }
- ]
- },
-
- "addon11@tests.mozilla.org": {
- "updates": [
- {
- "version": "2.0",
- "update_link": "http://localhost:%PORT%/addons/test_update11.xpi",
- "applications": {
- "gecko": {
- "strict_min_version": "0.1",
- "strict_max_version": "0.2"
- }
- }
- }
- ]
- },
-
- "addon12@tests.mozilla.org": {
- "updates": [
- {
- "version": "2.0",
- "update_link": "http://localhost:%PORT%/addons/test_update12.xpi",
- "applications": {
- "gecko": {
- "strict_min_version": "1",
- "advisory_max_version": "1"
- }
- }
- }
- ]
- }
- }
-}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_update_multi.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/test_update_multi.rdf
deleted file mode 100644
index f28a3f26d..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_update_multi.rdf
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:em="http://www.mozilla.org/2004/em-rdf#">
-
- <Description about="urn:mozilla:extension:updatemulti@tests.mozilla.org">
- <em:updates>
- <Seq>
- <li>
- <Description>
- <em:version>2.0</em:version>
- <em:targetApplication>
- <Description>
- <em:id>xpcshell@tests.mozilla.org</em:id>
- <em:minVersion>1</em:minVersion>
- <em:maxVersion>1</em:maxVersion>
- <em:updateLink>http://localhost:4444/addons/test_update_multi2.xpi</em:updateLink>
- </Description>
- </em:targetApplication>
- </Description>
- </li>
- </Seq>
- </em:updates>
- </Description>
-
-</RDF>
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecheck.json b/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecheck.json
deleted file mode 100644
index 811e50158..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecheck.json
+++ /dev/null
@@ -1,327 +0,0 @@
-{
- "addons": {
- "updatecheck1@tests.mozilla.org": {
- "updates": [
- {
- "version": "1.0",
- "update_link": "https://localhost:4444/addons/test1.xpi",
- "applications": {
- "gecko": {
- "strict_min_version": "1",
- "strict_max_version": "1"
- }
- }
- },
- {
- "_comment_": "This update is incompatible and so should not be considered a valid update",
- "version": "2.0",
- "update_link": "https://localhost:4444/addons/test2.xpi",
- "applications": {
- "gecko": {
- "strict_min_version": "2",
- "strict_max_version": "2"
- }
- }
- },
- {
- "version": "3.0",
- "update_link": "https://localhost:4444/addons/test3.xpi",
- "applications": {
- "gecko": {
- "strict_min_version": "1",
- "strict_max_version": "1"
- }
- }
- },
- {
- "version": "2.0",
- "update_link": "https://localhost:4444/addons/test2.xpi",
- "applications": {
- "gecko": {
- "strict_min_version": "1",
- "strict_max_version": "2"
- }
- }
- },
- {
- "_comment_": "This update is incompatible and so should not be considered a valid update",
- "version": "4.0",
- "update_link": "https://localhost:4444/addons/test4.xpi",
- "applications": {
- "gecko": {
- "strict_min_version": "2",
- "strict_max_version": "2"
- }
- }
- }
- ]
- },
-
- "test_bug378216_5@tests.mozilla.org": {
- "_comment_": "An update which expects a signature. It will fail since signatures are ",
- "_comment_": "supported in this format.",
- "_comment_": "The updateLink will also be ignored since it is not secure and there ",
- "_comment_": "is no updateHash.",
-
- "updates": [
- {
- "version": "2.0",
- "update_link": "http://localhost:4444/broken.xpi",
- "applications": {
- "gecko": {
- "strict_min_version": "1",
- "strict_max_version": "1"
- }
- }
- }
- ]
- },
-
- "test_bug378216_5@tests.mozilla.org": {
- "updates": [
- {
- "version": "2.0",
- "update_link": "http://localhost:4444/broken.xpi",
- "applications": {
- "gecko": {
- "strict_min_version": "1",
- "strict_max_version": "1"
- }
- }
- }
- ]
- },
-
- "test_bug378216_7@tests.mozilla.org": {
- "_comment_": "An update which expects a signature. It will fail since signatures are ",
- "_comment_": "supported in this format.",
- "_comment_": "The updateLink will also be ignored since it is not secure ",
- "_comment_": "and there is no updateHash.",
-
- "updates": [
- {
- "version": "2.0",
- "update_link": "http://localhost:4444/broken.xpi",
- "applications": {
- "gecko": {
- "strict_min_version": "1",
- "strict_max_version": "2"
- }
- }
- }
- ]
- },
-
- "test_bug378216_8@tests.mozilla.org": {
- "_comment_": "The updateLink will be ignored since it is not secure and ",
- "_comment_": "there is no updateHash.",
-
- "updates": [
- {
- "version": "2.0",
- "update_link": "http://localhost:4444/broken.xpi",
- "applications": {
- "gecko": {
- "strict_min_version": "1",
- "strict_max_version": "1"
- }
- }
- }
- ]
- },
-
- "test_bug378216_9@tests.mozilla.org": {
- "_comment_": "The updateLink will used since there is an updateHash to verify it.",
-
- "updates": [
- {
- "version": "2.0",
- "update_link": "http://localhost:4444/broken.xpi",
- "update_hash": "sha256:78fc1d2887eda35b4ad2e3a0b60120ca271ce6e6",
- "applications": {
- "gecko": {
- "strict_min_version": "1",
- "strict_max_version": "1"
- }
- }
- }
- ]
- },
-
- "test_bug378216_10@tests.mozilla.org": {
- "_comment_": "The updateLink will used since it is a secure URL.",
-
- "updates": [
- {
- "version": "2.0",
- "update_link": "https://localhost:4444/broken.xpi",
- "applications": {
- "gecko": {
- "strict_min_version": "1",
- "strict_max_version": "1"
- }
- }
- }
- ]
- },
-
- "test_bug378216_11@tests.mozilla.org": {
- "_comment_": "The updateLink will used since it is a secure URL.",
-
- "updates": [
- {
- "version": "2.0",
- "update_link": "https://localhost:4444/broken.xpi",
- "applications": {
- "gecko": {
- "strict_min_version": "1",
- "strict_max_version": "1"
- }
- }
- }
- ]
- },
-
- "test_bug378216_12@tests.mozilla.org": {
- "_comment_": "The updateLink will not be used since the updateHash ",
- "_comment_": "verifying it is not strong enough.",
-
- "updates": [
- {
- "version": "2.0",
- "update_link": "http://localhost:4444/broken.xpi",
- "update_hash": "sha1:78fc1d2887eda35b4ad2e3a0b60120ca271ce6e6",
- "applications": {
- "gecko": {
- "strict_min_version": "1",
- "strict_max_version": "1"
- }
- }
- }
- ]
- },
-
- "test_bug378216_13@tests.mozilla.org": {
- "_comment_": "An update with a weak hash. The updateLink will used since it is ",
- "_comment_": "a secure URL.",
-
- "updates": [
- {
- "version": "2.0",
- "update_link": "https://localhost:4444/broken.xpi",
- "update_hash": "sha1:78fc1d2887eda35b4ad2e3a0b60120ca271ce6e6",
- "applications": {
- "gecko": {
- "strict_min_version": "1",
- "strict_max_version": "1"
- }
- }
- }
- ]
- },
-
- "_comment_": "There should be no information present for test_bug378216_14",
-
- "test_bug378216_15@tests.mozilla.org": {
- "_comment_": "Invalid update JSON",
-
- "updates": "foo"
- },
-
- "ignore-compat@tests.mozilla.org": {
- "_comment_": "Various updates available - one is not compatible, but compatibility checking is disabled",
-
- "updates": [
- {
- "version": "1.0",
- "update_link": "https://localhost:4444/addons/test1.xpi",
- "applications": {
- "gecko": {
- "strict_min_version": "0.1",
- "advisory_max_version": "0.2"
- }
- }
- },
- {
- "version": "2.0",
- "update_link": "https://localhost:4444/addons/test2.xpi",
- "applications": {
- "gecko": {
- "strict_min_version": "0.5",
- "advisory_max_version": "0.6"
- }
- }
- },
- {
- "_comment_": "Update for future app versions - should never be compatible",
- "version": "3.0",
- "update_link": "https://localhost:4444/addons/test3.xpi",
- "applications": {
- "gecko": {
- "strict_min_version": "2",
- "advisory_max_version": "3"
- }
- }
- }
- ]
- },
-
- "compat-override@tests.mozilla.org": {
- "_comment_": "Various updates available - one is not compatible, but compatibility checking is disabled",
-
- "updates": [
- {
- "_comment_": "Has compatibility override, but it doesn't match this app version",
- "version": "1.0",
- "update_link": "https://localhost:4444/addons/test1.xpi",
- "applications": {
- "gecko": {
- "strict_min_version": "0.1",
- "advisory_max_version": "0.2"
- }
- }
- },
- {
- "_comment_": "Has compatibility override, so is incompaible",
- "version": "2.0",
- "update_link": "https://localhost:4444/addons/test2.xpi",
- "applications": {
- "gecko": {
- "strict_min_version": "0.5",
- "advisory_max_version": "0.6"
- }
- }
- },
- {
- "_comment_": "Update for future app versions - should never be compatible",
- "version": "3.0",
- "update_link": "https://localhost:4444/addons/test3.xpi",
- "applications": {
- "gecko": {
- "strict_min_version": "2",
- "advisory_max_version": "3"
- }
- }
- }
- ]
- },
-
- "compat-strict-optin@tests.mozilla.org": {
- "_comment_": "Opt-in to strict compatibility checking",
-
- "updates": [
- {
- "version": "1.0",
- "update_link": "https://localhost:4444/addons/test1.xpi",
- "_comment_": "strictCompatibility: true",
- "applications": {
- "gecko": {
- "strict_min_version": "0.1",
- "strict_max_version": "0.2"
- }
- }
- }
- ]
- }
- }
-}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecheck.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecheck.rdf
index c5d97ada0..93c82886a 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecheck.rdf
+++ b/toolkit/mozapps/extensions/test/xpcshell/data/test_updatecheck.rdf
@@ -236,7 +236,7 @@
A90eF5zy</em:signature>
</RDF:Description>
- <!-- An update with a valid signature. The updateLink will not be used since the
+ <!-- An update with a valid signature. The updateLink will used since the
updateHash verifying it is not strong enough. -->
<RDF:Description about="urn:mozilla:extension:test_bug378216_12@tests.mozilla.org">
<em:updates>
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_updateid.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/test_updateid.rdf
index c13928520..d59df9736 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_updateid.rdf
+++ b/toolkit/mozapps/extensions/test/xpcshell/data/test_updateid.rdf
@@ -14,7 +14,67 @@
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>1</em:maxVersion>
- <em:updateLink>http://localhost:4444/addons/test_updateid2.xpi</em:updateLink>
+ <em:updateLink>http://localhost:4444/addons/test_updateid2_2.xpi</em:updateLink>
+ </Description>
+ </em:targetApplication>
+ </Description>
+ </li>
+ </Seq>
+ </em:updates>
+ </Description>
+
+ <Description about="urn:mozilla:extension:addon2@tests.mozilla.org">
+ <em:updates>
+ <Seq>
+ <li>
+ <Description>
+ <em:version>3.0</em:version>
+ <em:targetApplication>
+ <Description>
+ <em:id>xpcshell@tests.mozilla.org</em:id>
+ <em:minVersion>1</em:minVersion>
+ <em:maxVersion>1</em:maxVersion>
+ <em:updateLink>http://localhost:4444/addons/test_updateid3_3.xpi</em:updateLink>
+ </Description>
+ </em:targetApplication>
+ </Description>
+ </li>
+ </Seq>
+ </em:updates>
+ </Description>
+
+ <Description about="urn:mozilla:extension:addon3@tests.mozilla.org">
+ <em:updates>
+ <Seq>
+ <li>
+ <Description>
+ <em:version>4.0</em:version>
+ <em:targetApplication>
+ <Description>
+ <em:id>xpcshell@tests.mozilla.org</em:id>
+ <em:minVersion>1</em:minVersion>
+ <em:maxVersion>1</em:maxVersion>
+ <em:updateLink>http://localhost:4444/addons/test_updateid4_4.xpi</em:updateLink>
+ </Description>
+ </em:targetApplication>
+ </Description>
+ </li>
+ </Seq>
+ </em:updates>
+ </Description>
+
+ <Description about="urn:mozilla:extension:addon4@tests.mozilla.org">
+ <em:updates>
+ <Seq>
+ <li>
+ <Description>
+ <em:version>5.0</em:version>
+ <em:targetApplication>
+ <Description>
+ <em:id>xpcshell@tests.mozilla.org</em:id>
+ <em:minVersion>1</em:minVersion>
+ <em:maxVersion>1</em:maxVersion>
+ <em:updateLink>http://localhost:4444/addons/test_updateid2_5.xpi</em:updateLink>
</Description>
</em:targetApplication>
</Description>
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/webext-implicit-id.xpi b/toolkit/mozapps/extensions/test/xpcshell/data/webext-implicit-id.xpi
deleted file mode 100644
index 6b4abaa69..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/data/webext-implicit-id.xpi
+++ /dev/null
Binary files differ
diff --git a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js b/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
index 960caceeb..60259944e 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
@@ -2,14 +2,11 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-var AM_Cc = Components.classes;
-var AM_Ci = Components.interfaces;
-var AM_Cu = Components.utils;
+const AM_Cc = Components.classes;
+const AM_Ci = Components.interfaces;
-AM_Cu.importGlobalProperties(["TextEncoder"]);
-
-const CERTDB_CONTRACTID = "@mozilla.org/security/x509certdb;1";
-const CERTDB_CID = Components.ID("{fb0bbc5c-452e-4783-b32c-80124693d871}");
+const XULAPPINFO_CONTRACTID = "@mozilla.org/xre/app-info;1";
+const XULAPPINFO_CID = Components.ID("{c763b610-9d49-455a-bbd2-ede71682a1ac}");
const PREF_EM_CHECK_UPDATE_SECURITY = "extensions.checkUpdateSecurity";
const PREF_EM_STRICT_COMPATIBILITY = "extensions.strictCompatibility";
@@ -17,20 +14,10 @@ const PREF_EM_MIN_COMPAT_APP_VERSION = "extensions.minCompatibleAppVersion"
const PREF_EM_MIN_COMPAT_PLATFORM_VERSION = "extensions.minCompatiblePlatformVersion";
const PREF_GETADDONS_BYIDS = "extensions.getAddons.get.url";
const PREF_GETADDONS_BYIDS_PERFORMANCE = "extensions.getAddons.getWithPerformance.url";
-const PREF_XPI_SIGNATURES_REQUIRED = "xpinstall.signatures.required";
// Forcibly end the test if it runs longer than 15 minutes
const TIMEOUT_MS = 900000;
-// Maximum error in file modification times. Some file systems don't store
-// modification times exactly. As long as we are closer than this then it
-// still passes.
-const MAX_TIME_DIFFERENCE = 3000;
-
-// Time to reset file modified time relative to Date.now() so we can test that
-// times are modified (10 hours old).
-const MAKE_FILE_OLD_DIFFERENCE = 10 * 3600 * 1000;
-
Components.utils.import("resource://gre/modules/addons/AddonRepository.jsm");
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/FileUtils.jsm");
@@ -38,300 +25,41 @@ Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://gre/modules/NetUtil.jsm");
Components.utils.import("resource://gre/modules/Promise.jsm");
Components.utils.import("resource://gre/modules/Task.jsm");
-const { OS } = Components.utils.import("resource://gre/modules/osfile.jsm", {});
+Components.utils.import("resource://gre/modules/osfile.jsm");
Components.utils.import("resource://gre/modules/AsyncShutdown.jsm");
-Components.utils.import("resource://testing-common/AddonTestUtils.jsm");
-
-XPCOMUtils.defineLazyModuleGetter(this, "Extension",
- "resource://gre/modules/Extension.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "ExtensionTestUtils",
- "resource://testing-common/ExtensionXPCShellUtils.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "HttpServer",
- "resource://testing-common/httpd.js");
-XPCOMUtils.defineLazyModuleGetter(this, "MockAsyncShutdown",
- "resource://testing-common/AddonTestUtils.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "MockRegistrar",
- "resource://testing-common/MockRegistrar.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "MockRegistry",
- "resource://testing-common/MockRegistry.jsm");
-
-const {
- awaitPromise,
- createAppInfo,
- createInstallRDF,
- createTempWebExtensionFile,
- createUpdateRDF,
- getFileForAddon,
- manuallyInstall,
- manuallyUninstall,
- promiseAddonByID,
- promiseAddonEvent,
- promiseAddonsByIDs,
- promiseAddonsWithOperationsByTypes,
- promiseCompleteAllInstalls,
- promiseConsoleOutput,
- promiseFindAddonUpdates,
- promiseInstallAllFiles,
- promiseInstallFile,
- promiseRestartManager,
- promiseSetExtensionModifiedTime,
- promiseShutdownManager,
- promiseStartupManager,
- promiseWriteProxyFileToDir,
- registerDirectory,
- setExtensionModifiedTime,
- writeFilesToZip
-} = AddonTestUtils;
-
-// WebExtension wrapper for ease of testing
-ExtensionTestUtils.init(this);
-
-AddonTestUtils.init(this);
-AddonTestUtils.overrideCertDB();
-
-Object.defineProperty(this, "gAppInfo", {
- get() {
- return AddonTestUtils.appInfo;
- },
-});
-
-Object.defineProperty(this, "gExtensionsINI", {
- get() {
- return AddonTestUtils.extensionsINI.clone();
- },
-});
-
-Object.defineProperty(this, "gInternalManager", {
- get() {
- return AddonTestUtils.addonIntegrationService.QueryInterface(AM_Ci.nsITimerCallback);
- },
-});
-
-Object.defineProperty(this, "gProfD", {
- get() {
- return AddonTestUtils.profileDir.clone();
- },
-});
-
-Object.defineProperty(this, "gTmpD", {
- get() {
- return AddonTestUtils.tempDir.clone();
- },
-});
-
-Object.defineProperty(this, "gUseRealCertChecks", {
- get() {
- return AddonTestUtils.useRealCertChecks;
- },
- set(val) {
- return AddonTestUtils.useRealCertChecks = val;
- },
-});
-
-Object.defineProperty(this, "TEST_UNPACKED", {
- get() {
- return AddonTestUtils.testUnpacked;
- },
- set(val) {
- return AddonTestUtils.testUnpacked = val;
- },
-});
+Services.prefs.setBoolPref("toolkit.osfile.log", true);
// We need some internal bits of AddonManager
-var AMscope = Components.utils.import("resource://gre/modules/AddonManager.jsm", {});
-var { AddonManager, AddonManagerInternal, AddonManagerPrivate } = AMscope;
-
-var gPort = null;
-var gUrlToFileMap = {};
-
-// Map resource://xpcshell-data/ to the data directory
-var resHandler = Services.io.getProtocolHandler("resource")
- .QueryInterface(AM_Ci.nsISubstitutingProtocolHandler);
-// Allow non-existent files because of bug 1207735
-var dataURI = NetUtil.newURI(do_get_file("data", true));
-resHandler.setSubstitution("xpcshell-data", dataURI);
-
-function isManifestRegistered(file) {
- let manifests = Components.manager.getManifestLocations();
- for (let i = 0; i < manifests.length; i++) {
- let manifest = manifests.queryElementAt(i, AM_Ci.nsIURI);
-
- // manifest is the url to the manifest file either in an XPI or a directory.
- // We want the location of the XPI or directory itself.
- if (manifest instanceof AM_Ci.nsIJARURI) {
- manifest = manifest.JARFile.QueryInterface(AM_Ci.nsIFileURL).file;
- }
- else if (manifest instanceof AM_Ci.nsIFileURL) {
- manifest = manifest.file.parent;
- }
- else {
- continue;
- }
-
- if (manifest.equals(file))
- return true;
- }
- return false;
-}
-
-// Listens to messages from bootstrap.js telling us what add-ons were started
-// and stopped etc. and performs some sanity checks that only installed add-ons
-// are started etc.
-this.BootstrapMonitor = {
- inited: false,
-
- // Contain the current state of add-ons in the system
- installed: new Map(),
- started: new Map(),
-
- // Contain the last state of shutdown and uninstall calls for an add-on
- stopped: new Map(),
- uninstalled: new Map(),
-
- startupPromises: [],
- installPromises: [],
-
- init() {
- this.inited = true;
- Services.obs.addObserver(this, "bootstrapmonitor-event", false);
- },
-
- shutdownCheck() {
- if (!this.inited)
- return;
-
- do_check_eq(this.started.size, 0);
- },
-
- clear(id) {
- this.installed.delete(id);
- this.started.delete(id);
- this.stopped.delete(id);
- this.uninstalled.delete(id);
- },
-
- promiseAddonStartup(id) {
- return new Promise(resolve => {
- this.startupPromises.push(resolve);
- });
- },
-
- promiseAddonInstall(id) {
- return new Promise(resolve => {
- this.installPromises.push(resolve);
- });
- },
-
- checkMatches(cached, current) {
- do_check_neq(cached, undefined);
- do_check_eq(current.data.version, cached.data.version);
- do_check_eq(current.data.installPath, cached.data.installPath);
- do_check_eq(current.data.resourceURI, cached.data.resourceURI);
- },
-
- checkAddonStarted(id, version = undefined) {
- let started = this.started.get(id);
- do_check_neq(started, undefined);
- if (version != undefined)
- do_check_eq(started.data.version, version);
-
- // Chrome should be registered by now
- let installPath = new FileUtils.File(started.data.installPath);
- let isRegistered = isManifestRegistered(installPath);
- do_check_true(isRegistered);
- },
-
- checkAddonNotStarted(id) {
- do_check_false(this.started.has(id));
- },
-
- checkAddonInstalled(id, version = undefined) {
- const installed = this.installed.get(id);
- notEqual(installed, undefined);
- if (version !== undefined) {
- equal(installed.data.version, version);
+let AMscope = Components.utils.import("resource://gre/modules/AddonManager.jsm");
+let AddonManager = AMscope.AddonManager;
+let AddonManagerInternal = AMscope.AddonManagerInternal;
+// Mock out AddonManager's reference to the AsyncShutdown module so we can shut
+// down AddonManager from the test
+let MockAsyncShutdown = {
+ hook: null,
+ status: null,
+ profileBeforeChange: {
+ addBlocker: function(aName, aBlocker, aOptions) {
+ do_print("Mock profileBeforeChange blocker for '" + aName + "'");
+ MockAsyncShutdown.hook = aBlocker;
+ MockAsyncShutdown.status = aOptions.fetchState;
}
- return installed;
},
+ // We can use the real Barrier
+ Barrier: AsyncShutdown.Barrier
+};
- checkAddonNotInstalled(id) {
- do_check_false(this.installed.has(id));
- },
-
- observe(subject, topic, data) {
- let info = JSON.parse(data);
- let id = info.data.id;
- let installPath = new FileUtils.File(info.data.installPath);
-
- if (subject && subject.wrappedJSObject) {
- // NOTE: in some of the new tests, we need to received the real objects instead of
- // their JSON representations, but most of the current tests expect intallPath
- // and resourceURI to have been converted to strings.
- info.data = Object.assign({}, subject.wrappedJSObject.data, {
- installPath: info.data.installPath,
- resourceURI: info.data.resourceURI,
- });
- }
-
- // If this is the install event the add-ons shouldn't already be installed
- if (info.event == "install") {
- this.checkAddonNotInstalled(id);
-
- this.installed.set(id, info);
-
- for (let resolve of this.installPromises)
- resolve();
- this.installPromises = [];
- }
- else {
- this.checkMatches(this.installed.get(id), info);
- }
-
- // If this is the shutdown event than the add-on should already be started
- if (info.event == "shutdown") {
- this.checkMatches(this.started.get(id), info);
-
- this.started.delete(id);
- this.stopped.set(id, info);
-
- // Chrome should still be registered at this point
- let isRegistered = isManifestRegistered(installPath);
- do_check_true(isRegistered);
-
- // XPIProvider doesn't bother unregistering chrome on app shutdown but
- // since we simulate restarts we must do so manually to keep the registry
- // consistent.
- if (info.reason == 2 /* APP_SHUTDOWN */)
- Components.manager.removeBootstrappedManifestLocation(installPath);
- }
- else {
- this.checkAddonNotStarted(id);
- }
-
- if (info.event == "uninstall") {
- // Chrome should be unregistered at this point
- let isRegistered = isManifestRegistered(installPath);
- do_check_false(isRegistered);
-
- this.installed.delete(id);
- this.uninstalled.set(id, info)
- }
- else if (info.event == "startup") {
- this.started.set(id, info);
+AMscope.AsyncShutdown = MockAsyncShutdown;
- // Chrome should be registered at this point
- let isRegistered = isManifestRegistered(installPath);
- do_check_true(isRegistered);
+var gInternalManager = null;
+var gAppInfo = null;
+var gAddonsList;
- for (let resolve of this.startupPromises)
- resolve();
- this.startupPromises = [];
- }
- }
-}
+var gPort = null;
+var gUrlToFileMap = {};
-AddonTestUtils.on("addon-manager-shutdown", () => BootstrapMonitor.shutdownCheck());
+var TEST_UNPACKED = false;
function isNightlyChannel() {
var channel = "default";
@@ -343,6 +71,51 @@ function isNightlyChannel() {
return channel != "aurora" && channel != "beta" && channel != "release" && channel != "esr";
}
+function createAppInfo(id, name, version, platformVersion) {
+ gAppInfo = {
+ // nsIXULAppInfo
+ vendor: "Mozilla",
+ name: name,
+ ID: id,
+ version: version,
+ appBuildID: "2007010101",
+ platformVersion: platformVersion ? platformVersion : "1.0",
+ platformBuildID: "2007010101",
+
+ // nsIXULRuntime
+ inSafeMode: false,
+ logConsoleErrors: true,
+ OS: "XPCShell",
+ XPCOMABI: "noarch-spidermonkey",
+ invalidateCachesOnRestart: function invalidateCachesOnRestart() {
+ // Do nothing
+ },
+
+ // nsICrashReporter
+ annotations: {},
+
+ annotateCrashReport: function(key, data) {
+ this.annotations[key] = data;
+ },
+
+ QueryInterface: XPCOMUtils.generateQI([AM_Ci.nsIXULAppInfo,
+ AM_Ci.nsIXULRuntime,
+ AM_Ci.nsICrashReporter,
+ AM_Ci.nsISupports])
+ };
+
+ var XULAppInfoFactory = {
+ createInstance: function (outer, iid) {
+ if (outer != null)
+ throw Components.results.NS_ERROR_NO_AGGREGATION;
+ return gAppInfo.QueryInterface(iid);
+ }
+ };
+ var registrar = Components.manager.QueryInterface(AM_Ci.nsIComponentRegistrar);
+ registrar.registerFactory(XULAPPINFO_CID, "XULAppInfo",
+ XULAPPINFO_CONTRACTID, XULAppInfoFactory);
+}
+
/**
* Tests that an add-on does appear in the crash report annotations, if
* crash reporting is enabled. The test will fail if the add-on is not in the
@@ -418,11 +191,11 @@ function do_get_file_hash(aFile, aAlgorithm) {
crypto.updateFromStream(fis, aFile.fileSize);
// return the two-digit hexadecimal code for a byte
- let toHexString = charCode => ("0" + charCode.toString(16)).slice(-2);
+ function toHexString(charCode)
+ ("0" + charCode.toString(16)).slice(-2);
let binary = crypto.finish(false);
- let hash = Array.from(binary, c => toHexString(c.charCodeAt(0)));
- return aAlgorithm + ":" + hash.join("");
+ return aAlgorithm + ":" + [toHexString(binary.charCodeAt(i)) for (i in binary)].join("")
}
/**
@@ -439,7 +212,9 @@ function do_get_addon_root_uri(aProfileDir, aId) {
path.leafName += ".xpi";
return "jar:" + Services.io.newFileURI(path).spec + "!/";
}
- return Services.io.newFileURI(path).spec;
+ else {
+ return Services.io.newFileURI(path).spec;
+ }
}
function do_get_expected_addon_name(aId) {
@@ -601,8 +376,54 @@ function do_check_icons(aActual, aExpected) {
}
}
+// Record the error (if any) from trying to save the XPI
+// database at shutdown time
+let gXPISaveError = null;
+
+/**
+ * Starts up the add-on manager as if it was started by the application.
+ *
+ * @param aAppChanged
+ * An optional boolean parameter to simulate the case where the
+ * application has changed version since the last run. If not passed it
+ * defaults to true
+ */
function startupManager(aAppChanged) {
- promiseStartupManager(aAppChanged);
+ if (gInternalManager)
+ do_throw("Test attempt to startup manager that was already started.");
+
+ if (aAppChanged || aAppChanged === undefined) {
+ if (gExtensionsINI.exists())
+ gExtensionsINI.remove(true);
+ }
+
+ gInternalManager = AM_Cc["@mozilla.org/addons/integration;1"].
+ getService(AM_Ci.nsIObserver).
+ QueryInterface(AM_Ci.nsITimerCallback);
+
+ gInternalManager.observe(null, "addons-startup", null);
+
+ // Load the add-ons list as it was after extension registration
+ loadAddonsList();
+}
+
+/**
+ * Helper to spin the event loop until a promise resolves or rejects
+ */
+function loopUntilPromise(aPromise) {
+ let done = false;
+ aPromise.then(
+ () => done = true,
+ err => {
+ do_report_unexpected_exception(err);
+ done = true;
+ });
+
+ let thr = Services.tm.mainThread;
+
+ while (!done) {
+ thr.processNextEvent(true);
+ }
}
/**
@@ -614,36 +435,270 @@ function startupManager(aAppChanged) {
* the application version has changed.
*/
function restartManager(aNewVersion) {
- awaitPromise(promiseRestartManager(aNewVersion));
+ loopUntilPromise(promiseRestartManager(aNewVersion));
+}
+
+function promiseRestartManager(aNewVersion) {
+ return promiseShutdownManager()
+ .then(null, err => do_report_unexpected_exception(err))
+ .then(() => {
+ if (aNewVersion) {
+ gAppInfo.version = aNewVersion;
+ startupManager(true);
+ }
+ else {
+ startupManager(false);
+ }
+ });
}
function shutdownManager() {
- awaitPromise(promiseShutdownManager());
+ loopUntilPromise(promiseShutdownManager());
+}
+
+function promiseShutdownManager() {
+ if (!gInternalManager) {
+ return Promise.resolve(false);
+ }
+
+ let hookErr = null;
+ Services.obs.notifyObservers(null, "quit-application-granted", null);
+ return MockAsyncShutdown.hook()
+ .then(null, err => hookErr = err)
+ .then( () => {
+ gInternalManager = null;
+
+ // Load the add-ons list as it was after application shutdown
+ loadAddonsList();
+
+ // Clear any crash report annotations
+ gAppInfo.annotations = {};
+
+ // Force the XPIProvider provider to reload to better
+ // simulate real-world usage.
+ let XPIscope = Components.utils.import("resource://gre/modules/addons/XPIProvider.jsm");
+ // This would be cleaner if I could get it as the rejection reason from
+ // the AddonManagerInternal.shutdown() promise
+ gXPISaveError = XPIscope.XPIProvider._shutdownError;
+ do_print("gXPISaveError set to: " + gXPISaveError);
+ AddonManagerPrivate.unregisterProvider(XPIscope.XPIProvider);
+ Components.utils.unload("resource://gre/modules/addons/XPIProvider.jsm");
+ if (hookErr) {
+ throw hookErr;
+ }
+ });
+}
+
+function loadAddonsList() {
+ function readDirectories(aSection) {
+ var dirs = [];
+ var keys = parser.getKeys(aSection);
+ while (keys.hasMore()) {
+ let descriptor = parser.getString(aSection, keys.getNext());
+ try {
+ let file = AM_Cc["@mozilla.org/file/local;1"].
+ createInstance(AM_Ci.nsIFile);
+ file.persistentDescriptor = descriptor;
+ dirs.push(file);
+ }
+ catch (e) {
+ // Throws if the directory doesn't exist, we can ignore this since the
+ // platform will too.
+ }
+ }
+ return dirs;
+ }
+
+ gAddonsList = {
+ extensions: [],
+ themes: [],
+ mpIncompatible: new Set()
+ };
+
+ if (!gExtensionsINI.exists())
+ return;
+
+ var factory = AM_Cc["@mozilla.org/xpcom/ini-parser-factory;1"].
+ getService(AM_Ci.nsIINIParserFactory);
+ var parser = factory.createINIParser(gExtensionsINI);
+ gAddonsList.extensions = readDirectories("ExtensionDirs");
+ gAddonsList.themes = readDirectories("ThemeDirs");
+ var keys = parser.getKeys("MultiprocessIncompatibleExtensions");
+ while (keys.hasMore()) {
+ let id = parser.getString("MultiprocessIncompatibleExtensions", keys.getNext());
+ gAddonsList.mpIncompatible.add(id);
+ }
+}
+
+function isItemInAddonsList(aType, aDir, aId) {
+ var path = aDir.clone();
+ path.append(aId);
+ var xpiPath = aDir.clone();
+ xpiPath.append(aId + ".xpi");
+ for (var i = 0; i < gAddonsList[aType].length; i++) {
+ let file = gAddonsList[aType][i];
+ if (!file.exists())
+ do_throw("Non-existant path found in extensions.ini: " + file.path)
+ if (file.isDirectory() && file.equals(path))
+ return true;
+ if (file.isFile() && file.equals(xpiPath))
+ return true;
+ }
+ return false;
}
function isItemMarkedMPIncompatible(aId) {
- return AddonTestUtils.addonsList.isMultiprocessIncompatible(aId);
+ return gAddonsList.mpIncompatible.has(aId);
}
function isThemeInAddonsList(aDir, aId) {
- return AddonTestUtils.addonsList.hasTheme(aDir, aId);
+ return isItemInAddonsList("themes", aDir, aId);
}
function isExtensionInAddonsList(aDir, aId) {
- return AddonTestUtils.addonsList.hasExtension(aDir, aId);
+ return isItemInAddonsList("extensions", aDir, aId);
}
function check_startup_changes(aType, aIds) {
var ids = aIds.slice(0);
ids.sort();
var changes = AddonManager.getStartupChanges(aType);
- changes = changes.filter(aEl => /@tests.mozilla.org$/.test(aEl));
+ changes = changes.filter(function(aEl) /@tests.mozilla.org$/.test(aEl));
changes.sort();
do_check_eq(JSON.stringify(ids), JSON.stringify(changes));
}
/**
+ * Escapes any occurances of &, ", < or > with XML entities.
+ *
+ * @param str
+ * The string to escape
+ * @return The escaped string
+ */
+function escapeXML(aStr) {
+ return aStr.toString()
+ .replace(/&/g, "&amp;")
+ .replace(/"/g, "&quot;")
+ .replace(/</g, "&lt;")
+ .replace(/>/g, "&gt;");
+}
+
+function writeLocaleStrings(aData) {
+ let rdf = "";
+ ["name", "description", "creator", "homepageURL"].forEach(function(aProp) {
+ if (aProp in aData)
+ rdf += "<em:" + aProp + ">" + escapeXML(aData[aProp]) + "</em:" + aProp + ">\n";
+ });
+
+ ["developer", "translator", "contributor"].forEach(function(aProp) {
+ if (aProp in aData) {
+ aData[aProp].forEach(function(aValue) {
+ rdf += "<em:" + aProp + ">" + escapeXML(aValue) + "</em:" + aProp + ">\n";
+ });
+ }
+ });
+ return rdf;
+}
+
+/**
+ * Creates an update.rdf structure as a string using for the update data passed.
+ *
+ * @param aData
+ * The update data as a JS object. Each property name is an add-on ID,
+ * the property value is an array of each version of the add-on. Each
+ * array value is a JS object containing the data for the version, at
+ * minimum a "version" and "targetApplications" property should be
+ * included to create a functional update manifest.
+ * @return the update.rdf structure as a string.
+ */
+function createUpdateRDF(aData) {
+ var rdf = '<?xml version="1.0"?>\n';
+ rdf += '<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\n' +
+ ' xmlns:em="http://www.mozilla.org/2004/em-rdf#">\n';
+
+ for (let addon in aData) {
+ rdf += ' <Description about="urn:mozilla:extension:' + escapeXML(addon) + '"><em:updates><Seq>\n';
+
+ for (let versionData of aData[addon]) {
+ rdf += ' <li><Description>\n';
+
+ for (let prop of ["version", "multiprocessCompatible"]) {
+ if (prop in versionData)
+ rdf += " <em:" + prop + ">" + escapeXML(versionData[prop]) + "</em:" + prop + ">\n";
+ }
+
+ if ("targetApplications" in versionData) {
+ for (let app of versionData.targetApplications) {
+ rdf += " <em:targetApplication><Description>\n";
+ for (let prop of ["id", "minVersion", "maxVersion", "updateLink", "updateHash"]) {
+ if (prop in app)
+ rdf += " <em:" + prop + ">" + escapeXML(app[prop]) + "</em:" + prop + ">\n";
+ }
+ rdf += " </Description></em:targetApplication>\n";
+ }
+ }
+
+ rdf += ' </Description></li>\n';
+ }
+
+ rdf += ' </Seq></em:updates></Description>\n'
+ }
+ rdf += "</RDF>\n";
+
+ return rdf;
+}
+
+function createInstallRDF(aData) {
+ var rdf = '<?xml version="1.0"?>\n';
+ rdf += '<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"\n' +
+ ' xmlns:em="http://www.mozilla.org/2004/em-rdf#">\n';
+ rdf += '<Description about="urn:mozilla:install-manifest">\n';
+
+ ["id", "version", "type", "internalName", "updateURL", "updateKey",
+ "optionsURL", "optionsType", "aboutURL", "iconURL", "icon64URL",
+ "skinnable", "bootstrap", "strictCompatibility", "multiprocessCompatible"].forEach(function(aProp) {
+ if (aProp in aData)
+ rdf += "<em:" + aProp + ">" + escapeXML(aData[aProp]) + "</em:" + aProp + ">\n";
+ });
+
+ rdf += writeLocaleStrings(aData);
+
+ if ("targetPlatforms" in aData) {
+ aData.targetPlatforms.forEach(function(aPlatform) {
+ rdf += "<em:targetPlatform>" + escapeXML(aPlatform) + "</em:targetPlatform>\n";
+ });
+ }
+
+ if ("targetApplications" in aData) {
+ aData.targetApplications.forEach(function(aApp) {
+ rdf += "<em:targetApplication><Description>\n";
+ ["id", "minVersion", "maxVersion"].forEach(function(aProp) {
+ if (aProp in aApp)
+ rdf += "<em:" + aProp + ">" + escapeXML(aApp[aProp]) + "</em:" + aProp + ">\n";
+ });
+ rdf += "</Description></em:targetApplication>\n";
+ });
+ }
+
+ if ("localized" in aData) {
+ aData.localized.forEach(function(aLocalized) {
+ rdf += "<em:localized><Description>\n";
+ if ("locale" in aLocalized) {
+ aLocalized.locale.forEach(function(aLocaleName) {
+ rdf += "<em:locale>" + escapeXML(aLocaleName) + "</em:locale>\n";
+ });
+ }
+ rdf += writeLocaleStrings(aLocalized);
+ rdf += "</Description></em:localized>\n";
+ });
+ }
+
+ rdf += "</Description>\n</RDF>\n";
+ return rdf;
+}
+
+/**
* Writes an install.rdf manifest into a directory using the properties passed
* in a JS object. The objects should contain a property for each property to
* appear in the RDF. The object may contain an array of objects with id,
@@ -660,22 +715,38 @@ function check_startup_changes(aType, aIds) {
* An optional dummy file to create in the directory
* @return An nsIFile for the directory in which the add-on is installed.
*/
-function writeInstallRDFToDir(aData, aDir, aId = aData.id, aExtraFile = null) {
- let files = {
- "install.rdf": AddonTestUtils.createInstallRDF(aData),
- };
- if (aExtraFile)
- files[aExtraFile] = "";
-
- let dir = aDir.clone();
- dir.append(aId);
-
- awaitPromise(AddonTestUtils.promiseWriteFilesToDir(dir.path, files));
+function writeInstallRDFToDir(aData, aDir, aId, aExtraFile) {
+ var id = aId ? aId : aData.id
+
+ var dir = aDir.clone();
+ dir.append(id);
+
+ var rdf = createInstallRDF(aData);
+ if (!dir.exists())
+ dir.create(AM_Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
+ var file = dir.clone();
+ file.append("install.rdf");
+ if (file.exists())
+ file.remove(true);
+ var fos = AM_Cc["@mozilla.org/network/file-output-stream;1"].
+ createInstance(AM_Ci.nsIFileOutputStream);
+ fos.init(file,
+ FileUtils.MODE_WRONLY | FileUtils.MODE_CREATE | FileUtils.MODE_TRUNCATE,
+ FileUtils.PERMS_FILE, 0);
+ fos.write(rdf, rdf.length);
+ fos.close();
+
+ if (!aExtraFile)
+ return dir;
+
+ file = dir.clone();
+ file.append(aExtraFile);
+ file.create(AM_Ci.nsIFile.NORMAL_FILE_TYPE, FileUtils.PERMS_FILE);
return dir;
}
/**
- * Writes an install.rdf manifest into a packed extension using the properties passed
+ * Writes an install.rdf manifest into an extension using the properties passed
* in a JS object. The objects should contain a property for each property to
* appear in the RDF. The object may contain an array of objects with id,
* minVersion and maxVersion in the targetApplications property to give target
@@ -691,26 +762,15 @@ function writeInstallRDFToDir(aData, aDir, aId = aData.id, aExtraFile = null) {
* An optional dummy file to create in the extension
* @return A file pointing to where the extension was installed
*/
-function writeInstallRDFToXPI(aData, aDir, aId = aData.id, aExtraFile = null) {
- let files = {
- "install.rdf": AddonTestUtils.createInstallRDF(aData),
- };
- if (aExtraFile)
- files[aExtraFile] = "";
-
- if (!aDir.exists())
- aDir.create(AM_Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
-
- var file = aDir.clone();
- file.append(`${aId}.xpi`);
-
- AddonTestUtils.writeFilesToZip(file.path, files);
-
- return file;
+function writeInstallRDFForExtension(aData, aDir, aId, aExtraFile) {
+ if (TEST_UNPACKED) {
+ return writeInstallRDFToDir(aData, aDir, aId, aExtraFile);
+ }
+ return writeInstallRDFToXPI(aData, aDir, aId, aExtraFile);
}
/**
- * Writes an install.rdf manifest into an extension using the properties passed
+ * Writes an install.rdf manifest into a packed extension using the properties passed
* in a JS object. The objects should contain a property for each property to
* appear in the RDF. The object may contain an array of objects with id,
* minVersion and maxVersion in the targetApplications property to give target
@@ -726,32 +786,50 @@ function writeInstallRDFToXPI(aData, aDir, aId = aData.id, aExtraFile = null) {
* An optional dummy file to create in the extension
* @return A file pointing to where the extension was installed
*/
-function writeInstallRDFForExtension(aData, aDir, aId, aExtraFile) {
- if (TEST_UNPACKED) {
- return writeInstallRDFToDir(aData, aDir, aId, aExtraFile);
- }
- return writeInstallRDFToXPI(aData, aDir, aId, aExtraFile);
+function writeInstallRDFToXPI(aData, aDir, aId, aExtraFile) {
+ var id = aId ? aId : aData.id
+
+ if (!aDir.exists())
+ aDir.create(AM_Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
+
+ var file = aDir.clone();
+ file.append(id + ".xpi");
+ writeInstallRDFToXPIFile(aData, file, aExtraFile);
+
+ return file;
}
/**
- * Writes a manifest.json manifest into an extension using the properties passed
- * in a JS object.
+ * Writes an install.rdf manifest into an XPI file using the properties passed
+ * in a JS object. The objects should contain a property for each property to
+ * appear in the RDF. The object may contain an array of objects with id,
+ * minVersion and maxVersion in the targetApplications property to give target
+ * application compatibility.
*
- * @param aManifest
- * The data to write
- * @param aDir
- * The install directory to add the extension to
- * @param aId
- * An optional string to override the default installation aId
- * @return A file pointing to where the extension was installed
+ * @param aData
+ * The object holding data about the add-on
+ * @param aFile
+ * The XPI file to write to. Any existing file will be overwritten
+ * @param aExtraFile
+ * An optional dummy file to create in the extension
*/
-function promiseWriteWebManifestForExtension(aData, aDir, aId = aData.applications.gecko.id) {
- let files = {
- "manifest.json": JSON.stringify(aData),
- }
- return AddonTestUtils.promiseWriteFilesToExtension(aDir.path, aId, files);
+function writeInstallRDFToXPIFile(aData, aFile, aExtraFile) {
+ var rdf = createInstallRDF(aData);
+ var stream = AM_Cc["@mozilla.org/io/string-input-stream;1"].
+ createInstance(AM_Ci.nsIStringInputStream);
+ stream.setData(rdf, -1);
+ var zipW = AM_Cc["@mozilla.org/zipwriter;1"].
+ createInstance(AM_Ci.nsIZipWriter);
+ zipW.open(aFile, FileUtils.MODE_WRONLY | FileUtils.MODE_CREATE | FileUtils.MODE_TRUNCATE);
+ zipW.addEntryStream("install.rdf", 0, AM_Ci.nsIZipWriter.COMPRESSION_NONE,
+ stream, false);
+ if (aExtraFile)
+ zipW.addEntryStream(aExtraFile, 0, AM_Ci.nsIZipWriter.COMPRESSION_NONE,
+ stream, false);
+ zipW.close();
}
+let temp_xpis = [];
/**
* Creates an XPI file for some manifest data in the temporary directory and
* returns the nsIFile for it. The file will be deleted when the test completes.
@@ -760,16 +838,148 @@ function promiseWriteWebManifestForExtension(aData, aDir, aId = aData.applicatio
* The object holding data about the add-on
* @return A file pointing to the created XPI file
*/
-function createTempXPIFile(aData, aExtraFile) {
- let files = {
- "install.rdf": aData,
- };
- if (typeof aExtraFile == "object")
- Object.assign(files, aExtraFile);
- else if (aExtraFile)
- files[aExtraFile] = "";
+function createTempXPIFile(aData) {
+ var file = gTmpD.clone();
+ file.append("foo.xpi");
+ do {
+ file.leafName = Math.floor(Math.random() * 1000000) + ".xpi";
+ } while (file.exists());
+
+ temp_xpis.push(file);
+ writeInstallRDFToXPIFile(aData, file);
+ return file;
+}
+
+/**
+ * Sets the last modified time of the extension, usually to trigger an update
+ * of its metadata. If the extension is unpacked, this function assumes that
+ * the extension contains only the install.rdf file.
+ *
+ * @param aExt a file pointing to either the packed extension or its unpacked directory.
+ * @param aTime the time to which we set the lastModifiedTime of the extension
+ *
+ * @deprecated Please use promiseSetExtensionModifiedTime instead
+ */
+function setExtensionModifiedTime(aExt, aTime) {
+ aExt.lastModifiedTime = aTime;
+ if (aExt.isDirectory()) {
+ let entries = aExt.directoryEntries
+ .QueryInterface(AM_Ci.nsIDirectoryEnumerator);
+ while (entries.hasMoreElements())
+ setExtensionModifiedTime(entries.nextFile, aTime);
+ entries.close();
+ }
+}
+function promiseSetExtensionModifiedTime(aPath, aTime) {
+ return Task.spawn(function* () {
+ yield OS.File.setDates(aPath, aTime, aTime);
+ let entries, iterator;
+ try {
+ let iterator = new OS.File.DirectoryIterator(aPath);
+ entries = yield iterator.nextBatch();
+ } catch (ex if ex instanceof OS.File.Error) {
+ return;
+ } finally {
+ if (iterator) {
+ iterator.close();
+ }
+ }
+ for (let entry of entries) {
+ yield promiseSetExtensionModifiedTime(entry.path, aTime);
+ }
+ });
+}
+
+/**
+ * Manually installs an XPI file into an install location by either copying the
+ * XPI there or extracting it depending on whether unpacking is being tested
+ * or not.
+ *
+ * @param aXPIFile
+ * The XPI file to install.
+ * @param aInstallLocation
+ * The install location (an nsIFile) to install into.
+ * @param aID
+ * The ID to install as.
+ */
+function manuallyInstall(aXPIFile, aInstallLocation, aID) {
+ if (TEST_UNPACKED) {
+ let dir = aInstallLocation.clone();
+ dir.append(aID);
+ dir.create(AM_Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
+ let zip = AM_Cc["@mozilla.org/libjar/zip-reader;1"].
+ createInstance(AM_Ci.nsIZipReader);
+ zip.open(aXPIFile);
+ let entries = zip.findEntries(null);
+ while (entries.hasMore()) {
+ let entry = entries.getNext();
+ let target = dir.clone();
+ entry.split("/").forEach(function(aPart) {
+ target.append(aPart);
+ });
+ zip.extract(entry, target);
+ }
+ zip.close();
+
+ return dir;
+ }
+ else {
+ let target = aInstallLocation.clone();
+ target.append(aID + ".xpi");
+ aXPIFile.copyTo(target.parent, target.leafName);
+ return target;
+ }
+}
+
+/**
+ * Manually uninstalls an add-on by removing its files from the install
+ * location.
+ *
+ * @param aInstallLocation
+ * The nsIFile of the install location to remove from.
+ * @param aID
+ * The ID of the add-on to remove.
+ */
+function manuallyUninstall(aInstallLocation, aID) {
+ let file = getFileForAddon(aInstallLocation, aID);
+
+ // In reality because the app is restarted a flush isn't necessary for XPIs
+ // removed outside the app, but for testing we must flush manually.
+ if (file.isFile())
+ Services.obs.notifyObservers(file, "flush-cache-entry", null);
+
+ file.remove(true);
+}
+
+/**
+ * Gets the nsIFile for where an add-on is installed. It may point to a file or
+ * a directory depending on whether add-ons are being installed unpacked or not.
+ *
+ * @param aDir
+ * The nsIFile for the install location
+ * @param aId
+ * The ID of the add-on
+ * @return an nsIFile
+ */
+function getFileForAddon(aDir, aId) {
+ var dir = aDir.clone();
+ dir.append(do_get_expected_addon_name(aId));
+ return dir;
+}
- return AddonTestUtils.createTempXPIFile(files);
+function registerDirectory(aKey, aDir) {
+ var dirProvider = {
+ getFile: function(aProp, aPersistent) {
+ aPersistent.value = true;
+ if (aProp == aKey)
+ return aDir.clone();
+ return null;
+ },
+
+ QueryInterface: XPCOMUtils.generateQI([AM_Ci.nsIDirectoryServiceProvider,
+ AM_Ci.nsISupports])
+ };
+ Services.dirsvc.registerProvider(dirProvider);
}
var gExpectedEvents = {};
@@ -898,13 +1108,9 @@ const AddonListener = {
const InstallListener = {
onNewInstall: function(install) {
if (install.state != AddonManager.STATE_DOWNLOADED &&
- install.state != AddonManager.STATE_DOWNLOAD_FAILED &&
install.state != AddonManager.STATE_AVAILABLE)
do_throw("Bad install state " + install.state);
- if (install.state != AddonManager.STATE_DOWNLOAD_FAILED)
- do_check_eq(install.error, 0);
- else
- do_check_neq(install.error, 0);
+ do_check_eq(install.error, 0);
do_check_eq("onNewInstall", getExpectedInstall());
return check_test_completed(arguments);
},
@@ -996,9 +1202,7 @@ function check_test_completed(aArgs) {
if (gExpectedInstalls instanceof Array &&
gExpectedInstalls.length > 0)
return undefined;
-
- for (let id in gExpectedInstalls) {
- let installList = gExpectedInstalls[id];
+ else for each (let installList in gExpectedInstalls) {
if (installList.length > 0)
return undefined;
}
@@ -1032,7 +1236,38 @@ function ensure_test_completed() {
* The callback to call when all installs have finished
*/
function completeAllInstalls(aInstalls, aCallback) {
- promiseCompleteAllInstalls(aInstalls).then(aCallback);
+ let count = aInstalls.length;
+
+ if (count == 0) {
+ aCallback();
+ return;
+ }
+
+ function installCompleted(aInstall) {
+ aInstall.removeListener(listener);
+
+ if (--count == 0)
+ do_execute_soon(aCallback);
+ }
+
+ let listener = {
+ onDownloadFailed: installCompleted,
+ onDownloadCancelled: installCompleted,
+ onInstallFailed: installCompleted,
+ onInstallCancelled: installCompleted,
+ onInstallEnded: installCompleted
+ };
+
+ aInstalls.forEach(function(aInstall) {
+ aInstall.addListener(listener);
+ aInstall.install();
+ });
+}
+
+function promiseCompleteAllInstalls(aInstalls) {
+ return new Promise(resolve => {
+ completeAllInstalls(aInstalls, resolve);
+ });
}
/**
@@ -1048,13 +1283,179 @@ function completeAllInstalls(aInstalls, aCallback) {
* aome way with the application
*/
function installAllFiles(aFiles, aCallback, aIgnoreIncompatible) {
- promiseInstallAllFiles(aFiles, aIgnoreIncompatible).then(aCallback);
+ let count = aFiles.length;
+ let installs = [];
+ function callback() {
+ if (aCallback) {
+ aCallback();
+ }
+ }
+ aFiles.forEach(function(aFile) {
+ AddonManager.getInstallForFile(aFile, function(aInstall) {
+ if (!aInstall)
+ do_throw("No AddonInstall created for " + aFile.path);
+ do_check_eq(aInstall.state, AddonManager.STATE_DOWNLOADED);
+
+ if (!aIgnoreIncompatible || !aInstall.addon.appDisabled)
+ installs.push(aInstall);
+
+ if (--count == 0)
+ completeAllInstalls(installs, callback);
+ });
+ });
+}
+
+function promiseInstallAllFiles(aFiles, aIgnoreIncompatible) {
+ let deferred = Promise.defer();
+ installAllFiles(aFiles, deferred.resolve, aIgnoreIncompatible);
+ return deferred.promise;
+
+}
+
+if ("nsIWindowsRegKey" in AM_Ci) {
+ var MockRegistry = {
+ LOCAL_MACHINE: {},
+ CURRENT_USER: {},
+ CLASSES_ROOT: {},
+
+ getRoot: function(aRoot) {
+ switch (aRoot) {
+ case AM_Ci.nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE:
+ return MockRegistry.LOCAL_MACHINE;
+ case AM_Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER:
+ return MockRegistry.CURRENT_USER;
+ case AM_Ci.nsIWindowsRegKey.ROOT_KEY_CLASSES_ROOT:
+ return MockRegistry.CLASSES_ROOT;
+ default:
+ do_throw("Unknown root " + aRootKey);
+ return null;
+ }
+ },
+
+ setValue: function(aRoot, aPath, aName, aValue) {
+ let rootKey = MockRegistry.getRoot(aRoot);
+
+ if (!(aPath in rootKey)) {
+ rootKey[aPath] = [];
+ }
+ else {
+ for (let i = 0; i < rootKey[aPath].length; i++) {
+ if (rootKey[aPath][i].name == aName) {
+ if (aValue === null)
+ rootKey[aPath].splice(i, 1);
+ else
+ rootKey[aPath][i].value = aValue;
+ return;
+ }
+ }
+ }
+
+ if (aValue === null)
+ return;
+
+ rootKey[aPath].push({
+ name: aName,
+ value: aValue
+ });
+ }
+ };
+
+ /**
+ * This is a mock nsIWindowsRegistry implementation. It only implements the
+ * methods that the extension manager requires.
+ */
+ function MockWindowsRegKey() {
+ }
+
+ MockWindowsRegKey.prototype = {
+ values: null,
+
+ // --- Overridden nsISupports interface functions ---
+ QueryInterface: XPCOMUtils.generateQI([AM_Ci.nsIWindowsRegKey]),
+
+ // --- Overridden nsIWindowsRegKey interface functions ---
+ open: function(aRootKey, aRelPath, aMode) {
+ let rootKey = MockRegistry.getRoot(aRootKey);
+
+ if (!(aRelPath in rootKey))
+ rootKey[aRelPath] = [];
+ this.values = rootKey[aRelPath];
+ },
+
+ close: function() {
+ this.values = null;
+ },
+
+ get valueCount() {
+ if (!this.values)
+ throw Components.results.NS_ERROR_FAILURE;
+ return this.values.length;
+ },
+
+ getValueName: function(aIndex) {
+ if (!this.values || aIndex >= this.values.length)
+ throw Components.results.NS_ERROR_FAILURE;
+ return this.values[aIndex].name;
+ },
+
+ readStringValue: function(aName) {
+ for (let value of this.values) {
+ if (value.name == aName)
+ return value.value;
+ }
+ return null;
+ }
+ };
+
+ var WinRegFactory = {
+ createInstance: function(aOuter, aIid) {
+ if (aOuter != null)
+ throw Components.results.NS_ERROR_NO_AGGREGATION;
+
+ var key = new MockWindowsRegKey();
+ return key.QueryInterface(aIid);
+ }
+ };
+
+ var registrar = Components.manager.QueryInterface(AM_Ci.nsIComponentRegistrar);
+ registrar.registerFactory(Components.ID("{0478de5b-0f38-4edb-851d-4c99f1ed8eba}"),
+ "Mock Windows Registry Implementation",
+ "@mozilla.org/windows-registry-key;1", WinRegFactory);
}
+// Get the profile directory for tests to use.
+const gProfD = do_get_profile();
+
const EXTENSIONS_DB = "extensions.json";
-var gExtensionsJSON = gProfD.clone();
+let gExtensionsJSON = gProfD.clone();
gExtensionsJSON.append(EXTENSIONS_DB);
+const EXTENSIONS_INI = "extensions.ini";
+let gExtensionsINI = gProfD.clone();
+gExtensionsINI.append(EXTENSIONS_INI);
+
+// Enable more extensive EM logging
+Services.prefs.setBoolPref("extensions.logging.enabled", true);
+
+// By default only load extensions from the profile install location
+Services.prefs.setIntPref("extensions.enabledScopes", AddonManager.SCOPE_PROFILE);
+
+// By default don't disable add-ons from any scope
+Services.prefs.setIntPref("extensions.autoDisableScopes", 0);
+
+// By default, don't cache add-ons in AddonRepository.jsm
+Services.prefs.setBoolPref("extensions.getAddons.cache.enabled", false);
+
+// Disable the compatibility updates window by default
+Services.prefs.setBoolPref("extensions.showMismatchUI", false);
+
+// Point update checks to the local machine for fast failures
+Services.prefs.setCharPref("extensions.update.url", "http://127.0.0.1/updateURL");
+Services.prefs.setCharPref("extensions.update.background.url", "http://127.0.0.1/updateBackgroundURL");
+Services.prefs.setCharPref("extensions.blocklist.url", "http://127.0.0.1/blocklistURL");
+
+// By default ignore bundled add-ons
+Services.prefs.setBoolPref("extensions.installDistroAddons", false);
// By default use strict compatibility
Services.prefs.setBoolPref("extensions.strictCompatibility", true);
@@ -1063,9 +1464,26 @@ Services.prefs.setBoolPref("extensions.strictCompatibility", true);
Services.prefs.setCharPref(PREF_EM_MIN_COMPAT_APP_VERSION, "0");
Services.prefs.setCharPref(PREF_EM_MIN_COMPAT_PLATFORM_VERSION, "0");
-// Ensure signature checks are enabled by default
-Services.prefs.setBoolPref(PREF_XPI_SIGNATURES_REQUIRED, true);
-
+// Register a temporary directory for the tests.
+const gTmpD = gProfD.clone();
+gTmpD.append("temp");
+gTmpD.create(AM_Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
+registerDirectory("TmpD", gTmpD);
+
+// Write out an empty blocklist.xml file to the profile to ensure nothing
+// is blocklisted by default
+var blockFile = gProfD.clone();
+blockFile.append("blocklist.xml");
+var stream = AM_Cc["@mozilla.org/network/file-output-stream;1"].
+ createInstance(AM_Ci.nsIFileOutputStream);
+stream.init(blockFile, FileUtils.MODE_WRONLY | FileUtils.MODE_CREATE | FileUtils.MODE_TRUNCATE,
+ FileUtils.PERMS_FILE, 0);
+
+var data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<blocklist xmlns=\"http://www.mozilla.org/2006/addons-blocklist\">\n" +
+ "</blocklist>\n";
+stream.write(data, data.length);
+stream.close();
// Copies blocklistFile (an nsIFile) to gProfD/blocklist.xml.
function copyBlocklistToProfile(blocklistFile) {
@@ -1091,40 +1509,51 @@ var timer = AM_Cc["@mozilla.org/timer;1"].createInstance(AM_Ci.nsITimer);
timer.init(timeout, TIMEOUT_MS, AM_Ci.nsITimer.TYPE_ONE_SHOT);
// Make sure that a given path does not exist
-function pathShouldntExist(file) {
- if (file.exists()) {
- do_throw(`Test cleanup: path ${file.path} exists when it should not`);
+function pathShouldntExist(aPath) {
+ if (aPath.exists()) {
+ do_throw("Test cleanup: path " + aPath.path + " exists when it should not");
}
}
do_register_cleanup(function addon_cleanup() {
if (timer)
timer.cancel();
-});
-/**
- * Creates a new HttpServer for testing, and begins listening on the
- * specified port. Automatically shuts down the server when the test
- * unit ends.
- *
- * @param port
- * The port to listen on. If omitted, listen on a random
- * port. The latter is the preferred behavior.
- *
- * @return HttpServer
- */
-function createHttpServer(port = -1) {
- let server = new HttpServer();
- server.start(port);
+ for (let file of temp_xpis) {
+ if (file.exists())
+ file.remove(false);
+ }
- do_register_cleanup(() => {
- return new Promise(resolve => {
- server.stop(resolve);
- });
- });
+ // Check that the temporary directory is empty
+ var dirEntries = gTmpD.directoryEntries
+ .QueryInterface(AM_Ci.nsIDirectoryEnumerator);
+ var entry;
+ while ((entry = dirEntries.nextFile)) {
+ do_throw("Found unexpected file in temporary directory: " + entry.leafName);
+ }
+ dirEntries.close();
- return server;
-}
+ var testDir = gProfD.clone();
+ testDir.append("extensions");
+ testDir.append("trash");
+ pathShouldntExist(testDir);
+
+ testDir.leafName = "staged";
+ pathShouldntExist(testDir);
+
+ testDir.leafName = "staged-xpis";
+ pathShouldntExist(testDir);
+
+ shutdownManager();
+
+ // Clear commonly set prefs.
+ try {
+ Services.prefs.clearUserPref(PREF_EM_CHECK_UPDATE_SECURITY);
+ } catch (e) {}
+ try {
+ Services.prefs.clearUserPref(PREF_EM_STRICT_COMPATIBILITY);
+ } catch (e) {}
+});
/**
* Handler function that responds with the interpolated
@@ -1154,7 +1583,7 @@ function interpolateAndServeFile(request, response) {
response.write(data);
} catch (e) {
- do_throw(`Exception while serving interpolated file: ${e}\n${e.stack}`);
+ do_throw("Exception while serving interpolated file.");
} finally {
cstream.close(); // this closes fstream as well
}
@@ -1195,7 +1624,7 @@ function do_exception_wrap(func) {
try {
func.apply(null, arguments);
}
- catch (e) {
+ catch(e) {
do_report_unexpected_exception(e);
}
};
@@ -1204,11 +1633,9 @@ function do_exception_wrap(func) {
/**
* Change the schema version of the JSON extensions database
*/
-function changeXPIDBVersion(aNewVersion, aMutator = undefined) {
+function changeXPIDBVersion(aNewVersion) {
let jData = loadJSON(gExtensionsJSON);
jData.schemaVersion = aNewVersion;
- if (aMutator)
- aMutator(jData);
saveJSON(jData, gExtensionsJSON);
}
@@ -1239,7 +1666,7 @@ function loadFile(aFile) {
function loadJSON(aFile) {
let data = loadFile(aFile);
do_print("Loaded JSON file " + aFile.path);
- return (JSON.parse(data));
+ return(JSON.parse(data));
}
/**
@@ -1271,75 +1698,62 @@ function callback_soon(aFunction) {
}
}
-function writeProxyFileToDir(aDir, aAddon, aId) {
- awaitPromise(promiseWriteProxyFileToDir(aDir, aAddon, aId));
-
- let file = aDir.clone();
- file.append(aId);
- return file
+/**
+ * A promise-based variant of AddonManager.getAddonsByIDs.
+ *
+ * @param {array} list As the first argument of AddonManager.getAddonsByIDs
+ * @return {promise}
+ * @resolve {array} The list of add-ons sent by AddonManaget.getAddonsByIDs to
+ * its callback.
+ */
+function promiseAddonsByIDs(list) {
+ return new Promise(resolve => AddonManager.getAddonsByIDs(list, resolve));
}
-function* serveSystemUpdate(xml, perform_update, testserver) {
- testserver.registerPathHandler("/data/update.xml", (request, response) => {
- response.write(xml);
- });
-
- try {
- yield perform_update();
- }
- finally {
- testserver.registerPathHandler("/data/update.xml", null);
- }
+/**
+ * A promise-based variant of AddonManager.getAddonByID.
+ *
+ * @param {string} aId The ID of the add-on.
+ * @return {promise}
+ * @resolve {AddonWrapper} The corresponding add-on, or null.
+ */
+function promiseAddonByID(aId) {
+ return new Promise(resolve => AddonManager.getAddonByID(aId, resolve));
}
-// Runs an update check making it use the passed in xml string. Uses the direct
-// call to the update function so we get rejections on failure.
-function* installSystemAddons(xml, testserver) {
- do_print("Triggering system add-on update check.");
-
- yield serveSystemUpdate(xml, function*() {
- let { XPIProvider } = Components.utils.import("resource://gre/modules/addons/XPIProvider.jsm", {});
- yield XPIProvider.updateSystemAddons();
- }, testserver);
+/**
+ * A promise-based variant of AddonManager.getAddonsWithOperationsByTypes
+ *
+ * @param {array} aTypes The first argument to
+ * AddonManager.getAddonsWithOperationsByTypes
+ * @return {promise}
+ * @resolve {array} The list of add-ons sent by
+ * AddonManaget.getAddonsWithOperationsByTypes to its callback.
+ */
+function promiseAddonsWithOperationsByTypes(aTypes) {
+ return new Promise(resolve => AddonManager.getAddonsWithOperationsByTypes(aTypes, resolve));
}
-// Runs a full add-on update check which will in some cases do a system add-on
-// update check. Always succeeds.
-function* updateAllSystemAddons(xml, testserver) {
- do_print("Triggering full add-on update check.");
-
- yield serveSystemUpdate(xml, function() {
- return new Promise(resolve => {
- Services.obs.addObserver(function() {
- Services.obs.removeObserver(arguments.callee, "addons-background-update-complete");
-
- resolve();
- }, "addons-background-update-complete", false);
-
- // Trigger the background update timer handler
- gInternalManager.notify(null);
- });
- }, testserver);
-}
-
-// Builds an update.xml file for an update check based on the data passed.
-function* buildSystemAddonUpdates(addons, root) {
- let xml = `<?xml version="1.0" encoding="UTF-8"?>\n\n<updates>\n`;
- if (addons) {
- xml += ` <addons>\n`;
- for (let addon of addons) {
- xml += ` <addon id="${addon.id}" URL="${root + addon.path}" version="${addon.version}"`;
- if (addon.size)
- xml += ` size="${addon.size}"`;
- if (addon.hashFunction)
- xml += ` hashFunction="${addon.hashFunction}"`;
- if (addon.hashValue)
- xml += ` hashValue="${addon.hashValue}"`;
- xml += `/>\n`;
- }
- xml += ` </addons>\n`;
- }
- xml += `</updates>\n`;
-
- return xml;
+/**
+ * Returns a promise that will be resolved when an add-on update check is
+ * complete. The value resolved will be an AddonInstall if a new version was
+ * found.
+ */
+function promiseFindAddonUpdates(addon, reason = AddonManager.UPDATE_WHEN_PERIODIC_UPDATE) {
+ return new Promise((resolve, reject) => {
+ addon.findUpdates({
+ install: null,
+
+ onUpdateAvailable: function(addon, install) {
+ this.install = install;
+ },
+
+ onUpdateFinished: function(addon, error) {
+ if (error == AddonManager.UPDATE_STATUS_NO_ERROR)
+ resolve(this.install);
+ else
+ reject(error);
+ }
+ }, reason);
+ });
}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/head_unpack.js b/toolkit/mozapps/extensions/test/xpcshell/head_unpack.js
index 6310bbc60..088898b41 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/head_unpack.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/head_unpack.js
@@ -1,3 +1,2 @@
-/* globals Services, TEST_UNPACKED: true*/
Services.prefs.setBoolPref("extensions.alwaysUnpack", true);
TEST_UNPACKED = true;
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository.js b/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository.js
index dd0dc1981..3f51d7226 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository.js
@@ -208,7 +208,7 @@ var SEARCH_RESULTS = [{
repositoryStatus: 8,
size: 5555,
updateDate: new Date(1265033045000),
-
+
}, {
id: "purchase1@tests.mozilla.org",
type: "extension",
@@ -403,7 +403,7 @@ function run_test() {
try {
aInstall.install();
}
- catch (e) {
+ catch(e) {
do_print("Failed to install add-on " + aInstall.sourceURI.spec);
do_report_unexpected_exception(e);
}
@@ -469,12 +469,12 @@ function run_test_1() {
initiallyUndefined: true,
preference: PREF_GETADDONS_BROWSEADDONS,
urlTests: urlTests,
- getURL: () => AddonRepository.homepageURL
+ getURL: function() AddonRepository.homepageURL
}, {
initiallyUndefined: true,
preference: PREF_GETADDONS_BROWSERECOMMENDED,
urlTests: urlTests,
- getURL: () => AddonRepository.getRecommendedURL()
+ getURL: function() AddonRepository.getRecommendedURL()
}, {
initiallyUndefined: false,
preference: PREF_GETADDONS_BROWSESEARCHRESULTS,
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository_cache.js b/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository_cache.js
index 203235940..0327ab6d0 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository_cache.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_AddonRepository_cache.js
@@ -6,7 +6,8 @@
Components.utils.import("resource://gre/modules/addons/AddonRepository.jsm");
-var gServer;
+Components.utils.import("resource://testing-common/httpd.js");
+let gServer;
const PORT = 4444;
const BASE_URL = "http://localhost:" + PORT;
@@ -21,7 +22,7 @@ const FILE_DATABASE = "addons.json";
const ADDON_NAMES = ["test_AddonRepository_1",
"test_AddonRepository_2",
"test_AddonRepository_3"];
-const ADDON_IDS = ADDON_NAMES.map(aName => aName + "@tests.mozilla.org");
+const ADDON_IDS = ADDON_NAMES.map(function(aName) aName + "@tests.mozilla.org");
const ADDON_FILES = ADDON_NAMES.map(do_get_addon);
const PREF_ADDON0_CACHE_ENABLED = "extensions." + ADDON_IDS[0] + ".getAddons.cache.enabled";
@@ -132,7 +133,7 @@ const REPOSITORY_ADDONS = [{
url: BASE_URL + "/repo/2/firstFull.png",
thumbnailURL: BASE_URL + "/repo/2/firstThumbnail.png",
caption: "Repo Add-on 2 - First Caption"
- }, {
+ } , {
url: BASE_URL + "/repo/2/secondFull.png",
thumbnailURL: BASE_URL + "/repo/2/secondThumbnail.png",
caption: "Repo Add-on 2 - Second Caption"
@@ -160,7 +161,7 @@ const REPOSITORY_ADDONS = [{
url: BASE_URL + "/repo/3/firstFull.png",
thumbnailURL: BASE_URL + "/repo/3/firstThumbnail.png",
caption: "Repo Add-on 3 - First Caption"
- }, {
+ } , {
url: BASE_URL + "/repo/3/secondFull.png",
thumbnailURL: BASE_URL + "/repo/3/secondThumbnail.png",
caption: "Repo Add-on 3 - Second Caption"
@@ -288,7 +289,7 @@ const WITH_CACHE = [{
url: BASE_URL + "/repo/2/firstFull.png",
thumbnailURL: BASE_URL + "/repo/2/firstThumbnail.png",
caption: "Repo Add-on 2 - First Caption"
- }, {
+ } , {
url: BASE_URL + "/repo/2/secondFull.png",
thumbnailURL: BASE_URL + "/repo/2/secondThumbnail.png",
caption: "Repo Add-on 2 - Second Caption"
@@ -320,7 +321,7 @@ const WITH_CACHE = [{
url: BASE_URL + "/repo/3/firstFull.png",
thumbnailURL: BASE_URL + "/repo/3/firstThumbnail.png",
caption: "Repo Add-on 3 - First Caption"
- }, {
+ } , {
url: BASE_URL + "/repo/3/secondFull.png",
thumbnailURL: BASE_URL + "/repo/3/secondThumbnail.png",
caption: "Repo Add-on 3 - Second Caption"
@@ -401,7 +402,7 @@ const WITH_EXTENSION_CACHE = [{
sourceURI: NetUtil.newURI(ADDON_FILES[2]).spec
}];
-var gDBFile = gProfD.clone();
+let gDBFile = gProfD.clone();
gDBFile.append(FILE_DATABASE);
/*
@@ -504,8 +505,9 @@ add_task(function* setup() {
yield promiseInstallAllFiles(ADDON_FILES);
yield promiseRestartManager();
- gServer = createHttpServer(PORT);
+ gServer = new HttpServer();
gServer.registerDirectory("/data/", do_get_file("data"));
+ gServer.start(PORT);
});
// Tests AddonRepository.cacheEnabled
@@ -702,3 +704,7 @@ add_task(function* run_test_17() {
let aAddons = yield promiseAddonsByIDs(ADDON_IDS);
check_results(aAddons, WITH_EXTENSION_CACHE);
});
+
+add_task(function* end_test() {
+ yield new Promise((resolve, reject) => gServer.stop(resolve));
+});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_ChromeManifestParser.js b/toolkit/mozapps/extensions/test/xpcshell/test_ChromeManifestParser.js
index 605c4224b..2e4adbe0f 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_ChromeManifestParser.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_ChromeManifestParser.js
@@ -1,108 +1,108 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-// Tests ChromeManifestParser.js
-
-Components.utils.import("resource://gre/modules/ChromeManifestParser.jsm");
-
-
-function run_test() {
- do_test_pending();
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "2");
-
- startupManager();
-
- installAllFiles([do_get_addon("test_chromemanifest_1"),
- do_get_addon("test_chromemanifest_2"),
- do_get_addon("test_chromemanifest_3"),
- do_get_addon("test_chromemanifest_4")],
- function() {
-
- restartManager();
- run_test_1();
- });
-}
-
-function run_test_1() {
- AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
- "addon2@tests.mozilla.org",
- "addon3@tests.mozilla.org",
- "addon4@tests.mozilla.org"],
- function([a1, a2, a3, a4]) {
- // addon1
- let a1Uri = a1.getResourceURI("/").spec;
- let expected = [
- {type: "content", baseURI: a1Uri, args: ["test-addon-1", "chrome/content"]},
- {type: "locale", baseURI: a1Uri, args: ["test-addon-1", "en-US", "locale/en-US"]},
- {type: "locale", baseURI: a1Uri, args: ["test-addon-1", "fr-FR", "locale/fr-FR"]},
- {type: "overlay", baseURI: a1Uri, args: ["chrome://browser/content/browser.xul", "chrome://test-addon-1/content/overlay.xul"]}
- ];
- let manifestURI = a1.getResourceURI("chrome.manifest");
- let manifest = ChromeManifestParser.parseSync(manifestURI);
-
- do_check_true(Array.isArray(manifest));
- do_check_eq(manifest.length, expected.length);
- for (let i = 0; i < manifest.length; i++) {
- do_check_eq(JSON.stringify(manifest[i]), JSON.stringify(expected[i]));
- }
-
- // addon2
- let a2Uri = a2.getResourceURI("/").spec;
- expected = [
- {type: "content", baseURI: a2Uri, args: ["test-addon-1", "chrome/content"]},
- {type: "locale", baseURI: a2Uri, args: ["test-addon-1", "en-US", "locale/en-US"]},
- {type: "locale", baseURI: a2Uri, args: ["test-addon-1", "fr-FR", "locale/fr-FR"]},
- {type: "overlay", baseURI: a2Uri, args: ["chrome://browser/content/browser.xul", "chrome://test-addon-1/content/overlay.xul"]},
- {type: "binary-component", baseURI: a2Uri, args: ["components/something.so"]}
- ];
- manifestURI = a2.getResourceURI("chrome.manifest");
- manifest = ChromeManifestParser.parseSync(manifestURI);
-
- do_check_true(Array.isArray(manifest));
- do_check_eq(manifest.length, expected.length);
- for (let i = 0; i < manifest.length; i++) {
- do_check_eq(JSON.stringify(manifest[i]), JSON.stringify(expected[i]));
- }
-
- // addon3
- let a3Uri = a3.getResourceURI("/").spec;
- expected = [
- {type: "content", baseURI: a3Uri, args: ["test-addon-1", "chrome/content"]},
- {type: "locale", baseURI: a3Uri, args: ["test-addon-1", "en-US", "locale/en-US"]},
- {type: "locale", baseURI: a3Uri, args: ["test-addon-1", "fr-FR", "locale/fr-FR"]},
- {type: "overlay", baseURI: a3Uri, args: ["chrome://browser/content/browser.xul", "chrome://test-addon-1/content/overlay.xul"]},
- {type: "binary-component", baseURI: a3Uri, args: ["components/something.so"]},
- {type: "locale", baseURI: "jar:" + a3.getResourceURI("/inner.jar").spec + "!/", args: ["test-addon-1", "en-NZ", "locale/en-NZ"]},
- ];
- manifestURI = a3.getResourceURI("chrome.manifest");
- manifest = ChromeManifestParser.parseSync(manifestURI);
-
- do_check_true(Array.isArray(manifest));
- do_check_eq(manifest.length, expected.length);
- for (let i = 0; i < manifest.length; i++) {
- do_check_eq(JSON.stringify(manifest[i]), JSON.stringify(expected[i]));
- }
-
- // addon4
- let a4Uri = a4.getResourceURI("/").spec;
- expected = [
- {type: "content", baseURI: a4Uri, args: ["test-addon-1", "chrome/content"]},
- {type: "locale", baseURI: a4Uri, args: ["test-addon-1", "en-US", "locale/en-US"]},
- {type: "locale", baseURI: a4Uri, args: ["test-addon-1", "fr-FR", "locale/fr-FR"]},
- {type: "overlay", baseURI: a4Uri, args: ["chrome://browser/content/browser.xul", "chrome://test-addon-1/content/overlay.xul"]},
- {type: "binary-component", baseURI: a4.getResourceURI("components/").spec, args: ["mycomponent.dll"]},
- {type: "binary-component", baseURI: a4.getResourceURI("components/other/").spec, args: ["thermalnuclearwar.dll"]}
- ];
- manifestURI = a4.getResourceURI("chrome.manifest");
- manifest = ChromeManifestParser.parseSync(manifestURI);
-
- do_check_true(Array.isArray(manifest));
- do_check_eq(manifest.length, expected.length);
- for (let i = 0; i < manifest.length; i++) {
- do_check_eq(JSON.stringify(manifest[i]), JSON.stringify(expected[i]));
- }
-
- do_execute_soon(do_test_finished);
- });
-}
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+// Tests ChromeManifestParser.js
+
+Components.utils.import("resource://gre/modules/ChromeManifestParser.jsm");
+
+
+function run_test() {
+ do_test_pending();
+ createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "2");
+
+ startupManager();
+
+ installAllFiles([do_get_addon("test_chromemanifest_1"),
+ do_get_addon("test_chromemanifest_2"),
+ do_get_addon("test_chromemanifest_3"),
+ do_get_addon("test_chromemanifest_4")],
+ function() {
+
+ restartManager();
+ run_test_1();
+ });
+}
+
+function run_test_1() {
+ AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
+ "addon2@tests.mozilla.org",
+ "addon3@tests.mozilla.org",
+ "addon4@tests.mozilla.org"],
+ function([a1, a2, a3, a4]) {
+ // addon1
+ let a1Uri = a1.getResourceURI("/").spec;
+ let expected = [
+ {type: "content", baseURI: a1Uri, args: ["test-addon-1", "chrome/content"]},
+ {type: "locale", baseURI: a1Uri, args: ["test-addon-1", "en-US", "locale/en-US"]},
+ {type: "locale", baseURI: a1Uri, args: ["test-addon-1", "fr-FR", "locale/fr-FR"]},
+ {type: "overlay", baseURI: a1Uri, args: ["chrome://browser/content/browser.xul", "chrome://test-addon-1/content/overlay.xul"]}
+ ];
+ let manifestURI = a1.getResourceURI("chrome.manifest");
+ let manifest = ChromeManifestParser.parseSync(manifestURI);
+
+ do_check_true(Array.isArray(manifest));
+ do_check_eq(manifest.length, expected.length);
+ for (let i = 0; i < manifest.length; i++) {
+ do_check_eq(JSON.stringify(manifest[i]), JSON.stringify(expected[i]));
+ }
+
+ // addon2
+ let a2Uri = a2.getResourceURI("/").spec;
+ expected = [
+ {type: "content", baseURI: a2Uri, args: ["test-addon-1", "chrome/content"]},
+ {type: "locale", baseURI: a2Uri, args: ["test-addon-1", "en-US", "locale/en-US"]},
+ {type: "locale", baseURI: a2Uri, args: ["test-addon-1", "fr-FR", "locale/fr-FR"]},
+ {type: "overlay", baseURI: a2Uri, args: ["chrome://browser/content/browser.xul", "chrome://test-addon-1/content/overlay.xul"]},
+ {type: "binary-component", baseURI: a2Uri, args: ["components/something.so"]}
+ ];
+ manifestURI = a2.getResourceURI("chrome.manifest");
+ manifest = ChromeManifestParser.parseSync(manifestURI);
+
+ do_check_true(Array.isArray(manifest));
+ do_check_eq(manifest.length, expected.length);
+ for (let i = 0; i < manifest.length; i++) {
+ do_check_eq(JSON.stringify(manifest[i]), JSON.stringify(expected[i]));
+ }
+
+ // addon3
+ let a3Uri = a3.getResourceURI("/").spec;
+ expected = [
+ {type: "content", baseURI: a3Uri, args: ["test-addon-1", "chrome/content"]},
+ {type: "locale", baseURI: a3Uri, args: ["test-addon-1", "en-US", "locale/en-US"]},
+ {type: "locale", baseURI: a3Uri, args: ["test-addon-1", "fr-FR", "locale/fr-FR"]},
+ {type: "overlay", baseURI: a3Uri, args: ["chrome://browser/content/browser.xul", "chrome://test-addon-1/content/overlay.xul"]},
+ {type: "binary-component", baseURI: a3Uri, args: ["components/something.so"]},
+ {type: "locale", baseURI: "jar:" + a3.getResourceURI("/inner.jar").spec + "!/", args: ["test-addon-1", "en-NZ", "locale/en-NZ"]},
+ ];
+ manifestURI = a3.getResourceURI("chrome.manifest");
+ manifest = ChromeManifestParser.parseSync(manifestURI);
+
+ do_check_true(Array.isArray(manifest));
+ do_check_eq(manifest.length, expected.length);
+ for (let i = 0; i < manifest.length; i++) {
+ do_check_eq(JSON.stringify(manifest[i]), JSON.stringify(expected[i]));
+ }
+
+ // addon4
+ let a4Uri = a4.getResourceURI("/").spec;
+ expected = [
+ {type: "content", baseURI: a4Uri, args: ["test-addon-1", "chrome/content"]},
+ {type: "locale", baseURI: a4Uri, args: ["test-addon-1", "en-US", "locale/en-US"]},
+ {type: "locale", baseURI: a4Uri, args: ["test-addon-1", "fr-FR", "locale/fr-FR"]},
+ {type: "overlay", baseURI: a4Uri, args: ["chrome://browser/content/browser.xul", "chrome://test-addon-1/content/overlay.xul"]},
+ {type: "binary-component", baseURI: a4.getResourceURI("components/").spec, args: ["mycomponent.dll"]},
+ {type: "binary-component", baseURI: a4.getResourceURI("components/other/").spec, args: ["thermalnuclearwar.dll"]}
+ ];
+ manifestURI = a4.getResourceURI("chrome.manifest");
+ manifest = ChromeManifestParser.parseSync(manifestURI);
+
+ do_check_true(Array.isArray(manifest));
+ do_check_eq(manifest.length, expected.length);
+ for (let i = 0; i < manifest.length; i++) {
+ do_check_eq(JSON.stringify(manifest[i]), JSON.stringify(expected[i]));
+ }
+
+ do_execute_soon(do_test_finished);
+ });
+}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_DeferredSave.js b/toolkit/mozapps/extensions/test/xpcshell/test_DeferredSave.js
index 2a6ff291e..7599c8b80 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_DeferredSave.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_DeferredSave.js
@@ -12,8 +12,8 @@ testFile.append("DeferredSaveTest");
Components.utils.import("resource://gre/modules/Promise.jsm");
-var DSContext = Components.utils.import("resource://gre/modules/DeferredSave.jsm", {});
-var DeferredSave = DSContext.DeferredSave;
+let DSContext = Components.utils.import("resource://gre/modules/DeferredSave.jsm", {});
+let DeferredSave = DSContext.DeferredSave;
// Test wrapper to let us do promise/task based testing of DeferredSave
function DeferredSaveTester(aDataProvider) {
@@ -67,7 +67,7 @@ function DeferredSaveTester(aDataProvider) {
};
return tester;
-}
+};
/**
* Install a mock nsITimer factory that triggers on the next spin of
@@ -147,7 +147,7 @@ function run_test() {
}
// Modify set data once, ask for save, make sure it saves cleanly
-add_task(function* test_basic_save_succeeds() {
+add_task(function test_basic_save_succeeds() {
setQuickMockTimer();
let tester = DeferredSaveTester();
let data = "Test 1 Data";
@@ -159,7 +159,7 @@ add_task(function* test_basic_save_succeeds() {
// Two saves called during the same event loop, both with callbacks
// Make sure we save only the second version of the data
-add_task(function* test_two_saves() {
+add_task(function test_two_saves() {
setQuickMockTimer();
let tester = DeferredSaveTester();
let firstCallback_happened = false;
@@ -182,7 +182,7 @@ add_task(function* test_two_saves() {
// Two saves called with a delay in between, both with callbacks
// Make sure we save the second version of the data
-add_task(function* test_two_saves_delay() {
+add_task(function test_two_saves_delay() {
let timerPromise = setPromiseMockTimer();
let tester = DeferredSaveTester();
let firstCallback_happened = false;
@@ -219,7 +219,7 @@ add_task(function* test_two_saves_delay() {
// Test case where OS.File immediately reports an error when the write begins
// Also check that the "error" getter correctly returns the error
// Then do a write that succeeds, and make sure the error is cleared
-add_task(function* test_error_immediate() {
+add_task(function test_error_immediate() {
let tester = DeferredSaveTester();
let testError = new Error("Forced failure");
function writeFail(aTester) {
@@ -243,7 +243,7 @@ add_task(function* test_error_immediate() {
// Save one set of changes, then while the write is in progress, modify the
// data two more times. Test that we re-write the dirty data exactly once
// after the first write succeeds
-add_task(function* dirty_while_writing() {
+add_task(function dirty_while_writing() {
let tester = DeferredSaveTester();
let firstData = "First data";
let secondData = "Second data";
@@ -303,6 +303,7 @@ add_task(function* dirty_while_writing() {
// A write callback for the OS.File.writeAtomic mock that rejects write attempts
function disabled_write_callback(aTester) {
do_throw("Should not have written during clean flush");
+ deferred.reject(new Error("Write during supposedly clean flush"));
}
// special write callback that disables itself to make sure
@@ -316,7 +317,7 @@ function write_then_disable(aTester) {
// Flush tests. First, do an ordinary clean save and then call flush;
// there should not be another save
-add_task(function* flush_after_save() {
+add_task(function flush_after_save() {
setQuickMockTimer();
let tester = DeferredSaveTester();
let dataToSave = "Flush after save";
@@ -327,7 +328,7 @@ add_task(function* flush_after_save() {
});
// Flush while a write is in progress, but the in-memory data is clean
-add_task(function* flush_during_write() {
+add_task(function flush_during_write() {
let tester = DeferredSaveTester();
let dataToSave = "Flush during write";
let firstCallback_happened = false;
@@ -360,7 +361,7 @@ add_task(function* flush_during_write() {
// Flush while dirty but write not in progress
// The data written should be the value at the time
// flush() is called, even if it is changed later
-add_task(function* flush_while_dirty() {
+add_task(function flush_while_dirty() {
let timerPromise = setPromiseMockTimer();
let tester = DeferredSaveTester();
let firstData = "Flush while dirty, valid data";
@@ -396,7 +397,7 @@ add_task(function* flush_while_dirty() {
// then flush, then modify the data again
// Data for the second write should be taken at the time
// flush() is called, even if it is modified later
-add_task(function* flush_writing_dirty() {
+add_task(function flush_writing_dirty() {
let timerPromise = setPromiseMockTimer();
let tester = DeferredSaveTester();
let firstData = "Flush first pass data";
@@ -453,7 +454,7 @@ add_task(function* flush_writing_dirty() {
// with the error and (b) make sure the provider is only
// called once in case of error
const expectedDataError = "Failed to serialize data";
-var badDataError = null;
+let badDataError = null;
function badDataProvider() {
let err = new Error(badDataError);
badDataError = "badDataProvider called twice";
@@ -462,7 +463,7 @@ function badDataProvider() {
// Handle cases where data provider throws
// First, throws during a normal save
-add_task(function* data_throw() {
+add_task(function data_throw() {
setQuickMockTimer();
badDataError = expectedDataError;
let tester = DeferredSaveTester(badDataProvider);
@@ -472,7 +473,7 @@ add_task(function* data_throw() {
});
// Now, throws during flush
-add_task(function* data_throw_during_flush() {
+add_task(function data_throw_during_flush() {
badDataError = expectedDataError;
let tester = DeferredSaveTester(badDataProvider);
let firstCallback_happened = false;
@@ -507,7 +508,7 @@ add_task(function* data_throw_during_flush() {
// actually restart timer for delayed write
// write completes
// delayed timer goes off, throws error because DeferredSave has been torn down
-add_task(function* delay_flush_race() {
+add_task(function delay_flush_race() {
let timerPromise = setPromiseMockTimer();
let tester = DeferredSaveTester();
let firstData = "First save";
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_LightweightThemeManager.js b/toolkit/mozapps/extensions/test/xpcshell/test_LightweightThemeManager.js
index 61a46b251..c0cf78a89 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_LightweightThemeManager.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_LightweightThemeManager.js
@@ -1,5 +1,5 @@
-var Cc = Components.classes;
-var Ci = Components.interfaces;
+const Cc = Components.classes;
+const Ci = Components.interfaces;
const MANDATORY = ["id", "name", "headerURL"];
const OPTIONAL = ["footerURL", "textcolor", "accentcolor", "iconURL",
@@ -19,20 +19,18 @@ function dummy(id) {
};
}
-function hasPermission(aAddon, aPerm) {
- var perm = AddonManager["PERM_CAN_" + aPerm.toUpperCase()];
- return !!(aAddon.permissions & perm);
-}
-
function run_test() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
startupManager();
Services.prefs.setIntPref("lightweightThemes.maxUsedThemes", 8);
- let {LightweightThemeManager: ltm} = Components.utils.import("resource://gre/modules/LightweightThemeManager.jsm", {});
+ var temp = {};
+ Components.utils.import("resource://gre/modules/LightweightThemeManager.jsm", temp);
+ do_check_eq(typeof temp.LightweightThemeManager, "object");
+
+ var ltm = temp.LightweightThemeManager;
- do_check_eq(typeof ltm, "object");
do_check_eq(typeof ltm.usedThemes, "object");
do_check_eq(ltm.usedThemes.length, 0);
do_check_eq(ltm.currentTheme, null);
@@ -207,71 +205,71 @@ function run_test() {
function roundtripSet(props, modify, test, secure) {
props.forEach(function (prop) {
- var theme = dummy();
- modify(theme, prop);
- test(roundtrip(theme, secure), prop, theme);
+ var data = dummy();
+ modify(data, prop);
+ test(roundtrip(data, secure), prop, data);
});
}
- roundtripSet(MANDATORY, function (theme, prop) {
- delete theme[prop];
+ roundtripSet(MANDATORY, function (data, prop) {
+ delete data[prop];
}, function (after) {
do_check_eq(after, null);
});
- roundtripSet(OPTIONAL, function (theme, prop) {
- delete theme[prop];
+ roundtripSet(OPTIONAL, function (data, prop) {
+ delete data[prop];
}, function (after) {
do_check_neq(after, null);
});
- roundtripSet(MANDATORY, function (theme, prop) {
- theme[prop] = "";
+ roundtripSet(MANDATORY, function (data, prop) {
+ data[prop] = "";
}, function (after) {
do_check_eq(after, null);
});
- roundtripSet(OPTIONAL, function (theme, prop) {
- theme[prop] = "";
+ roundtripSet(OPTIONAL, function (data, prop) {
+ data[prop] = "";
}, function (after, prop) {
do_check_eq(typeof after[prop], "undefined");
});
- roundtripSet(MANDATORY, function (theme, prop) {
- theme[prop] = " ";
+ roundtripSet(MANDATORY, function (data, prop) {
+ data[prop] = " ";
}, function (after) {
do_check_eq(after, null);
});
- roundtripSet(OPTIONAL, function (theme, prop) {
- theme[prop] = " ";
+ roundtripSet(OPTIONAL, function (data, prop) {
+ data[prop] = " ";
}, function (after, prop) {
do_check_neq(after, null);
do_check_eq(typeof after[prop], "undefined");
});
function non_urls(props) {
- return props.filter(prop => !/URL$/.test(prop));
+ return props.filter(function (prop) !/URL$/.test(prop));
}
function urls(props) {
- return props.filter(prop => /URL$/.test(prop));
+ return props.filter(function (prop) /URL$/.test(prop));
}
- roundtripSet(non_urls(MANDATORY.concat(OPTIONAL)), function (theme, prop) {
- theme[prop] = prop;
+ roundtripSet(non_urls(MANDATORY.concat(OPTIONAL)), function (data, prop) {
+ data[prop] = prop;
}, function (after, prop, before) {
do_check_eq(after[prop], before[prop]);
});
- roundtripSet(non_urls(MANDATORY.concat(OPTIONAL)), function (theme, prop) {
- theme[prop] = " " + prop + " ";
+ roundtripSet(non_urls(MANDATORY.concat(OPTIONAL)), function (data, prop) {
+ data[prop] = " " + prop + " ";
}, function (after, prop, before) {
do_check_eq(after[prop], before[prop].trim());
});
- roundtripSet(urls(MANDATORY.concat(OPTIONAL)), function (theme, prop) {
- theme[prop] = Math.random().toString();
+ roundtripSet(urls(MANDATORY.concat(OPTIONAL)), function (data, prop) {
+ data[prop] = Math.random().toString();
}, function (after, prop, before) {
if (prop == "updateURL")
do_check_eq(typeof after[prop], "undefined");
@@ -279,26 +277,26 @@ function run_test() {
do_check_eq(after[prop], "http://lwttest.invalid/" + before[prop]);
});
- roundtripSet(urls(MANDATORY.concat(OPTIONAL)), function (theme, prop) {
- theme[prop] = Math.random().toString();
+ roundtripSet(urls(MANDATORY.concat(OPTIONAL)), function (data, prop) {
+ data[prop] = Math.random().toString();
}, function (after, prop, before) {
do_check_eq(after[prop], "https://lwttest.invalid/" + before[prop]);
}, true);
- roundtripSet(urls(MANDATORY.concat(OPTIONAL)), function (theme, prop) {
- theme[prop] = "https://sub.lwttest.invalid/" + Math.random().toString();
+ roundtripSet(urls(MANDATORY.concat(OPTIONAL)), function (data, prop) {
+ data[prop] = "https://sub.lwttest.invalid/" + Math.random().toString();
}, function (after, prop, before) {
do_check_eq(after[prop], before[prop]);
});
- roundtripSet(urls(MANDATORY), function (theme, prop) {
- theme[prop] = "ftp://lwttest.invalid/" + Math.random().toString();
+ roundtripSet(urls(MANDATORY), function (data, prop) {
+ data[prop] = "ftp://lwttest.invalid/" + Math.random().toString();
}, function (after) {
do_check_eq(after, null);
});
- roundtripSet(urls(OPTIONAL), function (theme, prop) {
- theme[prop] = "ftp://lwttest.invalid/" + Math.random().toString();
+ roundtripSet(urls(OPTIONAL), function (data, prop) {
+ data[prop] = "ftp://lwttest.invalid/" + Math.random().toString();
}, function (after, prop) {
do_check_eq(typeof after[prop], "undefined");
});
@@ -513,86 +511,4 @@ function run_test() {
Services.prefs.clearUserPref("lightweightThemes.maxUsedThemes");
do_check_eq(ltm.usedThemes.length, 30);
-
- let usedThemes = ltm.usedThemes;
- for (let theme of usedThemes) {
- ltm.forgetUsedTheme(theme.id);
- }
-
- // Check builtInTheme functionality for Bug 1094821
- do_check_eq(ltm._builtInThemes.toString(), "[object Map]");
- do_check_eq([...ltm._builtInThemes.entries()].length, 0);
- do_check_eq(ltm.usedThemes.length, 0);
-
- ltm.addBuiltInTheme(dummy("builtInTheme0"));
- do_check_eq([...ltm._builtInThemes].length, 1);
- do_check_eq(ltm.usedThemes.length, 1);
- do_check_eq(ltm.usedThemes[0].id, "builtInTheme0");
-
- ltm.addBuiltInTheme(dummy("builtInTheme1"));
- do_check_eq([...ltm._builtInThemes].length, 2);
- do_check_eq(ltm.usedThemes.length, 2);
- do_check_eq(ltm.usedThemes[1].id, "builtInTheme1");
-
- // Clear all and then re-add
- ltm.clearBuiltInThemes();
- do_check_eq([...ltm._builtInThemes].length, 0);
- do_check_eq(ltm.usedThemes.length, 0);
-
- ltm.addBuiltInTheme(dummy("builtInTheme0"));
- ltm.addBuiltInTheme(dummy("builtInTheme1"));
- do_check_eq([...ltm._builtInThemes].length, 2);
- do_check_eq(ltm.usedThemes.length, 2);
-
- do_test_pending();
-
- AddonManager.getAddonByID("builtInTheme0@personas.mozilla.org", builtInThemeAddon => {
- // App specific theme can't be uninstalled or disabled,
- // but can be enabled (since it isn't already applied).
- do_check_eq(hasPermission(builtInThemeAddon, "uninstall"), false);
- do_check_eq(hasPermission(builtInThemeAddon, "disable"), false);
- do_check_eq(hasPermission(builtInThemeAddon, "enable"), true);
-
- ltm.currentTheme = dummy("x0");
- do_check_eq([...ltm._builtInThemes].length, 2);
- do_check_eq(ltm.usedThemes.length, 3);
- do_check_eq(ltm.usedThemes[0].id, "x0");
- do_check_eq(ltm.currentTheme.id, "x0");
- do_check_eq(ltm.usedThemes[1].id, "builtInTheme0");
- do_check_eq(ltm.usedThemes[2].id, "builtInTheme1");
-
- Assert.throws(() => { ltm.addBuiltInTheme(dummy("builtInTheme0")) },
- "Exception is thrown adding a duplicate theme");
- Assert.throws(() => { ltm.addBuiltInTheme("not a theme object") },
- "Exception is thrown adding an invalid theme");
-
- AddonManager.getAddonByID("x0@personas.mozilla.org", x0Addon => {
- // Currently applied (non-app-specific) can be uninstalled or disabled,
- // but can't be enabled (since it's already applied).
- do_check_eq(hasPermission(x0Addon, "uninstall"), true);
- do_check_eq(hasPermission(x0Addon, "disable"), true);
- do_check_eq(hasPermission(x0Addon, "enable"), false);
-
- ltm.forgetUsedTheme("x0");
- do_check_eq(ltm.currentTheme, null);
-
- // Removing the currently applied app specific theme should unapply it
- ltm.currentTheme = ltm.getUsedTheme("builtInTheme0");
- do_check_eq(ltm.currentTheme.id, "builtInTheme0");
- do_check_true(ltm.forgetBuiltInTheme("builtInTheme0"));
- do_check_eq(ltm.currentTheme, null);
-
- do_check_eq([...ltm._builtInThemes].length, 1);
- do_check_eq(ltm.usedThemes.length, 1);
-
- do_check_true(ltm.forgetBuiltInTheme("builtInTheme1"));
- do_check_false(ltm.forgetBuiltInTheme("not-an-existing-theme-id"));
-
- do_check_eq([...ltm._builtInThemes].length, 0);
- do_check_eq(ltm.usedThemes.length, 0);
- do_check_eq(ltm.currentTheme, null);
-
- do_test_finished();
- });
- });
}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_ProductAddonChecker.js b/toolkit/mozapps/extensions/test/xpcshell/test_ProductAddonChecker.js
deleted file mode 100644
index 6c562db65..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_ProductAddonChecker.js
+++ /dev/null
@@ -1,244 +0,0 @@
-"use strict";
-
-Components.utils.import("resource://gre/modules/addons/ProductAddonChecker.jsm");
-Components.utils.import("resource://testing-common/httpd.js");
-Components.utils.import("resource://gre/modules/osfile.jsm");
-
-const LocalFile = new Components.Constructor("@mozilla.org/file/local;1", AM_Ci.nsIFile, "initWithPath");
-
-var testserver = new HttpServer();
-testserver.registerDirectory("/data/", do_get_file("data/productaddons"));
-testserver.start();
-var root = testserver.identity.primaryScheme + "://" +
- testserver.identity.primaryHost + ":" +
- testserver.identity.primaryPort + "/data/"
-
-/**
- * Compares binary data of 2 arrays and returns true if they are the same
- *
- * @param arr1 The first array to compare
- * @param arr2 The second array to compare
-*/
-function compareBinaryData(arr1, arr2) {
- do_check_eq(arr1.length, arr2.length);
- for (let i = 0; i < arr1.length; i++) {
- if (arr1[i] != arr2[i]) {
- do_print("Data differs at index " + i +
- ", arr1: " + arr1[i] + ", arr2: " + arr2[i]);
- return false;
- }
- }
- return true;
-}
-
-/**
- * Reads a file's data and returns it
- *
- * @param file The file to read the data from
- * @return array of bytes for the data in the file.
-*/
-function getBinaryFileData(file) {
- let fileStream = AM_Cc["@mozilla.org/network/file-input-stream;1"].
- createInstance(AM_Ci.nsIFileInputStream);
- // Open as RD_ONLY with default permissions.
- fileStream.init(file, FileUtils.MODE_RDONLY, FileUtils.PERMS_FILE, 0);
-
- let stream = AM_Cc["@mozilla.org/binaryinputstream;1"].
- createInstance(AM_Ci.nsIBinaryInputStream);
- stream.setInputStream(fileStream);
- let bytes = stream.readByteArray(stream.available());
- fileStream.close();
- return bytes;
-}
-
-/**
- * Compares binary data of 2 files and returns true if they are the same
- *
- * @param file1 The first file to compare
- * @param file2 The second file to compare
-*/
-function compareFiles(file1, file2) {
- return compareBinaryData(getBinaryFileData(file1), getBinaryFileData(file2));
-}
-
-add_task(function* test_404() {
- let res = yield ProductAddonChecker.getProductAddonList(root + "404.xml");
- do_check_true(res.usedFallback);
-});
-
-add_task(function* test_not_xml() {
- let res = yield ProductAddonChecker.getProductAddonList(root + "bad.txt");
- do_check_true(res.usedFallback);
-});
-
-add_task(function* test_invalid_xml() {
- let res = yield ProductAddonChecker.getProductAddonList(root + "bad.xml");
- do_check_true(res.usedFallback);
-});
-
-add_task(function* test_wrong_xml() {
- let res = yield ProductAddonChecker.getProductAddonList(root + "bad2.xml");
- do_check_true(res.usedFallback);
-});
-
-add_task(function* test_missing() {
- let addons = yield ProductAddonChecker.getProductAddonList(root + "missing.xml");
- do_check_eq(addons, null);
-});
-
-add_task(function* test_empty() {
- let res = yield ProductAddonChecker.getProductAddonList(root + "empty.xml");
- do_check_true(Array.isArray(res.gmpAddons));
- do_check_eq(res.gmpAddons.length, 0);
-});
-
-add_task(function* test_good_xml() {
- let res = yield ProductAddonChecker.getProductAddonList(root + "good.xml");
- do_check_true(Array.isArray(res.gmpAddons));
-
- // There are three valid entries in the XML
- do_check_eq(res.gmpAddons.length, 5);
-
- let addon = res.gmpAddons[0];
- do_check_eq(addon.id, "test1");
- do_check_eq(addon.URL, "http://example.com/test1.xpi");
- do_check_eq(addon.hashFunction, undefined);
- do_check_eq(addon.hashValue, undefined);
- do_check_eq(addon.version, undefined);
- do_check_eq(addon.size, undefined);
-
- addon = res.gmpAddons[1];
- do_check_eq(addon.id, "test2");
- do_check_eq(addon.URL, "http://example.com/test2.xpi");
- do_check_eq(addon.hashFunction, "md5");
- do_check_eq(addon.hashValue, "djhfgsjdhf");
- do_check_eq(addon.version, undefined);
- do_check_eq(addon.size, undefined);
-
- addon = res.gmpAddons[2];
- do_check_eq(addon.id, "test3");
- do_check_eq(addon.URL, "http://example.com/test3.xpi");
- do_check_eq(addon.hashFunction, undefined);
- do_check_eq(addon.hashValue, undefined);
- do_check_eq(addon.version, "1.0");
- do_check_eq(addon.size, 45);
-
- addon = res.gmpAddons[3];
- do_check_eq(addon.id, "test4");
- do_check_eq(addon.URL, undefined);
- do_check_eq(addon.hashFunction, undefined);
- do_check_eq(addon.hashValue, undefined);
- do_check_eq(addon.version, undefined);
- do_check_eq(addon.size, undefined);
-
- addon = res.gmpAddons[4];
- do_check_eq(addon.id, undefined);
- do_check_eq(addon.URL, "http://example.com/test5.xpi");
- do_check_eq(addon.hashFunction, undefined);
- do_check_eq(addon.hashValue, undefined);
- do_check_eq(addon.version, undefined);
- do_check_eq(addon.size, undefined);
-});
-
-add_task(function* test_download_nourl() {
- try {
- let path = yield ProductAddonChecker.downloadAddon({});
-
- yield OS.File.remove(path);
- do_throw("Should not have downloaded a file with a missing url");
- }
- catch (e) {
- do_check_true(true, "Should have thrown when downloading a file with a missing url.");
- }
-});
-
-add_task(function* test_download_missing() {
- try {
- let path = yield ProductAddonChecker.downloadAddon({
- URL: root + "nofile.xpi",
- });
-
- yield OS.File.remove(path);
- do_throw("Should not have downloaded a missing file");
- }
- catch (e) {
- do_check_true(true, "Should have thrown when downloading a missing file.");
- }
-});
-
-add_task(function* test_download_noverify() {
- let path = yield ProductAddonChecker.downloadAddon({
- URL: root + "unsigned.xpi",
- });
-
- let stat = yield OS.File.stat(path);
- do_check_false(stat.isDir);
- do_check_eq(stat.size, 452)
-
- do_check_true(compareFiles(do_get_file("data/productaddons/unsigned.xpi"), new LocalFile(path)));
-
- yield OS.File.remove(path);
-});
-
-add_task(function* test_download_badsize() {
- try {
- let path = yield ProductAddonChecker.downloadAddon({
- URL: root + "unsigned.xpi",
- size: 400,
- });
-
- yield OS.File.remove(path);
- do_throw("Should not have downloaded a file with a bad size");
- }
- catch (e) {
- do_check_true(true, "Should have thrown when downloading a file with a bad size.");
- }
-});
-
-add_task(function* test_download_badhashfn() {
- try {
- let path = yield ProductAddonChecker.downloadAddon({
- URL: root + "unsigned.xpi",
- hashFunction: "sha2567",
- hashValue: "9b9abf7ddfc1a6d7ffc7e0247481dcc202363e4445ad3494fb22036f1698c7f3",
- });
-
- yield OS.File.remove(path);
- do_throw("Should not have downloaded a file with a bad hash function");
- }
- catch (e) {
- do_check_true(true, "Should have thrown when downloading a file with a bad hash function.");
- }
-});
-
-add_task(function* test_download_badhash() {
- try {
- let path = yield ProductAddonChecker.downloadAddon({
- URL: root + "unsigned.xpi",
- hashFunction: "sha256",
- hashValue: "8b9abf7ddfc1a6d7ffc7e0247481dcc202363e4445ad3494fb22036f1698c7f3",
- });
-
- yield OS.File.remove(path);
- do_throw("Should not have downloaded a file with a bad hash");
- }
- catch (e) {
- do_check_true(true, "Should have thrown when downloading a file with a bad hash.");
- }
-});
-
-add_task(function* test_download_works() {
- let path = yield ProductAddonChecker.downloadAddon({
- URL: root + "unsigned.xpi",
- size: 452,
- hashFunction: "sha256",
- hashValue: "9b9abf7ddfc1a6d7ffc7e0247481dcc202363e4445ad3494fb22036f1698c7f3",
- });
-
- let stat = yield OS.File.stat(path);
- do_check_false(stat.isDir);
-
- do_check_true(compareFiles(do_get_file("data/productaddons/unsigned.xpi"), new LocalFile(path)));
-
- yield OS.File.remove(path);
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_XPIStates.js b/toolkit/mozapps/extensions/test/xpcshell/test_XPIStates.js
index 99ab8ab13..37ac161ca 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_XPIStates.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_XPIStates.js
@@ -60,7 +60,7 @@ writeInstallRDFToDir({
maxVersion: "1"
}],
name: "Unpacked, Enabled",
-}, profileDir, undefined, "extraFile.js");
+}, profileDir, null, "extraFile.js");
// Unpacked, disabled
@@ -75,12 +75,12 @@ writeInstallRDFToDir({
maxVersion: "1"
}],
name: "Unpacked, disabled",
-}, profileDir, undefined, "extraFile.js");
+}, profileDir, null, "extraFile.js");
// Keep track of the last time stamp we've used, so that we can keep moving
// it forward (if we touch two different files in the same add-on with the same
// timestamp we may not consider the change significant)
-var lastTimestamp = Date.now();
+let lastTimestamp = Date.now();
/*
* Helper function to touch a file and then test whether we detect the change.
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_XPIcancel.js b/toolkit/mozapps/extensions/test/xpcshell/test_XPIcancel.js
index d733778a5..7d8778301 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_XPIcancel.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_XPIcancel.js
@@ -4,8 +4,8 @@
// Test the cancellable doing/done/cancelAll API in XPIProvider
-var scope = Components.utils.import("resource://gre/modules/addons/XPIProvider.jsm");
-var XPIProvider = scope.XPIProvider;
+let scope = Components.utils.import("resource://gre/modules/addons/XPIProvider.jsm");
+let XPIProvider = scope.XPIProvider;
function run_test() {
// Check that cancelling with nothing in progress doesn't blow up
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_addon_path_service.js b/toolkit/mozapps/extensions/test/xpcshell/test_addon_path_service.js
index 56ce3c614..30bb577a1 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_addon_path_service.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_addon_path_service.js
@@ -2,7 +2,7 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-var service = Components.classes["@mozilla.org/addon-path-service;1"].getService(Components.interfaces.amIAddonPathService);
+let service = Components.classes["@mozilla.org/addon-path-service;1"].getService(Components.interfaces.amIAddonPathService);
function insert(path, value)
{
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_asyncBlocklistLoad.js b/toolkit/mozapps/extensions/test/xpcshell/test_asyncBlocklistLoad.js
index 38e563979..11d9f2943 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_asyncBlocklistLoad.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_asyncBlocklistLoad.js
@@ -6,7 +6,7 @@ function run_test() {
run_next_test();
}
-add_task(function* () {
+add_task(function () {
let blocklist = AM_Cc["@mozilla.org/extensions/blocklist;1"].
getService().wrappedJSObject;
let scope = Components.utils.import("resource://gre/modules/osfile.jsm");
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_backgroundupdate.js b/toolkit/mozapps/extensions/test/xpcshell/test_backgroundupdate.js
index 3890b76e1..d69c33e33 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_backgroundupdate.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_backgroundupdate.js
@@ -92,10 +92,6 @@ function run_test_2() {
"http://localhost:" + gPort +"/data/test_backgroundupdate.rdf");
restartManager();
- // Do hotfix checks
- Services.prefs.setCharPref("extensions.hotfix.id", "hotfix@tests.mozilla.org");
- Services.prefs.setCharPref("extensions.hotfix.url", "http://localhost:" + gPort + "/missing.rdf");
-
let installCount = 0;
let completeCount = 0;
let sawCompleteNotification = false;
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_gfx.js b/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_gfx.js
deleted file mode 100644
index cbcd5cb7e..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_gfx.js
+++ /dev/null
@@ -1,157 +0,0 @@
-const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
-
-Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-
-const TEST_APP_ID = "xpcshell@tests.mozilla.org";
-
-
-const EVENT_NAME = "blocklist-data-gfxItems";
-
-const SAMPLE_GFX_RECORD = {
- "driverVersionComparator": "LESS_THAN_OR_EQUAL",
- "driverVersion": "8.17.12.5896",
- "vendor": "0x10de",
- "blockID": "g36",
- "feature": "DIRECT3D_9_LAYERS",
- "devices": ["0x0a6c", "geforce"],
- "featureStatus": "BLOCKED_DRIVER_VERSION",
- "last_modified": 1458035931837,
- "os": "WINNT 6.1",
- "id": "3f947f16-37c2-4e96-d356-78b26363729b",
- "versionRange": {"minVersion": 0, "maxVersion": "*"}
-};
-
-
-function Blocklist() {
- let blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
- getService().wrappedJSObject;
- blocklist._clear();
- return blocklist;
-}
-
-
-function run_test() {
- run_next_test();
-}
-
-
-add_task(function* test_sends_serialized_data() {
- const blocklist = Blocklist();
- blocklist._gfxEntries = [SAMPLE_GFX_RECORD];
-
- const expected = "blockID:g36\tdevices:0x0a6c,geforce\tdriverVersion:8.17.12.5896\t" +
- "driverVersionComparator:LESS_THAN_OR_EQUAL\tfeature:DIRECT3D_9_LAYERS\t" +
- "featureStatus:BLOCKED_DRIVER_VERSION\tos:WINNT 6.1\tvendor:0x10de\t" +
- "versionRange:0,*";
- let received;
- const observe = (subject, topic, data) => { received = data };
- Services.obs.addObserver(observe, EVENT_NAME, false);
- blocklist._notifyObserversBlocklistGFX();
- equal(received, expected);
- Services.obs.removeObserver(observe, EVENT_NAME);
-});
-
-
-add_task(function* test_parsing_fails_if_devices_contains_comma() {
- const input = "<blocklist xmlns=\"http://www.mozilla.org/2006/addons-blocklist\">" +
- "<gfxItems>" +
- " <gfxBlacklistEntry>" +
- " <devices>" +
- " <device>0x2,582</device>" +
- " <device>0x2782</device>" +
- " </devices>" +
- " </gfxBlacklistEntry>" +
- "</gfxItems>" +
- "</blocklist>";
- const blocklist = Blocklist();
- blocklist._loadBlocklistFromString(input);
- equal(blocklist._gfxEntries[0].devices.length, 1);
- equal(blocklist._gfxEntries[0].devices[0], "0x2782");
-});
-
-
-add_task(function* test_empty_values_are_ignored() {
- const input = "<blocklist xmlns=\"http://www.mozilla.org/2006/addons-blocklist\">" +
- "<gfxItems>" +
- " <gfxBlacklistEntry>" +
- " <os></os>" +
- " </gfxBlacklistEntry>" +
- "</gfxItems>" +
- "</blocklist>";
- const blocklist = Blocklist();
- let received;
- const observe = (subject, topic, data) => { received = data };
- Services.obs.addObserver(observe, EVENT_NAME, false);
- blocklist._loadBlocklistFromString(input);
- ok(received.indexOf("os" < 0));
- Services.obs.removeObserver(observe, EVENT_NAME);
-});
-
-add_task(function* test_empty_devices_are_ignored() {
- const input = "<blocklist xmlns=\"http://www.mozilla.org/2006/addons-blocklist\">" +
- "<gfxItems>" +
- " <gfxBlacklistEntry>" +
- " <devices></devices>" +
- " </gfxBlacklistEntry>" +
- "</gfxItems>" +
- "</blocklist>";
- const blocklist = Blocklist();
- let received;
- const observe = (subject, topic, data) => { received = data };
- Services.obs.addObserver(observe, EVENT_NAME, false);
- blocklist._loadBlocklistFromString(input);
- ok(received.indexOf("devices" < 0));
- Services.obs.removeObserver(observe, EVENT_NAME);
-});
-
-add_task(function* test_version_range_default_values() {
- const input = "<blocklist xmlns=\"http://www.mozilla.org/2006/addons-blocklist\">" +
- "<gfxItems>" +
- " <gfxBlacklistEntry>" +
- " <versionRange minVersion=\"13.0b2\" maxVersion=\"42.0\"/>" +
- " </gfxBlacklistEntry>" +
- " <gfxBlacklistEntry>" +
- " <versionRange maxVersion=\"2.0\"/>" +
- " </gfxBlacklistEntry>" +
- " <gfxBlacklistEntry>" +
- " <versionRange minVersion=\"1.0\"/>" +
- " </gfxBlacklistEntry>" +
- " <gfxBlacklistEntry>" +
- " <versionRange minVersion=\" \"/>" +
- " </gfxBlacklistEntry>" +
- " <gfxBlacklistEntry>" +
- " <versionRange/>" +
- " </gfxBlacklistEntry>" +
- "</gfxItems>" +
- "</blocklist>";
- const blocklist = Blocklist();
- blocklist._loadBlocklistFromString(input);
- equal(blocklist._gfxEntries[0].versionRange.minVersion, "13.0b2");
- equal(blocklist._gfxEntries[0].versionRange.maxVersion, "42.0");
- equal(blocklist._gfxEntries[1].versionRange.minVersion, "0");
- equal(blocklist._gfxEntries[1].versionRange.maxVersion, "2.0");
- equal(blocklist._gfxEntries[2].versionRange.minVersion, "1.0");
- equal(blocklist._gfxEntries[2].versionRange.maxVersion, "*");
- equal(blocklist._gfxEntries[3].versionRange.minVersion, "0");
- equal(blocklist._gfxEntries[3].versionRange.maxVersion, "*");
- equal(blocklist._gfxEntries[4].versionRange.minVersion, "0");
- equal(blocklist._gfxEntries[4].versionRange.maxVersion, "*");
-});
-
-add_task(function* test_blockid_attribute() {
- const input = "<blocklist xmlns=\"http://www.mozilla.org/2006/addons-blocklist\">" +
- "<gfxItems>" +
- " <gfxBlacklistEntry blockID=\"g60\">" +
- " <vendor> 0x10de </vendor>" +
- " </gfxBlacklistEntry>" +
- " <gfxBlacklistEntry>" +
- " <feature> DIRECT3D_9_LAYERS </feature>" +
- " </gfxBlacklistEntry>" +
- "</gfxItems>" +
- "</blocklist>";
- const blocklist = Blocklist();
- blocklist._loadBlocklistFromString(input);
- equal(blocklist._gfxEntries[0].blockID, "g60");
- ok(!blocklist._gfxEntries[1].hasOwnProperty("blockID"));
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_metadata_filters.js b/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_metadata_filters.js
index 5befa6fa0..15e951bce 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_metadata_filters.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_metadata_filters.js
@@ -5,12 +5,11 @@
// Tests blocking of extensions by ID, name, creator, homepageURL, updateURL
// and RegExps for each. See bug 897735.
-var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
+const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
const URI_EXTENSION_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul";
Cu.import("resource://testing-common/httpd.js");
-Cu.import("resource://testing-common/MockRegistrar.jsm");
var testserver = new HttpServer();
testserver.start(-1);
gPort = testserver.identity.primaryPort;
@@ -24,18 +23,18 @@ profileDir.append("extensions");
// Don't need the full interface, attempts to call other methods will just
// throw which is just fine
var WindowWatcher = {
- openWindow: function(parent, url, name, features, args) {
+ openWindow: function(parent, url, name, features, arguments) {
// Should be called to list the newly blocklisted items
do_check_eq(url, URI_EXTENSION_BLOCKLIST_DIALOG);
// Simulate auto-disabling any softblocks
- var list = args.wrappedJSObject.list;
+ var list = arguments.wrappedJSObject.list;
list.forEach(function(aItem) {
if (!aItem.blocked)
aItem.disable = true;
});
- // run the code after the blocklist is closed
+ //run the code after the blocklist is closed
Services.obs.notifyObservers(null, "addon-blocklist-closed", null);
},
@@ -49,7 +48,20 @@ var WindowWatcher = {
}
};
-MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher);
+var WindowWatcherFactory = {
+ createInstance: function createInstance(outer, iid) {
+ if (outer != null)
+ throw Cr.NS_ERROR_NO_AGGREGATION;
+ return WindowWatcher.QueryInterface(iid);
+ }
+};
+
+var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
+registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
+ "Fake Window Watcher",
+ "@mozilla.org/embedcomp/window-watcher;1",
+ WindowWatcherFactory);
+
function load_blocklist(aFile, aCallback) {
Services.obs.addObserver(function() {
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_prefs.js b/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_prefs.js
index 41ef62f98..71112387b 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_prefs.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_prefs.js
@@ -5,7 +5,7 @@
// Tests resetting of preferences in blocklist entry when an add-on is blocked.
// See bug 802434.
-var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
+const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
const URI_EXTENSION_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul";
@@ -15,7 +15,6 @@ XPCOMUtils.defineLazyGetter(this, "gPref", function bls_gPref() {
});
Cu.import("resource://testing-common/httpd.js");
-Cu.import("resource://testing-common/MockRegistrar.jsm");
var testserver = new HttpServer();
testserver.start(-1);
gPort = testserver.identity.primaryPort;
@@ -30,18 +29,18 @@ profileDir.append("extensions");
// Don't need the full interface, attempts to call other methods will just
// throw which is just fine
var WindowWatcher = {
- openWindow: function(parent, url, name, features, args) {
+ openWindow: function(parent, url, name, features, arguments) {
// Should be called to list the newly blocklisted items
do_check_eq(url, URI_EXTENSION_BLOCKLIST_DIALOG);
// Simulate auto-disabling any softblocks
- var list = args.wrappedJSObject.list;
+ var list = arguments.wrappedJSObject.list;
list.forEach(function(aItem) {
if (!aItem.blocked)
aItem.disable = true;
});
- // run the code after the blocklist is closed
+ //run the code after the blocklist is closed
Services.obs.notifyObservers(null, "addon-blocklist-closed", null);
},
@@ -55,7 +54,19 @@ var WindowWatcher = {
}
};
-MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher);
+var WindowWatcherFactory = {
+ createInstance: function createInstance(outer, iid) {
+ if (outer != null)
+ throw Cr.NS_ERROR_NO_AGGREGATION;
+ return WindowWatcher.QueryInterface(iid);
+ }
+};
+
+var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
+registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
+ "Fake Window Watcher",
+ "@mozilla.org/embedcomp/window-watcher;1",
+ WindowWatcherFactory);
function load_blocklist(aFile, aCallback) {
Services.obs.addObserver(function() {
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_regexp.js b/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_regexp.js
index c89ccdef8..d9acf7170 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_regexp.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_blocklist_regexp.js
@@ -1,114 +1,125 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-// Checks that blocklist entries using RegExp work as expected. This only covers
-// behavior specific to RegExp entries - general behavior is already tested
-// in test_blocklistchange.js.
-
-var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
-
-const URI_EXTENSION_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul";
-
-Cu.import("resource://testing-common/httpd.js");
-Cu.import("resource://testing-common/MockRegistrar.jsm");
-var testserver = new HttpServer();
-testserver.start(-1);
-gPort = testserver.identity.primaryPort;
-
-// register static files with server and interpolate port numbers in them
-mapFile("/data/test_blocklist_regexp_1.xml", testserver);
-
-const profileDir = gProfD.clone();
-profileDir.append("extensions");
-
-// Don't need the full interface, attempts to call other methods will just
-// throw which is just fine
-var WindowWatcher = {
- openWindow: function(parent, url, name, features, args) {
- // Should be called to list the newly blocklisted items
- do_check_eq(url, URI_EXTENSION_BLOCKLIST_DIALOG);
-
- // Simulate auto-disabling any softblocks
- var list = args.wrappedJSObject.list;
- list.forEach(function(aItem) {
- if (!aItem.blocked)
- aItem.disable = true;
- });
-
- // run the code after the blocklist is closed
- Services.obs.notifyObservers(null, "addon-blocklist-closed", null);
-
- },
-
- QueryInterface: function(iid) {
- if (iid.equals(Ci.nsIWindowWatcher)
- || iid.equals(Ci.nsISupports))
- return this;
-
- throw Cr.NS_ERROR_NO_INTERFACE;
- }
-};
-
-MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher);
-
-
-function load_blocklist(aFile, aCallback) {
- Services.obs.addObserver(function() {
- Services.obs.removeObserver(arguments.callee, "blocklist-updated");
-
- do_execute_soon(aCallback);
- }, "blocklist-updated", false);
-
- Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
- gPort + "/data/" + aFile);
- var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
- getService(Ci.nsITimerCallback);
- blocklist.notify(null);
-}
-
-
-function end_test() {
- testserver.stop(do_test_finished);
-}
-
-
-function run_test() {
- do_test_pending();
-
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
-
- writeInstallRDFForExtension({
- id: "block1@tests.mozilla.org",
- version: "1.0",
- name: "RegExp blocked add-on",
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "3"
- }]
- }, profileDir);
-
- startupManager();
-
- AddonManager.getAddonsByIDs(["block1@tests.mozilla.org"], function([a1]) {
- do_check_eq(a1.blocklistState, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
-
- run_test_1();
- });
-}
-
-function run_test_1() {
- load_blocklist("test_blocklist_regexp_1.xml", function() {
- restartManager();
-
- AddonManager.getAddonsByIDs(["block1@tests.mozilla.org"], function([a1]) {
- // Blocklist contains two entries that will match this addon - ensure
- // that the first one is applied.
- do_check_neq(a1, null);
- do_check_eq(a1.blocklistState, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
-
- end_test();
- });
- });
-}
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+// Checks that blocklist entries using RegExp work as expected. This only covers
+// behavior specific to RegExp entries - general behavior is already tested
+// in test_blocklistchange.js.
+
+const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
+
+const URI_EXTENSION_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul";
+
+Cu.import("resource://testing-common/httpd.js");
+var testserver = new HttpServer();
+testserver.start(-1);
+gPort = testserver.identity.primaryPort;
+
+// register static files with server and interpolate port numbers in them
+mapFile("/data/test_blocklist_regexp_1.xml", testserver);
+
+const profileDir = gProfD.clone();
+profileDir.append("extensions");
+
+// Don't need the full interface, attempts to call other methods will just
+// throw which is just fine
+var WindowWatcher = {
+ openWindow: function(parent, url, name, features, arguments) {
+ // Should be called to list the newly blocklisted items
+ do_check_eq(url, URI_EXTENSION_BLOCKLIST_DIALOG);
+
+ // Simulate auto-disabling any softblocks
+ var list = arguments.wrappedJSObject.list;
+ list.forEach(function(aItem) {
+ if (!aItem.blocked)
+ aItem.disable = true;
+ });
+
+ //run the code after the blocklist is closed
+ Services.obs.notifyObservers(null, "addon-blocklist-closed", null);
+
+ },
+
+ QueryInterface: function(iid) {
+ if (iid.equals(Ci.nsIWindowWatcher)
+ || iid.equals(Ci.nsISupports))
+ return this;
+
+ throw Cr.NS_ERROR_NO_INTERFACE;
+ }
+};
+
+var WindowWatcherFactory = {
+ createInstance: function createInstance(outer, iid) {
+ if (outer != null)
+ throw Cr.NS_ERROR_NO_AGGREGATION;
+ return WindowWatcher.QueryInterface(iid);
+ }
+};
+
+var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
+registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
+ "Fake Window Watcher",
+ "@mozilla.org/embedcomp/window-watcher;1",
+ WindowWatcherFactory);
+
+
+function load_blocklist(aFile, aCallback) {
+ Services.obs.addObserver(function() {
+ Services.obs.removeObserver(arguments.callee, "blocklist-updated");
+
+ do_execute_soon(aCallback);
+ }, "blocklist-updated", false);
+
+ Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
+ gPort + "/data/" + aFile);
+ var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
+ getService(Ci.nsITimerCallback);
+ blocklist.notify(null);
+}
+
+
+function end_test() {
+ testserver.stop(do_test_finished);
+}
+
+
+function run_test() {
+ do_test_pending();
+
+ createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
+
+ writeInstallRDFForExtension({
+ id: "block1@tests.mozilla.org",
+ version: "1.0",
+ name: "RegExp blocked add-on",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "1",
+ maxVersion: "3"
+ }]
+ }, profileDir);
+
+ startupManager();
+
+ AddonManager.getAddonsByIDs(["block1@tests.mozilla.org"], function([a1]) {
+ do_check_eq(a1.blocklistState, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
+
+ run_test_1();
+ });
+}
+
+function run_test_1() {
+ load_blocklist("test_blocklist_regexp_1.xml", function() {
+ restartManager();
+
+ AddonManager.getAddonsByIDs(["block1@tests.mozilla.org"], function([a1]) {
+ // Blocklist contains two entries that will match this addon - ensure
+ // that the first one is applied.
+ do_check_neq(a1, null);
+ do_check_eq(a1.blocklistState, Ci.nsIBlocklistService.STATE_SOFTBLOCKED);
+
+ end_test();
+ });
+ });
+}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_blocklistchange.js b/toolkit/mozapps/extensions/test/xpcshell/test_blocklistchange.js
index d065f700d..46f939943 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_blocklistchange.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_blocklistchange.js
@@ -27,20 +27,21 @@
// softblocked and have to be manually re-enabled if they become completely
// unblocked (bug 657520)
-var Cc = Components.classes;
-var Ci = Components.interfaces;
-var Cu = Components.utils;
-var Cr = Components.results;
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+const Cu = Components.utils;
+const Cr = Components.results;
const URI_EXTENSION_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul";
Cu.import("resource://gre/modules/NetUtil.jsm");
-Cu.import("resource://testing-common/MockRegistrar.jsm");
// Allow insecure updates
Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false)
-var testserver = createHttpServer();
+Cu.import("resource://testing-common/httpd.js");
+var testserver = new HttpServer();
+testserver.start(-1);
gPort = testserver.identity.primaryPort;
// register static files with server and interpolate port numbers in them
@@ -345,7 +346,7 @@ var WindowWatcher = {
aItem.disable = true;
});
- // run the code after the blocklist is closed
+ //run the code after the blocklist is closed
Services.obs.notifyObservers(null, "addon-blocklist-closed", null);
},
@@ -359,7 +360,13 @@ var WindowWatcher = {
}
};
-MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher);
+var WindowWatcherFactory = {
+ createInstance: function createInstance(outer, iid) {
+ if (outer != null)
+ throw Components.results.NS_ERROR_NO_AGGREGATION;
+ return WindowWatcher.QueryInterface(iid);
+ }
+};
var InstallConfirm = {
confirm: function(aWindow, aUrl, aInstalls, aInstallCount) {
@@ -386,6 +393,9 @@ var InstallConfirmFactory = {
};
var registrar = Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar);
+registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
+ "Fake Window Watcher",
+ "@mozilla.org/embedcomp/window-watcher;1", WindowWatcherFactory);
registrar.registerFactory(Components.ID("{f0863905-4dde-42e2-991c-2dc8209bc9ca}"),
"Fake Install Prompt",
"@mozilla.org/addons/web-install-prompt;1", InstallConfirmFactory);
@@ -481,7 +491,7 @@ function Pmanual_update(aVersion) {
// the add-on is valid or not.
let webInstaller = Cc["@mozilla.org/addons/web-install-listener;1"]
.getService(Ci.amIWebInstallListener);
- webInstaller.onWebInstallRequested(null, null, installs);
+ webInstaller.onWebInstallRequested(null, null, installs, installs.length);
return Promise.all(completePromises);
});
@@ -1303,3 +1313,9 @@ add_task(function* run_local_install_test() {
check_addon(h, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
check_addon(r, "1.0", false, false, Ci.nsIBlocklistService.STATE_BLOCKED);
});
+
+add_task(function* shutdown_httpserver() {
+ yield new Promise((resolve, reject) => {
+ testserver.stop(resolve);
+ });
+});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap.js b/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap.js
index ff58599bc..e8d12c1fa 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap.js
@@ -11,9 +11,6 @@ const ADDON_UNINSTALL = 6;
const ADDON_UPGRADE = 7;
const ADDON_DOWNGRADE = 8;
-const ID1 = "bootstrap1@tests.mozilla.org";
-const ID2 = "bootstrap2@tests.mozilla.org";
-
// This verifies that bootstrappable add-ons can be used without restarts.
Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://gre/modules/Promise.jsm");
@@ -22,8 +19,6 @@ Components.utils.import("resource://gre/modules/Promise.jsm");
Services.prefs.setIntPref("extensions.enabledScopes",
AddonManager.SCOPE_PROFILE + AddonManager.SCOPE_USER);
-BootstrapMonitor.init();
-
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
const profileDir = gProfD.clone();
@@ -35,49 +30,99 @@ registerDirectory("XREUSysExt", userExtDir.parent);
Components.utils.import("resource://testing-common/httpd.js");
var testserver = new HttpServer();
-testserver.start(undefined);
+testserver.start(-1);
gPort = testserver.identity.primaryPort;
testserver.registerDirectory("/addons/", do_get_file("addons"));
+function resetPrefs() {
+ Services.prefs.setIntPref("bootstraptest.active_version", -1);
+ Services.prefs.setIntPref("bootstraptest.installed_version", -1);
+ Services.prefs.setIntPref("bootstraptest2.active_version", -1);
+ Services.prefs.setIntPref("bootstraptest2.installed_version", -1);
+ Services.prefs.setIntPref("bootstraptest.startup_reason", -1);
+ Services.prefs.setIntPref("bootstraptest.shutdown_reason", -1);
+ Services.prefs.setIntPref("bootstraptest.install_reason", -1);
+ Services.prefs.setIntPref("bootstraptest.uninstall_reason", -1);
+ Services.prefs.setIntPref("bootstraptest.startup_oldversion", -1);
+ Services.prefs.setIntPref("bootstraptest.shutdown_newversion", -1);
+ Services.prefs.setIntPref("bootstraptest.install_oldversion", -1);
+ Services.prefs.setIntPref("bootstraptest.uninstall_newversion", -1);
+}
+
+function waitForPref(aPref, aCallback) {
+ function prefChanged() {
+ Services.prefs.removeObserver(aPref, prefChanged);
+ // Always let whoever set the preference keep running
+ do_execute_soon(aCallback);
+ }
+ Services.prefs.addObserver(aPref, prefChanged, false);
+}
+
+function promisePref(aPref) {
+ let deferred = Promise.defer();
+
+ waitForPref(aPref, deferred.resolve.bind(deferred));
+
+ return deferred.promise;
+}
+
+function promiseInstall(aFiles) {
+ let deferred = Promise.defer();
+
+ installAllFiles(aFiles, function() {
+ deferred.resolve();
+ });
+
+ return deferred.promise;
+}
+
+function getActiveVersion() {
+ return Services.prefs.getIntPref("bootstraptest.active_version");
+}
+
+function getInstalledVersion() {
+ return Services.prefs.getIntPref("bootstraptest.installed_version");
+}
+
+function getActiveVersion2() {
+ return Services.prefs.getIntPref("bootstraptest2.active_version");
+}
+
+function getInstalledVersion2() {
+ return Services.prefs.getIntPref("bootstraptest2.installed_version");
+}
+
function getStartupReason() {
- let info = BootstrapMonitor.started.get(ID1);
- return info ? info.reason : undefined;
+ return Services.prefs.getIntPref("bootstraptest.startup_reason");
}
function getShutdownReason() {
- let info = BootstrapMonitor.stopped.get(ID1);
- return info ? info.reason : undefined;
+ return Services.prefs.getIntPref("bootstraptest.shutdown_reason");
}
function getInstallReason() {
- let info = BootstrapMonitor.installed.get(ID1);
- return info ? info.reason : undefined;
+ return Services.prefs.getIntPref("bootstraptest.install_reason");
}
function getUninstallReason() {
- let info = BootstrapMonitor.uninstalled.get(ID1);
- return info ? info.reason : undefined;
+ return Services.prefs.getIntPref("bootstraptest.uninstall_reason");
}
function getStartupOldVersion() {
- let info = BootstrapMonitor.started.get(ID1);
- return info ? info.data.oldVersion : undefined;
+ return Services.prefs.getIntPref("bootstraptest.startup_oldversion");
}
function getShutdownNewVersion() {
- let info = BootstrapMonitor.stopped.get(ID1);
- return info ? info.data.newVersion : undefined;
+ return Services.prefs.getIntPref("bootstraptest.shutdown_newversion");
}
function getInstallOldVersion() {
- let info = BootstrapMonitor.installed.get(ID1);
- return info ? info.data.oldVersion : undefined;
+ return Services.prefs.getIntPref("bootstraptest.install_oldversion");
}
function getUninstallNewVersion() {
- let info = BootstrapMonitor.uninstalled.get(ID1);
- return info ? info.data.newVersion : undefined;
+ return Services.prefs.getIntPref("bootstraptest.uninstall_newversion");
}
function do_check_bootstrappedPref(aCallback) {
@@ -112,6 +157,8 @@ function do_check_bootstrappedPref(aCallback) {
function run_test() {
do_test_pending();
+ resetPrefs();
+
startupManager();
do_check_false(gExtensionsJSON.exists());
@@ -141,18 +188,18 @@ function run_test_1() {
do_check_false(install.addon.hasResource("foo.bar"));
do_check_eq(install.addon.operationsRequiringRestart &
AddonManager.OP_NEEDS_RESTART_INSTALL, 0);
- do_check_not_in_crash_annotation(ID1, "1.0");
+ do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0");
let addon = install.addon;
- BootstrapMonitor.promiseAddonStartup(ID1).then(function() {
+ waitForPref("bootstraptest.startup_reason", function() {
do_check_bootstrappedPref(function() {
check_test_1(addon.syncGUID);
});
});
prepare_test({
- [ID1]: [
+ "bootstrap1@tests.mozilla.org": [
["onInstalling", false],
"onInstalled"
]
@@ -163,7 +210,7 @@ function run_test_1() {
do_check_true(addon.hasResource("install.rdf"));
// startup should not have been called yet.
- BootstrapMonitor.checkAddonNotStarted(ID1);
+ do_check_eq(getActiveVersion(), -1);
});
install.install();
});
@@ -177,7 +224,7 @@ function check_test_1(installSyncGUID) {
// doesn't require a restart.
do_check_eq(installs.length, 0);
- AddonManager.getAddonByID(ID1, function(b1) {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
do_check_neq(b1, null);
do_check_eq(b1.version, "1.0");
do_check_neq(b1.syncGUID, null);
@@ -185,17 +232,16 @@ function check_test_1(installSyncGUID) {
do_check_false(b1.appDisabled);
do_check_false(b1.userDisabled);
do_check_true(b1.isActive);
- do_check_false(b1.isSystem);
- BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
- BootstrapMonitor.checkAddonStarted(ID1, "1.0");
+ do_check_eq(getInstalledVersion(), 1);
+ do_check_eq(getActiveVersion(), 1);
do_check_eq(getStartupReason(), ADDON_INSTALL);
- do_check_eq(getStartupOldVersion(), undefined);
+ do_check_eq(getStartupOldVersion(), 0);
do_check_true(b1.hasResource("install.rdf"));
do_check_true(b1.hasResource("bootstrap.js"));
do_check_false(b1.hasResource("foo.bar"));
- do_check_in_crash_annotation(ID1, "1.0");
+ do_check_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0");
- let dir = do_get_addon_root_uri(profileDir, ID1);
+ let dir = do_get_addon_root_uri(profileDir, "bootstrap1@tests.mozilla.org");
do_check_eq(b1.getResourceURI("bootstrap.js").spec, dir + "bootstrap.js");
AddonManager.getAddonsWithOperationsByTypes(null, function(list) {
@@ -209,9 +255,9 @@ function check_test_1(installSyncGUID) {
// Tests that disabling doesn't require a restart
function run_test_2() {
- AddonManager.getAddonByID(ID1, function(b1) {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
prepare_test({
- [ID1]: [
+ "bootstrap1@tests.mozilla.org": [
["onDisabling", false],
"onDisabled"
]
@@ -227,13 +273,13 @@ function run_test_2() {
do_check_false(b1.appDisabled);
do_check_true(b1.userDisabled);
do_check_false(b1.isActive);
- BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
- BootstrapMonitor.checkAddonNotStarted(ID1);
+ do_check_eq(getInstalledVersion(), 1);
+ do_check_eq(getActiveVersion(), 0);
do_check_eq(getShutdownReason(), ADDON_DISABLE);
- do_check_eq(getShutdownNewVersion(), undefined);
- do_check_not_in_crash_annotation(ID1, "1.0");
+ do_check_eq(getShutdownNewVersion(), 0);
+ do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0");
- AddonManager.getAddonByID(ID1, function(newb1) {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(newb1) {
do_check_neq(newb1, null);
do_check_eq(newb1.version, "1.0");
do_check_false(newb1.appDisabled);
@@ -248,20 +294,20 @@ function run_test_2() {
// Test that restarting doesn't accidentally re-enable
function run_test_3() {
shutdownManager();
- BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
- BootstrapMonitor.checkAddonNotStarted(ID1);
+ do_check_eq(getInstalledVersion(), 1);
+ do_check_eq(getActiveVersion(), 0);
do_check_eq(getShutdownReason(), ADDON_DISABLE);
- do_check_eq(getShutdownNewVersion(), undefined);
+ do_check_eq(getShutdownNewVersion(), 0);
startupManager(false);
- BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
- BootstrapMonitor.checkAddonNotStarted(ID1);
+ do_check_eq(getInstalledVersion(), 1);
+ do_check_eq(getActiveVersion(), 0);
do_check_eq(getShutdownReason(), ADDON_DISABLE);
- do_check_eq(getShutdownNewVersion(), undefined);
- do_check_not_in_crash_annotation(ID1, "1.0");
+ do_check_eq(getShutdownNewVersion(), 0);
+ do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0");
do_check_false(gExtensionsINI.exists());
- AddonManager.getAddonByID(ID1, function(b1) {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
do_check_neq(b1, null);
do_check_eq(b1.version, "1.0");
do_check_false(b1.appDisabled);
@@ -274,9 +320,9 @@ function run_test_3() {
// Tests that enabling doesn't require a restart
function run_test_4() {
- AddonManager.getAddonByID(ID1, function(b1) {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
prepare_test({
- [ID1]: [
+ "bootstrap1@tests.mozilla.org": [
["onEnabling", false],
"onEnabled"
]
@@ -292,14 +338,13 @@ function run_test_4() {
do_check_false(b1.appDisabled);
do_check_false(b1.userDisabled);
do_check_true(b1.isActive);
- do_check_false(b1.isSystem);
- BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
- BootstrapMonitor.checkAddonStarted(ID1, "1.0");
+ do_check_eq(getInstalledVersion(), 1);
+ do_check_eq(getActiveVersion(), 1);
do_check_eq(getStartupReason(), ADDON_ENABLE);
- do_check_eq(getStartupOldVersion(), undefined);
- do_check_in_crash_annotation(ID1, "1.0");
+ do_check_eq(getStartupOldVersion(), 0);
+ do_check_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0");
- AddonManager.getAddonByID(ID1, function(newb1) {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(newb1) {
do_check_neq(newb1, null);
do_check_eq(newb1.version, "1.0");
do_check_false(newb1.appDisabled);
@@ -317,25 +362,24 @@ function run_test_5() {
// By the time we've shut down, the database must have been written
do_check_true(gExtensionsJSON.exists());
- BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
- BootstrapMonitor.checkAddonNotStarted(ID1);
+ do_check_eq(getInstalledVersion(), 1);
+ do_check_eq(getActiveVersion(), 0);
do_check_eq(getShutdownReason(), APP_SHUTDOWN);
- do_check_eq(getShutdownNewVersion(), undefined);
- do_check_not_in_crash_annotation(ID1, "1.0");
+ do_check_eq(getShutdownNewVersion(), 0);
+ do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0");
startupManager(false);
- BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
- BootstrapMonitor.checkAddonStarted(ID1, "1.0");
+ do_check_eq(getInstalledVersion(), 1);
+ do_check_eq(getActiveVersion(), 1);
do_check_eq(getStartupReason(), APP_STARTUP);
- do_check_eq(getStartupOldVersion(), undefined);
- do_check_in_crash_annotation(ID1, "1.0");
+ do_check_eq(getStartupOldVersion(), 0);
+ do_check_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0");
- AddonManager.getAddonByID(ID1, function(b1) {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
do_check_neq(b1, null);
do_check_eq(b1.version, "1.0");
do_check_false(b1.appDisabled);
do_check_false(b1.userDisabled);
do_check_true(b1.isActive);
- do_check_false(b1.isSystem);
do_check_false(isExtensionInAddonsList(profileDir, b1.id));
do_check_bootstrappedPref(run_test_6);
@@ -357,9 +401,9 @@ function run_test_6() {
do_check_eq(install.name, "Test Bootstrap 1");
do_check_eq(install.state, AddonManager.STATE_DOWNLOADED);
- BootstrapMonitor.promiseAddonStartup(ID1).then(check_test_6);
+ waitForPref("bootstraptest.startup_reason", check_test_6);
prepare_test({
- [ID1]: [
+ "bootstrap1@tests.mozilla.org": [
["onInstalling", false],
"onInstalled"
]
@@ -373,23 +417,22 @@ function run_test_6() {
}
function check_test_6() {
- AddonManager.getAddonByID(ID1, function(b1) {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
do_check_neq(b1, null);
do_check_eq(b1.version, "2.0");
do_check_false(b1.appDisabled);
do_check_false(b1.userDisabled);
do_check_true(b1.isActive);
- do_check_false(b1.isSystem);
- BootstrapMonitor.checkAddonInstalled(ID1, "2.0");
- BootstrapMonitor.checkAddonStarted(ID1, "2.0");
+ do_check_eq(getInstalledVersion(), 2);
+ do_check_eq(getActiveVersion(), 2);
do_check_eq(getStartupReason(), ADDON_UPGRADE);
do_check_eq(getInstallOldVersion(), 1);
do_check_eq(getStartupOldVersion(), 1);
do_check_eq(getShutdownReason(), ADDON_UPGRADE);
do_check_eq(getShutdownNewVersion(), 2);
do_check_eq(getUninstallNewVersion(), 2);
- do_check_not_in_crash_annotation(ID1, "1.0");
- do_check_in_crash_annotation(ID1, "2.0");
+ do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0");
+ do_check_in_crash_annotation("bootstrap1@tests.mozilla.org", "2.0");
do_check_bootstrappedPref(run_test_7);
});
@@ -397,9 +440,9 @@ function check_test_6() {
// Tests that uninstalling doesn't require a restart
function run_test_7() {
- AddonManager.getAddonByID(ID1, function(b1) {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
prepare_test({
- [ID1]: [
+ "bootstrap1@tests.mozilla.org": [
["onUninstalling", false],
"onUninstalled"
]
@@ -415,18 +458,18 @@ function run_test_7() {
function check_test_7() {
ensure_test_completed();
- BootstrapMonitor.checkAddonNotInstalled(ID1);
- BootstrapMonitor.checkAddonNotStarted(ID1);
+ do_check_eq(getInstalledVersion(), 0);
+ do_check_eq(getActiveVersion(), 0);
do_check_eq(getShutdownReason(), ADDON_UNINSTALL);
- do_check_eq(getShutdownNewVersion(), undefined);
- do_check_not_in_crash_annotation(ID1, "2.0");
+ do_check_eq(getShutdownNewVersion(), 0);
+ do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "2.0");
- AddonManager.getAddonByID(ID1, callback_soon(function(b1) {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", callback_soon(function(b1) {
do_check_eq(b1, null);
restartManager();
- AddonManager.getAddonByID(ID1, function(newb1) {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(newb1) {
do_check_eq(newb1, null);
do_check_bootstrappedPref(run_test_8);
@@ -440,22 +483,21 @@ function run_test_8() {
shutdownManager();
manuallyInstall(do_get_addon("test_bootstrap1_1"), profileDir,
- ID1);
+ "bootstrap1@tests.mozilla.org");
startupManager(false);
- AddonManager.getAddonByID(ID1, function(b1) {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
do_check_neq(b1, null);
do_check_eq(b1.version, "1.0");
do_check_false(b1.appDisabled);
do_check_false(b1.userDisabled);
do_check_true(b1.isActive);
- do_check_false(b1.isSystem);
- BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
- BootstrapMonitor.checkAddonStarted(ID1, "1.0");
+ do_check_eq(getInstalledVersion(), 1);
+ do_check_eq(getActiveVersion(), 1);
do_check_eq(getStartupReason(), ADDON_INSTALL);
- do_check_eq(getStartupOldVersion(), undefined);
- do_check_in_crash_annotation(ID1, "1.0");
+ do_check_eq(getStartupOldVersion(), 0);
+ do_check_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0");
do_check_bootstrappedPref(run_test_9);
});
@@ -465,14 +507,13 @@ function run_test_8() {
function run_test_9() {
shutdownManager();
- manuallyUninstall(profileDir, ID1);
- BootstrapMonitor.clear(ID1);
+ manuallyUninstall(profileDir, "bootstrap1@tests.mozilla.org");
startupManager(false);
- AddonManager.getAddonByID(ID1, function(b1) {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
do_check_eq(b1, null);
- do_check_not_in_crash_annotation(ID1, "1.0");
+ do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0");
do_check_bootstrappedPref(run_test_10);
});
@@ -481,6 +522,7 @@ function run_test_9() {
// Tests that installing a downgrade sends the right reason
function run_test_10() {
+ resetPrefs();
prepare_test({ }, [
"onNewInstall"
]);
@@ -496,11 +538,11 @@ function run_test_10() {
do_check_true(install.addon.hasResource("install.rdf"));
do_check_true(install.addon.hasResource("bootstrap.js"));
do_check_false(install.addon.hasResource("foo.bar"));
- do_check_not_in_crash_annotation(ID1, "2.0");
+ do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "2.0");
- BootstrapMonitor.promiseAddonStartup(ID1).then(check_test_10_pt1);
+ waitForPref("bootstraptest.startup_reason", check_test_10_pt1);
prepare_test({
- [ID1]: [
+ "bootstrap1@tests.mozilla.org": [
["onInstalling", false],
"onInstalled"
]
@@ -515,21 +557,20 @@ function run_test_10() {
}
function check_test_10_pt1() {
- AddonManager.getAddonByID(ID1, function(b1) {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
do_check_neq(b1, null);
do_check_eq(b1.version, "2.0");
do_check_false(b1.appDisabled);
do_check_false(b1.userDisabled);
do_check_true(b1.isActive);
- do_check_false(b1.isSystem);
- BootstrapMonitor.checkAddonInstalled(ID1, "2.0");
- BootstrapMonitor.checkAddonStarted(ID1, "2.0");
+ do_check_eq(getInstalledVersion(), 2);
+ do_check_eq(getActiveVersion(), 2);
do_check_eq(getStartupReason(), ADDON_INSTALL);
- do_check_eq(getStartupOldVersion(), undefined);
+ do_check_eq(getStartupOldVersion(), 0);
do_check_true(b1.hasResource("install.rdf"));
do_check_true(b1.hasResource("bootstrap.js"));
do_check_false(b1.hasResource("foo.bar"));
- do_check_in_crash_annotation(ID1, "2.0");
+ do_check_in_crash_annotation("bootstrap1@tests.mozilla.org", "2.0");
prepare_test({ }, [
"onNewInstall"
@@ -544,9 +585,9 @@ function check_test_10_pt1() {
do_check_eq(install.name, "Test Bootstrap 1");
do_check_eq(install.state, AddonManager.STATE_DOWNLOADED);
- BootstrapMonitor.promiseAddonStartup(ID1).then(check_test_10_pt2);
+ waitForPref("bootstraptest.startup_reason", check_test_10_pt2);
prepare_test({
- [ID1]: [
+ "bootstrap1@tests.mozilla.org": [
["onInstalling", false],
"onInstalled"
]
@@ -560,23 +601,22 @@ function check_test_10_pt1() {
}
function check_test_10_pt2() {
- AddonManager.getAddonByID(ID1, function(b1) {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
do_check_neq(b1, null);
do_check_eq(b1.version, "1.0");
do_check_false(b1.appDisabled);
do_check_false(b1.userDisabled);
do_check_true(b1.isActive);
- do_check_false(b1.isSystem);
- BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
- BootstrapMonitor.checkAddonStarted(ID1, "1.0");
+ do_check_eq(getInstalledVersion(), 1);
+ do_check_eq(getActiveVersion(), 1);
do_check_eq(getStartupReason(), ADDON_DOWNGRADE);
do_check_eq(getInstallOldVersion(), 2);
do_check_eq(getStartupOldVersion(), 2);
do_check_eq(getShutdownReason(), ADDON_DOWNGRADE);
do_check_eq(getShutdownNewVersion(), 1);
do_check_eq(getUninstallNewVersion(), 1);
- do_check_in_crash_annotation(ID1, "1.0");
- do_check_not_in_crash_annotation(ID1, "2.0");
+ do_check_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0");
+ do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "2.0");
do_check_bootstrappedPref(run_test_11);
});
@@ -584,9 +624,9 @@ function check_test_10_pt2() {
// Tests that uninstalling a disabled add-on still calls the uninstall method
function run_test_11() {
- AddonManager.getAddonByID(ID1, function(b1) {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
prepare_test({
- [ID1]: [
+ "bootstrap1@tests.mozilla.org": [
["onDisabling", false],
"onDisabled",
["onUninstalling", false],
@@ -596,11 +636,11 @@ function run_test_11() {
b1.userDisabled = true;
- BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
- BootstrapMonitor.checkAddonNotStarted(ID1);
+ do_check_eq(getInstalledVersion(), 1);
+ do_check_eq(getActiveVersion(), 0);
do_check_eq(getShutdownReason(), ADDON_DISABLE);
- do_check_eq(getShutdownNewVersion(), undefined);
- do_check_not_in_crash_annotation(ID1, "1.0");
+ do_check_eq(getShutdownNewVersion(), 0);
+ do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0");
b1.uninstall();
@@ -610,9 +650,9 @@ function run_test_11() {
function check_test_11() {
ensure_test_completed();
- BootstrapMonitor.checkAddonNotInstalled(ID1);
- BootstrapMonitor.checkAddonNotStarted(ID1);
- do_check_not_in_crash_annotation(ID1, "1.0");
+ do_check_eq(getInstalledVersion(), 0);
+ do_check_eq(getActiveVersion(), 0);
+ do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0");
do_check_bootstrappedPref(run_test_12);
}
@@ -623,22 +663,21 @@ function run_test_12() {
shutdownManager();
manuallyInstall(do_get_addon("test_bootstrap1_1"), profileDir,
- ID1);
+ "bootstrap1@tests.mozilla.org");
startupManager(true);
- AddonManager.getAddonByID(ID1, function(b1) {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
do_check_neq(b1, null);
do_check_eq(b1.version, "1.0");
do_check_false(b1.appDisabled);
do_check_false(b1.userDisabled);
do_check_true(b1.isActive);
- do_check_false(b1.isSystem);
- BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
- BootstrapMonitor.checkAddonStarted(ID1, "1.0");
+ do_check_eq(getInstalledVersion(), 1);
+ do_check_eq(getActiveVersion(), 1);
do_check_eq(getStartupReason(), ADDON_INSTALL);
- do_check_eq(getStartupOldVersion(), undefined);
- do_check_in_crash_annotation(ID1, "1.0");
+ do_check_eq(getStartupOldVersion(), 0);
+ do_check_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0");
b1.uninstall();
do_execute_soon(test_12_restart);
@@ -666,10 +705,10 @@ function run_test_13() {
do_check_eq(install.version, "3.0");
do_check_eq(install.name, "Test Bootstrap 1");
do_check_eq(install.state, AddonManager.STATE_DOWNLOADED);
- do_check_not_in_crash_annotation(ID1, "3.0");
+ do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "3.0");
prepare_test({
- [ID1]: [
+ "bootstrap1@tests.mozilla.org": [
["onInstalling", false],
"onInstalled"
]
@@ -687,15 +726,15 @@ function check_test_13() {
// doesn't require a restart.
do_check_eq(installs.length, 0);
- AddonManager.getAddonByID(ID1, function(b1) {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
do_check_neq(b1, null);
do_check_eq(b1.version, "3.0");
do_check_true(b1.appDisabled);
do_check_false(b1.userDisabled);
do_check_false(b1.isActive);
- BootstrapMonitor.checkAddonInstalled(ID1, "3.0"); // We call install even for disabled add-ons
- BootstrapMonitor.checkAddonNotStarted(ID1); // Should not have called startup though
- do_check_not_in_crash_annotation(ID1, "3.0");
+ do_check_eq(getInstalledVersion(), 3); // We call install even for disabled add-ons
+ do_check_eq(getActiveVersion(), 0); // Should not have called startup though
+ do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "3.0");
do_execute_soon(test_13_restart);
});
@@ -705,15 +744,15 @@ function check_test_13() {
function test_13_restart() {
restartManager();
- AddonManager.getAddonByID(ID1, function(b1) {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
do_check_neq(b1, null);
do_check_eq(b1.version, "3.0");
do_check_true(b1.appDisabled);
do_check_false(b1.userDisabled);
do_check_false(b1.isActive);
- BootstrapMonitor.checkAddonInstalled(ID1, "3.0"); // We call install even for disabled add-ons
- BootstrapMonitor.checkAddonNotStarted(ID1); // Should not have called startup though
- do_check_not_in_crash_annotation(ID1, "3.0");
+ do_check_eq(getInstalledVersion(), 3); // We call install even for disabled add-ons
+ do_check_eq(getActiveVersion(), 0); // Should not have called startup though
+ do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "3.0");
do_check_bootstrappedPref(function() {
b1.uninstall();
@@ -730,19 +769,19 @@ function run_test_14() {
shutdownManager();
manuallyInstall(do_get_addon("test_bootstrap1_3"), profileDir,
- ID1);
+ "bootstrap1@tests.mozilla.org");
startupManager(false);
- AddonManager.getAddonByID(ID1, function(b1) {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
do_check_neq(b1, null);
do_check_eq(b1.version, "3.0");
do_check_true(b1.appDisabled);
do_check_false(b1.userDisabled);
do_check_false(b1.isActive);
- BootstrapMonitor.checkAddonInstalled(ID1, "3.0"); // We call install even for disabled add-ons
- BootstrapMonitor.checkAddonNotStarted(ID1); // Should not have called startup though
- do_check_not_in_crash_annotation(ID1, "3.0");
+ do_check_eq(getInstalledVersion(), 3); // We call install even for disabled add-ons
+ do_check_eq(getActiveVersion(), 0); // Should not have called startup though
+ do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "3.0");
do_check_bootstrappedPref(function() {
b1.uninstall();
@@ -755,21 +794,21 @@ function run_test_14() {
// Tests that upgrading a disabled bootstrapped extension still calls uninstall
// and install but doesn't startup the new version
function run_test_15() {
- BootstrapMonitor.promiseAddonStartup(ID1).then(function test_15_after_startup() {
- AddonManager.getAddonByID(ID1, function(b1) {
+ resetPrefs();
+ waitForPref("bootstraptest.startup_reason", function test_15_after_startup() {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
do_check_neq(b1, null);
do_check_eq(b1.version, "1.0");
do_check_false(b1.appDisabled);
do_check_false(b1.userDisabled);
do_check_true(b1.isActive);
- do_check_false(b1.isSystem);
- BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
- BootstrapMonitor.checkAddonStarted(ID1, "1.0");
+ do_check_eq(getInstalledVersion(), 1);
+ do_check_eq(getActiveVersion(), 1);
b1.userDisabled = true;
do_check_false(b1.isActive);
- BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
- BootstrapMonitor.checkAddonNotStarted(ID1);
+ do_check_eq(getInstalledVersion(), 1);
+ do_check_eq(getActiveVersion(), 0);
prepare_test({ }, [
"onNewInstall"
@@ -782,7 +821,7 @@ function run_test_15() {
do_check_true(install.addon.userDisabled);
prepare_test({
- [ID1]: [
+ "bootstrap1@tests.mozilla.org": [
["onInstalling", false],
"onInstalled"
]
@@ -798,28 +837,28 @@ function run_test_15() {
}
function check_test_15() {
- AddonManager.getAddonByID(ID1, function(b1) {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
do_check_neq(b1, null);
do_check_eq(b1.version, "2.0");
do_check_false(b1.appDisabled);
do_check_true(b1.userDisabled);
do_check_false(b1.isActive);
- BootstrapMonitor.checkAddonInstalled(ID1, "2.0");
- BootstrapMonitor.checkAddonNotStarted(ID1);
+ do_check_eq(getInstalledVersion(), 2);
+ do_check_eq(getActiveVersion(), 0);
do_check_bootstrappedPref(function() {
restartManager();
- AddonManager.getAddonByID(ID1, callback_soon(function(b1_2) {
- do_check_neq(b1_2, null);
- do_check_eq(b1_2.version, "2.0");
- do_check_false(b1_2.appDisabled);
- do_check_true(b1_2.userDisabled);
- do_check_false(b1_2.isActive);
- BootstrapMonitor.checkAddonInstalled(ID1, "2.0");
- BootstrapMonitor.checkAddonNotStarted(ID1);
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", callback_soon(function(b1) {
+ do_check_neq(b1, null);
+ do_check_eq(b1.version, "2.0");
+ do_check_false(b1.appDisabled);
+ do_check_true(b1.userDisabled);
+ do_check_false(b1.isActive);
+ do_check_eq(getInstalledVersion(), 2);
+ do_check_eq(getActiveVersion(), 0);
- b1_2.uninstall();
+ b1.uninstall();
run_test_16();
}));
@@ -829,13 +868,13 @@ function check_test_15() {
// Tests that bootstrapped extensions don't get loaded when in safe mode
function run_test_16() {
- BootstrapMonitor.promiseAddonStartup(ID1).then(function test_16_after_startup() {
- AddonManager.getAddonByID(ID1, callback_soon(function(b1) {
+ resetPrefs();
+ waitForPref("bootstraptest.startup_reason", function test_16_after_startup() {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", callback_soon(function(b1) {
// Should have installed and started
- BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
- BootstrapMonitor.checkAddonStarted(ID1, "1.0");
+ do_check_eq(getInstalledVersion(), 1);
+ do_check_eq(getActiveVersion(), 1);
do_check_true(b1.isActive);
- do_check_false(b1.isSystem);
do_check_eq(b1.iconURL, "chrome://foo/skin/icon.png");
do_check_eq(b1.aboutURL, "chrome://foo/content/about.xul");
do_check_eq(b1.optionsURL, "chrome://foo/content/options.xul");
@@ -843,31 +882,31 @@ function run_test_16() {
shutdownManager();
// Should have stopped
- BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
- BootstrapMonitor.checkAddonNotStarted(ID1);
+ do_check_eq(getInstalledVersion(), 1);
+ do_check_eq(getActiveVersion(), 0);
gAppInfo.inSafeMode = true;
startupManager(false);
- AddonManager.getAddonByID(ID1, callback_soon(function(b1_2) {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", callback_soon(function(b1) {
// Should still be stopped
- BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
- BootstrapMonitor.checkAddonNotStarted(ID1);
- do_check_false(b1_2.isActive);
- do_check_eq(b1_2.iconURL, null);
- do_check_eq(b1_2.aboutURL, null);
- do_check_eq(b1_2.optionsURL, null);
+ do_check_eq(getInstalledVersion(), 1);
+ do_check_eq(getActiveVersion(), 0);
+ do_check_false(b1.isActive);
+ do_check_eq(b1.iconURL, null);
+ do_check_eq(b1.aboutURL, null);
+ do_check_eq(b1.optionsURL, null);
shutdownManager();
gAppInfo.inSafeMode = false;
startupManager(false);
// Should have started
- BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
- BootstrapMonitor.checkAddonStarted(ID1, "1.0");
+ do_check_eq(getInstalledVersion(), 1);
+ do_check_eq(getActiveVersion(), 1);
- AddonManager.getAddonByID(ID1, function(b1_3) {
- b1_3.uninstall();
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
+ b1.uninstall();
do_execute_soon(run_test_17);
});
@@ -882,18 +921,18 @@ function run_test_17() {
shutdownManager();
manuallyInstall(do_get_addon("test_bootstrap1_1"), userExtDir,
- ID1);
+ "bootstrap1@tests.mozilla.org");
+ resetPrefs();
startupManager();
- AddonManager.getAddonByID(ID1, function(b1) {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
// Should have installed and started
- BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
- BootstrapMonitor.checkAddonStarted(ID1, "1.0");
+ do_check_eq(getInstalledVersion(), 1);
+ do_check_eq(getActiveVersion(), 1);
do_check_neq(b1, null);
do_check_eq(b1.version, "1.0");
do_check_true(b1.isActive);
- do_check_false(b1.isSystem);
do_check_bootstrappedPref(run_test_18);
});
@@ -902,15 +941,15 @@ function run_test_17() {
// Check that installing a new bootstrapped extension in the profile replaces
// the existing one
function run_test_18() {
- BootstrapMonitor.promiseAddonStartup(ID1).then(function test_18_after_startup() {
- AddonManager.getAddonByID(ID1, function(b1) {
+ resetPrefs();
+ waitForPref("bootstraptest.startup_reason", function test_18_after_startup() {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
// Should have installed and started
- BootstrapMonitor.checkAddonInstalled(ID1, "2.0");
- BootstrapMonitor.checkAddonStarted(ID1, "2.0");
+ do_check_eq(getInstalledVersion(), 2);
+ do_check_eq(getActiveVersion(), 2);
do_check_neq(b1, null);
do_check_eq(b1.version, "2.0");
do_check_true(b1.isActive);
- do_check_false(b1.isSystem);
do_check_eq(getShutdownReason(), ADDON_UPGRADE);
do_check_eq(getUninstallReason(), ADDON_UPGRADE);
@@ -930,10 +969,11 @@ function run_test_18() {
// Check that uninstalling the profile version reveals the non-profile one
function run_test_19() {
- AddonManager.getAddonByID(ID1, function(b1) {
+ resetPrefs();
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
// The revealed add-on gets activated asynchronously
prepare_test({
- [ID1]: [
+ "bootstrap1@tests.mozilla.org": [
["onUninstalling", false],
"onUninstalled",
["onInstalling", false],
@@ -946,14 +986,13 @@ function run_test_19() {
}
function check_test_19() {
- AddonManager.getAddonByID(ID1, function(b1) {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
// Should have reverted to the older version
- BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
- BootstrapMonitor.checkAddonStarted(ID1, "1.0");
+ do_check_eq(getInstalledVersion(), 1);
+ do_check_eq(getActiveVersion(), 1);
do_check_neq(b1, null);
do_check_eq(b1.version, "1.0");
do_check_true(b1.isActive);
- do_check_false(b1.isSystem);
// TODO these reasons really should be ADDON_DOWNGRADE (bug 607818)
do_check_eq(getShutdownReason(), ADDON_UNINSTALL);
@@ -961,10 +1000,10 @@ function check_test_19() {
do_check_eq(getInstallReason(), ADDON_INSTALL);
do_check_eq(getStartupReason(), ADDON_INSTALL);
- do_check_eq(getShutdownNewVersion(), undefined);
- do_check_eq(getUninstallNewVersion(), undefined);
- do_check_eq(getInstallOldVersion(), undefined);
- do_check_eq(getStartupOldVersion(), undefined);
+ do_check_eq(getShutdownNewVersion(), 0);
+ do_check_eq(getUninstallNewVersion(), 0);
+ do_check_eq(getInstallOldVersion(), 0);
+ do_check_eq(getStartupOldVersion(), 0);
do_check_bootstrappedPref(run_test_20);
});
@@ -973,31 +1012,31 @@ function check_test_19() {
// Check that a new profile extension detected at startup replaces the non-profile
// one
function run_test_20() {
+ resetPrefs();
shutdownManager();
manuallyInstall(do_get_addon("test_bootstrap1_2"), profileDir,
- ID1);
+ "bootstrap1@tests.mozilla.org");
startupManager();
- AddonManager.getAddonByID(ID1, function(b1) {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
// Should have installed and started
- BootstrapMonitor.checkAddonInstalled(ID1, "2.0");
- BootstrapMonitor.checkAddonStarted(ID1, "2.0");
+ do_check_eq(getInstalledVersion(), 2);
+ do_check_eq(getActiveVersion(), 2);
do_check_neq(b1, null);
do_check_eq(b1.version, "2.0");
do_check_true(b1.isActive);
- do_check_false(b1.isSystem);
do_check_eq(getShutdownReason(), APP_SHUTDOWN);
do_check_eq(getUninstallReason(), ADDON_UPGRADE);
do_check_eq(getInstallReason(), ADDON_UPGRADE);
do_check_eq(getStartupReason(), APP_STARTUP);
- do_check_eq(getShutdownNewVersion(), undefined);
+ do_check_eq(getShutdownNewVersion(), 0);
do_check_eq(getUninstallNewVersion(), 2);
do_check_eq(getInstallOldVersion(), 1);
- do_check_eq(getStartupOldVersion(), undefined);
+ do_check_eq(getStartupOldVersion(), 0);
do_execute_soon(run_test_21);
});
@@ -1005,43 +1044,40 @@ function run_test_20() {
// Check that a detected removal reveals the non-profile one
function run_test_21() {
+ resetPrefs();
shutdownManager();
- do_check_eq(getShutdownReason(), APP_SHUTDOWN);
- do_check_eq(getShutdownNewVersion(), undefined);
-
- manuallyUninstall(profileDir, ID1);
- BootstrapMonitor.clear(ID1);
+ manuallyUninstall(profileDir, "bootstrap1@tests.mozilla.org");
startupManager();
- AddonManager.getAddonByID(ID1, function(b1) {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
// Should have installed and started
- BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
- BootstrapMonitor.checkAddonStarted(ID1, "1.0");
+ do_check_eq(getInstalledVersion(), 1);
+ do_check_eq(getActiveVersion(), 1);
do_check_neq(b1, null);
do_check_eq(b1.version, "1.0");
do_check_true(b1.isActive);
- do_check_false(b1.isSystem);
+
+ do_check_eq(getShutdownReason(), APP_SHUTDOWN);
+ do_check_eq(getShutdownNewVersion(), 0);
// This won't be set as the bootstrap script was gone so we couldn't
// uninstall it properly
- do_check_eq(getUninstallReason(), undefined);
- do_check_eq(getUninstallNewVersion(), undefined);
+ do_check_eq(getUninstallReason(), -1);
+ do_check_eq(getUninstallNewVersion(), -1);
- do_check_eq(getInstallReason(), ADDON_DOWNGRADE);
- do_check_eq(getInstallOldVersion(), 2);
+ // TODO this reason should probably be ADDON_DOWNGRADE (bug 607818)
+ do_check_eq(getInstallReason(), ADDON_INSTALL);
+ do_check_eq(getInstallOldVersion(), 0);
do_check_eq(getStartupReason(), APP_STARTUP);
- do_check_eq(getStartupOldVersion(), undefined);
+ do_check_eq(getStartupOldVersion(), 0);
do_check_bootstrappedPref(function() {
- shutdownManager();
+ manuallyUninstall(userExtDir, "bootstrap1@tests.mozilla.org");
- manuallyUninstall(userExtDir, ID1);
- BootstrapMonitor.clear(ID1);
-
- startupManager(false);
+ restartManager();
run_test_22();
});
});
@@ -1052,55 +1088,53 @@ function run_test_22() {
shutdownManager();
let file = manuallyInstall(do_get_addon("test_bootstrap1_1"), profileDir,
- ID1);
+ "bootstrap1@tests.mozilla.org");
// Make it look old so changes are detected
setExtensionModifiedTime(file, file.lastModifiedTime - 5000);
startupManager();
- AddonManager.getAddonByID(ID1, callback_soon(function(b1) {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", callback_soon(function(b1) {
// Should have installed and started
- BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
- BootstrapMonitor.checkAddonStarted(ID1, "1.0");
+ do_check_eq(getInstalledVersion(), 1);
+ do_check_eq(getActiveVersion(), 1);
do_check_neq(b1, null);
do_check_eq(b1.version, "1.0");
do_check_true(b1.isActive);
- do_check_false(b1.isSystem);
+ resetPrefs();
shutdownManager();
- do_check_eq(getShutdownReason(), APP_SHUTDOWN);
- do_check_eq(getShutdownNewVersion(), undefined);
-
- manuallyUninstall(profileDir, ID1);
- BootstrapMonitor.clear(ID1);
+ manuallyUninstall(profileDir, "bootstrap1@tests.mozilla.org");
manuallyInstall(do_get_addon("test_bootstrap1_2"), profileDir,
- ID1);
+ "bootstrap1@tests.mozilla.org");
startupManager();
- AddonManager.getAddonByID(ID1, function(b1_2) {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
// Should have installed and started
- BootstrapMonitor.checkAddonInstalled(ID1, "2.0");
- BootstrapMonitor.checkAddonStarted(ID1, "2.0");
- do_check_neq(b1_2, null);
- do_check_eq(b1_2.version, "2.0");
- do_check_true(b1_2.isActive);
- do_check_false(b1_2.isSystem);
+ do_check_eq(getInstalledVersion(), 2);
+ do_check_eq(getActiveVersion(), 2);
+ do_check_neq(b1, null);
+ do_check_eq(b1.version, "2.0");
+ do_check_true(b1.isActive);
+
+ do_check_eq(getShutdownReason(), APP_SHUTDOWN);
+ do_check_eq(getShutdownNewVersion(), 0);
// This won't be set as the bootstrap script was gone so we couldn't
// uninstall it properly
- do_check_eq(getUninstallReason(), undefined);
- do_check_eq(getUninstallNewVersion(), undefined);
+ do_check_eq(getUninstallReason(), -1);
+ do_check_eq(getUninstallNewVersion(), -1);
do_check_eq(getInstallReason(), ADDON_UPGRADE);
do_check_eq(getInstallOldVersion(), 1);
do_check_eq(getStartupReason(), APP_STARTUP);
- do_check_eq(getStartupOldVersion(), undefined);
+ do_check_eq(getStartupOldVersion(), 0);
do_check_bootstrappedPref(function() {
- b1_2.uninstall();
+ b1.uninstall();
run_test_23();
});
@@ -1134,11 +1168,11 @@ function run_test_23() {
do_check_false(install.addon.hasResource("foo.bar"));
do_check_eq(install.addon.operationsRequiringRestart &
AddonManager.OP_NEEDS_RESTART_INSTALL, 0);
- do_check_not_in_crash_annotation(ID1, "1.0");
+ do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0");
let addon = install.addon;
prepare_test({
- [ID1]: [
+ "bootstrap1@tests.mozilla.org": [
["onInstalling", false],
"onInstalled"
]
@@ -1160,32 +1194,31 @@ function check_test_23() {
// doesn't require a restart.
do_check_eq(installs.length, 0);
- AddonManager.getAddonByID(ID1, function(b1) {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
do_execute_soon(function test_23_after_startup() {
do_check_neq(b1, null);
do_check_eq(b1.version, "1.0");
do_check_false(b1.appDisabled);
do_check_false(b1.userDisabled);
do_check_true(b1.isActive);
- do_check_false(b1.isSystem);
- BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
- BootstrapMonitor.checkAddonStarted(ID1, "1.0");
+ do_check_eq(getInstalledVersion(), 1);
+ do_check_eq(getActiveVersion(), 1);
do_check_eq(getStartupReason(), ADDON_INSTALL);
- do_check_eq(getStartupOldVersion(), undefined);
+ do_check_eq(getStartupOldVersion(), 0);
do_check_true(b1.hasResource("install.rdf"));
do_check_true(b1.hasResource("bootstrap.js"));
do_check_false(b1.hasResource("foo.bar"));
- do_check_in_crash_annotation(ID1, "1.0");
+ do_check_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0");
- let dir = do_get_addon_root_uri(profileDir, ID1);
+ let dir = do_get_addon_root_uri(profileDir, "bootstrap1@tests.mozilla.org");
do_check_eq(b1.getResourceURI("bootstrap.js").spec, dir + "bootstrap.js");
AddonManager.getAddonsWithOperationsByTypes(null, callback_soon(function(list) {
do_check_eq(list.length, 0);
restartManager();
- AddonManager.getAddonByID(ID1, callback_soon(function(b1_2) {
- b1_2.uninstall();
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", callback_soon(function(b1) {
+ b1.uninstall();
restartManager();
testserver.stop(run_test_24);
@@ -1198,42 +1231,45 @@ function check_test_23() {
// Tests that we recover from a broken preference
function run_test_24() {
+ resetPrefs();
do_print("starting 24");
- Promise.all([BootstrapMonitor.promiseAddonStartup(ID2),
- promiseInstallAllFiles([do_get_addon("test_bootstrap1_1"), do_get_addon("test_bootstrap2_1")])])
+ Promise.all([promisePref("bootstraptest2.active_version"),
+ promiseInstall([do_get_addon("test_bootstrap1_1"), do_get_addon("test_bootstrap2_1")])])
.then(function test_24_pref() {
do_print("test 24 got prefs");
- BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
- BootstrapMonitor.checkAddonStarted(ID1, "1.0");
- BootstrapMonitor.checkAddonInstalled(ID2, "1.0");
- BootstrapMonitor.checkAddonStarted(ID2, "1.0");
+ do_check_eq(getInstalledVersion(), 1);
+ do_check_eq(getActiveVersion(), 1);
+ do_check_eq(getInstalledVersion2(), 1);
+ do_check_eq(getActiveVersion2(), 1);
+
+ resetPrefs();
restartManager();
- BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
- BootstrapMonitor.checkAddonStarted(ID1, "1.0");
- BootstrapMonitor.checkAddonInstalled(ID2, "1.0");
- BootstrapMonitor.checkAddonStarted(ID2, "1.0");
+ do_check_eq(getInstalledVersion(), -1);
+ do_check_eq(getActiveVersion(), 1);
+ do_check_eq(getInstalledVersion2(), -1);
+ do_check_eq(getActiveVersion2(), 1);
shutdownManager();
- BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
- BootstrapMonitor.checkAddonNotStarted(ID1);
- BootstrapMonitor.checkAddonInstalled(ID2, "1.0");
- BootstrapMonitor.checkAddonNotStarted(ID2);
+ do_check_eq(getInstalledVersion(), -1);
+ do_check_eq(getActiveVersion(), 0);
+ do_check_eq(getInstalledVersion2(), -1);
+ do_check_eq(getActiveVersion2(), 0);
- // Break the preference
+ // Break the preferece
let bootstrappedAddons = JSON.parse(Services.prefs.getCharPref("extensions.bootstrappedAddons"));
- bootstrappedAddons[ID1].descriptor += "foo";
+ bootstrappedAddons["bootstrap1@tests.mozilla.org"].descriptor += "foo";
Services.prefs.setCharPref("extensions.bootstrappedAddons", JSON.stringify(bootstrappedAddons));
startupManager(false);
- BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
- BootstrapMonitor.checkAddonStarted(ID1, "1.0");
- BootstrapMonitor.checkAddonInstalled(ID2, "1.0");
- BootstrapMonitor.checkAddonStarted(ID2, "1.0");
+ do_check_eq(getInstalledVersion(), -1);
+ do_check_eq(getActiveVersion(), 1);
+ do_check_eq(getInstalledVersion2(), -1);
+ do_check_eq(getActiveVersion2(), 1);
run_test_25();
});
@@ -1242,36 +1278,34 @@ function run_test_24() {
// Tests that updating from a bootstrappable add-on to a normal add-on calls
// the uninstall method
function run_test_25() {
- BootstrapMonitor.promiseAddonStartup(ID1).then(function test_25_after_pref() {
+ waitForPref("bootstraptest.startup_reason", function test_25_after_pref() {
do_print("test 25 pref change detected");
- BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
- BootstrapMonitor.checkAddonStarted(ID1, "1.0");
+ do_check_eq(getInstalledVersion(), 1);
+ do_check_eq(getActiveVersion(), 1);
installAllFiles([do_get_addon("test_bootstrap1_4")], function() {
// Needs a restart to complete this so the old version stays running
- BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
- BootstrapMonitor.checkAddonStarted(ID1, "1.0");
+ do_check_eq(getInstalledVersion(), 1);
+ do_check_eq(getActiveVersion(), 1);
- AddonManager.getAddonByID(ID1, callback_soon(function(b1) {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", callback_soon(function(b1) {
do_check_neq(b1, null);
do_check_eq(b1.version, "1.0");
do_check_true(b1.isActive);
- do_check_false(b1.isSystem);
do_check_true(hasFlag(b1.pendingOperations, AddonManager.PENDING_UPGRADE));
restartManager();
- BootstrapMonitor.checkAddonNotInstalled(ID1);
+ do_check_eq(getInstalledVersion(), 0);
do_check_eq(getUninstallReason(), ADDON_UPGRADE);
do_check_eq(getUninstallNewVersion(), 4);
- BootstrapMonitor.checkAddonNotStarted(ID1);
+ do_check_eq(getActiveVersion(), 0);
- AddonManager.getAddonByID(ID1, function(b1_2) {
- do_check_neq(b1_2, null);
- do_check_eq(b1_2.version, "4.0");
- do_check_true(b1_2.isActive);
- do_check_false(b1_2.isSystem);
- do_check_eq(b1_2.pendingOperations, AddonManager.PENDING_NONE);
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
+ do_check_neq(b1, null);
+ do_check_eq(b1.version, "4.0");
+ do_check_true(b1.isActive);
+ do_check_eq(b1.pendingOperations, AddonManager.PENDING_NONE);
do_check_bootstrappedPref(run_test_26);
});
@@ -1288,29 +1322,27 @@ function run_test_25() {
function run_test_26() {
installAllFiles([do_get_addon("test_bootstrap1_1")], function() {
// Needs a restart to complete this
- BootstrapMonitor.checkAddonNotInstalled(ID1);
- BootstrapMonitor.checkAddonNotStarted(ID1);
+ do_check_eq(getInstalledVersion(), 0);
+ do_check_eq(getActiveVersion(), 0);
- AddonManager.getAddonByID(ID1, callback_soon(function(b1) {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", callback_soon(function(b1) {
do_check_neq(b1, null);
do_check_eq(b1.version, "4.0");
do_check_true(b1.isActive);
- do_check_false(b1.isSystem);
do_check_true(hasFlag(b1.pendingOperations, AddonManager.PENDING_UPGRADE));
restartManager();
- BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
+ do_check_eq(getInstalledVersion(), 1);
do_check_eq(getInstallReason(), ADDON_DOWNGRADE);
do_check_eq(getInstallOldVersion(), 4);
- BootstrapMonitor.checkAddonStarted(ID1, "1.0");
+ do_check_eq(getActiveVersion(), 1);
- AddonManager.getAddonByID(ID1, function(b1_2) {
- do_check_neq(b1_2, null);
- do_check_eq(b1_2.version, "1.0");
- do_check_true(b1_2.isActive);
- do_check_false(b1_2.isSystem);
- do_check_eq(b1_2.pendingOperations, AddonManager.PENDING_NONE);
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
+ do_check_neq(b1, null);
+ do_check_eq(b1.version, "1.0");
+ do_check_true(b1.isActive);
+ do_check_eq(b1.pendingOperations, AddonManager.PENDING_NONE);
do_check_bootstrappedPref(run_test_27);
});
@@ -1321,38 +1353,38 @@ function run_test_26() {
// Tests that updating from a bootstrappable add-on to a normal add-on while
// disabled calls the uninstall method
function run_test_27() {
- AddonManager.getAddonByID(ID1, function(b1) {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
do_check_neq(b1, null);
b1.userDisabled = true;
do_check_eq(b1.version, "1.0");
do_check_false(b1.isActive);
do_check_eq(b1.pendingOperations, AddonManager.PENDING_NONE);
- BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
- BootstrapMonitor.checkAddonNotStarted(ID1);
+ do_check_eq(getInstalledVersion(), 1);
+ do_check_eq(getActiveVersion(), 0);
installAllFiles([do_get_addon("test_bootstrap1_4")], function() {
// Updating disabled things happens immediately
- BootstrapMonitor.checkAddonNotInstalled(ID1);
+ do_check_eq(getInstalledVersion(), 0);
do_check_eq(getUninstallReason(), ADDON_UPGRADE);
do_check_eq(getUninstallNewVersion(), 4);
- BootstrapMonitor.checkAddonNotStarted(ID1);
+ do_check_eq(getActiveVersion(), 0);
- AddonManager.getAddonByID(ID1, callback_soon(function(b1_2) {
- do_check_neq(b1_2, null);
- do_check_eq(b1_2.version, "4.0");
- do_check_false(b1_2.isActive);
- do_check_eq(b1_2.pendingOperations, AddonManager.PENDING_NONE);
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", callback_soon(function(b1) {
+ do_check_neq(b1, null);
+ do_check_eq(b1.version, "4.0");
+ do_check_false(b1.isActive);
+ do_check_eq(b1.pendingOperations, AddonManager.PENDING_NONE);
restartManager();
- BootstrapMonitor.checkAddonNotInstalled(ID1);
- BootstrapMonitor.checkAddonNotStarted(ID1);
+ do_check_eq(getInstalledVersion(), 0);
+ do_check_eq(getActiveVersion(), 0);
- AddonManager.getAddonByID(ID1, function(b1_3) {
- do_check_neq(b1_3, null);
- do_check_eq(b1_3.version, "4.0");
- do_check_false(b1_3.isActive);
- do_check_eq(b1_3.pendingOperations, AddonManager.PENDING_NONE);
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
+ do_check_neq(b1, null);
+ do_check_eq(b1.version, "4.0");
+ do_check_false(b1.isActive);
+ do_check_eq(b1.pendingOperations, AddonManager.PENDING_NONE);
do_check_bootstrappedPref(run_test_28);
});
@@ -1367,12 +1399,12 @@ function run_test_28() {
installAllFiles([do_get_addon("test_bootstrap1_1")], function() {
do_execute_soon(function bootstrap_disabled_downgrade_check() {
// Doesn't need a restart to complete this
- BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
+ do_check_eq(getInstalledVersion(), 1);
do_check_eq(getInstallReason(), ADDON_DOWNGRADE);
do_check_eq(getInstallOldVersion(), 4);
- BootstrapMonitor.checkAddonNotStarted(ID1);
+ do_check_eq(getActiveVersion(), 0);
- AddonManager.getAddonByID(ID1, callback_soon(function(b1) {
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", callback_soon(function(b1) {
do_check_neq(b1, null);
do_check_eq(b1.version, "1.0");
do_check_false(b1.isActive);
@@ -1381,19 +1413,18 @@ function run_test_28() {
restartManager();
- BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
- BootstrapMonitor.checkAddonNotStarted(ID1);
-
- AddonManager.getAddonByID(ID1, function(b1_2) {
- do_check_neq(b1_2, null);
- do_check_true(b1_2.userDisabled);
- b1_2.userDisabled = false;
- do_check_eq(b1_2.version, "1.0");
- do_check_true(b1_2.isActive);
- do_check_false(b1_2.isSystem);
- do_check_eq(b1_2.pendingOperations, AddonManager.PENDING_NONE);
- BootstrapMonitor.checkAddonInstalled(ID1, "1.0");
- BootstrapMonitor.checkAddonStarted(ID1, "1.0");
+ do_check_eq(getInstalledVersion(), 1);
+ do_check_eq(getActiveVersion(), 0);
+
+ AddonManager.getAddonByID("bootstrap1@tests.mozilla.org", function(b1) {
+ do_check_neq(b1, null);
+ do_check_true(b1.userDisabled);
+ b1.userDisabled = false;
+ do_check_eq(b1.version, "1.0");
+ do_check_true(b1.isActive);
+ do_check_eq(b1.pendingOperations, AddonManager.PENDING_NONE);
+ do_check_eq(getInstalledVersion(), 1);
+ do_check_eq(getActiveVersion(), 1);
do_check_bootstrappedPref(do_test_finished);
});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap_const.js b/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap_const.js
deleted file mode 100644
index 101d49510..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap_const.js
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
-startupManager();
-
-add_task(function*() {
- let sawInstall = false;
- Services.obs.addObserver(function() {
- sawInstall = true;
- }, "addon-install", false);
-
- yield promiseInstallAllFiles([do_get_addon("test_bootstrap_const")]);
-
- ok(sawInstall);
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap_globals.js b/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap_globals.js
index 29b538d21..2243a21a2 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap_globals.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap_globals.js
@@ -23,7 +23,7 @@ function run_test() {
}, "bootstrap-request-globals", false);
Services.obs.addObserver(function({ wrappedJSObject: seenGlobals }) {
- for (let [name, ] of EXPECTED_GLOBALS)
+ for (let [name,] of EXPECTED_GLOBALS)
do_check_true(seenGlobals.has(name));
sawGlobals = true;
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug1180901.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug1180901.js
deleted file mode 100644
index c13531dff..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug1180901.js
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-function run_test() {
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
- startupManager();
- run_next_test();
-}
-
-add_task(function* () {
- let profileDir = OS.Constants.Path.profileDir;
- let trashDir = OS.Path.join(profileDir, "extensions", "trash");
- let testFile = OS.Path.join(trashDir, "test.txt");
-
- yield OS.File.makeDir(trashDir, {
- from: profileDir,
- ignoreExisting: true
- });
-
- let trashDirExists = yield OS.File.exists(trashDir);
- ok(trashDirExists, "trash directory should have been created");
-
- let file = yield OS.File.open(testFile, {create: true}, {winShare: 0});
- let fileExists = yield OS.File.exists(testFile);
- ok(fileExists, "test.txt should have been created in " + trashDir);
-
- yield promiseInstallAllFiles([do_get_addon("test_install1")]);
- yield promiseRestartManager();
- fileExists = yield OS.File.exists(testFile);
- ok(fileExists, "test.txt still exists");
- yield file.close();
- yield OS.File.removeDir(OS.Path.join(OS.Constants.Path.profileDir, "extensions"));
- yield promiseShutdownManager();
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug1180901_2.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug1180901_2.js
deleted file mode 100644
index 8e9f30ef2..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug1180901_2.js
+++ /dev/null
@@ -1,60 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-function run_test() {
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
- startupManager();
- run_next_test();
-}
-
-add_task(function* () {
- let profileDir = OS.Constants.Path.profileDir;
- let trashDir = OS.Path.join(profileDir, "extensions", "trash");
- let testFile = OS.Path.join(trashDir, "test.txt");
-
- yield OS.File.makeDir(trashDir, {
- from: profileDir,
- ignoreExisting: true
- });
-
- let trashDirExists = yield OS.File.exists(trashDir);
- ok(trashDirExists, "trash directory should have been created");
-
- let file = yield OS.File.open(testFile, {create: true}, {winShare: 0});
- let fileExists = yield OS.File.exists(testFile);
- ok(fileExists, "test.txt should have been created in " + trashDir);
-
- let promiseInstallStatus = new Promise((resolve, reject) => {
- let listener = {
- onInstallFailed: function() {
- AddonManager.removeInstallListener(listener);
- reject("extension installation should not have failed");
- },
- onInstallEnded: function() {
- AddonManager.removeInstallListener(listener);
- ok(true, "extension installation should not have failed");
- resolve();
- }
- };
-
- AddonManager.addInstallListener(listener);
- });
-
- yield promiseInstallAllFiles([do_get_addon("test_bootstrap1_1")]);
-
- // The testFile should still exist at this point because we have not
- // yet closed the file handle and as a result, Windows cannot remove it.
- fileExists = yield OS.File.exists(testFile);
- ok(fileExists, "test.txt should still exist");
-
- // Wait for the AddonManager to tell us if the installation of the extension
- // succeeded or not.
- yield promiseInstallStatus;
-
- // Cleanup
- yield promiseShutdownManager();
- yield file.close();
- yield OS.File.remove(testFile);
- yield OS.File.removeDir(trashDir);
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug299716.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug299716.js
index 66656abe6..5de941f32 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug299716.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug299716.js
@@ -105,8 +105,9 @@ function do_check_item(aItem, aVersion, aAddonsEntry) {
do_throw("Addon " + aAddonsEntry.id + " wasn't detected");
if (aItem.version != aVersion)
do_throw("Addon " + aAddonsEntry.id + " was version " + aItem.version + " instead of " + aVersion);
- } else if (aItem != null) {
- do_throw("Addon " + aAddonsEntry.id + " was detected");
+ } else {
+ if (aItem != null)
+ do_throw("Addon " + aAddonsEntry.id + " was detected");
}
}
@@ -148,7 +149,7 @@ function run_test() {
startupManager();
dump("\n\n*** INSTALLING NEW ITEMS\n\n");
- installAllFiles(ADDONS.map(a => do_get_addon(a.addon)), run_test_pt2,
+ installAllFiles([do_get_addon(a.addon) for each (a in ADDONS)], run_test_pt2,
true);
}
@@ -160,7 +161,7 @@ function run_test_pt2() {
dump("\n\n*** RESTARTING EXTENSION MANAGER\n\n");
restartManager();
- AddonManager.getAddonsByIDs(ADDONS.map(a => a.id), function(items) {
+ AddonManager.getAddonsByIDs([a.id for each (a in ADDONS)], function(items) {
dump("\n\n*** REQUESTING UPDATE\n\n");
// checkListener will call run_test_pt3().
next_test = run_test_pt3;
@@ -185,7 +186,7 @@ function run_test_pt2() {
function run_test_pt3() {
// Install the new items.
dump("\n\n*** UPDATING ITEMS\n\n");
- completeAllInstalls(ADDONS.filter(a => a.newInstall).map(a => a.newInstall),
+ completeAllInstalls([a.newInstall for each(a in ADDONS) if (a.newInstall)],
run_test_pt4);
}
@@ -197,7 +198,7 @@ function run_test_pt4() {
restartManager();
dump("\n\n*** FINAL CHECKS\n\n");
- AddonManager.getAddonsByIDs(ADDONS.map(a => a.id), function(items) {
+ AddonManager.getAddonsByIDs([a.id for each (a in ADDONS)], function(items) {
for (var i = 0; i < ADDONS.length; i++) {
var item = items[i];
do_check_item(item, "0.2", ADDONS[i]);
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug324121.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug324121.js
index 84b6c6189..b88c07b23 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug324121.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug324121.js
@@ -136,11 +136,11 @@ function run_test() {
startupManager();
- installAllFiles(ADDONS.map(a => do_get_addon(a.addon)), function() {
+ installAllFiles([do_get_addon(a.addon) for each (a in ADDONS)], function() {
restartManager();
- AddonManager.getAddonByID(ADDONS[0].id, callback_soon(function(firstAddon) {
- do_check_true(firstAddon);
- firstAddon.userDisabled = true;
+ AddonManager.getAddonByID(ADDONS[0].id, callback_soon(function(addon) {
+ do_check_true(!(!addon));
+ addon.userDisabled = true;
restartManager();
AddonManager.getAddonsByTypes(["extension"], function(installedItems) {
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug335238.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug335238.js
index 251bdca70..e691bb570 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug335238.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug335238.js
@@ -9,11 +9,10 @@ const PREF_SELECTED_LOCALE = "general.useragent.locale";
// Disables security checking our updates which haven't been signed
Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
-var Ci = Components.interfaces;
-var Cu = Components.utils;
+const Ci = Components.interfaces;
+const Cu = Components.utils;
Cu.import("resource://testing-common/httpd.js");
-Cu.import("resource://testing-common/MockRegistrar.jsm");
// This is the data we expect to see sent as part of the update url.
var EXPECTED = [
@@ -106,7 +105,16 @@ var BlocklistService = {
}
};
-MockRegistrar.register("@mozilla.org/extensions/blocklist;1", BlocklistService);
+var BlocklistServiceFactory = {
+ createInstance: function (outer, iid) {
+ if (outer != null)
+ throw Components.results.NS_ERROR_NO_AGGREGATION;
+ return BlocklistService.QueryInterface(iid);
+ }
+};
+var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
+registrar.registerFactory(Components.ID("{61189e7a-6b1b-44b8-ac81-f180a6105085}"), "BlocklistService",
+ "@mozilla.org/extensions/blocklist;1", BlocklistServiceFactory);
var server;
@@ -154,7 +162,7 @@ function run_test() {
Services.prefs.setCharPref(PREF_SELECTED_LOCALE, "en-US");
startupManager();
- installAllFiles(ADDONS.map(a => do_get_addon(a.addon)), function() {
+ installAllFiles([do_get_addon(a.addon) for each (a in ADDONS)], function() {
restartManager();
AddonManager.getAddonByID(ADDONS[1].id, callback_soon(function(addon) {
@@ -162,7 +170,7 @@ function run_test() {
addon.userDisabled = true;
restartManager();
- AddonManager.getAddonsByIDs(ADDONS.map(a => a.id), function(installedItems) {
+ AddonManager.getAddonsByIDs([a.id for each (a in ADDONS)], function(installedItems) {
installedItems.forEach(function(item) {
updateListener.pendingCount++;
item.findUpdates(updateListener, AddonManager.UPDATE_WHEN_USER_REQUESTED);
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug371495.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug371495.js
index 43656f126..3a80c1945 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug371495.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug371495.js
@@ -23,10 +23,10 @@ function run_test()
do_check_eq(addon.name, "Test theme");
restartManager();
- AddonManager.getAddonByID(ID, callback_soon(function(addon2) {
- do_check_neq(addon2, null);
- do_check_eq(addon2.optionsURL, null);
- do_check_eq(addon2.aboutURL, null);
+ AddonManager.getAddonByID(ID, callback_soon(function(addon) {
+ do_check_neq(addon, null);
+ do_check_eq(addon.optionsURL, null);
+ do_check_eq(addon.aboutURL, null);
do_execute_soon(do_test_finished);
}));
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug393285.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug393285.js
index ebc330cdd..90cf29753 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug393285.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug393285.js
@@ -3,12 +3,11 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
+const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
const URI_EXTENSION_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul";
Cu.import("resource://testing-common/httpd.js");
-Cu.import("resource://testing-common/MockRegistrar.jsm");
var testserver = new HttpServer();
testserver.start(-1);
gPort = testserver.identity.primaryPort;
@@ -19,7 +18,7 @@ mapFile("/data/test_bug393285.xml", testserver);
const profileDir = gProfD.clone();
profileDir.append("extensions");
-var addonIDs = ["test_bug393285_1@tests.mozilla.org",
+let addonIDs = ["test_bug393285_1@tests.mozilla.org",
"test_bug393285_2@tests.mozilla.org",
"test_bug393285_3a@tests.mozilla.org",
"test_bug393285_3b@tests.mozilla.org",
@@ -37,18 +36,18 @@ var addonIDs = ["test_bug393285_1@tests.mozilla.org",
// A window watcher to deal with the blocklist UI dialog.
var WindowWatcher = {
- openWindow: function(parent, url, name, features, args) {
+ openWindow: function(parent, url, name, features, arguments) {
// Should be called to list the newly blocklisted items
do_check_eq(url, URI_EXTENSION_BLOCKLIST_DIALOG);
// Simulate auto-disabling any softblocks
- var list = args.wrappedJSObject.list;
+ var list = arguments.wrappedJSObject.list;
list.forEach(function(aItem) {
if (!aItem.blocked)
aItem.disable = true;
});
- // run the code after the blocklist is closed
+ //run the code after the blocklist is closed
Services.obs.notifyObservers(null, "addon-blocklist-closed", null);
},
@@ -62,7 +61,19 @@ var WindowWatcher = {
}
};
-MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher);
+var WindowWatcherFactory = {
+ createInstance: function createInstance(outer, iid) {
+ if (outer != null)
+ throw Cr.NS_ERROR_NO_AGGREGATION;
+ return WindowWatcher.QueryInterface(iid);
+ }
+};
+
+var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
+registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
+ "Fake Window Watcher",
+ "@mozilla.org/embedcomp/window-watcher;1",
+ WindowWatcherFactory);
function load_blocklist(aFile, aCallback) {
@@ -258,7 +269,7 @@ function run_test() {
startupManager();
AddonManager.getAddonsByIDs(addonIDs, function(addons) {
- for (let addon of addons) {
+ for (addon of addons) {
do_check_eq(addon.blocklistState, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
}
run_test_1();
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug406118.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug406118.js
index e22ab87c9..724b48dd5 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug406118.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug406118.js
@@ -3,17 +3,16 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-var addonIDs = ["test_bug393285_1@tests.mozilla.org",
+let addonIDs = ["test_bug393285_1@tests.mozilla.org",
"test_bug393285_2@tests.mozilla.org",
"test_bug393285_3a@tests.mozilla.org",
"test_bug393285_4@tests.mozilla.org"];
-var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
+const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
const URI_EXTENSION_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul";
Cu.import("resource://testing-common/httpd.js");
-Cu.import("resource://testing-common/MockRegistrar.jsm");
var testserver = new HttpServer();
testserver.start(-1);
gPort = testserver.identity.primaryPort;
@@ -26,18 +25,18 @@ profileDir.append("extensions");
// A window watcher to deal with the blocklist UI dialog.
var WindowWatcher = {
- openWindow: function(parent, url, name, features, args) {
+ openWindow: function(parent, url, name, features, arguments) {
// Should be called to list the newly blocklisted items
do_check_eq(url, URI_EXTENSION_BLOCKLIST_DIALOG);
// Simulate auto-disabling any softblocks
- var list = args.wrappedJSObject.list;
+ var list = arguments.wrappedJSObject.list;
list.forEach(function(aItem) {
if (!aItem.blocked)
aItem.disable = true;
});
- // run the code after the blocklist is closed
+ //run the code after the blocklist is closed
Services.obs.notifyObservers(null, "addon-blocklist-closed", null);
},
@@ -51,7 +50,20 @@ var WindowWatcher = {
}
};
-MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher);
+var WindowWatcherFactory = {
+ createInstance: function createInstance(outer, iid) {
+ if (outer != null)
+ throw Cr.NS_ERROR_NO_AGGREGATION;
+ return WindowWatcher.QueryInterface(iid);
+ }
+};
+
+var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
+registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
+ "Fake Window Watcher",
+ "@mozilla.org/embedcomp/window-watcher;1",
+ WindowWatcherFactory);
+
function load_blocklist(aFile, aCallback) {
Services.obs.addObserver(function() {
@@ -125,7 +137,7 @@ function run_test() {
startupManager();
AddonManager.getAddonsByIDs(addonIDs, function(addons) {
- for (let addon of addons) {
+ for (addon of addons) {
do_check_eq(addon.blocklistState, Ci.nsIBlocklistService.STATE_NOT_BLOCKED);
}
run_test_1();
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug430120.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug430120.js
index e13f36a7c..74080dba9 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug430120.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug430120.js
@@ -14,7 +14,6 @@ const CATEGORY_UPDATE_TIMER = "update-timer";
// Get the HTTP server.
Components.utils.import("resource://testing-common/httpd.js");
-Components.utils.import("resource://testing-common/MockRegistrar.jsm");
var testserver;
var gOSVersion;
var gBlocklist;
@@ -50,7 +49,16 @@ var timerService = {
}
};
-MockRegistrar.register("@mozilla.org/updates/timer-manager;1", timerService);
+var TimerServiceFactory = {
+ createInstance: function (outer, iid) {
+ if (outer != null)
+ throw Components.results.NS_ERROR_NO_AGGREGATION;
+ return timerService.QueryInterface(iid);
+ }
+};
+var registrar = Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar);
+registrar.registerFactory(Components.ID("{61189e7a-6b1b-44b8-ac81-f180a6105085}"), "TimerService",
+ "@mozilla.org/updates/timer-manager;1", TimerServiceFactory);
function failHandler(metadata, response) {
do_throw("Should not have attempted to retrieve the blocklist when it is disabled");
@@ -67,8 +75,7 @@ function pathHandler(metadata, response) {
ABI += "-u-" + macutils.architecturesInBinary;
}
do_check_eq(metadata.queryString,
- "xpcshell@tests.mozilla.org&1&XPCShell&1&" +
- gAppInfo.appBuildID + "&" +
+ "xpcshell@tests.mozilla.org&1&XPCShell&1&2007010101&" +
"XPCShell_" + ABI + "&locale&updatechannel&" +
gOSVersion + "&1.9&distribution&distribution-version");
gBlocklist.observe(null, "quit-application", "");
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug449027.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug449027.js
index 1512a7f92..623a6a14a 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug449027.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug449027.js
@@ -4,11 +4,10 @@
*/
const URI_EXTENSION_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul";
-var Ci = Components.interfaces;
-var Cu = Components.utils;
+const Ci = Components.interfaces;
+const Cu = Components.utils;
Cu.import("resource://testing-common/httpd.js");
-Cu.import("resource://testing-common/MockRegistrar.jsm");
var ADDONS = [{
id: "test_bug449027_1@tests.mozilla.org",
@@ -250,15 +249,23 @@ var PluginHost = {
}
}
+var PluginHostFactory = {
+ createInstance: function (outer, iid) {
+ if (outer != null)
+ throw Components.results.NS_ERROR_NO_AGGREGATION;
+ return PluginHost.QueryInterface(iid);
+ }
+};
+
// Don't need the full interface, attempts to call other methods will just
// throw which is just fine
var WindowWatcher = {
- openWindow: function(parent, url, name, features, args) {
+ openWindow: function(parent, url, name, features, arguments) {
// Should be called to list the newly blocklisted items
do_check_eq(url, URI_EXTENSION_BLOCKLIST_DIALOG);
do_check_neq(gCallback, null);
- args = args.wrappedJSObject;
+ var args = arguments.wrappedJSObject;
gNewBlocks = [];
var list = args.list;
@@ -278,8 +285,20 @@ var WindowWatcher = {
}
}
-MockRegistrar.register("@mozilla.org/plugin/host;1", PluginHost);
-MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher);
+var WindowWatcherFactory = {
+ createInstance: function createInstance(outer, iid) {
+ if (outer != null)
+ throw Components.results.NS_ERROR_NO_AGGREGATION;
+ return WindowWatcher.QueryInterface(iid);
+ }
+};
+var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
+registrar.registerFactory(Components.ID("{721c3e73-969e-474b-a6dc-059fd288c428}"),
+ "Fake Plugin Host",
+ "@mozilla.org/plugin/host;1", PluginHostFactory);
+registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
+ "Fake Window Watcher",
+ "@mozilla.org/embedcomp/window-watcher;1", WindowWatcherFactory);
function create_addon(addon) {
var installrdf = "<?xml version=\"1.0\"?>\n" +
@@ -303,10 +322,10 @@ function create_addon(addon) {
target.append("extensions");
target.append(addon.id);
target.append("install.rdf");
- target.create(target.NORMAL_FILE_TYPE, 0o644);
+ target.create(target.NORMAL_FILE_TYPE, 0644);
var stream = Components.classes["@mozilla.org/network/file-output-stream;1"]
.createInstance(Ci.nsIFileOutputStream);
- stream.init(target, 0x04 | 0x08 | 0x20, 0o664, 0); // write, create, truncate
+ stream.init(target, 0x04 | 0x08 | 0x20, 0664, 0); // write, create, truncate
stream.write(installrdf, installrdf.length);
stream.close();
}
@@ -317,7 +336,7 @@ function create_addon(addon) {
* the newly blocked items compared to the previous test.
*/
function check_state(test, lastTest, callback) {
- AddonManager.getAddonsByIDs(ADDONS.map(a => a.id), function(addons) {
+ AddonManager.getAddonsByIDs([a.id for each (a in ADDONS)], function(addons) {
for (var i = 0; i < ADDONS.length; i++) {
var blocked = addons[i].blocklistState == Ci.nsIBlocklistService.STATE_BLOCKED;
if (blocked != ADDONS[i][test])
@@ -386,13 +405,13 @@ function run_test() {
function check_test_pt1() {
dump("Checking pt 1\n");
- AddonManager.getAddonsByIDs(ADDONS.map(a => a.id), function(addons) {
+ AddonManager.getAddonsByIDs([a.id for each (a in ADDONS)], function(addons) {
for (var i = 0; i < ADDONS.length; i++) {
if (!addons[i])
do_throw("Addon " + (i + 1) + " did not get installed correctly");
}
- do_execute_soon(function checkstate1() { check_state("start", null, run_test_pt2); });
+ do_execute_soon(function checkstate1() {check_state("start", null, run_test_pt2);});
});
}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug455906.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug455906.js
index 06e29b376..9a41e827c 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug455906.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug455906.js
@@ -3,15 +3,14 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-var Cc = Components.classes;
-var Ci = Components.interfaces;
-var Cu = Components.utils;
-var Cr = Components.results;
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+const Cu = Components.utils;
+const Cr = Components.results;
const URI_EXTENSION_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul";
Cu.import("resource://testing-common/httpd.js");
-Cu.import("resource://testing-common/MockRegistrar.jsm");
var gTestserver = new HttpServer();
gTestserver.start(-1);
gPort = gTestserver.identity.primaryPort;
@@ -128,11 +127,19 @@ var PluginHost = {
if (iid.equals(Ci.nsIPluginHost)
|| iid.equals(Ci.nsISupports))
return this;
-
+
throw Components.results.NS_ERROR_NO_INTERFACE;
}
}
+var PluginHostFactory = {
+ createInstance: function (outer, iid) {
+ if (outer != null)
+ throw Components.results.NS_ERROR_NO_AGGREGATION;
+ return PluginHost.QueryInterface(iid);
+ }
+};
+
// Don't need the full interface, attempts to call other methods will just
// throw which is just fine
var WindowWatcher = {
@@ -145,7 +152,7 @@ var WindowWatcher = {
gNotificationCheck(args);
}
- // run the code after the blocklist is closed
+ //run the code after the blocklist is closed
Services.obs.notifyObservers(null, "addon-blocklist-closed", null);
// Call the next test after the blocklist has finished up
@@ -161,8 +168,20 @@ var WindowWatcher = {
}
}
-MockRegistrar.register("@mozilla.org/plugin/host;1", PluginHost);
-MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher);
+var WindowWatcherFactory = {
+ createInstance: function createInstance(outer, iid) {
+ if (outer != null)
+ throw Components.results.NS_ERROR_NO_AGGREGATION;
+ return WindowWatcher.QueryInterface(iid);
+ }
+};
+var registrar = Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar);
+registrar.registerFactory(Components.ID("{721c3e73-969e-474b-a6dc-059fd288c428}"),
+ "Fake Plugin Host",
+ "@mozilla.org/plugin/host;1", PluginHostFactory);
+registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
+ "Fake Window Watcher",
+ "@mozilla.org/embedcomp/window-watcher;1", WindowWatcherFactory);
function create_addon(addon) {
var installrdf = "<?xml version=\"1.0\"?>\n" +
@@ -211,7 +230,7 @@ function check_plugin_state(plugin) {
return plugin.disabled + "," + plugin.blocklisted;
}
-function create_blocklistURL(blockID) {
+function create_blocklistURL(blockID){
let url = Services.urlFormatter.formatURLPref(PREF_BLOCKLIST_ITEM_URL);
url = url.replace(/%blockID%/g, blockID);
return url;
@@ -239,7 +258,7 @@ function run_test() {
// Before every main test this is the state the add-ons are meant to be in
function check_initial_state(callback) {
- AddonManager.getAddonsByIDs(ADDONS.map(a => a.id), function(addons) {
+ AddonManager.getAddonsByIDs([a.id for each (a in ADDONS)], function(addons) {
do_check_eq(check_addon_state(addons[0]), "true,false,false");
do_check_eq(check_addon_state(addons[1]), "false,false,false");
do_check_eq(check_addon_state(addons[2]), "false,false,false");
@@ -247,7 +266,7 @@ function check_initial_state(callback) {
do_check_eq(check_addon_state(addons[4]), "false,false,false");
do_check_eq(check_addon_state(addons[5]), "false,false,true");
do_check_eq(check_addon_state(addons[6]), "false,false,true");
-
+
do_check_eq(check_plugin_state(PLUGINS[0]), "true,false");
do_check_eq(check_plugin_state(PLUGINS[1]), "false,false");
do_check_eq(check_plugin_state(PLUGINS[2]), "false,false");
@@ -263,27 +282,27 @@ function check_initial_state(callback) {
function check_test_pt1() {
dump("Checking pt 1\n");
- AddonManager.getAddonsByIDs(ADDONS.map(a => a.id), callback_soon(function(addons) {
+ AddonManager.getAddonsByIDs([a.id for each (a in ADDONS)], callback_soon(function(addons) {
for (var i = 0; i < ADDONS.length; i++) {
if (!addons[i])
do_throw("Addon " + (i + 1) + " did not get installed correctly");
}
-
+
do_check_eq(check_addon_state(addons[0]), "false,false,false");
do_check_eq(check_addon_state(addons[1]), "false,false,false");
do_check_eq(check_addon_state(addons[2]), "false,false,false");
-
+
// Warn add-ons should be soft disabled automatically
do_check_eq(check_addon_state(addons[3]), "true,true,false");
do_check_eq(check_addon_state(addons[4]), "true,true,false");
-
+
// Blocked and incompatible should be app disabled only
do_check_eq(check_addon_state(addons[5]), "false,false,true");
do_check_eq(check_addon_state(addons[6]), "false,false,true");
-
+
// We've overridden the plugin host so we cannot tell what that would have
// initialised the plugins as
-
+
// Put the add-ons into the base state
addons[0].userDisabled = true;
addons[4].userDisabled = false;
@@ -335,14 +354,13 @@ function check_test_pt2() {
restartManager();
dump("Checking results pt 2\n");
- AddonManager.getAddonsByIDs(ADDONS.map(a => a.id), callback_soon(function(addons) {
+ AddonManager.getAddonsByIDs([a.id for each (a in ADDONS)], callback_soon(function(addons) {
// Should have disabled this add-on as requested
do_check_eq(check_addon_state(addons[2]), "true,true,false");
do_check_eq(check_plugin_state(PLUGINS[2]), "true,false");
// The blocked add-on should have changed to soft disabled
do_check_eq(check_addon_state(addons[5]), "true,true,false");
- do_check_eq(check_addon_state(addons[6]), "true,true,true");
do_check_eq(check_plugin_state(PLUGINS[5]), "true,false");
// These should have been unchanged
@@ -350,6 +368,7 @@ function check_test_pt2() {
do_check_eq(check_addon_state(addons[1]), "false,false,false");
do_check_eq(check_addon_state(addons[3]), "true,true,false");
do_check_eq(check_addon_state(addons[4]), "false,false,false");
+ do_check_eq(check_addon_state(addons[6]), "false,false,true");
do_check_eq(check_plugin_state(PLUGINS[0]), "true,false");
do_check_eq(check_plugin_state(PLUGINS[1]), "false,false");
do_check_eq(check_plugin_state(PLUGINS[3]), "true,false");
@@ -421,7 +440,7 @@ function check_test_pt3() {
let blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
getService(Ci.nsIBlocklistService);
- AddonManager.getAddonsByIDs(ADDONS.map(a => a.id), function(addons) {
+ AddonManager.getAddonsByIDs([a.id for each (a in ADDONS)], function(addons) {
// All should have gained the blocklist state, user disabled as previously
do_check_eq(check_addon_state(addons[0]), "true,false,true");
do_check_eq(check_addon_state(addons[1]), "false,false,true");
@@ -437,11 +456,11 @@ function check_test_pt3() {
do_check_eq(check_addon_state(addons[3]), "false,false,true");
// Check blockIDs are correct
- do_check_eq(blocklist.getAddonBlocklistURL(addons[0]), create_blocklistURL(addons[0].id));
- do_check_eq(blocklist.getAddonBlocklistURL(addons[1]), create_blocklistURL(addons[1].id));
- do_check_eq(blocklist.getAddonBlocklistURL(addons[2]), create_blocklistURL(addons[2].id));
- do_check_eq(blocklist.getAddonBlocklistURL(addons[3]), create_blocklistURL(addons[3].id));
- do_check_eq(blocklist.getAddonBlocklistURL(addons[4]), create_blocklistURL(addons[4].id));
+ do_check_eq(blocklist.getAddonBlocklistURL(addons[0]),create_blocklistURL(addons[0].id));
+ do_check_eq(blocklist.getAddonBlocklistURL(addons[1]),create_blocklistURL(addons[1].id));
+ do_check_eq(blocklist.getAddonBlocklistURL(addons[2]),create_blocklistURL(addons[2].id));
+ do_check_eq(blocklist.getAddonBlocklistURL(addons[3]),create_blocklistURL(addons[3].id));
+ do_check_eq(blocklist.getAddonBlocklistURL(addons[4]),create_blocklistURL(addons[4].id));
// All plugins have the same blockID on the test
do_check_eq(blocklist.getPluginBlocklistURL(PLUGINS[0]), create_blocklistURL('test_bug455906_plugin'));
@@ -488,7 +507,7 @@ function check_test_pt4() {
restartManager();
dump("Checking results pt 4\n");
- AddonManager.getAddonsByIDs(ADDONS.map(a => a.id), function(addons) {
+ AddonManager.getAddonsByIDs([a.id for each (a in ADDONS)], function(addons) {
// This should have become unblocked
do_check_eq(check_addon_state(addons[5]), "false,false,false");
do_check_eq(check_plugin_state(PLUGINS[5]), "false,false");
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug465190.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug465190.js
index e8e2353e2..fc8c772c9 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug465190.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug465190.js
@@ -5,7 +5,7 @@
var installLocation = gProfD.clone();
installLocation.append("baddir");
-installLocation.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0o664);
+installLocation.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0664);
var dirProvider2 = {
getFile: function(prop, persistent) {
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug468528.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug468528.js
index 01c976a17..5e8702eb7 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug468528.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug468528.js
@@ -48,7 +48,7 @@ function run_test() {
// not blocked - won't match due to invalid regexp
do_check_true(blocklist.getPluginBlocklistState(PLUGINS[1], "1", "1.9") == nsIBLS.STATE_NOT_BLOCKED);
-
+
// blocked - the invalid regexp for the previous item shouldn't affect this one
do_check_true(blocklist.getPluginBlocklistState(PLUGINS[2], "1", "1.9") == nsIBLS.STATE_BLOCKED);
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_1.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_1.js
index 920c3731a..c456506ce 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_1.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_1.js
@@ -28,7 +28,7 @@ function run_test() {
startupManager();
- installAllFiles(ADDONS.map(a => do_get_addon(a)), function() {
+ installAllFiles([do_get_addon(a) for each (a in ADDONS)], function() {
restartManager();
AddonManager.getAddonsByIDs(["bug470377_1@tests.mozilla.org",
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_1_strictcompat.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_1_strictcompat.js
index 6fa11eb39..1e542dff8 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_1_strictcompat.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_1_strictcompat.js
@@ -28,7 +28,7 @@ function run_test() {
startupManager();
- installAllFiles(ADDONS.map(a => do_get_addon(a)), function() {
+ installAllFiles([do_get_addon(a) for each (a in ADDONS)], function() {
restartManager();
AddonManager.getAddonsByIDs(["bug470377_1@tests.mozilla.org",
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_2.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_2.js
index 0c912ceff..15e8d54c4 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_2.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_2.js
@@ -28,7 +28,7 @@ function run_test() {
startupManager();
AddonManager.checkCompatibility = false;
- installAllFiles(ADDONS.map(a => do_get_addon(a)), function() {
+ installAllFiles([do_get_addon(a) for each (a in ADDONS)], function() {
restartManager();
AddonManager.getAddonsByIDs(["bug470377_1@tests.mozilla.org",
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3.js
index 0d1d30f3b..fcac471ee 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3.js
@@ -13,31 +13,31 @@ function run_test() {
var dest = gProfD.clone();
dest.append("extensions");
dest.append("bug470377_1@tests.mozilla.org");
- dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0o755);
+ dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
var source = do_get_file("data/test_bug470377/install_1.rdf");
source.copyTo(dest, "install.rdf");
dest = gProfD.clone();
dest.append("extensions");
dest.append("bug470377_2@tests.mozilla.org");
- dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0o755);
+ dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
source = do_get_file("data/test_bug470377/install_2.rdf");
source.copyTo(dest, "install.rdf");
dest = gProfD.clone();
dest.append("extensions");
dest.append("bug470377_3@tests.mozilla.org");
- dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0o755);
+ dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
source = do_get_file("data/test_bug470377/install_3.rdf");
source.copyTo(dest, "install.rdf");
dest = gProfD.clone();
dest.append("extensions");
dest.append("bug470377_4@tests.mozilla.org");
- dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0o755);
+ dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
source = do_get_file("data/test_bug470377/install_4.rdf");
source.copyTo(dest, "install.rdf");
dest = gProfD.clone();
dest.append("extensions");
dest.append("bug470377_5@tests.mozilla.org");
- dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0o755);
+ dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
source = do_get_file("data/test_bug470377/install_5.rdf");
source.copyTo(dest, "install.rdf");
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3_strictcompat.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3_strictcompat.js
index 100ea99d7..7a3347320 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3_strictcompat.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_3_strictcompat.js
@@ -12,31 +12,31 @@ function run_test() {
var dest = gProfD.clone();
dest.append("extensions");
dest.append("bug470377_1@tests.mozilla.org");
- dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0o755);
+ dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
var source = do_get_file("data/test_bug470377/install_1.rdf");
source.copyTo(dest, "install.rdf");
dest = gProfD.clone();
dest.append("extensions");
dest.append("bug470377_2@tests.mozilla.org");
- dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0o755);
+ dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
source = do_get_file("data/test_bug470377/install_2.rdf");
source.copyTo(dest, "install.rdf");
dest = gProfD.clone();
dest.append("extensions");
dest.append("bug470377_3@tests.mozilla.org");
- dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0o755);
+ dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
source = do_get_file("data/test_bug470377/install_3.rdf");
source.copyTo(dest, "install.rdf");
dest = gProfD.clone();
dest.append("extensions");
dest.append("bug470377_4@tests.mozilla.org");
- dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0o755);
+ dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
source = do_get_file("data/test_bug470377/install_4.rdf");
source.copyTo(dest, "install.rdf");
dest = gProfD.clone();
dest.append("extensions");
dest.append("bug470377_5@tests.mozilla.org");
- dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0o755);
+ dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
source = do_get_file("data/test_bug470377/install_5.rdf");
source.copyTo(dest, "install.rdf");
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_4.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_4.js
index c51c38b0c..701cbe448 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_4.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug470377_4.js
@@ -12,27 +12,27 @@ function run_test() {
profileDir.append("extensions");
var dest = profileDir.clone();
dest.append("bug470377_1@tests.mozilla.org");
- dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0o755);
+ dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
var source = do_get_file("data/test_bug470377/install_1.rdf");
source.copyTo(dest, "install.rdf");
dest = profileDir.clone();
dest.append("bug470377_2@tests.mozilla.org");
- dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0o755);
+ dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
source = do_get_file("data/test_bug470377/install_2.rdf");
source.copyTo(dest, "install.rdf");
dest = profileDir.clone();
dest.append("bug470377_3@tests.mozilla.org");
- dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0o755);
+ dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
source = do_get_file("data/test_bug470377/install_3.rdf");
source.copyTo(dest, "install.rdf");
dest = profileDir.clone();
dest.append("bug470377_4@tests.mozilla.org");
- dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0o755);
+ dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
source = do_get_file("data/test_bug470377/install_4.rdf");
source.copyTo(dest, "install.rdf");
dest = profileDir.clone();
dest.append("bug470377_5@tests.mozilla.org");
- dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0o755);
+ dest.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
source = do_get_file("data/test_bug470377/install_5.rdf");
source.copyTo(dest, "install.rdf");
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_1.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_1.js
index 46b65ffff..c684e0ca2 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_1.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_1.js
@@ -2,8 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-var Cc = Components.classes;
-var Ci = Components.interfaces;
+const Cc = Components.classes;
+const Ci = Components.interfaces;
const nsIBLS = Ci.nsIBlocklistService;
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_2.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_2.js
index 261739da4..a8c369f1b 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_2.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_2.js
@@ -2,8 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-var Cc = Components.classes;
-var Ci = Components.interfaces;
+const Cc = Components.classes;
+const Ci = Components.interfaces;
const nsIBLS = Ci.nsIBlocklistService;
@@ -26,16 +26,17 @@ function run_test() {
var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].getService(nsIBLS);
var prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
- prefs.setBoolPref("plugin.load_flash_only", false);
-
var plugin = get_test_plugintag();
if (!plugin)
do_throw("Plugin tag not found");
- // run the code after the blocklist is closed
+ //run the code after the blocklist is closed
Services.obs.notifyObservers(null, "addon-blocklist-closed", null);
do_execute_soon(function() {
// should be marked as outdated by the blocklist
do_check_true(blocklist.getPluginBlocklistState(plugin, "1", "1.9") == nsIBLS.STATE_OUTDATED);
+
+ // should indicate that a warning should be shown
+ do_check_true(prefs.getBoolPref("plugins.update.notifyUser"));
});
}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_3.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_3.js
index 634361991..1267a8772 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_3.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug514327_3.js
@@ -2,13 +2,12 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-var Cc = Components.classes;
-var Ci = Components.interfaces;
-var Cu = Components.utils;
-var Cr = Components.results;
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+const Cu = Components.utils;
+const Cr = Components.results;
Cu.import("resource://testing-common/httpd.js");
-Cu.import("resource://testing-common/MockRegistrar.jsm");
const nsIBLS = Ci.nsIBlocklistService;
const URI_EXTENSION_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul";
@@ -52,21 +51,29 @@ var PluginHost = {
if (iid.equals(Ci.nsIPluginHost)
|| iid.equals(Ci.nsISupports))
return this;
-
+
throw Components.results.NS_ERROR_NO_INTERFACE;
}
}
+var PluginHostFactory = {
+ createInstance: function (outer, iid) {
+ if (outer != null)
+ throw Components.results.NS_ERROR_NO_AGGREGATION;
+ return PluginHost.QueryInterface(iid);
+ }
+};
+
// Don't need the full interface, attempts to call other methods will just
// throw which is just fine
var WindowWatcher = {
- openWindow: function(parent, url, name, features, args) {
+ openWindow: function(parent, url, name, features, arguments) {
// Should be called to list the newly blocklisted items
do_check_eq(url, URI_EXTENSION_BLOCKLIST_DIALOG);
// Should only include one item
- do_check_eq(args.wrappedJSObject.list.length, 1);
+ do_check_eq(arguments.wrappedJSObject.list.length, 1);
// And that item should be the blocked plugin, not the outdated one
- var item = args.wrappedJSObject.list[0];
+ var item = arguments.wrappedJSObject.list[0];
do_check_true(item.item instanceof Ci.nsIPluginTag);
do_check_neq(item.name, "test_bug514327_outdated");
@@ -83,8 +90,21 @@ var WindowWatcher = {
}
}
-MockRegistrar.register("@mozilla.org/plugin/host;1", PluginHost);
-MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher);
+var WindowWatcherFactory = {
+ createInstance: function createInstance(outer, iid) {
+ if (outer != null)
+ throw Components.results.NS_ERROR_NO_AGGREGATION;
+ return WindowWatcher.QueryInterface(iid);
+ }
+};
+
+var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
+registrar.registerFactory(Components.ID("{721c3e73-969e-474b-a6dc-059fd288c428}"),
+ "Fake Plugin Host",
+ "@mozilla.org/plugin/host;1", PluginHostFactory);
+registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
+ "Fake Window Watcher",
+ "@mozilla.org/embedcomp/window-watcher;1", WindowWatcherFactory);
function do_update_blocklist(aDatafile, aNextPart) {
@@ -106,13 +126,13 @@ function run_test() {
// initialize the blocklist with no entries
copyBlocklistToProfile(do_get_file("data/test_bug514327_3_empty.xml"));
-
+
gPrefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
gBlocklist = Cc["@mozilla.org/extensions/blocklist;1"].getService(nsIBLS);
-
+
// should NOT be marked as outdated by the blocklist
do_check_true(gBlocklist.getPluginBlocklistState(PLUGINS[0], "1", "1.9") == nsIBLS.STATE_NOT_BLOCKED);
-
+
do_test_pending();
// update blocklist with data that marks the plugin as outdated
@@ -122,7 +142,12 @@ function run_test() {
function test_part_1() {
// plugin should now be marked as outdated
do_check_true(gBlocklist.getPluginBlocklistState(PLUGINS[0], "1", "1.9") == nsIBLS.STATE_OUTDATED);
-
+ // and the notifyUser pref should be set to true
+ do_check_true(gPrefs.getBoolPref("plugins.update.notifyUser"));
+
+ // preternd the user has been notified, reset the pref
+ gPrefs.setBoolPref("plugins.update.notifyUser", false);
+
// update blocklist with data that marks the plugin as outdated
do_update_blocklist("test_bug514327_3_outdated_2.xml", test_part_2);
}
@@ -130,6 +155,8 @@ function test_part_1() {
function test_part_2() {
// plugin should still be marked as outdated
do_check_true(gBlocklist.getPluginBlocklistState(PLUGINS[0], "1", "1.9") == nsIBLS.STATE_OUTDATED);
+ // and the notifyUser pref should NOT be set to true, as the plugin was already outdated
+ do_check_false(gPrefs.getBoolPref("plugins.update.notifyUser"));
finish();
}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug541420.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug541420.js
index b7af5453f..1f70b42d5 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug541420.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug541420.js
@@ -29,7 +29,7 @@ function run_test() {
// only tests if the file is an application so it is better to just check the
// raw permission bits
if (!("nsIWindowsRegKey" in Components.interfaces))
- do_check_true((file.permissions & 0o100) == 0o100);
+ do_check_true((file.permissions & 0100) == 0100);
do_execute_soon(do_test_finished);
});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug542391.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug542391.js
index aa1bbd53f..ceb472f98 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug542391.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug542391.js
@@ -9,12 +9,12 @@ const PREF_EM_SHOW_MISMATCH_UI = "extensions.showMismatchUI";
// The test extension uses an insecure update url.
Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
-var Cc = Components.classes;
-var Ci = Components.interfaces;
-var Cu = Components.utils;
-var Cr = Components.results;
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+const Cu = Components.utils;
+const Cr = Components.results;
-Cu.import("resource://testing-common/MockRegistrar.jsm");
+Cu.import("resource://testing-common/httpd.js");
var testserver;
const profileDir = gProfD.clone();
@@ -26,14 +26,14 @@ var gCheckUpdates = false;
// This will be called to show the compatibility update dialog.
var WindowWatcher = {
expected: false,
- args: null,
+ arguments: null,
openWindow: function(parent, url, name, features, args) {
do_check_true(Services.startup.interrupted);
do_check_eq(url, URI_EXTENSION_UPDATE_DIALOG);
do_check_true(this.expected);
this.expected = false;
- this.args = args.QueryInterface(AM_Ci.nsIVariant);
+ this.arguments = args.QueryInterface(AM_Ci.nsIVariant);
var updated = !gCheckUpdates;
if (gCheckUpdates) {
@@ -77,7 +77,18 @@ var WindowWatcher = {
}
}
-MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher);
+var WindowWatcherFactory = {
+ createInstance: function createInstance(outer, iid) {
+ if (outer != null)
+ throw Components.results.NS_ERROR_NO_AGGREGATION;
+ return WindowWatcher.QueryInterface(iid);
+ }
+};
+
+var registrar = Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar);
+registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
+ "Fake Window Watcher",
+ "@mozilla.org/embedcomp/window-watcher;1", WindowWatcherFactory);
function check_state_v1([a1, a2, a3, a4, a5, a6]) {
do_check_neq(a1, null);
@@ -295,9 +306,10 @@ add_task(function* init() {
}, profileDir);
// Create and configure the HTTP server.
- testserver = createHttpServer(4444);
+ testserver = new HttpServer();
testserver.registerDirectory("/data/", do_get_file("data"));
testserver.registerDirectory("/addons/", do_get_file("addons"));
+ testserver.start(4444);
startupManager();
@@ -385,9 +397,9 @@ add_task(function* run_test_1() {
"override1x2-1x3@tests.mozilla.org"]);
check_state_v3(addons);
- do_check_eq(WindowWatcher.args.length, 2);
- do_check_true(WindowWatcher.args.indexOf("upgradeable1x2-3@tests.mozilla.org") >= 0);
- do_check_true(WindowWatcher.args.indexOf("override1x2-1x3@tests.mozilla.org") >= 0);
+ do_check_eq(WindowWatcher.arguments.length, 2);
+ do_check_true(WindowWatcher.arguments.indexOf("upgradeable1x2-3@tests.mozilla.org") >= 0);
+ do_check_true(WindowWatcher.arguments.indexOf("override1x2-1x3@tests.mozilla.org") >= 0);
});
// Downgrade to version 2 which will remove appDisable from two add-ons
@@ -438,8 +450,8 @@ add_task(function* run_test_5() {
"override1x2-1x3@tests.mozilla.org"]);
check_state_v3_2(addons);
- do_check_eq(WindowWatcher.args.length, 1);
- do_check_true(WindowWatcher.args.indexOf("upgradeable1x2-3@tests.mozilla.org") >= 0);
+ do_check_eq(WindowWatcher.arguments.length, 1);
+ do_check_true(WindowWatcher.arguments.indexOf("upgradeable1x2-3@tests.mozilla.org") >= 0);
});
// Downgrade to version 1 which will appEnable all the add-ons
@@ -462,3 +474,13 @@ add_task(function* run_test_6() {
"override1x2-1x3@tests.mozilla.org"]);
check_state_v1_2(addons);
});
+
+add_task(function* cleanup() {
+ return new Promise((resolve, reject) => {
+ testserver.stop(resolve);
+ });
+});
+
+function run_test() {
+ run_next_test();
+}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug559800.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug559800.js
index 866ad3ad7..41057cd76 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug559800.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug559800.js
@@ -10,7 +10,7 @@ profileDir.append("extensions");
// getting an unused port
Components.utils.import("resource://testing-common/httpd.js");
-var gServer = new HttpServer();
+let gServer = new HttpServer();
gServer.start(-1);
gPort = gServer.identity.primaryPort;
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug563256.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug563256.js
index 497e66526..2437cf748 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug563256.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug563256.js
@@ -39,7 +39,7 @@ function run_test() {
}, profileDir);
startupManager();
-
+
do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "classic/1.0");
AddonManager.getAddonsByIDs(["default@tests.mozilla.org",
@@ -236,22 +236,22 @@ function check_test_2() {
do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "classic/1.0");
AddonManager.getAddonsByIDs(["default@tests.mozilla.org",
- "alternate@tests.mozilla.org"], function([d2, a2]) {
- do_check_neq(d2, null);
- do_check_false(d2.userDisabled);
- do_check_false(d2.appDisabled);
- do_check_true(d2.isActive);
- do_check_true(isThemeInAddonsList(profileDir, d2.id));
- do_check_false(hasFlag(d2.permissions, AddonManager.PERM_CAN_DISABLE));
- do_check_false(hasFlag(d2.permissions, AddonManager.PERM_CAN_ENABLE));
-
- do_check_neq(a2, null);
- do_check_true(a2.userDisabled);
- do_check_false(a2.appDisabled);
- do_check_false(a2.isActive);
- do_check_false(isThemeInAddonsList(profileDir, a2.id));
- do_check_false(hasFlag(a2.permissions, AddonManager.PERM_CAN_DISABLE));
- do_check_true(hasFlag(a2.permissions, AddonManager.PERM_CAN_ENABLE));
+ "alternate@tests.mozilla.org"], function([d, a]) {
+ do_check_neq(d, null);
+ do_check_false(d.userDisabled);
+ do_check_false(d.appDisabled);
+ do_check_true(d.isActive);
+ do_check_true(isThemeInAddonsList(profileDir, d.id));
+ do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_DISABLE));
+ do_check_false(hasFlag(d.permissions, AddonManager.PERM_CAN_ENABLE));
+
+ do_check_neq(a, null);
+ do_check_true(a.userDisabled);
+ do_check_false(a.appDisabled);
+ do_check_false(a.isActive);
+ do_check_false(isThemeInAddonsList(profileDir, a.id));
+ do_check_false(hasFlag(a.permissions, AddonManager.PERM_CAN_DISABLE));
+ do_check_true(hasFlag(a.permissions, AddonManager.PERM_CAN_ENABLE));
end_test();
});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug564030.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug564030.js
index 92ba3d68f..b5ac157c7 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug564030.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug564030.js
@@ -49,13 +49,13 @@ function run_test() {
restartManager();
- AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a2) {
- do_check_neq(a2, null);
- do_check_eq(a2.version, "2.0");
- do_check_false(a2.userDisabled);
- do_check_false(a2.appDisabled);
- do_check_true(a2.isActive);
- do_check_true(isExtensionInAddonsList(profileDir, a2.id));
+ AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a) {
+ do_check_neq(a, null);
+ do_check_eq(a.version, "2.0");
+ do_check_false(a.userDisabled);
+ do_check_false(a.appDisabled);
+ do_check_true(a.isActive);
+ do_check_true(isExtensionInAddonsList(profileDir, a.id));
do_execute_soon(do_test_finished);
});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug570173.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug570173.js
index 2c87d8c79..70de3b426 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug570173.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug570173.js
@@ -7,6 +7,7 @@
// The test extension uses an insecure update url.
Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
+Components.utils.import("resource://testing-common/httpd.js");
var testserver;
const profileDir = gProfD.clone();
profileDir.append("extensions");
@@ -15,47 +16,65 @@ function run_test() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
// Create and configure the HTTP server.
- testserver = createHttpServer();
+ testserver = new HttpServer();
testserver.registerDirectory("/data/", do_get_file("data"));
testserver.registerDirectory("/addons/", do_get_file("addons"));
+ testserver.start(-1);
gPort = testserver.identity.primaryPort;
- run_next_test();
+ writeInstallRDFForExtension({
+ id: "addon1@tests.mozilla.org",
+ version: "1.0",
+ updateURL: "http://localhost:" + gPort + "/data/test_missing.rdf",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "1",
+ maxVersion: "1"
+ }],
+ name: "Test Addon 1",
+ }, profileDir);
+
+ startupManager();
+
+ do_test_pending();
+ run_test_1();
+}
+
+function end_test() {
+ testserver.stop(do_test_finished);
}
// Verify that an update check returns the correct errors.
-add_task(function* () {
- for (let manifestType of ["rdf", "json"]) {
- writeInstallRDFForExtension({
- id: "addon1@tests.mozilla.org",
- version: "1.0",
- updateURL: `http://localhost:${gPort}/data/test_missing.${manifestType}`,
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "1"
- }],
- name: "Test Addon 1",
- bootstrap: "true",
- }, profileDir);
-
- yield promiseRestartManager();
-
- let addon = yield promiseAddonByID("addon1@tests.mozilla.org");
-
- ok(addon);
- ok(addon.updateURL.endsWith(manifestType));
- equal(addon.version, "1.0");
-
- // We're expecting an error, so resolve when the promise is rejected.
- let update = yield promiseFindAddonUpdates(addon, AddonManager.UPDATE_WHEN_USER_REQUESTED)
- .catch(Promise.resolve);
-
- ok(!update.compatibilityUpdate, "not expecting a compatibility update");
- ok(!update.updateAvailable, "not expecting a compatibility update");
-
- equal(update.error, AddonManager.UPDATE_STATUS_DOWNLOAD_ERROR);
-
- addon.uninstall();
- }
-});
+function run_test_1() {
+ AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
+ do_check_neq(a1, null);
+ do_check_eq(a1.version, "1.0");
+
+ let sawCompat = false;
+ let sawUpdate = false;
+ a1.findUpdates({
+ onNoCompatibilityUpdateAvailable: function(addon) {
+ sawCompat = true;
+ },
+
+ onCompatibilityUpdateAvailable: function(addon) {
+ do_throw("Should not have seen a compatibility update");
+ },
+
+ onNoUpdateAvailable: function(addon) {
+ sawUpdate = true;
+ },
+
+ onUpdateAvailable: function(addon, install) {
+ do_throw("Should not have seen an update");
+ },
+
+ onUpdateFinished: function(addon, error) {
+ do_check_true(sawCompat);
+ do_check_true(sawUpdate);
+ do_check_eq(error, AddonManager.UPDATE_STATUS_DOWNLOAD_ERROR);
+ end_test();
+ }
+ }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
+ });
+}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug576735.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug576735.js
index df64e159d..007e82706 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug576735.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug576735.js
@@ -53,12 +53,12 @@ function run_test() {
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org"],
- function([a1_2, a2_2]) {
+ function([a1, a2]) {
// Addon1 should no longer be installed
- do_check_eq(a1_2, null);
+ do_check_eq(a1, null);
// Addon2 should have been detected
- do_check_neq(a2_2, null);
+ do_check_neq(a2, null);
do_execute_soon(do_test_finished);
});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug587088.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug587088.js
index 8d9857e7f..01de80634 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug587088.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug587088.js
@@ -96,22 +96,22 @@ function run_test_1() {
restartManager();
- AddonManager.getAddonByID("addon1@tests.mozilla.org", callback_soon(function(a1_2) {
- check_addon_upgrading(a1_2);
+ AddonManager.getAddonByID("addon1@tests.mozilla.org", callback_soon(function(a1) {
+ check_addon_upgrading(a1);
restartManager();
- AddonManager.getAddonByID("addon1@tests.mozilla.org", callback_soon(function(a1_3) {
- check_addon_upgrading(a1_3);
+ AddonManager.getAddonByID("addon1@tests.mozilla.org", callback_soon(function(a1) {
+ check_addon_upgrading(a1);
fstream.close();
restartManager();
- AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1_4) {
- check_addon(a1_4, "2.0");
+ AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
+ check_addon(a1, "2.0");
- a1_4.uninstall();
+ a1.uninstall();
do_execute_soon(run_test_2);
});
}));
@@ -146,20 +146,20 @@ function run_test_2() {
restartManager();
- AddonManager.getAddonByID("addon1@tests.mozilla.org", callback_soon(function(a1_2) {
- check_addon_uninstalling(a1_2, true);
+ AddonManager.getAddonByID("addon1@tests.mozilla.org", callback_soon(function(a1) {
+ check_addon_uninstalling(a1, true);
restartManager();
- AddonManager.getAddonByID("addon1@tests.mozilla.org", callback_soon(function(a1_3) {
- check_addon_uninstalling(a1_3, true);
+ AddonManager.getAddonByID("addon1@tests.mozilla.org", callback_soon(function(a1) {
+ check_addon_uninstalling(a1, true);
fstream.close();
restartManager();
- AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1_4) {
- do_check_eq(a1_4, null);
+ AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
+ do_check_eq(a1, null);
var dir = profileDir.clone();
dir.append(do_get_expected_addon_name("addon1@tests.mozilla.org"));
do_check_false(dir.exists());
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug594058.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug594058.js
index 858579815..9bbda59a8 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug594058.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug594058.js
@@ -10,9 +10,7 @@ Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
// Allow the mismatch UI to show
Services.prefs.setBoolPref("extensions.showMismatchUI", true);
-Components.utils.import("resource://testing-common/MockRegistrar.jsm");
-
-var Ci = Components.interfaces;
+const Ci = Components.interfaces;
const extDir = gProfD.clone();
extDir.append("extensions");
@@ -20,7 +18,7 @@ var gCachePurged = false;
// Override the window watcher
var WindowWatcher = {
- openWindow: function(parent, url, name, features, args) {
+ openWindow: function(parent, url, name, features, arguments) {
do_check_false(gCachePurged);
},
@@ -33,7 +31,18 @@ var WindowWatcher = {
}
}
-MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher);
+var WindowWatcherFactory = {
+ createInstance: function createInstance(outer, iid) {
+ if (outer != null)
+ throw Components.results.NS_ERROR_NO_AGGREGATION;
+ return WindowWatcher.QueryInterface(iid);
+ }
+};
+
+var registrar = Components.manager.QueryInterface(AM_Ci.nsIComponentRegistrar);
+registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
+ "Fake Window Watcher",
+ "@mozilla.org/embedcomp/window-watcher;1", WindowWatcherFactory);
/**
* Start the test by installing extensions.
@@ -84,5 +93,5 @@ function run_test() {
do_check_false(gCachePurged);
do_test_finished();
- });
+ });
}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug596343.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug596343.js
new file mode 100644
index 000000000..96e95c5ad
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug596343.js
@@ -0,0 +1,86 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+const URI_EXTENSION_SELECT_DIALOG = "chrome://mozapps/content/extensions/selectAddons.xul";
+const URI_EXTENSION_UPDATE_DIALOG = "chrome://mozapps/content/extensions/update.xul";
+const PREF_EM_SHOW_MISMATCH_UI = "extensions.showMismatchUI";
+const PREF_SHOWN_SELECTION_UI = "extensions.shownSelectionUI";
+
+const profileDir = gProfD.clone();
+profileDir.append("extensions");
+
+var gExpectedURL = null;
+
+// This will be called to show the any update dialog.
+var WindowWatcher = {
+ openWindow: function(parent, url, name, features, arguments) {
+ do_check_eq(url, gExpectedURL);
+ gExpectedURL = null;
+ },
+
+ QueryInterface: function(iid) {
+ if (iid.equals(AM_Ci.nsIWindowWatcher)
+ || iid.equals(AM_Ci.nsISupports))
+ return this;
+
+ throw Components.results.NS_ERROR_NO_INTERFACE;
+ }
+}
+
+var WindowWatcherFactory = {
+ createInstance: function createInstance(outer, iid) {
+ if (outer != null)
+ throw Components.results.NS_ERROR_NO_AGGREGATION;
+ return WindowWatcher.QueryInterface(iid);
+ }
+};
+
+var registrar = Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar);
+registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
+ "Fake Window Watcher",
+ "@mozilla.org/embedcomp/window-watcher;1", WindowWatcherFactory);
+
+// Tests that the selection UI is displayed when upgrading an existing profile
+function run_test() {
+ createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
+
+ Services.prefs.setBoolPref(PREF_EM_SHOW_MISMATCH_UI, true);
+
+ var dest = writeInstallRDFForExtension({
+ id: "addon1@tests.mozilla.org",
+ version: "1.0",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "1",
+ maxVersion: "2"
+ }],
+ name: "Test Addon 1",
+ }, profileDir);
+
+ // For a new profile it should disable showing the selection UI in the future
+ // without showing the selection UI
+ gExpectedURL = URI_EXTENSION_SELECT_DIALOG;
+ startupManager();
+
+ do_check_true(Services.prefs.getBoolPref(PREF_SHOWN_SELECTION_UI));
+ do_check_eq(gExpectedURL, URI_EXTENSION_SELECT_DIALOG);
+
+ // Reset the 'already shown' pref so that we can test that the first upgrade of
+ // an existing profile shows the selection UI
+ Services.prefs.clearUserPref(PREF_SHOWN_SELECTION_UI);
+
+ restartManager("2");
+
+ do_check_true(Services.prefs.getBoolPref(PREF_SHOWN_SELECTION_UI));
+ do_check_eq(gExpectedURL, null);
+
+ // Once we've seen the selection UI once, future upgrades will show the update dialog
+ // but only if this upgrade disabled an add-on
+ gExpectedURL = URI_EXTENSION_UPDATE_DIALOG;
+
+ restartManager("3");
+
+ do_check_eq(gExpectedURL, null);
+}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug596607.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug596607.js
index bdcf93a1f..3e655dc87 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug596607.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug596607.js
@@ -38,18 +38,11 @@ const addon2Dir = writeInstallRDFForExtension(addon2, gProfD, "addon2");
const addon3Dir = gProfD.clone();
addon3Dir.append("addon3@tests.mozilla.org");
-let registry;
-
function run_test() {
// This test only works where there is a registry.
if (!("nsIWindowsRegKey" in AM_Ci))
return;
- registry = new MockRegistry();
- do_register_cleanup(() => {
- registry.shutdown();
- });
-
do_test_pending();
run_test_1();
@@ -57,15 +50,15 @@ function run_test() {
// Tests whether starting a fresh profile with a bad entry works
function run_test_1() {
- registry.setValue(AM_Ci.nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE,
- "SOFTWARE\\Mozilla\\XPCShell\\Extensions",
- "addon1@tests.mozilla.org", addon1Dir.path);
- registry.setValue(AM_Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
- "SOFTWARE\\Mozilla\\XPCShell\\Extensions",
- "addon2@tests.mozilla.org", addon2Dir.path);
- registry.setValue(AM_Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
- "SOFTWARE\\Mozilla\\XPCShell\\Extensions",
- "addon3@tests.mozilla.org", addon3Dir.path);
+ MockRegistry.setValue(AM_Ci.nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE,
+ "SOFTWARE\\Mozilla\\XPCShell\\Extensions",
+ "addon1@tests.mozilla.org", addon1Dir.path);
+ MockRegistry.setValue(AM_Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
+ "SOFTWARE\\Mozilla\\XPCShell\\Extensions",
+ "addon2@tests.mozilla.org", addon2Dir.path);
+ MockRegistry.setValue(AM_Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
+ "SOFTWARE\\Mozilla\\XPCShell\\Extensions",
+ "addon3@tests.mozilla.org", addon3Dir.path);
startupManager();
@@ -92,9 +85,9 @@ function run_test_1() {
function run_test_2() {
shutdownManager();
- registry.setValue(AM_Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
- "SOFTWARE\\Mozilla\\XPCShell\\Extensions",
- "addon3@tests.mozilla.org", addon3Dir.path);
+ MockRegistry.setValue(AM_Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
+ "SOFTWARE\\Mozilla\\XPCShell\\Extensions",
+ "addon3@tests.mozilla.org", addon3Dir.path);
startupManager(false);
@@ -121,9 +114,9 @@ function run_test_2() {
function run_test_3() {
shutdownManager();
- registry.setValue(AM_Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
- "SOFTWARE\\Mozilla\\XPCShell\\Extensions",
- "addon3@tests.mozilla.org", null);
+ MockRegistry.setValue(AM_Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
+ "SOFTWARE\\Mozilla\\XPCShell\\Extensions",
+ "addon3@tests.mozilla.org", null);
startupManager(false);
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug619730.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug619730.js
index 1c21385e0..761daf4eb 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug619730.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug619730.js
@@ -3,9 +3,9 @@
*/
// Tests whether
-var Cc = Components.classes;
-var Ci = Components.interfaces;
-var Cu = Components.utils;
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+const Cu = Components.utils;
Cu.import("resource://testing-common/httpd.js");
@@ -20,7 +20,7 @@ function load_blocklist(file, aCallback) {
do_execute_soon(aCallback);
}, "blocklist-updated", false);
-
+
Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
gPort + "/data/" + file);
var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug655254.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug655254.js
index 449c59065..45274b734 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug655254.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug655254.js
@@ -84,11 +84,11 @@ function run_test_1() {
onUpdateFinished: function() {
restartManager();
- AddonManager.getAddonByID("addon1@tests.mozilla.org", callback_soon(function(a1_2) {
- do_check_neq(a1_2, null);
- do_check_false(a1_2.appDisabled);
- do_check_true(a1_2.isActive);
- do_check_true(isExtensionInAddonsList(userDir, a1_2.id));
+ AddonManager.getAddonByID("addon1@tests.mozilla.org", callback_soon(function(a1) {
+ do_check_neq(a1, null);
+ do_check_false(a1.appDisabled);
+ do_check_true(a1.isActive);
+ do_check_true(isExtensionInAddonsList(userDir, a1.id));
shutdownManager();
@@ -103,16 +103,16 @@ function run_test_1() {
startupManager(false);
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
- "addon2@tests.mozilla.org"], function([a1_3, a2_3]) {
- do_check_neq(a1_3, null);
- do_check_false(a1_3.appDisabled);
- do_check_true(a1_3.isActive);
- do_check_true(isExtensionInAddonsList(userDir, a1_3.id));
-
- do_check_neq(a2_3, null);
- do_check_false(a2_3.appDisabled);
- do_check_true(a2_3.isActive);
- do_check_false(isExtensionInAddonsList(userDir, a2_3.id));
+ "addon2@tests.mozilla.org"], function([a1, a2]) {
+ do_check_neq(a1, null);
+ do_check_false(a1.appDisabled);
+ do_check_true(a1.isActive);
+ do_check_true(isExtensionInAddonsList(userDir, a1.id));
+
+ do_check_neq(a2, null);
+ do_check_false(a2.appDisabled);
+ do_check_true(a2.isActive);
+ do_check_false(isExtensionInAddonsList(userDir, a2.id));
do_check_eq(Services.prefs.getIntPref("bootstraptest.active_version"), 1);
do_execute_soon(run_test_2);
@@ -123,7 +123,7 @@ function run_test_1() {
});
}
-// Set up the profile
+//Set up the profile
function run_test_2() {
AddonManager.getAddonByID("addon2@tests.mozilla.org", callback_soon(function(a2) {
do_check_neq(a2, null);
@@ -146,16 +146,16 @@ function run_test_2() {
startupManager(false);
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
- "addon2@tests.mozilla.org"], function([a1_2, a2_2]) {
- do_check_neq(a1_2, null);
- do_check_false(a1_2.appDisabled);
- do_check_true(a1_2.isActive);
- do_check_true(isExtensionInAddonsList(userDir, a1_2.id));
-
- do_check_neq(a2_2, null);
- do_check_true(a2_2.userDisabled);
- do_check_false(a2_2.isActive);
- do_check_false(isExtensionInAddonsList(userDir, a2_2.id));
+ "addon2@tests.mozilla.org"], function([a1, a2]) {
+ do_check_neq(a1, null);
+ do_check_false(a1.appDisabled);
+ do_check_true(a1.isActive);
+ do_check_true(isExtensionInAddonsList(userDir, a1.id));
+
+ do_check_neq(a2, null);
+ do_check_true(a2.userDisabled);
+ do_check_false(a2.isActive);
+ do_check_false(isExtensionInAddonsList(userDir, a2.id));
do_check_eq(Services.prefs.getIntPref("bootstraptest.active_version"), 0);
end_test();
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug659772.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug659772.js
index 6e98a69a4..c6e8ab4e2 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug659772.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug659772.js
@@ -148,45 +148,45 @@ function run_test_1() {
"addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org"],
- function([a1_2, a2_2, a3_2, a4_2]) {
- do_check_neq(a1_2, null);
- do_check_eq(a1_2.version, "2.0");
- do_check_false(a1_2.appDisabled);
- do_check_false(a1_2.userDisabled);
- do_check_true(a1_2.isActive);
+ function([a1, a2, a3, a4]) {
+ do_check_neq(a1, null);
+ do_check_eq(a1.version, "2.0");
+ do_check_false(a1.appDisabled);
+ do_check_false(a1.userDisabled);
+ do_check_true(a1.isActive);
do_check_true(isExtensionInAddonsList(profileDir, addon1.id));
- do_check_neq(a2_2, null);
- do_check_eq(a2_2.version, "2.0");
- do_check_false(a2_2.appDisabled);
- do_check_false(a2_2.userDisabled);
- do_check_true(a2_2.isActive);
+ do_check_neq(a2, null);
+ do_check_eq(a2.version, "2.0");
+ do_check_false(a2.appDisabled);
+ do_check_false(a2.userDisabled);
+ do_check_true(a2.isActive);
do_check_true(isExtensionInAddonsList(profileDir, addon2.id));
// Should stay enabled because we migrate the compat info from
// the previous version of the DB
- do_check_neq(a3_2, null);
- do_check_eq(a3_2.version, "2.0");
- todo_check_false(a3_2.appDisabled); // XXX unresolved issue
- do_check_false(a3_2.userDisabled);
- todo_check_true(a3_2.isActive); // XXX same
+ do_check_neq(a3, null);
+ do_check_eq(a3.version, "2.0");
+ todo_check_false(a3.appDisabled); // XXX unresolved issue
+ do_check_false(a3.userDisabled);
+ todo_check_true(a3.isActive); // XXX same
todo_check_true(isExtensionInAddonsList(profileDir, addon3.id)); // XXX same
- do_check_neq(a4_2, null);
- do_check_eq(a4_2.version, "2.0");
- do_check_true(a4_2.appDisabled);
- do_check_false(a4_2.userDisabled);
- do_check_false(a4_2.isActive);
+ do_check_neq(a4, null);
+ do_check_eq(a4.version, "2.0");
+ do_check_true(a4.appDisabled);
+ do_check_false(a4.userDisabled);
+ do_check_false(a4.isActive);
do_check_false(isExtensionInAddonsList(profileDir, addon4.id));
// Check that install and uninstall haven't been called on the bootstrapped addon
do_check_false(Services.prefs.prefHasUserValue("bootstraptest.install_reason"));
do_check_false(Services.prefs.prefHasUserValue("bootstraptest.uninstall_reason"));
- a1_2.uninstall();
- a2_2.uninstall();
- a3_2.uninstall();
- a4_2.uninstall();
+ a1.uninstall();
+ a2.uninstall();
+ a3.uninstall();
+ a4.uninstall();
do_execute_soon(run_test_2);
});
});
@@ -290,51 +290,51 @@ function run_test_2() {
"addon2@tests.mozilla.org",
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org"],
- callback_soon(function([a1_2, a2_2, a3_2, a4_2]) {
- do_check_neq(a1_2, null);
- do_check_eq(a1_2.version, "2.0");
- do_check_true(a1_2.appDisabled);
- do_check_false(a1_2.userDisabled);
- do_check_false(a1_2.isActive);
+ callback_soon(function([a1, a2, a3, a4]) {
+ do_check_neq(a1, null);
+ do_check_eq(a1.version, "2.0");
+ do_check_true(a1.appDisabled);
+ do_check_false(a1.userDisabled);
+ do_check_false(a1.isActive);
do_check_false(isExtensionInAddonsList(profileDir, addon1.id));
- do_check_neq(a2_2, null);
- do_check_eq(a2_2.version, "2.0");
- do_check_false(a2_2.appDisabled);
- do_check_false(a2_2.userDisabled);
- do_check_true(a2_2.isActive);
+ do_check_neq(a2, null);
+ do_check_eq(a2.version, "2.0");
+ do_check_false(a2.appDisabled);
+ do_check_false(a2.userDisabled);
+ do_check_true(a2.isActive);
do_check_true(isExtensionInAddonsList(profileDir, addon2.id));
// Should become appDisabled because we migrate the compat info from
// the previous version of the DB
- do_check_neq(a3_2, null);
- do_check_eq(a3_2.version, "2.0");
- todo_check_true(a3_2.appDisabled);
- do_check_false(a3_2.userDisabled);
- todo_check_false(a3_2.isActive);
+ do_check_neq(a3, null);
+ do_check_eq(a3.version, "2.0");
+ todo_check_true(a3.appDisabled);
+ do_check_false(a3.userDisabled);
+ todo_check_false(a3.isActive);
todo_check_false(isExtensionInAddonsList(profileDir, addon3.id));
- do_check_neq(a4_2, null);
- do_check_eq(a4_2.version, "2.0");
- do_check_false(a4_2.appDisabled);
- do_check_false(a4_2.userDisabled);
- do_check_true(a4_2.isActive);
+ do_check_neq(a4, null);
+ do_check_eq(a4.version, "2.0");
+ do_check_false(a4.appDisabled);
+ do_check_false(a4.userDisabled);
+ do_check_true(a4.isActive);
do_check_true(isExtensionInAddonsList(profileDir, addon4.id));
// Check that install and uninstall haven't been called on the bootstrapped addon
do_check_false(Services.prefs.prefHasUserValue("bootstraptest.install_reason"));
do_check_false(Services.prefs.prefHasUserValue("bootstraptest.uninstall_reason"));
- a1_2.uninstall();
- a2_2.uninstall();
- a3_2.uninstall();
- a4_2.uninstall();
+ a1.uninstall();
+ a2.uninstall();
+ a3.uninstall();
+ a4.uninstall();
restartManager();
shutdownManager();
do_test_finished();
}));
- }
+ };
});
}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug675371.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug675371.js
index 6f2a5e7cd..579335d8a 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug675371.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug675371.js
@@ -35,7 +35,7 @@ function check_test() {
do_check_true(addon.isActive);
// Tests that chrome.manifest is registered when the addon is installed.
- var target = { };
+ var target = { active: false };
Services.scriptloader.loadSubScript("chrome://bug675371/content/test.js", target);
do_check_true(target.active);
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bug757663.js b/toolkit/mozapps/extensions/test/xpcshell/test_bug757663.js
index 54cee0839..648c7acc3 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug757663.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug757663.js
@@ -1,112 +1,112 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-// This test verifies that removing a listener during a callback for that type
-// of listener still results in all listeners being called.
-
-var addon1 = {
- id: "addon1@tests.mozilla.org",
- version: "2.0",
- name: "Test 1",
- bootstrap: "true",
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "1"
- }]
-};
-
-var listener1 = {
- sawEvent: false,
- onDisabling: function() {
- this.sawEvent = true;
- AddonManager.removeAddonListener(this);
- },
- onNewInstall: function() {
- this.sawEvent = true;
- AddonManager.removeInstallListener(this);
- }
-};
-var listener2 = {
- sawEvent: false,
- onDisabling: function() {
- this.sawEvent = true;
- },
- onNewInstall: function() {
- this.sawEvent = true;
- }
-};
-var listener3 = {
- sawEvent: false,
- onDisabling: function() {
- this.sawEvent = true;
- },
- onNewInstall: function() {
- this.sawEvent = true;
- }
-};
-
-const profileDir = gProfD.clone();
-profileDir.append("extensions");
-
-
-function run_test() {
- do_test_pending();
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
-
- writeInstallRDFForExtension(addon1, profileDir);
- startupManager();
-
- run_test_1();
-}
-
-function run_test_1() {
- AddonManager.addAddonListener(listener1);
- AddonManager.addAddonListener(listener2);
- AddonManager.addAddonListener(listener3);
-
- AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org"], function([a1]) {
- do_check_neq(a1, null);
- do_check_false(a1.userDisabled);
- do_check_true(a1.isActive);
-
- a1.userDisabled = true;
-
- do_check_true(listener1.sawEvent);
- listener1.sawEvent = false;
- do_check_true(listener2.sawEvent);
- listener2.sawEvent = false;
- do_check_true(listener3.sawEvent);
- listener3.sawEvent = false;
-
- AddonManager.removeAddonListener(listener1);
- AddonManager.removeAddonListener(listener2);
- AddonManager.removeAddonListener(listener3);
-
- a1.uninstall();
- run_test_2();
- });
-}
-
-function run_test_2() {
- AddonManager.addInstallListener(listener1);
- AddonManager.addInstallListener(listener2);
- AddonManager.addInstallListener(listener3);
-
- AddonManager.getInstallForFile(do_get_addon("test_bug757663"), function(aInstall) {
-
- do_check_true(listener1.sawEvent);
- listener1.sawEvent = false;
- do_check_true(listener2.sawEvent);
- listener2.sawEvent = false;
- do_check_true(listener3.sawEvent);
- listener3.sawEvent = false;
-
- AddonManager.removeInstallListener(listener1);
- AddonManager.removeInstallListener(listener2);
- AddonManager.removeInstallListener(listener3);
-
- do_execute_soon(do_test_finished);
- });
-}
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+// This test verifies that removing a listener during a callback for that type
+// of listener still results in all listeners being called.
+
+var addon1 = {
+ id: "addon1@tests.mozilla.org",
+ version: "2.0",
+ name: "Test 1",
+ bootstrap: "true",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "1",
+ maxVersion: "1"
+ }]
+};
+
+var listener1 = {
+ sawEvent: false,
+ onDisabling: function() {
+ this.sawEvent = true;
+ AddonManager.removeAddonListener(this);
+ },
+ onNewInstall: function() {
+ this.sawEvent = true;
+ AddonManager.removeInstallListener(this);
+ }
+};
+var listener2 = {
+ sawEvent: false,
+ onDisabling: function() {
+ this.sawEvent = true;
+ },
+ onNewInstall: function() {
+ this.sawEvent = true;
+ }
+};
+var listener3 = {
+ sawEvent: false,
+ onDisabling: function() {
+ this.sawEvent = true;
+ },
+ onNewInstall: function() {
+ this.sawEvent = true;
+ }
+};
+
+const profileDir = gProfD.clone();
+profileDir.append("extensions");
+
+
+function run_test() {
+ do_test_pending();
+ createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
+
+ writeInstallRDFForExtension(addon1, profileDir);
+ startupManager();
+
+ run_test_1();
+}
+
+function run_test_1() {
+ AddonManager.addAddonListener(listener1);
+ AddonManager.addAddonListener(listener2);
+ AddonManager.addAddonListener(listener3);
+
+ AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org"], function([a1]) {
+ do_check_neq(a1, null);
+ do_check_false(a1.userDisabled);
+ do_check_true(a1.isActive);
+
+ a1.userDisabled = true;
+
+ do_check_true(listener1.sawEvent);
+ listener1.sawEvent = false;
+ do_check_true(listener2.sawEvent);
+ listener2.sawEvent = false;
+ do_check_true(listener3.sawEvent);
+ listener3.sawEvent = false;
+
+ AddonManager.removeAddonListener(listener1);
+ AddonManager.removeAddonListener(listener2);
+ AddonManager.removeAddonListener(listener3);
+
+ a1.uninstall();
+ run_test_2();
+ });
+}
+
+function run_test_2() {
+ AddonManager.addInstallListener(listener1);
+ AddonManager.addInstallListener(listener2);
+ AddonManager.addInstallListener(listener3);
+
+ AddonManager.getInstallForFile(do_get_addon("test_bug757663"), function(aInstall) {
+
+ do_check_true(listener1.sawEvent);
+ listener1.sawEvent = false;
+ do_check_true(listener2.sawEvent);
+ listener2.sawEvent = false;
+ do_check_true(listener3.sawEvent);
+ listener3.sawEvent = false;
+
+ AddonManager.removeInstallListener(listener1);
+ AddonManager.removeInstallListener(listener2);
+ AddonManager.removeInstallListener(listener3);
+
+ do_execute_soon(do_test_finished);
+ });
+}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_cache_certdb.js b/toolkit/mozapps/extensions/test/xpcshell/test_cache_certdb.js
deleted file mode 100644
index edb442aad..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_cache_certdb.js
+++ /dev/null
@@ -1,82 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-// We require signature checks for this test
-Services.prefs.setBoolPref(PREF_XPI_SIGNATURES_REQUIRED, true);
-gUseRealCertChecks = true;
-
-const CERT = `MIIDITCCAgmgAwIBAgIJALAv8fydd6nBMA0GCSqGSIb3DQEBBQUAMCcxJTAjBgNV
-BAMMHGJvb3RzdHJhcDFAdGVzdHMubW96aWxsYS5vcmcwHhcNMTYwMjAyMjMxNjUy
-WhcNMjYwMTMwMjMxNjUyWjAnMSUwIwYDVQQDDBxib290c3RyYXAxQHRlc3RzLm1v
-emlsbGEub3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5caNuLTu
-H8dEqNntLlhKi4y09hrgcF3cb6n5Xx9DIHA8CKiZxt9qGXKeeiDwEiiQ8ibJYzdc
-jLkbzJUyPVUaH9ygrWynSpSTOvv/Ys3+ERrCo9W7Zuzwdmzt6TTEjFMS4lVx06us
-3uUqkdp3JMgCqCEbOFZiztICiSKrp8QFJkAfApZzBqmJOPOWH0yZ2CRRzvbQZ6af
-hqQDUalJQjWfsenyUWphhbREqExetxHJFR3OrmJt/shXVyz6dD7TBuE3PPUh1RpE
-3ejVufcTzjV3XmK79PxsKLM9V2+ww9e9V3OET57kyvn+bpSWdUYm3X4DA8dxNW6+
-kTFWRnQNZ+zQVQIDAQABo1AwTjAdBgNVHQ4EFgQUac36ccv+99N5HxYa8dCDYRaF
-HNQwHwYDVR0jBBgwFoAUac36ccv+99N5HxYa8dCDYRaFHNQwDAYDVR0TBAUwAwEB
-/zANBgkqhkiG9w0BAQUFAAOCAQEAFfu3MN8EtY5wcxOFdGShOmGQPm2MJJVE6MG+
-p4RqHrukHZSgKOyWjkRk7t6NXzNcnHco9HFv7FQRAXSJ5zObmyu+TMZlu4jHHCav
-GMcV3C/4SUGtlipZbgNe00UAIm6tM3Wh8dr38W7VYg4KGAwXou5XhQ9gCAnSn90o
-H/42NqHTjJsR4v18izX2aO25ARQdMby7Lsr5j9RqweHywiSlPusFcKRseqOnIP0d
-JT3+qh78LeMbNBO2mYD3SP/zu0TAmkAVNcj2KPw0+a0kVZ15rvslPC/K3xn9msMk
-fQthv3rDAcsWvi9YO7T+vylgZBgJfn1ZqpQqy58xN96uh6nPOw==`;
-
-function overrideCertDB() {
- // Unregister the real database.
- let registrar = Components.manager.QueryInterface(AM_Ci.nsIComponentRegistrar);
- let factory = registrar.getClassObject(CERTDB_CID, AM_Ci.nsIFactory);
- registrar.unregisterFactory(CERTDB_CID, factory);
-
- // Get the real DB
- let realCertDB = factory.createInstance(null, AM_Ci.nsIX509CertDB);
-
- let fakeCert = realCertDB.constructX509FromBase64(CERT.replace(/\n/g, ""));
-
- let fakeCertDB = {
- openSignedAppFileAsync(root, file, callback) {
- callback.openSignedAppFileFinished(Components.results.NS_OK, null, fakeCert);
- },
-
- verifySignedDirectoryAsync(root, dir, callback) {
- callback.verifySignedDirectoryFinished(Components.results.NS_OK, fakeCert);
- },
-
- QueryInterface: XPCOMUtils.generateQI([AM_Ci.nsIX509CertDB])
- };
-
- for (let property of Object.keys(realCertDB)) {
- if (property in fakeCertDB) {
- continue;
- }
-
- if (typeof realCertDB[property] == "function") {
- fakeCertDB[property] = realCertDB[property].bind(realCertDB);
- }
- }
-
- let certDBFactory = {
- createInstance: function(outer, iid) {
- if (outer != null) {
- throw Components.results.NS_ERROR_NO_AGGREGATION;
- }
- return fakeCertDB.QueryInterface(iid);
- }
- };
- registrar.registerFactory(CERTDB_CID, "CertDB",
- CERTDB_CONTRACTID, certDBFactory);
-}
-
-add_task(function*() {
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
- startupManager();
-
- // Once the application is started we shouldn't be able to replace the
- // certificate database
- overrideCertDB();
-
- let install = yield new Promise(resolve => AddonManager.getInstallForFile(do_get_addon("test_bootstrap1_1"), resolve));
- do_check_eq(install.state, AddonManager.STATE_DOWNLOAD_FAILED);
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_cacheflush.js b/toolkit/mozapps/extensions/test/xpcshell/test_cacheflush.js
index f3448abd2..4e7da0ee7 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_cacheflush.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_cacheflush.js
@@ -11,9 +11,6 @@ var CacheFlushObserver = {
observe: function(aSubject, aTopic, aData) {
if (aTopic != "flush-cache-entry")
return;
- // Ignore flushes triggered by the fake cert DB
- if (aData == "cert-override")
- return;
do_check_true(gExpectedFile != null);
do_check_true(aSubject instanceof AM_Ci.nsIFile);
@@ -88,7 +85,7 @@ function run_test_2() {
function run_test_3() {
AddonManager.getInstallForFile(do_get_addon("test_cacheflush2"), function(aInstall) {
aInstall.addListener({
- onInstallStarted: function() {
+ onInstallStarted: function(aInstall) {
// We should flush the staged XPI when completing the install
gExpectedFile = gProfD.clone();
gExpectedFile.append("extensions");
@@ -96,7 +93,7 @@ function run_test_3() {
gExpectedFile.append("addon2@tests.mozilla.org.xpi");
},
- onInstallEnded: function() {
+ onInstallEnded: function(aInstall) {
do_check_eq(gCacheFlushCount, 1);
gExpectedFile = null;
gCacheFlushCount = 0;
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_checkCompatibility_themeOverride.js b/toolkit/mozapps/extensions/test/xpcshell/test_checkCompatibility_themeOverride.js
index b6cb13e08..c872d75c3 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_checkCompatibility_themeOverride.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_checkCompatibility_themeOverride.js
@@ -1,93 +1,93 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-// This verifies that the (temporary)
-// extensions.checkCompatibility.temporaryThemeOverride_minAppVersion
-// preference works.
-
-var ADDONS = [{
- id: "addon1@tests.mozilla.org",
- type: 4,
- internalName: "theme1/1.0",
- version: "1.0",
- name: "Test 1",
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1.0",
- maxVersion: "1.0"
- }]
-}, {
- id: "addon2@tests.mozilla.org",
- type: 4,
- internalName: "theme2/1.0",
- version: "1.0",
- name: "Test 2",
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "2.0",
- maxVersion: "2.0"
- }]
-}];
-
-const profileDir = gProfD.clone();
-profileDir.append("extensions");
-
-
-function run_test() {
- do_test_pending();
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3.0", "1");
-
- for (let a of ADDONS) {
- writeInstallRDFForExtension(a, profileDir);
- }
-
- startupManager();
-
- run_test_1();
-}
-
-function run_test_1() {
- AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
- "addon2@tests.mozilla.org"],
- function([a1, a2]) {
-
- do_check_neq(a1, null);
- do_check_false(a1.isActive);
- do_check_false(a1.isCompatible);
- do_check_true(a1.appDisabled);
-
- do_check_neq(a2, null);
- do_check_false(a2.isActive);
- do_check_false(a2.isCompatible);
- do_check_true(a1.appDisabled);
-
- do_execute_soon(run_test_2);
- });
-}
-
-function run_test_2() {
- Services.prefs.setCharPref("extensions.checkCompatibility.temporaryThemeOverride_minAppVersion", "2.0");
- if (isNightlyChannel())
- Services.prefs.setBoolPref("extensions.checkCompatibility.nightly", false);
- else
- Services.prefs.setBoolPref("extensions.checkCompatibility.3.0", false);
- restartManager();
-
- AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
- "addon2@tests.mozilla.org"],
- function([a1, a2]) {
-
- do_check_neq(a1, null);
- do_check_false(a1.isActive);
- do_check_false(a1.isCompatible);
- do_check_true(a1.appDisabled);
-
- do_check_neq(a2, null);
- do_check_false(a2.isActive);
- do_check_false(a2.isCompatible);
- do_check_false(a2.appDisabled);
-
- do_execute_soon(do_test_finished);
- });
-}
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+// This verifies that the (temporary)
+// extensions.checkCompatibility.temporaryThemeOverride_minAppVersion
+// preference works.
+
+var ADDONS = [{
+ id: "addon1@tests.mozilla.org",
+ type: 4,
+ internalName: "theme1/1.0",
+ version: "1.0",
+ name: "Test 1",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "1.0",
+ maxVersion: "1.0"
+ }]
+}, {
+ id: "addon2@tests.mozilla.org",
+ type: 4,
+ internalName: "theme2/1.0",
+ version: "1.0",
+ name: "Test 2",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "2.0",
+ maxVersion: "2.0"
+ }]
+}];
+
+const profileDir = gProfD.clone();
+profileDir.append("extensions");
+
+
+function run_test() {
+ do_test_pending();
+ createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3.0", "1");
+
+ for (let a of ADDONS) {
+ writeInstallRDFForExtension(a, profileDir);
+ }
+
+ startupManager();
+
+ run_test_1();
+}
+
+function run_test_1() {
+ AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
+ "addon2@tests.mozilla.org"],
+ function([a1, a2]) {
+
+ do_check_neq(a1, null);
+ do_check_false(a1.isActive);
+ do_check_false(a1.isCompatible);
+ do_check_true(a1.appDisabled);
+
+ do_check_neq(a2, null);
+ do_check_false(a2.isActive);
+ do_check_false(a2.isCompatible);
+ do_check_true(a1.appDisabled);
+
+ do_execute_soon(run_test_2);
+ });
+}
+
+function run_test_2() {
+ Services.prefs.setCharPref("extensions.checkCompatibility.temporaryThemeOverride_minAppVersion", "2.0");
+ if (isNightlyChannel())
+ Services.prefs.setBoolPref("extensions.checkCompatibility.nightly", false);
+ else
+ Services.prefs.setBoolPref("extensions.checkCompatibility.3.0", false);
+ restartManager();
+
+ AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
+ "addon2@tests.mozilla.org"],
+ function([a1, a2]) {
+
+ do_check_neq(a1, null);
+ do_check_false(a1.isActive);
+ do_check_false(a1.isCompatible);
+ do_check_true(a1.appDisabled);
+
+ do_check_neq(a2, null);
+ do_check_false(a2.isActive);
+ do_check_false(a2.isCompatible);
+ do_check_false(a2.appDisabled);
+
+ do_execute_soon(do_test_finished);
+ });
+}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_compatoverrides.js b/toolkit/mozapps/extensions/test/xpcshell/test_compatoverrides.js
index c079534c3..ef60306db 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_compatoverrides.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_compatoverrides.js
@@ -255,5 +255,5 @@ function run_test_1() {
function run_test_2() {
do_print("Run test 2");
restartManager();
- check_compat_status(end_test);
+ check_compat_status(end_test);
}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_corrupt.js b/toolkit/mozapps/extensions/test/xpcshell/test_corrupt.js
index 210c6a936..4c8b3750d 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_corrupt.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_corrupt.js
@@ -265,73 +265,72 @@ function run_test_1() {
"addon7@tests.mozilla.org",
"theme1@tests.mozilla.org",
"theme2@tests.mozilla.org"],
- callback_soon(function([a1_2, a2_2, a3_2, a4_2, a5_2, a6_2, a7_2, t1_2, t2_2]) {
+ callback_soon(function([a1, a2, a3, a4, a5, a6, a7, t1, t2]) {
// Should be correctly recovered
- do_check_neq(a1_2, null);
- do_check_true(a1_2.isActive);
- do_check_false(a1_2.userDisabled);
- do_check_false(a1_2.appDisabled);
- do_check_eq(a1_2.pendingOperations, AddonManager.PENDING_NONE);
+ do_check_neq(a1, null);
+ do_check_true(a1.isActive);
+ do_check_false(a1.userDisabled);
+ do_check_false(a1.appDisabled);
+ do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE);
// Should be correctly recovered
- do_check_neq(a2_2, null);
- do_check_false(a2_2.isActive);
- do_check_true(a2_2.userDisabled);
- do_check_false(a2_2.appDisabled);
- do_check_eq(a2_2.pendingOperations, AddonManager.PENDING_NONE);
+ do_check_neq(a2, null);
+ do_check_false(a2.isActive);
+ do_check_true(a2.userDisabled);
+ do_check_false(a2.appDisabled);
+ do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE);
// The compatibility update won't be recovered but it should still be
// active for this session
- do_check_neq(a3_2, null);
- do_check_true(a3_2.isActive);
- do_check_false(a3_2.userDisabled);
- do_check_false(a3_2.appDisabled);
- do_check_eq(a3_2.pendingOperations, AddonManager.PENDING_NONE);
+ do_check_neq(a3, null);
+ do_check_true(a3.isActive);
+ do_check_false(a3.userDisabled);
+ do_check_false(a3.appDisabled);
+ do_check_eq(a3.pendingOperations, AddonManager.PENDING_NONE);
// The compatibility update won't be recovered and with strict
// compatibility it would not have been able to tell that it was
// previously userDisabled. However, without strict compat, it wasn't
// appDisabled, so it knows it must have been userDisabled.
- do_check_neq(a4_2, null);
- do_check_false(a4_2.isActive);
- do_check_true(a4_2.userDisabled);
- do_check_false(a4_2.appDisabled);
- do_check_eq(a4_2.pendingOperations, AddonManager.PENDING_NONE);
-
- do_check_neq(a5_2, null);
- do_check_true(a5_2.isActive);
- do_check_false(a5_2.userDisabled);
- do_check_false(a5_2.appDisabled);
- do_check_eq(a5_2.pendingOperations, AddonManager.PENDING_NONE);
-
- do_check_neq(a6_2, null);
- do_check_true(a6_2.isActive);
- do_check_false(a6_2.userDisabled);
- do_check_false(a6_2.appDisabled);
- do_check_eq(a6_2.pendingOperations, AddonManager.PENDING_NONE);
-
- do_check_neq(a7_2, null);
- do_check_false(a7_2.isActive);
- do_check_true(a7_2.userDisabled);
- do_check_false(a7_2.appDisabled);
- do_check_eq(a7_2.pendingOperations, AddonManager.PENDING_NONE);
+ do_check_neq(a4, null);
+ do_check_false(a4.isActive);
+ do_check_true(a4.userDisabled);
+ do_check_false(a4.appDisabled);
+ do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE);
+
+ do_check_neq(a5, null);
+ do_check_true(a5.isActive);
+ do_check_false(a5.userDisabled);
+ do_check_false(a5.appDisabled);
+ do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
+
+ do_check_neq(a6, null);
+ do_check_true(a6.isActive);
+ do_check_false(a6.userDisabled);
+ do_check_false(a6.appDisabled);
+ do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE);
+
+ do_check_neq(a7, null);
+ do_check_false(a7.isActive);
+ do_check_true(a7.userDisabled);
+ do_check_false(a7.appDisabled);
+ do_check_eq(a7.pendingOperations, AddonManager.PENDING_NONE);
// Should be correctly recovered
- do_check_neq(t1_2, null);
- do_check_false(t1_2.isActive);
- do_check_true(t1_2.userDisabled);
- do_check_false(t1_2.appDisabled);
- do_check_eq(t1_2.pendingOperations, AddonManager.PENDING_NONE);
+ do_check_neq(t1, null);
+ do_check_false(t1.isActive);
+ do_check_true(t1.userDisabled);
+ do_check_false(t1.appDisabled);
+ do_check_eq(t1.pendingOperations, AddonManager.PENDING_NONE);
// Should be correctly recovered
- do_check_neq(t2_2, null);
- do_check_true(t2_2.isActive);
- do_check_false(t2_2.userDisabled);
- do_check_false(t2_2.appDisabled);
- do_check_eq(t2_2.pendingOperations, AddonManager.PENDING_NONE);
+ do_check_neq(t2, null);
+ do_check_true(t2.isActive);
+ do_check_false(t2.userDisabled);
+ do_check_false(t2.appDisabled);
+ do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
- Assert.throws(shutdownManager);
- startupManager(false);
+ restartManager();
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org",
@@ -342,62 +341,60 @@ function run_test_1() {
"addon7@tests.mozilla.org",
"theme1@tests.mozilla.org",
"theme2@tests.mozilla.org"],
- callback_soon(function([a1_3, a2_3, a3_3, a4_3, a5_3, a6_3, a7_3, t1_3, t2_3]) {
- do_check_neq(a1_3, null);
- do_check_true(a1_3.isActive);
- do_check_false(a1_3.userDisabled);
- do_check_false(a1_3.appDisabled);
- do_check_eq(a1_3.pendingOperations, AddonManager.PENDING_NONE);
-
- do_check_neq(a2_3, null);
- do_check_false(a2_3.isActive);
- do_check_true(a2_3.userDisabled);
- do_check_false(a2_3.appDisabled);
- do_check_eq(a2_3.pendingOperations, AddonManager.PENDING_NONE);
-
- do_check_neq(a3_3, null);
- do_check_true(a3_3.isActive);
- do_check_false(a3_3.userDisabled);
- do_check_false(a3_3.appDisabled);
- do_check_eq(a3_3.pendingOperations, AddonManager.PENDING_NONE);
-
- do_check_neq(a4_3, null);
- do_check_false(a4_3.isActive);
- do_check_true(a4_3.userDisabled);
- do_check_false(a4_3.appDisabled);
- do_check_eq(a4_3.pendingOperations, AddonManager.PENDING_NONE);
-
- do_check_neq(a5_3, null);
- do_check_true(a5_3.isActive);
- do_check_false(a5_3.userDisabled);
- do_check_false(a5_3.appDisabled);
- do_check_eq(a5_3.pendingOperations, AddonManager.PENDING_NONE);
-
- do_check_neq(a6_3, null);
- do_check_true(a6_3.isActive);
- do_check_false(a6_3.userDisabled);
- do_check_false(a6_3.appDisabled);
- do_check_eq(a6_3.pendingOperations, AddonManager.PENDING_NONE);
-
- do_check_neq(a7_3, null);
- do_check_false(a7_3.isActive);
- do_check_true(a7_3.userDisabled);
- do_check_false(a7_3.appDisabled);
- do_check_eq(a7_3.pendingOperations, AddonManager.PENDING_NONE);
-
- do_check_neq(t1_3, null);
- do_check_false(t1_3.isActive);
- do_check_true(t1_3.userDisabled);
- do_check_false(t1_3.appDisabled);
- do_check_eq(t1_3.pendingOperations, AddonManager.PENDING_NONE);
-
- do_check_neq(t2_3, null);
- do_check_true(t2_3.isActive);
- do_check_false(t2_3.userDisabled);
- do_check_false(t2_3.appDisabled);
- do_check_eq(t2_3.pendingOperations, AddonManager.PENDING_NONE);
-
- Assert.throws(shutdownManager);
+ callback_soon(function([a1, a2, a3, a4, a5, a6, a7, t1, t2]) {
+ do_check_neq(a1, null);
+ do_check_true(a1.isActive);
+ do_check_false(a1.userDisabled);
+ do_check_false(a1.appDisabled);
+ do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE);
+
+ do_check_neq(a2, null);
+ do_check_false(a2.isActive);
+ do_check_true(a2.userDisabled);
+ do_check_false(a2.appDisabled);
+ do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE);
+
+ do_check_neq(a3, null);
+ do_check_true(a3.isActive);
+ do_check_false(a3.userDisabled);
+ do_check_false(a3.appDisabled);
+ do_check_eq(a3.pendingOperations, AddonManager.PENDING_NONE);
+
+ do_check_neq(a4, null);
+ do_check_false(a4.isActive);
+ do_check_true(a4.userDisabled);
+ do_check_false(a4.appDisabled);
+ do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE);
+
+ do_check_neq(a5, null);
+ do_check_true(a5.isActive);
+ do_check_false(a5.userDisabled);
+ do_check_false(a5.appDisabled);
+ do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
+
+ do_check_neq(a6, null);
+ do_check_true(a6.isActive);
+ do_check_false(a6.userDisabled);
+ do_check_false(a6.appDisabled);
+ do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE);
+
+ do_check_neq(a7, null);
+ do_check_false(a7.isActive);
+ do_check_true(a7.userDisabled);
+ do_check_false(a7.appDisabled);
+ do_check_eq(a7.pendingOperations, AddonManager.PENDING_NONE);
+
+ do_check_neq(t1, null);
+ do_check_false(t1.isActive);
+ do_check_true(t1.userDisabled);
+ do_check_false(t1.appDisabled);
+ do_check_eq(t1.pendingOperations, AddonManager.PENDING_NONE);
+
+ do_check_neq(t2, null);
+ do_check_true(t2.isActive);
+ do_check_false(t2.userDisabled);
+ do_check_false(t2.appDisabled);
+ do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
end_test();
}));
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_corrupt_strictcompat.js b/toolkit/mozapps/extensions/test/xpcshell/test_corrupt_strictcompat.js
index 622973472..3ba6d213b 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_corrupt_strictcompat.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_corrupt_strictcompat.js
@@ -266,71 +266,70 @@ function run_test_1() {
"addon7@tests.mozilla.org",
"theme1@tests.mozilla.org",
"theme2@tests.mozilla.org"],
- callback_soon(function([a1_2, a2_2, a3_2, a4_2, a5_2, a6_2, a7_2, t1_2, t2_2]) {
+ callback_soon(function([a1, a2, a3, a4, a5, a6, a7, t1, t2]) {
// Should be correctly recovered
- do_check_neq(a1_2, null);
- do_check_true(a1_2.isActive);
- do_check_false(a1_2.userDisabled);
- do_check_false(a1_2.appDisabled);
- do_check_eq(a1_2.pendingOperations, AddonManager.PENDING_NONE);
+ do_check_neq(a1, null);
+ do_check_true(a1.isActive);
+ do_check_false(a1.userDisabled);
+ do_check_false(a1.appDisabled);
+ do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE);
// Should be correctly recovered
- do_check_neq(a2_2, null);
- do_check_false(a2_2.isActive);
- do_check_true(a2_2.userDisabled);
- do_check_false(a2_2.appDisabled);
- do_check_eq(a2_2.pendingOperations, AddonManager.PENDING_NONE);
+ do_check_neq(a2, null);
+ do_check_false(a2.isActive);
+ do_check_true(a2.userDisabled);
+ do_check_false(a2.appDisabled);
+ do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE);
// The compatibility update won't be recovered but it should still be
// active for this session
- do_check_neq(a3_2, null);
- do_check_true(a3_2.isActive);
- do_check_false(a3_2.userDisabled);
- do_check_true(a3_2.appDisabled);
- do_check_eq(a3_2.pendingOperations, AddonManager.PENDING_DISABLE);
+ do_check_neq(a3, null);
+ do_check_true(a3.isActive);
+ do_check_false(a3.userDisabled);
+ do_check_true(a3.appDisabled);
+ do_check_eq(a3.pendingOperations, AddonManager.PENDING_DISABLE);
// The compatibility update won't be recovered and it will not have been
// able to tell that it was previously userDisabled
- do_check_neq(a4_2, null);
- do_check_false(a4_2.isActive);
- do_check_false(a4_2.userDisabled);
- do_check_true(a4_2.appDisabled);
- do_check_eq(a4_2.pendingOperations, AddonManager.PENDING_NONE);
-
- do_check_neq(a5_2, null);
- do_check_false(a5_2.isActive);
- do_check_false(a5_2.userDisabled);
- do_check_true(a5_2.appDisabled);
- do_check_eq(a5_2.pendingOperations, AddonManager.PENDING_NONE);
-
- do_check_neq(a6_2, null);
- do_check_true(a6_2.isActive);
- do_check_false(a6_2.userDisabled);
- do_check_false(a6_2.appDisabled);
- do_check_eq(a6_2.pendingOperations, AddonManager.PENDING_NONE);
-
- do_check_neq(a7_2, null);
- do_check_false(a7_2.isActive);
- do_check_true(a7_2.userDisabled);
- do_check_false(a7_2.appDisabled);
- do_check_eq(a7_2.pendingOperations, AddonManager.PENDING_NONE);
+ do_check_neq(a4, null);
+ do_check_false(a4.isActive);
+ do_check_false(a4.userDisabled);
+ do_check_true(a4.appDisabled);
+ do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE);
+
+ do_check_neq(a5, null);
+ do_check_false(a5.isActive);
+ do_check_false(a5.userDisabled);
+ do_check_true(a5.appDisabled);
+ do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
+
+ do_check_neq(a6, null);
+ do_check_true(a6.isActive);
+ do_check_false(a6.userDisabled);
+ do_check_false(a6.appDisabled);
+ do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE);
+
+ do_check_neq(a7, null);
+ do_check_false(a7.isActive);
+ do_check_true(a7.userDisabled);
+ do_check_false(a7.appDisabled);
+ do_check_eq(a7.pendingOperations, AddonManager.PENDING_NONE);
// Should be correctly recovered
- do_check_neq(t1_2, null);
- do_check_false(t1_2.isActive);
- do_check_true(t1_2.userDisabled);
- do_check_false(t1_2.appDisabled);
- do_check_eq(t1_2.pendingOperations, AddonManager.PENDING_NONE);
+ do_check_neq(t1, null);
+ do_check_false(t1.isActive);
+ do_check_true(t1.userDisabled);
+ do_check_false(t1.appDisabled);
+ do_check_eq(t1.pendingOperations, AddonManager.PENDING_NONE);
// Should be correctly recovered
- do_check_neq(t2_2, null);
- do_check_true(t2_2.isActive);
- do_check_false(t2_2.userDisabled);
- do_check_false(t2_2.appDisabled);
- do_check_eq(t2_2.pendingOperations, AddonManager.PENDING_NONE);
+ do_check_neq(t2, null);
+ do_check_true(t2.isActive);
+ do_check_false(t2.userDisabled);
+ do_check_false(t2.appDisabled);
+ do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
- Assert.throws(shutdownManager);
- startupManager(false);
+ restartManager();
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
"addon2@tests.mozilla.org",
@@ -341,62 +340,60 @@ function run_test_1() {
"addon7@tests.mozilla.org",
"theme1@tests.mozilla.org",
"theme2@tests.mozilla.org"],
- callback_soon(function([a1_3, a2_3, a3_3, a4_3, a5_3, a6_3, a7_3, t1_3, t2_3]) {
- do_check_neq(a1_3, null);
- do_check_true(a1_3.isActive);
- do_check_false(a1_3.userDisabled);
- do_check_false(a1_3.appDisabled);
- do_check_eq(a1_3.pendingOperations, AddonManager.PENDING_NONE);
-
- do_check_neq(a2_3, null);
- do_check_false(a2_3.isActive);
- do_check_true(a2_3.userDisabled);
- do_check_false(a2_3.appDisabled);
- do_check_eq(a2_3.pendingOperations, AddonManager.PENDING_NONE);
-
- do_check_neq(a3_3, null);
- do_check_false(a3_3.isActive);
- do_check_false(a3_3.userDisabled);
- do_check_true(a3_3.appDisabled);
- do_check_eq(a3_3.pendingOperations, AddonManager.PENDING_NONE);
-
- do_check_neq(a4_3, null);
- do_check_false(a4_3.isActive);
- do_check_false(a4_3.userDisabled);
- do_check_true(a4_3.appDisabled);
- do_check_eq(a4_3.pendingOperations, AddonManager.PENDING_NONE);
-
- do_check_neq(a5_3, null);
- do_check_false(a5_3.isActive);
- do_check_false(a5_3.userDisabled);
- do_check_true(a5_3.appDisabled);
- do_check_eq(a5_3.pendingOperations, AddonManager.PENDING_NONE);
-
- do_check_neq(a6_3, null);
- do_check_true(a6_3.isActive);
- do_check_false(a6_3.userDisabled);
- do_check_false(a6_3.appDisabled);
- do_check_eq(a6_3.pendingOperations, AddonManager.PENDING_NONE);
-
- do_check_neq(a7_3, null);
- do_check_false(a7_3.isActive);
- do_check_true(a7_3.userDisabled);
- do_check_false(a7_3.appDisabled);
- do_check_eq(a7_3.pendingOperations, AddonManager.PENDING_NONE);
-
- do_check_neq(t1_3, null);
- do_check_false(t1_3.isActive);
- do_check_true(t1_3.userDisabled);
- do_check_false(t1_3.appDisabled);
- do_check_eq(t1_3.pendingOperations, AddonManager.PENDING_NONE);
-
- do_check_neq(t2_3, null);
- do_check_true(t2_3.isActive);
- do_check_false(t2_3.userDisabled);
- do_check_false(t2_3.appDisabled);
- do_check_eq(t2_3.pendingOperations, AddonManager.PENDING_NONE);
-
- Assert.throws(shutdownManager);
+ callback_soon(function([a1, a2, a3, a4, a5, a6, a7, t1, t2]) {
+ do_check_neq(a1, null);
+ do_check_true(a1.isActive);
+ do_check_false(a1.userDisabled);
+ do_check_false(a1.appDisabled);
+ do_check_eq(a1.pendingOperations, AddonManager.PENDING_NONE);
+
+ do_check_neq(a2, null);
+ do_check_false(a2.isActive);
+ do_check_true(a2.userDisabled);
+ do_check_false(a2.appDisabled);
+ do_check_eq(a2.pendingOperations, AddonManager.PENDING_NONE);
+
+ do_check_neq(a3, null);
+ do_check_false(a3.isActive);
+ do_check_false(a3.userDisabled);
+ do_check_true(a3.appDisabled);
+ do_check_eq(a3.pendingOperations, AddonManager.PENDING_NONE);
+
+ do_check_neq(a4, null);
+ do_check_false(a4.isActive);
+ do_check_false(a4.userDisabled);
+ do_check_true(a4.appDisabled);
+ do_check_eq(a4.pendingOperations, AddonManager.PENDING_NONE);
+
+ do_check_neq(a5, null);
+ do_check_false(a5.isActive);
+ do_check_false(a5.userDisabled);
+ do_check_true(a5.appDisabled);
+ do_check_eq(a5.pendingOperations, AddonManager.PENDING_NONE);
+
+ do_check_neq(a6, null);
+ do_check_true(a6.isActive);
+ do_check_false(a6.userDisabled);
+ do_check_false(a6.appDisabled);
+ do_check_eq(a6.pendingOperations, AddonManager.PENDING_NONE);
+
+ do_check_neq(a7, null);
+ do_check_false(a7.isActive);
+ do_check_true(a7.userDisabled);
+ do_check_false(a7.appDisabled);
+ do_check_eq(a7.pendingOperations, AddonManager.PENDING_NONE);
+
+ do_check_neq(t1, null);
+ do_check_false(t1.isActive);
+ do_check_true(t1.userDisabled);
+ do_check_false(t1.appDisabled);
+ do_check_eq(t1.pendingOperations, AddonManager.PENDING_NONE);
+
+ do_check_neq(t2, null);
+ do_check_true(t2.isActive);
+ do_check_false(t2.userDisabled);
+ do_check_false(t2.appDisabled);
+ do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
end_test();
}));
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_dataDirectory.js b/toolkit/mozapps/extensions/test/xpcshell/test_dataDirectory.js
index bf75818e9..99babc722 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_dataDirectory.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_dataDirectory.js
@@ -11,11 +11,11 @@ var ADDON = {
addon: "test_data_directory"
};
-function run_test() {
- var expectedDir = gProfD.clone();
- expectedDir.append("extension-data");
- expectedDir.append(ADDON.id);
+var expectedDir = gProfD.clone();
+expectedDir.append("extension-data");
+expectedDir.append(ADDON.id);
+function run_test() {
do_test_pending();
do_check_false(expectedDir.exists());
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_delay_update.js b/toolkit/mozapps/extensions/test/xpcshell/test_delay_update.js
deleted file mode 100644
index 3d7eef051..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_delay_update.js
+++ /dev/null
@@ -1,260 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-// This verifies that delaying an update works
-
-// The test extension uses an insecure update url.
-Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
-
-Components.utils.import("resource://testing-common/httpd.js");
-const profileDir = gProfD.clone();
-profileDir.append("extensions");
-const tempdir = gTmpD.clone();
-
-const IGNORE_ID = "test_delay_update_ignore@tests.mozilla.org";
-const COMPLETE_ID = "test_delay_update_complete@tests.mozilla.org";
-const DEFER_ID = "test_delay_update_defer@tests.mozilla.org";
-
-const TEST_IGNORE_PREF = "delaytest.ignore";
-
-// Note that we would normally use BootstrapMonitor but it currently requires
-// the objects in `data` to be serializable, and we need a real reference to the
-// `instanceID` symbol to test.
-
-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);
-testserver.registerDirectory("/addons/", do_get_file("addons"));
-
-function* createIgnoreAddon() {
- writeInstallRDFToDir({
- id: IGNORE_ID,
- version: "1.0",
- bootstrap: true,
- unpack: true,
- updateURL: `http://localhost:${gPort}/data/test_delay_updates_ignore.rdf`,
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "1"
- }],
- name: "Test Delay Update Ignore",
- }, profileDir, IGNORE_ID, "bootstrap.js");
-
- let unpacked_addon = profileDir.clone();
- unpacked_addon.append(IGNORE_ID);
- do_get_file("data/test_delay_update_ignore/bootstrap.js")
- .copyTo(unpacked_addon, "bootstrap.js");
-}
-
-function* createCompleteAddon() {
- writeInstallRDFToDir({
- id: COMPLETE_ID,
- version: "1.0",
- bootstrap: true,
- unpack: true,
- updateURL: `http://localhost:${gPort}/data/test_delay_updates_complete.rdf`,
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "1"
- }],
- name: "Test Delay Update Complete",
- }, profileDir, COMPLETE_ID, "bootstrap.js");
-
- let unpacked_addon = profileDir.clone();
- unpacked_addon.append(COMPLETE_ID);
- do_get_file("data/test_delay_update_complete/bootstrap.js")
- .copyTo(unpacked_addon, "bootstrap.js");
-}
-
-function* createDeferAddon() {
- writeInstallRDFToDir({
- id: DEFER_ID,
- version: "1.0",
- bootstrap: true,
- unpack: true,
- updateURL: `http://localhost:${gPort}/data/test_delay_updates_defer.rdf`,
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "1"
- }],
- name: "Test Delay Update Defer",
- }, profileDir, DEFER_ID, "bootstrap.js");
-
- let unpacked_addon = profileDir.clone();
- unpacked_addon.append(DEFER_ID);
- do_get_file("data/test_delay_update_defer/bootstrap.js")
- .copyTo(unpacked_addon, "bootstrap.js");
-}
-
-// add-on registers upgrade listener, and ignores update.
-add_task(function*() {
-
- yield createIgnoreAddon();
-
- startupManager();
-
- let addon = yield promiseAddonByID(IGNORE_ID);
- do_check_neq(addon, null);
- do_check_eq(addon.version, "1.0");
- do_check_eq(addon.name, "Test Delay Update Ignore");
- do_check_true(addon.isCompatible);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.type, "extension");
-
- let update = yield promiseFindAddonUpdates(addon);
- let install = update.updateAvailable;
-
- yield promiseCompleteAllInstalls([install]);
-
- do_check_eq(install.state, AddonManager.STATE_POSTPONED);
-
- // addon upgrade has been delayed
- let addon_postponed = yield promiseAddonByID(IGNORE_ID);
- do_check_neq(addon_postponed, null);
- do_check_eq(addon_postponed.version, "1.0");
- do_check_eq(addon_postponed.name, "Test Delay Update Ignore");
- do_check_true(addon_postponed.isCompatible);
- do_check_false(addon_postponed.appDisabled);
- do_check_true(addon_postponed.isActive);
- do_check_eq(addon_postponed.type, "extension");
- do_check_true(Services.prefs.getBoolPref(TEST_IGNORE_PREF));
-
- // restarting allows upgrade to proceed
- yield promiseRestartManager();
-
- let addon_upgraded = yield promiseAddonByID(IGNORE_ID);
- do_check_neq(addon_upgraded, null);
- do_check_eq(addon_upgraded.version, "2.0");
- do_check_eq(addon_upgraded.name, "Test Delay Update Ignore");
- do_check_true(addon_upgraded.isCompatible);
- do_check_false(addon_upgraded.appDisabled);
- do_check_true(addon_upgraded.isActive);
- do_check_eq(addon_upgraded.type, "extension");
-
- yield shutdownManager();
-});
-
-// add-on registers upgrade listener, and allows update.
-add_task(function*() {
-
- yield createCompleteAddon();
-
- startupManager();
-
- let addon = yield promiseAddonByID(COMPLETE_ID);
- do_check_neq(addon, null);
- do_check_eq(addon.version, "1.0");
- do_check_eq(addon.name, "Test Delay Update Complete");
- do_check_true(addon.isCompatible);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.type, "extension");
-
- let update = yield promiseFindAddonUpdates(addon);
- let install = update.updateAvailable;
-
- yield promiseCompleteAllInstalls([install]);
-
- // upgrade is initially postponed
- let addon_postponed = yield promiseAddonByID(COMPLETE_ID);
- do_check_neq(addon_postponed, null);
- do_check_eq(addon_postponed.version, "1.0");
- do_check_eq(addon_postponed.name, "Test Delay Update Complete");
- do_check_true(addon_postponed.isCompatible);
- do_check_false(addon_postponed.appDisabled);
- do_check_true(addon_postponed.isActive);
- do_check_eq(addon_postponed.type, "extension");
-
- // addon upgrade has been allowed
- let [addon_allowed] = yield promiseAddonEvent("onInstalled");
- do_check_neq(addon_allowed, null);
- do_check_eq(addon_allowed.version, "2.0");
- do_check_eq(addon_allowed.name, "Test Delay Update Complete");
- do_check_true(addon_allowed.isCompatible);
- do_check_false(addon_allowed.appDisabled);
- do_check_true(addon_allowed.isActive);
- do_check_eq(addon_allowed.type, "extension");
-
- // restarting changes nothing
- yield promiseRestartManager();
-
- let addon_upgraded = yield promiseAddonByID(COMPLETE_ID);
- do_check_neq(addon_upgraded, null);
- do_check_eq(addon_upgraded.version, "2.0");
- do_check_eq(addon_upgraded.name, "Test Delay Update Complete");
- do_check_true(addon_upgraded.isCompatible);
- do_check_false(addon_upgraded.appDisabled);
- do_check_true(addon_upgraded.isActive);
- do_check_eq(addon_upgraded.type, "extension");
-
- yield shutdownManager();
-});
-
-// add-on registers upgrade listener, initially defers update then allows upgrade
-add_task(function*() {
-
- yield createDeferAddon();
-
- startupManager();
-
- let addon = yield promiseAddonByID(DEFER_ID);
- do_check_neq(addon, null);
- do_check_eq(addon.version, "1.0");
- do_check_eq(addon.name, "Test Delay Update Defer");
- do_check_true(addon.isCompatible);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.type, "extension");
-
- let update = yield promiseFindAddonUpdates(addon);
- let install = update.updateAvailable;
-
- yield promiseCompleteAllInstalls([install]);
-
- // upgrade is initially postponed
- let addon_postponed = yield promiseAddonByID(DEFER_ID);
- do_check_neq(addon_postponed, null);
- do_check_eq(addon_postponed.version, "1.0");
- do_check_eq(addon_postponed.name, "Test Delay Update Defer");
- do_check_true(addon_postponed.isCompatible);
- do_check_false(addon_postponed.appDisabled);
- do_check_true(addon_postponed.isActive);
- do_check_eq(addon_postponed.type, "extension");
-
- // add-on will not allow upgrade until fake event fires
- AddonManagerPrivate.callAddonListeners("onFakeEvent");
-
- // addon upgrade has been allowed
- let [addon_allowed] = yield promiseAddonEvent("onInstalled");
- do_check_neq(addon_allowed, null);
- do_check_eq(addon_allowed.version, "2.0");
- do_check_eq(addon_allowed.name, "Test Delay Update Defer");
- do_check_true(addon_allowed.isCompatible);
- do_check_false(addon_allowed.appDisabled);
- do_check_true(addon_allowed.isActive);
- do_check_eq(addon_allowed.type, "extension");
-
- // restarting changes nothing
- yield promiseRestartManager();
-
- let addon_upgraded = yield promiseAddonByID(DEFER_ID);
- do_check_neq(addon_upgraded, null);
- do_check_eq(addon_upgraded.version, "2.0");
- do_check_eq(addon_upgraded.name, "Test Delay Update Defer");
- do_check_true(addon_upgraded.isCompatible);
- do_check_false(addon_upgraded.appDisabled);
- do_check_true(addon_upgraded.isActive);
- do_check_eq(addon_upgraded.type, "extension");
-
- yield shutdownManager();
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_delay_update_webextension.js b/toolkit/mozapps/extensions/test/xpcshell/test_delay_update_webextension.js
deleted file mode 100644
index cdfac8f8c..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_delay_update_webextension.js
+++ /dev/null
@@ -1,344 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-// This verifies that delaying an update works for WebExtensions.
-
-// The test extension uses an insecure update url.
-Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false);
-
-/* globals browser*/
-
-const profileDir = gProfD.clone();
-profileDir.append("extensions");
-const tempdir = gTmpD.clone();
-const stageDir = profileDir.clone();
-stageDir.append("staged");
-
-const IGNORE_ID = "test_delay_update_ignore_webext@tests.mozilla.org";
-const COMPLETE_ID = "test_delay_update_complete_webext@tests.mozilla.org";
-const DEFER_ID = "test_delay_update_defer_webext@tests.mozilla.org";
-const NOUPDATE_ID = "test_no_update_webext@tests.mozilla.org";
-
-// Create and configure the HTTP server.
-let testserver = createHttpServer();
-gPort = testserver.identity.primaryPort;
-mapFile("/data/test_delay_updates_complete.json", testserver);
-mapFile("/data/test_delay_updates_ignore.json", testserver);
-mapFile("/data/test_delay_updates_defer.json", testserver);
-mapFile("/data/test_no_update.json", testserver);
-testserver.registerDirectory("/addons/", do_get_file("addons"));
-
-createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "42");
-
-const { Management } = Components.utils.import("resource://gre/modules/Extension.jsm", {});
-
-function promiseWebExtensionStartup() {
- return new Promise(resolve => {
- let listener = (event, extension) => {
- Management.off("startup", listener);
- resolve(extension);
- };
-
- Management.on("startup", listener);
- });
-}
-
-// add-on registers upgrade listener, and ignores update.
-add_task(function* delay_updates_ignore() {
- startupManager();
-
- let extension = ExtensionTestUtils.loadExtension({
- useAddonManager: "permanent",
- manifest: {
- "version": "1.0",
- "applications": {
- "gecko": {
- "id": IGNORE_ID,
- "update_url": `http://localhost:${gPort}/data/test_delay_updates_ignore.json`,
- },
- },
- },
- background() {
- browser.runtime.onUpdateAvailable.addListener(details => {
- if (details) {
- if (details.version) {
- // This should be the version of the pending update.
- browser.test.assertEq("2.0", details.version, "correct version");
- browser.test.notifyPass("delay");
- }
- } else {
- browser.test.fail("no details object passed");
- }
- });
- browser.test.sendMessage("ready");
- },
- }, IGNORE_ID);
-
- yield Promise.all([extension.startup(), extension.awaitMessage("ready")]);
-
- let addon = yield promiseAddonByID(IGNORE_ID);
- do_check_neq(addon, null);
- do_check_eq(addon.version, "1.0");
- do_check_eq(addon.name, "Generated extension");
- do_check_true(addon.isCompatible);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.type, "extension");
-
- let update = yield promiseFindAddonUpdates(addon);
- let install = update.updateAvailable;
-
- yield promiseCompleteAllInstalls([install]);
-
- do_check_eq(install.state, AddonManager.STATE_POSTPONED);
-
- // addon upgrade has been delayed
- let addon_postponed = yield promiseAddonByID(IGNORE_ID);
- do_check_neq(addon_postponed, null);
- do_check_eq(addon_postponed.version, "1.0");
- do_check_eq(addon_postponed.name, "Generated extension");
- do_check_true(addon_postponed.isCompatible);
- do_check_false(addon_postponed.appDisabled);
- do_check_true(addon_postponed.isActive);
- do_check_eq(addon_postponed.type, "extension");
-
- yield extension.awaitFinish("delay");
-
- // restarting allows upgrade to proceed
- yield extension.markUnloaded();
- yield promiseRestartManager();
-
- let addon_upgraded = yield promiseAddonByID(IGNORE_ID);
- yield promiseWebExtensionStartup();
-
- do_check_neq(addon_upgraded, null);
- do_check_eq(addon_upgraded.version, "2.0");
- do_check_eq(addon_upgraded.name, "Delay Upgrade");
- do_check_true(addon_upgraded.isCompatible);
- do_check_false(addon_upgraded.appDisabled);
- do_check_true(addon_upgraded.isActive);
- do_check_eq(addon_upgraded.type, "extension");
-
- yield addon_upgraded.uninstall();
- yield promiseShutdownManager();
-});
-
-// add-on registers upgrade listener, and allows update.
-add_task(function* delay_updates_complete() {
- startupManager();
-
- let extension = ExtensionTestUtils.loadExtension({
- useAddonManager: "permanent",
- manifest: {
- "version": "1.0",
- "applications": {
- "gecko": {
- "id": COMPLETE_ID,
- "update_url": `http://localhost:${gPort}/data/test_delay_updates_complete.json`,
- },
- },
- },
- background() {
- browser.runtime.onUpdateAvailable.addListener(details => {
- browser.test.notifyPass("reload");
- browser.runtime.reload();
- });
- browser.test.sendMessage("ready");
- },
- }, COMPLETE_ID);
-
- yield Promise.all([extension.startup(), extension.awaitMessage("ready")]);
-
- let addon = yield promiseAddonByID(COMPLETE_ID);
- do_check_neq(addon, null);
- do_check_eq(addon.version, "1.0");
- do_check_eq(addon.name, "Generated extension");
- do_check_true(addon.isCompatible);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.type, "extension");
-
- let update = yield promiseFindAddonUpdates(addon);
- let install = update.updateAvailable;
-
- let promiseInstalled = promiseAddonEvent("onInstalled");
- yield promiseCompleteAllInstalls([install]);
-
- yield extension.awaitFinish("reload");
-
- // addon upgrade has been allowed
- let [addon_allowed] = yield promiseInstalled;
- yield promiseWebExtensionStartup();
-
- do_check_neq(addon_allowed, null);
- do_check_eq(addon_allowed.version, "2.0");
- do_check_eq(addon_allowed.name, "Delay Upgrade");
- do_check_true(addon_allowed.isCompatible);
- do_check_false(addon_allowed.appDisabled);
- do_check_true(addon_allowed.isActive);
- do_check_eq(addon_allowed.type, "extension");
-
- if (stageDir.exists()) {
- do_throw("Staging directory should not exist for formerly-postponed extension");
- }
-
- yield extension.markUnloaded();
- yield addon_allowed.uninstall();
- yield promiseShutdownManager();
-});
-
-// add-on registers upgrade listener, initially defers update then allows upgrade
-add_task(function* delay_updates_defer() {
- startupManager();
-
- let extension = ExtensionTestUtils.loadExtension({
- useAddonManager: "permanent",
- manifest: {
- "version": "1.0",
- "applications": {
- "gecko": {
- "id": DEFER_ID,
- "update_url": `http://localhost:${gPort}/data/test_delay_updates_defer.json`,
- },
- },
- },
- background() {
- browser.runtime.onUpdateAvailable.addListener(details => {
- // Upgrade will only proceed when "allow" message received.
- browser.test.onMessage.addListener(msg => {
- if (msg == "allow") {
- browser.test.notifyPass("allowed");
- browser.runtime.reload();
- } else {
- browser.test.fail(`wrong message: ${msg}`);
- }
- });
- browser.test.sendMessage("truly ready");
- });
- browser.test.sendMessage("ready");
- },
- }, DEFER_ID);
-
- yield Promise.all([extension.startup(), extension.awaitMessage("ready")]);
-
- let addon = yield promiseAddonByID(DEFER_ID);
- do_check_neq(addon, null);
- do_check_eq(addon.version, "1.0");
- do_check_eq(addon.name, "Generated extension");
- do_check_true(addon.isCompatible);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.type, "extension");
-
- let update = yield promiseFindAddonUpdates(addon);
- let install = update.updateAvailable;
-
- let promiseInstalled = promiseAddonEvent("onInstalled");
- yield promiseCompleteAllInstalls([install]);
-
- do_check_eq(install.state, AddonManager.STATE_POSTPONED);
-
- // upgrade is initially postponed
- let addon_postponed = yield promiseAddonByID(DEFER_ID);
- do_check_neq(addon_postponed, null);
- do_check_eq(addon_postponed.version, "1.0");
- do_check_eq(addon_postponed.name, "Generated extension");
- do_check_true(addon_postponed.isCompatible);
- do_check_false(addon_postponed.appDisabled);
- do_check_true(addon_postponed.isActive);
- do_check_eq(addon_postponed.type, "extension");
-
- // add-on will not allow upgrade until message is received
- yield extension.awaitMessage("truly ready");
- extension.sendMessage("allow");
- yield extension.awaitFinish("allowed");
-
- // addon upgrade has been allowed
- let [addon_allowed] = yield promiseInstalled;
- yield promiseWebExtensionStartup();
-
- do_check_neq(addon_allowed, null);
- do_check_eq(addon_allowed.version, "2.0");
- do_check_eq(addon_allowed.name, "Delay Upgrade");
- do_check_true(addon_allowed.isCompatible);
- do_check_false(addon_allowed.appDisabled);
- do_check_true(addon_allowed.isActive);
- do_check_eq(addon_allowed.type, "extension");
-
- yield extension.markUnloaded();
- yield promiseRestartManager();
-
- // restart changes nothing
- addon_allowed = yield promiseAddonByID(DEFER_ID);
- yield promiseWebExtensionStartup();
-
- do_check_neq(addon_allowed, null);
- do_check_eq(addon_allowed.version, "2.0");
- do_check_eq(addon_allowed.name, "Delay Upgrade");
- do_check_true(addon_allowed.isCompatible);
- do_check_false(addon_allowed.appDisabled);
- do_check_true(addon_allowed.isActive);
- do_check_eq(addon_allowed.type, "extension");
-
- yield addon_allowed.uninstall();
- yield promiseShutdownManager();
-});
-
-// browser.runtime.reload() without a pending upgrade should just reload.
-add_task(function* runtime_reload() {
- startupManager();
-
- let extension = ExtensionTestUtils.loadExtension({
- useAddonManager: "permanent",
- manifest: {
- "version": "1.0",
- "applications": {
- "gecko": {
- "id": NOUPDATE_ID,
- "update_url": `http://localhost:${gPort}/data/test_no_update.json`,
- },
- },
- },
- background() {
- browser.test.onMessage.addListener(msg => {
- if (msg == "reload") {
- browser.runtime.reload();
- } else {
- browser.test.fail(`wrong message: ${msg}`);
- }
- });
- browser.test.sendMessage("ready");
- },
- }, NOUPDATE_ID);
-
- yield Promise.all([extension.startup(), extension.awaitMessage("ready")]);
-
- let addon = yield promiseAddonByID(NOUPDATE_ID);
- do_check_neq(addon, null);
- do_check_eq(addon.version, "1.0");
- do_check_eq(addon.name, "Generated extension");
- do_check_true(addon.isCompatible);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.type, "extension");
-
- yield promiseFindAddonUpdates(addon);
-
- extension.sendMessage("reload");
- // Wait for extension to restart, to make sure reload works.
- yield promiseWebExtensionStartup();
-
- addon = yield promiseAddonByID(NOUPDATE_ID);
- do_check_neq(addon, null);
- do_check_eq(addon.version, "1.0");
- do_check_eq(addon.name, "Generated extension");
- do_check_true(addon.isCompatible);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.type, "extension");
-
- yield extension.markUnloaded();
- yield addon.uninstall();
- yield promiseShutdownManager();
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_dependencies.js b/toolkit/mozapps/extensions/test/xpcshell/test_dependencies.js
deleted file mode 100644
index 3afc03f84..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_dependencies.js
+++ /dev/null
@@ -1,144 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-const profileDir = gProfD.clone();
-profileDir.append("extensions");
-
-createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
-startupManager();
-
-const BOOTSTRAP = String.raw`
- Components.utils.import("resource://gre/modules/Services.jsm");
-
- function startup(data) {
- Services.obs.notifyObservers(null, "test-addon-bootstrap-startup", data.id);
- }
- function shutdown(data) {
- Services.obs.notifyObservers(null, "test-addon-bootstrap-shutdown", data.id);
- }
- function install() {}
- function uninstall() {}
-`;
-
-const ADDONS = [
- {
- id: "addon1@dependency-test.mozilla.org",
- dependencies: ["addon2@dependency-test.mozilla.org"],
- },
- {
- id: "addon2@dependency-test.mozilla.org",
- dependencies: ["addon3@dependency-test.mozilla.org"],
- },
- {
- id: "addon3@dependency-test.mozilla.org",
- },
- {
- id: "addon4@dependency-test.mozilla.org",
- },
- {
- id: "addon5@dependency-test.mozilla.org",
- dependencies: ["addon2@dependency-test.mozilla.org"],
- },
-];
-
-let addonFiles = [];
-
-let events = [];
-add_task(function* setup() {
- let startupObserver = (subject, topic, data) => {
- events.push(["startup", data]);
- };
- let shutdownObserver = (subject, topic, data) => {
- events.push(["shutdown", data]);
- };
-
- Services.obs.addObserver(startupObserver, "test-addon-bootstrap-startup", false);
- Services.obs.addObserver(shutdownObserver, "test-addon-bootstrap-shutdown", false);
- do_register_cleanup(() => {
- Services.obs.removeObserver(startupObserver, "test-addon-bootstrap-startup");
- Services.obs.removeObserver(shutdownObserver, "test-addon-bootstrap-shutdown");
- });
-
- for (let addon of ADDONS) {
- Object.assign(addon, {
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "1",
- }],
- version: "1.0",
- name: addon.id,
- bootstrap: true,
- });
-
- addonFiles.push(createTempXPIFile(addon, {"bootstrap.js": BOOTSTRAP}));
- }
-});
-
-add_task(function*() {
- deepEqual(events, [], "Should have no events");
-
- yield promiseInstallAllFiles([addonFiles[3]]);
-
- deepEqual(events, [
- ["startup", ADDONS[3].id],
- ]);
-
- events.length = 0;
-
- yield promiseInstallAllFiles([addonFiles[0]]);
- deepEqual(events, [], "Should have no events");
-
- yield promiseInstallAllFiles([addonFiles[1]]);
- deepEqual(events, [], "Should have no events");
-
- yield promiseInstallAllFiles([addonFiles[2]]);
-
- deepEqual(events, [
- ["startup", ADDONS[2].id],
- ["startup", ADDONS[1].id],
- ["startup", ADDONS[0].id],
- ]);
-
- events.length = 0;
-
- yield promiseInstallAllFiles([addonFiles[2]]);
-
- deepEqual(events, [
- ["shutdown", ADDONS[0].id],
- ["shutdown", ADDONS[1].id],
- ["shutdown", ADDONS[2].id],
-
- ["startup", ADDONS[2].id],
- ["startup", ADDONS[1].id],
- ["startup", ADDONS[0].id],
- ]);
-
- events.length = 0;
-
- yield promiseInstallAllFiles([addonFiles[4]]);
-
- deepEqual(events, [
- ["startup", ADDONS[4].id],
- ]);
-
- events.length = 0;
-
- yield promiseRestartManager();
-
- deepEqual(events, [
- ["shutdown", ADDONS[4].id],
- ["shutdown", ADDONS[3].id],
- ["shutdown", ADDONS[0].id],
- ["shutdown", ADDONS[1].id],
- ["shutdown", ADDONS[2].id],
-
- ["startup", ADDONS[2].id],
- ["startup", ADDONS[1].id],
- ["startup", ADDONS[0].id],
- ["startup", ADDONS[3].id],
- ["startup", ADDONS[4].id],
- ]);
-});
-
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_dictionary.js b/toolkit/mozapps/extensions/test/xpcshell/test_dictionary.js
index f4b6a0535..c24b5a1b0 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_dictionary.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_dictionary.js
@@ -39,7 +39,7 @@ mapFile("/data/test_dictionary.rdf", testserver);
var HunspellEngine = {
dictionaryDirs: [],
listener: null,
-
+
QueryInterface: function hunspell_qi(iid) {
if (iid.equals(Components.interfaces.nsISupports) ||
iid.equals(Components.interfaces.nsIFactory) ||
@@ -89,7 +89,7 @@ var HunspellEngine = {
Components.manager.nsIComponentRegistrar.registerFactory(this.classID,
"Test hunspell", this.contractID, this);
},
-
+
deactivate: function hunspell_deactivate() {
Components.manager.nsIComponentRegistrar.unregisterFactory(this.classID, this);
Components.manager.nsIComponentRegistrar.registerFactory(this.origClassID,
@@ -175,16 +175,6 @@ function check_test_1() {
let dir = do_get_addon_root_uri(profileDir, "ab-CD@dictionaries.addons.mozilla.org");
- let chromeReg = AM_Cc["@mozilla.org/chrome/chrome-registry;1"].
- getService(AM_Ci.nsIChromeRegistry);
- try {
- chromeReg.convertChromeURL(NetUtil.newURI("chrome://dict/content/dict.xul"));
- do_throw("Chrome manifest should not have been registered");
- }
- catch (e) {
- // Expected the chrome url to not be registered
- }
-
AddonManager.getAddonsWithOperationsByTypes(null, function(list) {
do_check_eq(list.length, 0);
@@ -348,7 +338,7 @@ function run_test_8() {
let dir = profileDir.clone();
dir.append("ab-CD@dictionaries.addons.mozilla.org");
- dir.create(AM_Ci.nsIFile.DIRECTORY_TYPE, 0o755);
+ dir.create(AM_Ci.nsIFile.DIRECTORY_TYPE, 0755);
let zip = AM_Cc["@mozilla.org/libjar/zip-reader;1"].
createInstance(AM_Ci.nsIZipReader);
zip.open(do_get_addon("test_dictionary"));
@@ -356,7 +346,7 @@ function run_test_8() {
zip.extract("install.rdf", dir);
dir = dir.parent;
dir.append("dictionaries");
- dir.create(AM_Ci.nsIFile.DIRECTORY_TYPE, 0o755);
+ dir.create(AM_Ci.nsIFile.DIRECTORY_TYPE, 0755);
dir.append("ab-CD.dic");
zip.extract("dictionaries/ab-CD.dic", dir);
zip.close();
@@ -401,7 +391,7 @@ function run_test_12() {
let dir = profileDir.clone();
dir.append("ab-CD@dictionaries.addons.mozilla.org");
- dir.create(AM_Ci.nsIFile.DIRECTORY_TYPE, 0o755);
+ dir.create(AM_Ci.nsIFile.DIRECTORY_TYPE, 0755);
let zip = AM_Cc["@mozilla.org/libjar/zip-reader;1"].
createInstance(AM_Ci.nsIZipReader);
zip.open(do_get_addon("test_dictionary"));
@@ -409,7 +399,7 @@ function run_test_12() {
zip.extract("install.rdf", dir);
dir = dir.parent;
dir.append("dictionaries");
- dir.create(AM_Ci.nsIFile.DIRECTORY_TYPE, 0o755);
+ dir.create(AM_Ci.nsIFile.DIRECTORY_TYPE, 0755);
dir.append("ab-CD.dic");
zip.extract("dictionaries/ab-CD.dic", dir);
zip.close();
@@ -452,10 +442,10 @@ function run_test_16() {
startupManager(false);
AddonManager.getAddonByID("ab-CD@dictionaries.addons.mozilla.org",
- callback_soon(function(b1_2) {
+ callback_soon(function(b1) {
// Should still be stopped
do_check_false(HunspellEngine.isDictionaryEnabled("ab-CD.dic"));
- do_check_false(b1_2.isActive);
+ do_check_false(b1.isActive);
shutdownManager();
gAppInfo.inSafeMode = false;
@@ -464,8 +454,8 @@ function run_test_16() {
// Should have started
do_check_true(HunspellEngine.isDictionaryEnabled("ab-CD.dic"));
- AddonManager.getAddonByID("ab-CD@dictionaries.addons.mozilla.org", function(b1_3) {
- b1_3.uninstall();
+ AddonManager.getAddonByID("ab-CD@dictionaries.addons.mozilla.org", function(b1) {
+ b1.uninstall();
do_execute_soon(run_test_17);
});
@@ -481,7 +471,7 @@ function run_test_17() {
let dir = userExtDir.clone();
dir.append("ab-CD@dictionaries.addons.mozilla.org");
- dir.create(AM_Ci.nsIFile.DIRECTORY_TYPE, 0o755);
+ dir.create(AM_Ci.nsIFile.DIRECTORY_TYPE, 0755);
let zip = AM_Cc["@mozilla.org/libjar/zip-reader;1"].
createInstance(AM_Ci.nsIZipReader);
zip.open(do_get_addon("test_dictionary"));
@@ -489,7 +479,7 @@ function run_test_17() {
zip.extract("install.rdf", dir);
dir = dir.parent;
dir.append("dictionaries");
- dir.create(AM_Ci.nsIFile.DIRECTORY_TYPE, 0o755);
+ dir.create(AM_Ci.nsIFile.DIRECTORY_TYPE, 0755);
dir.append("ab-CD.dic");
zip.extract("dictionaries/ab-CD.dic", dir);
zip.close();
@@ -583,8 +573,8 @@ function check_test_23() {
do_check_eq(list.length, 0);
restartManager();
- AddonManager.getAddonByID("ab-CD@dictionaries.addons.mozilla.org", function(b1_2) {
- b1_2.uninstall();
+ AddonManager.getAddonByID("ab-CD@dictionaries.addons.mozilla.org", function(b1) {
+ b1.uninstall();
do_execute_soon(run_test_25);
});
}));
@@ -617,11 +607,11 @@ function run_test_25() {
do_check_false(HunspellEngine.isDictionaryEnabled("ab-CD.dic"));
- AddonManager.getAddonByID("ab-CD@dictionaries.addons.mozilla.org", function(b1_2) {
- do_check_neq(b1_2, null);
- do_check_eq(b1_2.version, "2.0");
- do_check_true(b1_2.isActive);
- do_check_eq(b1_2.pendingOperations, AddonManager.PENDING_NONE);
+ AddonManager.getAddonByID("ab-CD@dictionaries.addons.mozilla.org", function(b1) {
+ do_check_neq(b1, null);
+ do_check_eq(b1.version, "2.0");
+ do_check_true(b1.isActive);
+ do_check_eq(b1.pendingOperations, AddonManager.PENDING_NONE);
do_execute_soon(run_test_26);
});
@@ -650,14 +640,14 @@ function run_test_26() {
do_check_true(HunspellEngine.isDictionaryEnabled("ab-CD.dic"));
- AddonManager.getAddonByID("ab-CD@dictionaries.addons.mozilla.org", function(b1_2) {
- do_check_neq(b1_2, null);
- do_check_eq(b1_2.version, "1.0");
- do_check_true(b1_2.isActive);
- do_check_eq(b1_2.pendingOperations, AddonManager.PENDING_NONE);
+ AddonManager.getAddonByID("ab-CD@dictionaries.addons.mozilla.org", function(b1) {
+ do_check_neq(b1, null);
+ do_check_eq(b1.version, "1.0");
+ do_check_true(b1.isActive);
+ do_check_eq(b1.pendingOperations, AddonManager.PENDING_NONE);
HunspellEngine.deactivate();
- b1_2.uninstall();
+ b1.uninstall();
do_execute_soon(run_test_27);
});
}));
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_distribution.js b/toolkit/mozapps/extensions/test/xpcshell/test_distribution.js
index 720b454cc..9f5bfacca 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_distribution.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_distribution.js
@@ -68,7 +68,7 @@ function setOldModificationTime() {
extension.append("addon1@tests.mozilla.org");
else
extension.append("addon1@tests.mozilla.org.xpi");
- setExtensionModifiedTime(extension, Date.now() - MAKE_FILE_OLD_DIFFERENCE);
+ setExtensionModifiedTime(extension, Date.now - 10000);
startupManager(false);
}
@@ -78,11 +78,9 @@ function run_test() {
run_test_1();
}
-// Tests that on the first startup the add-on gets installed, with now as the
-// profile modifiedTime.
+// Tests that on the first startup the add-on gets installed
function run_test_1() {
- let extension = writeInstallRDFForExtension(addon1_1, distroDir);
- setExtensionModifiedTime(extension, Date.now() - MAKE_FILE_OLD_DIFFERENCE);
+ writeInstallRDFForExtension(addon1_1, distroDir);
startupManager();
@@ -93,15 +91,6 @@ function run_test_1() {
do_check_eq(a1.scope, AddonManager.SCOPE_PROFILE);
do_check_false(a1.foreignInstall);
- // Modification time should be updated when the addon is copied to the
- // profile.
- let testURI = a1.getResourceURI(TEST_UNPACKED ? "install.rdf" : "");
- let testFile = testURI.QueryInterface(Components.interfaces.nsIFileURL).file;
-
- do_check_true(testFile.exists());
- let difference = testFile.lastModifiedTime - Date.now();
- do_check_true(Math.abs(difference) < MAX_TIME_DIFFERENCE);
-
do_execute_soon(run_test_2);
});
}
@@ -165,8 +154,8 @@ function run_test_5() {
restartManager();
- AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1_2) {
- do_check_eq(a1_2, null);
+ AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
+ do_check_eq(a1, null);
do_execute_soon(run_test_6);
});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_dss.js b/toolkit/mozapps/extensions/test/xpcshell/test_dss.js
index b408cc9c7..7b171212a 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_dss.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_dss.js
@@ -6,7 +6,7 @@ Components.utils.import("resource://gre/modules/NetUtil.jsm");
// using a dynamic port in the addon metadata
Components.utils.import("resource://testing-common/httpd.js");
-var gServer = new HttpServer();
+let gServer = new HttpServer();
gServer.start(-1);
gPort = gServer.identity.primaryPort;
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_duplicateplugins.js b/toolkit/mozapps/extensions/test/xpcshell/test_duplicateplugins.js
index 4d1848ea4..bad560306 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_duplicateplugins.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_duplicateplugins.js
@@ -2,9 +2,7 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-Components.utils.import("resource://testing-common/MockRegistrar.jsm");
-
-var Ci = Components.interfaces;
+const Ci = Components.interfaces;
// This verifies that duplicate plugins are coalesced and maintain their ID
// across restarts.
@@ -15,9 +13,7 @@ var PLUGINS = [{
version: "1",
blocklisted: false,
enabledState: Ci.nsIPluginTag.STATE_ENABLED,
- get disabled() {
- return this.enabledState == Ci.nsIPluginTag.STATE_DISABLED;
- },
+ get disabled() this.enabledState == Ci.nsIPluginTag.STATE_DISABLED,
filename: "/home/mozilla/.plugins/dupplugin1.so"
}, {
name: "Duplicate Plugin 1",
@@ -25,9 +21,8 @@ var PLUGINS = [{
version: "1",
blocklisted: false,
enabledState: Ci.nsIPluginTag.STATE_ENABLED,
- get disabled() {
- return this.enabledState == Ci.nsIPluginTag.STATE_DISABLED;
- },
+ get disabled() this.enabledState == Ci.nsIPluginTag.STATE_DISABLED,
+ filename: "",
filename: "/usr/lib/plugins/dupplugin1.so"
}, {
name: "Duplicate Plugin 2",
@@ -35,9 +30,7 @@ var PLUGINS = [{
version: "1",
blocklisted: false,
enabledState: Ci.nsIPluginTag.STATE_ENABLED,
- get disabled() {
- return this.enabledState == Ci.nsIPluginTag.STATE_DISABLED;
- },
+ get disabled() this.enabledState == Ci.nsIPluginTag.STATE_DISABLED,
filename: "/home/mozilla/.plugins/dupplugin2.so"
}, {
name: "Duplicate Plugin 2",
@@ -45,9 +38,8 @@ var PLUGINS = [{
version: "1",
blocklisted: false,
enabledState: Ci.nsIPluginTag.STATE_ENABLED,
- get disabled() {
- return this.enabledState == Ci.nsIPluginTag.STATE_DISABLED;
- },
+ get disabled() this.enabledState == Ci.nsIPluginTag.STATE_DISABLED,
+ filename: "",
filename: "/usr/lib/plugins/dupplugin2.so"
}, {
name: "Non-duplicate Plugin", // 3
@@ -55,9 +47,7 @@ var PLUGINS = [{
version: "1",
blocklisted: false,
enabledState: Ci.nsIPluginTag.STATE_ENABLED,
- get disabled() {
- return this.enabledState == Ci.nsIPluginTag.STATE_DISABLED;
- },
+ get disabled() this.enabledState == Ci.nsIPluginTag.STATE_DISABLED,
filename: "/home/mozilla/.plugins/dupplugin3.so"
}, {
name: "Non-duplicate Plugin", // 4
@@ -65,9 +55,8 @@ var PLUGINS = [{
version: "1",
blocklisted: false,
enabledState: Ci.nsIPluginTag.STATE_ENABLED,
- get disabled() {
- return this.enabledState == Ci.nsIPluginTag.STATE_DISABLED;
- },
+ get disabled() this.enabledState == Ci.nsIPluginTag.STATE_DISABLED,
+ filename: "",
filename: "/usr/lib/plugins/dupplugin4.so"
}, {
name: "Another Non-duplicate Plugin", // 5
@@ -75,9 +64,7 @@ var PLUGINS = [{
version: "1",
blocklisted: false,
enabledState: Ci.nsIPluginTag.STATE_ENABLED,
- get disabled() {
- return this.enabledState == Ci.nsIPluginTag.STATE_DISABLED;
- },
+ get disabled() this.enabledState == Ci.nsIPluginTag.STATE_DISABLED,
filename: "/home/mozilla/.plugins/dupplugin5.so"
}];
@@ -92,12 +79,23 @@ var PluginHost = {
if (iid.equals(Components.interfaces.nsIPluginHost)
|| iid.equals(Components.interfaces.nsISupports))
return this;
-
+
throw Components.results.NS_ERROR_NO_INTERFACE;
}
}
-MockRegistrar.register("@mozilla.org/plugin/host;1", PluginHost);
+var PluginHostFactory = {
+ createInstance: function (outer, iid) {
+ if (outer != null)
+ throw Components.results.NS_ERROR_NO_AGGREGATION;
+ return PluginHost.QueryInterface(iid);
+ }
+};
+
+var registrar = Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar);
+registrar.registerFactory(Components.ID("{721c3e73-969e-474b-a6dc-059fd288c428}"),
+ "Fake Plugin Host",
+ "@mozilla.org/plugin/host;1", PluginHostFactory);
var gPluginIDs = [null, null, null, null, null];
@@ -176,10 +174,10 @@ function run_test_3() {
[PLUGINS[0], PLUGINS[1]] = [PLUGINS[1], PLUGINS[0]];
restartManager();
- AddonManager.getAddonByID(gPluginIDs[0], function(p_2) {
- do_check_neq(p_2, null);
- do_check_eq(p_2.name, "Duplicate Plugin 1");
- do_check_eq(p_2.description, "A duplicate plugin");
+ AddonManager.getAddonByID(gPluginIDs[0], function(p) {
+ do_check_neq(p, null);
+ do_check_eq(p.name, "Duplicate Plugin 1");
+ do_check_eq(p.description, "A duplicate plugin");
do_execute_soon(do_test_finished);
});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_e10s_restartless.js b/toolkit/mozapps/extensions/test/xpcshell/test_e10s_restartless.js
deleted file mode 100644
index 1a3a0e747..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_e10s_restartless.js
+++ /dev/null
@@ -1,429 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-const ID = "bootstrap1@tests.mozilla.org";
-const ID2 = "bootstrap2@tests.mozilla.org";
-
-const APP_STARTUP = 1;
-const ADDON_INSTALL = 5;
-
-function getStartupReason(id) {
- let info = BootstrapMonitor.started.get(id);
- return info ? info.reason : undefined;
-}
-
-BootstrapMonitor.init();
-
-createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
-
-startupManager();
-
-function* check_normal() {
- let install = yield new Promise(resolve => AddonManager.getInstallForFile(do_get_addon("test_bootstrap1_1"), resolve));
- yield promiseCompleteAllInstalls([install]);
- do_check_eq(install.state, AddonManager.STATE_INSTALLED);
- do_check_false(hasFlag(install.addon.pendingOperations, AddonManager.PENDING_INSTALL));
-
- BootstrapMonitor.checkAddonInstalled(ID);
- BootstrapMonitor.checkAddonStarted(ID);
-
- let addon = yield promiseAddonByID(ID);
- do_check_eq(addon, install.addon);
-
- do_check_false(hasFlag(addon.operationsRequiringRestart, AddonManager.OP_NEEDS_RESTART_DISABLE));
- addon.userDisabled = true;
- BootstrapMonitor.checkAddonNotStarted(ID);
- do_check_false(addon.isActive);
- do_check_false(hasFlag(addon.pendingOperations, AddonManager.PENDING_DISABLE));
-
- do_check_false(hasFlag(addon.operationsRequiringRestart, AddonManager.OP_NEEDS_RESTART_ENABLE));
- addon.userDisabled = false;
- BootstrapMonitor.checkAddonStarted(ID);
- do_check_true(addon.isActive);
- do_check_false(hasFlag(addon.pendingOperations, AddonManager.PENDING_ENABLE));
-
- do_check_false(hasFlag(addon.operationsRequiringRestart, AddonManager.OP_NEEDS_RESTART_UNINSTALL));
- addon.uninstall();
- BootstrapMonitor.checkAddonNotStarted(ID);
- BootstrapMonitor.checkAddonNotInstalled(ID);
-
- yield promiseRestartManager();
-}
-
-// Installing the add-on normally doesn't require a restart
-add_task(function*() {
- gAppInfo.browserTabsRemoteAutostart = false;
- Services.prefs.setBoolPref("extensions.e10sBlocksEnabling", false);
-
- yield check_normal();
-});
-
-// Enabling the pref doesn't change anything
-add_task(function*() {
- gAppInfo.browserTabsRemoteAutostart = false;
- Services.prefs.setBoolPref("extensions.e10sBlocksEnabling", true);
-
- yield check_normal();
-});
-
-// Default e10s doesn't change anything
-add_task(function*() {
- gAppInfo.browserTabsRemoteAutostart = true;
- Services.prefs.setBoolPref("extensions.e10sBlocksEnabling", false);
-
- yield check_normal();
-});
-
-// Pref and e10s blocks install
-add_task(function*() {
- gAppInfo.browserTabsRemoteAutostart = true;
- Services.prefs.setBoolPref("extensions.e10sBlocksEnabling", true);
-
- let install = yield new Promise(resolve => AddonManager.getInstallForFile(do_get_addon("test_bootstrap1_1"), resolve));
- yield promiseCompleteAllInstalls([install]);
- do_check_eq(install.state, AddonManager.STATE_INSTALLED);
- do_check_true(hasFlag(install.addon.pendingOperations, AddonManager.PENDING_INSTALL));
-
- let addon = yield promiseAddonByID(ID);
- do_check_eq(addon, null);
-
- yield promiseRestartManager();
-
- BootstrapMonitor.checkAddonInstalled(ID);
- BootstrapMonitor.checkAddonStarted(ID);
- do_check_eq(getStartupReason(ID), ADDON_INSTALL);
-
- addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
-
- do_check_false(hasFlag(addon.operationsRequiringRestart, AddonManager.OP_NEEDS_RESTART_DISABLE));
- addon.userDisabled = true;
- BootstrapMonitor.checkAddonNotStarted(ID);
- do_check_false(addon.isActive);
- do_check_false(hasFlag(addon.pendingOperations, AddonManager.PENDING_DISABLE));
-
- do_check_true(hasFlag(addon.operationsRequiringRestart, AddonManager.OP_NEEDS_RESTART_ENABLE));
- addon.userDisabled = false;
- BootstrapMonitor.checkAddonNotStarted(ID);
- do_check_false(addon.isActive);
- do_check_true(hasFlag(addon.pendingOperations, AddonManager.PENDING_ENABLE));
-
- yield promiseRestartManager();
-
- addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
-
- do_check_true(addon.isActive);
- BootstrapMonitor.checkAddonStarted(ID);
-
- do_check_false(hasFlag(addon.operationsRequiringRestart, AddonManager.OP_NEEDS_RESTART_UNINSTALL));
- addon.uninstall();
- BootstrapMonitor.checkAddonNotStarted(ID);
- BootstrapMonitor.checkAddonNotInstalled(ID);
-
- yield promiseRestartManager();
-});
-
-add_task(function*() {
- gAppInfo.browserTabsRemoteAutostart = true;
- Services.prefs.setBoolPref("extensions.e10sBlocksEnabling", true);
-
- let install = yield new Promise(resolve => AddonManager.getInstallForFile(do_get_addon("test_bootstrap1_1"), resolve));
- yield promiseCompleteAllInstalls([install]);
- do_check_eq(install.state, AddonManager.STATE_INSTALLED);
- do_check_true(hasFlag(install.addon.pendingOperations, AddonManager.PENDING_INSTALL));
-
- let addon = yield promiseAddonByID(ID);
- do_check_eq(addon, null);
-
- yield promiseRestartManager();
-
- // After install and restart we should block.
- let blocked = Services.prefs.getBoolPref("extensions.e10sBlockedByAddons");
- do_check_true(blocked);
-
- BootstrapMonitor.checkAddonInstalled(ID);
- BootstrapMonitor.checkAddonStarted(ID);
- do_check_eq(getStartupReason(ID), ADDON_INSTALL);
-
- addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
-
- do_check_false(hasFlag(addon.operationsRequiringRestart, AddonManager.OP_NEEDS_RESTART_DISABLE));
- addon.userDisabled = true;
- BootstrapMonitor.checkAddonNotStarted(ID);
- do_check_false(addon.isActive);
- do_check_false(hasFlag(addon.pendingOperations, AddonManager.PENDING_DISABLE));
- do_check_true(hasFlag(addon.operationsRequiringRestart, AddonManager.OP_NEEDS_RESTART_ENABLE));
-
- yield promiseRestartManager();
-
- // After disable and restart we should not block.
- blocked = Services.prefs.getBoolPref("extensions.e10sBlockedByAddons");
- do_check_false(blocked);
-
- addon = yield promiseAddonByID(ID);
- addon.userDisabled = false;
- BootstrapMonitor.checkAddonNotStarted(ID);
- do_check_false(addon.isActive);
- do_check_true(hasFlag(addon.pendingOperations, AddonManager.PENDING_ENABLE));
-
- yield promiseRestartManager();
-
- // After re-enable and restart we should block.
- blocked = Services.prefs.getBoolPref("extensions.e10sBlockedByAddons");
- do_check_true(blocked);
-
- addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
-
- do_check_true(addon.isActive);
- BootstrapMonitor.checkAddonStarted(ID);
- // This should probably be ADDON_ENABLE, but its not easy to make
- // that happen. See bug 1304392 for discussion.
- do_check_eq(getStartupReason(ID), APP_STARTUP);
-
- do_check_false(hasFlag(addon.operationsRequiringRestart, AddonManager.OP_NEEDS_RESTART_UNINSTALL));
- addon.uninstall();
- BootstrapMonitor.checkAddonNotStarted(ID);
- BootstrapMonitor.checkAddonNotInstalled(ID);
-
- yield promiseRestartManager();
-
- // After uninstall and restart we should not block.
- blocked = Services.prefs.getBoolPref("extensions.e10sBlockedByAddons");
- do_check_false(blocked);
-
- restartManager();
-});
-
-add_task(function*() {
- gAppInfo.browserTabsRemoteAutostart = true;
- Services.prefs.setBoolPref("extensions.e10sBlocksEnabling", true);
-
- let install1 = yield new Promise(resolve => AddonManager.getInstallForFile(do_get_addon("test_bootstrap1_1"), resolve));
- let install2 = yield new Promise(resolve => AddonManager.getInstallForFile(do_get_addon("test_bootstrap2_1"), resolve));
- yield promiseCompleteAllInstalls([install1, install2]);
- do_check_eq(install1.state, AddonManager.STATE_INSTALLED);
- do_check_eq(install2.state, AddonManager.STATE_INSTALLED);
- do_check_true(hasFlag(install1.addon.pendingOperations, AddonManager.PENDING_INSTALL));
- do_check_true(hasFlag(install2.addon.pendingOperations, AddonManager.PENDING_INSTALL));
-
- let addon = yield promiseAddonByID(ID);
- let addon2 = yield promiseAddonByID(ID2);
-
- do_check_eq(addon, null);
- do_check_eq(addon2, null);
-
- yield promiseRestartManager();
-
- // After install and restart we should block.
- let blocked = Services.prefs.getBoolPref("extensions.e10sBlockedByAddons");
- do_check_true(blocked);
-
- BootstrapMonitor.checkAddonInstalled(ID);
- BootstrapMonitor.checkAddonStarted(ID);
- do_check_eq(getStartupReason(ID), ADDON_INSTALL);
-
- BootstrapMonitor.checkAddonInstalled(ID2);
- BootstrapMonitor.checkAddonStarted(ID2);
- do_check_eq(getStartupReason(ID2), ADDON_INSTALL);
-
- addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
- addon2 = yield promiseAddonByID(ID2);
- do_check_neq(addon2, null);
-
- do_check_false(hasFlag(addon.operationsRequiringRestart, AddonManager.OP_NEEDS_RESTART_DISABLE));
- addon.userDisabled = true;
- BootstrapMonitor.checkAddonNotStarted(ID);
- do_check_false(addon.isActive);
- do_check_false(hasFlag(addon.pendingOperations, AddonManager.PENDING_DISABLE));
- do_check_true(hasFlag(addon.operationsRequiringRestart, AddonManager.OP_NEEDS_RESTART_ENABLE));
-
- yield promiseRestartManager();
-
- // After disable one addon and restart we should block.
- blocked = Services.prefs.getBoolPref("extensions.e10sBlockedByAddons");
- do_check_true(blocked);
-
- addon2 = yield promiseAddonByID(ID2);
-
- do_check_false(hasFlag(addon2.operationsRequiringRestart, AddonManager.OP_NEEDS_RESTART_DISABLE));
- addon2.userDisabled = true;
- BootstrapMonitor.checkAddonNotStarted(ID2);
- do_check_false(addon2.isActive);
- do_check_false(hasFlag(addon2.pendingOperations, AddonManager.PENDING_DISABLE));
- do_check_true(hasFlag(addon2.operationsRequiringRestart, AddonManager.OP_NEEDS_RESTART_ENABLE));
-
- yield promiseRestartManager();
-
- // After disable both addons and restart we should not block.
- blocked = Services.prefs.getBoolPref("extensions.e10sBlockedByAddons");
- do_check_false(blocked);
-
- addon = yield promiseAddonByID(ID);
- addon.userDisabled = false;
- BootstrapMonitor.checkAddonNotStarted(ID);
- do_check_false(addon.isActive);
- do_check_true(hasFlag(addon.pendingOperations, AddonManager.PENDING_ENABLE));
-
- yield promiseRestartManager();
-
- // After re-enable one addon and restart we should block.
- blocked = Services.prefs.getBoolPref("extensions.e10sBlockedByAddons");
- do_check_true(blocked);
-
- addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
-
- do_check_true(addon.isActive);
- BootstrapMonitor.checkAddonStarted(ID);
- // Bug 1304392 again (see comment above)
- do_check_eq(getStartupReason(ID), APP_STARTUP);
-
- do_check_false(hasFlag(addon.operationsRequiringRestart, AddonManager.OP_NEEDS_RESTART_UNINSTALL));
- addon.uninstall();
- BootstrapMonitor.checkAddonNotStarted(ID);
- BootstrapMonitor.checkAddonNotInstalled(ID);
-
- yield promiseRestartManager();
-
- // After uninstall the only enabled addon and restart we should not block.
- blocked = Services.prefs.getBoolPref("extensions.e10sBlockedByAddons");
- do_check_false(blocked);
-
- addon2 = yield promiseAddonByID(ID2);
- addon2.uninstall();
-
- restartManager();
-});
-
-// Check that the rollout policy sets work as expected
-add_task(function*() {
- gAppInfo.browserTabsRemoteAutostart = true;
- Services.prefs.setBoolPref("extensions.e10sBlocksEnabling", true);
- Services.prefs.setCharPref("extensions.e10s.rollout.policy", "xpcshell-test");
-
- // Both 'bootstrap1' and 'bootstrap2' addons are listed in the allowed policy
- // set, so they should install and start normally.
- yield check_normal();
-
- // Check that the two add-ons can be installed together correctly as
- // check_normal() only perform checks on bootstrap1.
- let install1 = yield new Promise(resolve => AddonManager.getInstallForFile(do_get_addon("test_bootstrap1_1"), resolve));
- let install2 = yield new Promise(resolve => AddonManager.getInstallForFile(do_get_addon("test_bootstrap2_1"), resolve));
- yield promiseCompleteAllInstalls([install1, install2]);
-
- do_check_eq(install1.state, AddonManager.STATE_INSTALLED);
- do_check_eq(install2.state, AddonManager.STATE_INSTALLED);
- do_check_false(hasFlag(install1.addon.pendingOperations, AddonManager.PENDING_INSTALL));
- do_check_false(hasFlag(install2.addon.pendingOperations, AddonManager.PENDING_INSTALL));
-
- let addon = yield promiseAddonByID(ID);
- let addon2 = yield promiseAddonByID(ID2);
-
- do_check_neq(addon, null);
- do_check_neq(addon2, null);
-
- BootstrapMonitor.checkAddonInstalled(ID);
- BootstrapMonitor.checkAddonStarted(ID);
-
- BootstrapMonitor.checkAddonInstalled(ID2);
- BootstrapMonitor.checkAddonStarted(ID2);
-
- yield promiseRestartManager();
-
- // After install and restart e10s should not be blocked.
- let blocked = Services.prefs.getBoolPref("extensions.e10sBlockedByAddons");
- do_check_false(blocked);
-
- // Check that adding bootstrap2 to the blocklist will trigger a disable of e10s.
- Services.prefs.setCharPref("extensions.e10s.rollout.blocklist", ID2);
- blocked = Services.prefs.getBoolPref("extensions.e10sBlockedByAddons");
- do_check_true(blocked);
-
- yield promiseRestartManager();
-
- // Check that after restarting, e10s continues to be blocked.
- blocked = Services.prefs.getBoolPref("extensions.e10sBlockedByAddons");
- do_check_true(blocked);
-
- // Check that uninstalling bootstrap2 (which is in the blocklist) will
- // cause e10s to be re-enabled.
- addon2 = yield promiseAddonByID(ID2);
- do_check_false(hasFlag(addon2.operationsRequiringRestart, AddonManager.OP_NEEDS_RESTART_UNINSTALL));
- addon2.uninstall();
- BootstrapMonitor.checkAddonNotStarted(ID2);
- BootstrapMonitor.checkAddonNotInstalled(ID2);
-
- yield promiseRestartManager();
-
- // After uninstall the blocklisted addon and restart we should not block.
- blocked = Services.prefs.getBoolPref("extensions.e10sBlockedByAddons");
- do_check_false(blocked);
-
-
- // Let's perform similar checks again, now that bootstrap2 is in the blocklist.
- // The bootstrap1 add-on should install and start correctly, but bootstrap2 should not.
- addon = yield promiseAddonByID(ID);
- addon.uninstall();
- BootstrapMonitor.checkAddonNotStarted(ID);
- BootstrapMonitor.checkAddonNotInstalled(ID);
-
- yield promiseRestartManager();
-
- install1 = yield new Promise(resolve => AddonManager.getInstallForFile(do_get_addon("test_bootstrap1_1"), resolve));
- install2 = yield new Promise(resolve => AddonManager.getInstallForFile(do_get_addon("test_bootstrap2_1"), resolve));
- yield promiseCompleteAllInstalls([install1, install2]);
-
- do_check_eq(install1.state, AddonManager.STATE_INSTALLED);
- do_check_eq(install2.state, AddonManager.STATE_INSTALLED);
- do_check_false(hasFlag(install1.addon.pendingOperations, AddonManager.PENDING_INSTALL));
- do_check_true(hasFlag(install2.addon.pendingOperations, AddonManager.PENDING_INSTALL));
-
- addon = yield promiseAddonByID(ID);
- addon2 = yield promiseAddonByID(ID2);
-
- do_check_neq(addon, null);
- do_check_eq(addon2, null);
-
- BootstrapMonitor.checkAddonInstalled(ID);
- BootstrapMonitor.checkAddonStarted(ID);
-
- BootstrapMonitor.checkAddonNotInstalled(ID2);
- BootstrapMonitor.checkAddonNotStarted(ID2);
-
- yield promiseRestartManager();
-
- blocked = Services.prefs.getBoolPref("extensions.e10sBlockedByAddons");
- do_check_true(blocked);
-
- // Clean-up
- addon = yield promiseAddonByID(ID);
- addon2 = yield promiseAddonByID(ID2);
-
- addon.uninstall();
- BootstrapMonitor.checkAddonNotStarted(ID);
- BootstrapMonitor.checkAddonNotInstalled(ID);
-
- addon2.uninstall();
- BootstrapMonitor.checkAddonNotStarted(ID2);
- BootstrapMonitor.checkAddonNotInstalled(ID2);
-
- Services.prefs.clearUserPref("extensions.e10s.rollout.policy");
- Services.prefs.clearUserPref("extensions.e10s.rollout.blocklist");
-
- yield promiseRestartManager();
-});
-
-// The hotfix is unaffected
-add_task(function*() {
- gAppInfo.browserTabsRemoteAutostart = true;
- Services.prefs.setBoolPref("extensions.e10sBlocksEnabling", true);
- Services.prefs.setCharPref("extensions.hotfix.id", ID);
- Services.prefs.setBoolPref("extensions.hotfix.cert.checkAttributes", false);
-
- yield check_normal();
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_error.js b/toolkit/mozapps/extensions/test/xpcshell/test_error.js
index 11a465b55..2184399e2 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_error.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_error.js
@@ -66,7 +66,7 @@ function run_test_4() {
}
// Checks that a file that doesn't exist shows an error
-function run_test_5() {
+function run_test_4() {
let file = do_get_file("data");
file.append("missing.xpi");
AddonManager.getInstallForFile(file, function(install) {
@@ -74,12 +74,12 @@ function run_test_5() {
do_check_eq(install.state, AddonManager.STATE_DOWNLOAD_FAILED);
do_check_eq(install.error, AddonManager.ERROR_NETWORK_FAILURE);
- run_test_6();
+ run_test_5();
});
}
// Checks that an add-on with an illegal ID shows an error
-function run_test_6() {
+function run_test_5() {
AddonManager.getInstallForFile(do_get_addon("test_bug567173"), function(install) {
do_check_neq(install, null);
do_check_eq(install.state, AddonManager.STATE_DOWNLOAD_FAILED);
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_experiment.js b/toolkit/mozapps/extensions/test/xpcshell/test_experiment.js
index 3dcd83da8..25172749d 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_experiment.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_experiment.js
@@ -1,131 +1,104 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
-var scope = Components.utils.import("resource://gre/modules/addons/XPIProvider.jsm");
+let scope = Components.utils.import("resource://gre/modules/addons/XPIProvider.jsm");
const XPIProvider = scope.XPIProvider;
-const ID = "experiment1@tests.mozilla.org";
-
-var gIsNightly = false;
function run_test() {
- BootstrapMonitor.init();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
startupManager();
- gIsNightly = isNightlyChannel();
-
run_next_test();
}
-add_task(function* test_experiment() {
- BootstrapMonitor.checkAddonNotInstalled(ID);
- BootstrapMonitor.checkAddonNotStarted(ID);
-
- yield promiseInstallAllFiles([do_get_addon("test_experiment1")]);
-
- BootstrapMonitor.checkAddonInstalled(ID, "1.0");
- BootstrapMonitor.checkAddonNotStarted(ID);
-
- let addon = yield promiseAddonByID(ID);
- Assert.ok(addon, "Addon is found.");
-
- Assert.ok(addon.userDisabled, "Experiments are userDisabled by default.");
- Assert.ok(!addon.appDisabled, "Experiments are not appDisabled by compatibility.");
- Assert.equal(addon.isActive, false, "Add-on is not active.");
- Assert.equal(addon.updateURL, null, "No updateURL for experiments.");
- Assert.equal(addon.applyBackgroundUpdates, AddonManager.AUTOUPDATE_DISABLE,
- "Background updates are disabled.");
- Assert.equal(addon.permissions, AddonManager.PERM_CAN_UNINSTALL + AddonManager.PERM_CAN_ENABLE,
- "Permissions are minimal.");
- Assert.ok(!(addon.pendingOperations & AddonManager.PENDING_ENABLE),
- "Should not be pending enable");
- Assert.ok(!(addon.pendingOperations & AddonManager.PENDING_DISABLE),
- "Should not be pending disable");
-
- // Setting applyBackgroundUpdates should not work.
- addon.applyBackgroundUpdates = AddonManager.AUTOUPDATE_ENABLE;
- Assert.equal(addon.applyBackgroundUpdates, AddonManager.AUTOUPDATE_DISABLE,
- "Setting applyBackgroundUpdates shouldn't do anything.");
-
- let noCompatibleCalled = false;
- let noUpdateCalled = false;
- let finishedCalled = false;
-
- let listener = {
- onNoCompatibilityUpdateAvailable: () => { noCompatibleCalled = true; },
- onNoUpdateAvailable: () => { noUpdateCalled = true; },
- onUpdateFinished: () => { finishedCalled = true; },
- };
-
- addon.findUpdates(listener, "testing", null, null);
- Assert.ok(noCompatibleCalled, "Listener called.");
- Assert.ok(noUpdateCalled, "Listener called.");
- Assert.ok(finishedCalled, "Listener called.");
+add_test(function test_experiment() {
+ AddonManager.getInstallForFile(do_get_addon("test_experiment1"), (install) => {
+ completeAllInstalls([install], () => {
+ AddonManager.getAddonByID("experiment1@tests.mozilla.org", (addon) => {
+ Assert.ok(addon, "Addon is found.");
+
+ Assert.ok(addon.userDisabled, "Experiments are userDisabled by default.");
+ Assert.equal(addon.isActive, false, "Add-on is not active.");
+ Assert.equal(addon.updateURL, null, "No updateURL for experiments.");
+ Assert.equal(addon.applyBackgroundUpdates, AddonManager.AUTOUPDATE_DISABLE,
+ "Background updates are disabled.");
+ Assert.equal(addon.permissions, AddonManager.PERM_CAN_UNINSTALL,
+ "Permissions are minimal.");
+ Assert.ok(!(addon.pendingOperations & AddonManager.PENDING_ENABLE),
+ "Should not be pending enable");
+ Assert.ok(!(addon.pendingOperations & AddonManager.PENDING_DISABLE),
+ "Should not be pending disable");
+
+ // Setting applyBackgroundUpdates should not work.
+ addon.applyBackgroundUpdates = AddonManager.AUTOUPDATE_ENABLE;
+ Assert.equal(addon.applyBackgroundUpdates, AddonManager.AUTOUPDATE_DISABLE,
+ "Setting applyBackgroundUpdates shouldn't do anything.");
+
+ let noCompatibleCalled = false;
+ let noUpdateCalled = false;
+ let finishedCalled = false;
+
+ let listener = {
+ onNoCompatibilityUpdateAvailable: () => { noCompatibleCalled = true; },
+ onNoUpdateAvailable: () => { noUpdateCalled = true; },
+ onUpdateFinished: () => { finishedCalled = true; },
+ };
+
+ addon.findUpdates(listener, "testing", null, null);
+ Assert.ok(noCompatibleCalled, "Listener called.");
+ Assert.ok(noUpdateCalled, "Listener called.");
+ Assert.ok(finishedCalled, "Listener called.");
+
+ run_next_test();
+ });
+ });
+ });
});
// Changes to userDisabled should not be persisted to the database.
-add_task(function* test_userDisabledNotPersisted() {
- let addon = yield promiseAddonByID(ID);
- Assert.ok(addon, "Add-on is found.");
- Assert.ok(addon.userDisabled, "Add-on is user disabled.");
-
- let promise = promiseAddonEvent("onEnabled");
- addon.userDisabled = false;
- let [addon2] = yield promise;
-
- BootstrapMonitor.checkAddonInstalled(ID, "1.0");
- BootstrapMonitor.checkAddonStarted(ID, "1.0");
-
- Assert.equal(addon2.id, addon.id, "Changed add-on matches expected.");
- Assert.equal(addon2.userDisabled, false, "Add-on is no longer user disabled.");
- Assert.ok(addon2.isActive, "Add-on is active.");
-
- Assert.ok(ID in XPIProvider.bootstrappedAddons,
- "Experiment add-on listed in XPIProvider bootstrapped list.");
-
- addon = yield promiseAddonByID(ID);
- Assert.ok(addon, "Add-on retrieved.");
- Assert.equal(addon.userDisabled, false, "Add-on is still enabled after API retrieve.");
- Assert.ok(addon.isActive, "Add-on is still active.");
- Assert.ok(!(addon.pendingOperations & AddonManager.PENDING_ENABLE),
- "Should not be pending enable");
- Assert.ok(!(addon.pendingOperations & AddonManager.PENDING_DISABLE),
- "Should not be pending disable");
-
- // Now when we restart the manager the add-on should revert state.
- yield promiseRestartManager();
- let persisted = JSON.parse(Services.prefs.getCharPref("extensions.bootstrappedAddons"));
- Assert.ok(!(ID in persisted),
- "Experiment add-on not persisted to bootstrappedAddons.");
-
- BootstrapMonitor.checkAddonInstalled(ID, "1.0");
- BootstrapMonitor.checkAddonNotStarted(ID);
-
- addon = yield promiseAddonByID(ID);
- Assert.ok(addon, "Add-on retrieved.");
- Assert.ok(addon.userDisabled, "Add-on is disabled after restart.");
- Assert.equal(addon.isActive, false, "Add-on is not active after restart.");
- addon.uninstall();
-
- BootstrapMonitor.checkAddonNotInstalled(ID);
- BootstrapMonitor.checkAddonNotStarted(ID);
-});
-
-add_task(function* test_checkCompatibility() {
- if (gIsNightly)
- Services.prefs.setBoolPref("extensions.checkCompatibility.nightly", false);
- else
- Services.prefs.setBoolPref("extensions.checkCompatibility.1", false);
-
- yield promiseRestartManager();
-
- yield promiseInstallAllFiles([do_get_addon("test_experiment1")]);
- let addon = yield promiseAddonByID(ID);
-
- BootstrapMonitor.checkAddonInstalled(ID, "1.0");
- BootstrapMonitor.checkAddonNotStarted(ID);
-
- Assert.ok(addon, "Add-on is found.");
- Assert.ok(addon.userDisabled, "Add-on is user disabled.");
- Assert.ok(!addon.appDisabled, "Add-on is not app disabled.");
+add_test(function test_userDisabledNotPersisted() {
+ AddonManager.getAddonByID("experiment1@tests.mozilla.org", (addon) => {
+ Assert.ok(addon, "Add-on is found.");
+ Assert.ok(addon.userDisabled, "Add-on is user disabled.");
+
+ let listener = {
+ onEnabled: (addon2) => {
+ AddonManager.removeAddonListener(listener);
+
+ Assert.equal(addon2.id, addon.id, "Changed add-on matches expected.");
+ Assert.equal(addon2.userDisabled, false, "Add-on is no longer user disabled.");
+ Assert.ok(addon2.isActive, "Add-on is active.");
+
+ Assert.ok("experiment1@tests.mozilla.org" in XPIProvider.bootstrappedAddons,
+ "Experiment add-on listed in XPIProvider bootstrapped list.");
+
+ AddonManager.getAddonByID("experiment1@tests.mozilla.org", (addon) => {
+ Assert.ok(addon, "Add-on retrieved.");
+ Assert.equal(addon.userDisabled, false, "Add-on is still enabled after API retrieve.");
+ Assert.ok(addon.isActive, "Add-on is still active.");
+ Assert.ok(!(addon.pendingOperations & AddonManager.PENDING_ENABLE),
+ "Should not be pending enable");
+ Assert.ok(!(addon.pendingOperations & AddonManager.PENDING_DISABLE),
+ "Should not be pending disable");
+
+ // Now when we restart the manager the add-on should revert state.
+ restartManager();
+ let persisted = JSON.parse(Services.prefs.getCharPref("extensions.bootstrappedAddons"));
+ Assert.ok(!("experiment1@tests.mozilla.org" in persisted),
+ "Experiment add-on not persisted to bootstrappedAddons.");
+
+ AddonManager.getAddonByID("experiment1@tests.mozilla.org", (addon) => {
+ Assert.ok(addon, "Add-on retrieved.");
+ Assert.ok(addon.userDisabled, "Add-on is disabled after restart.");
+ Assert.equal(addon.isActive, false, "Add-on is not active after restart.");
+
+ run_next_test();
+ });
+ });
+ },
+ };
+
+ AddonManager.addAddonListener(listener);
+ addon.userDisabled = false;
+ });
});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_ext_management.js b/toolkit/mozapps/extensions/test/xpcshell/test_ext_management.js
deleted file mode 100644
index a3b3f477c..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_ext_management.js
+++ /dev/null
@@ -1,137 +0,0 @@
-"use strict";
-
-add_task(function* setup() {
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "48", "48");
- startupManager();
-});
-
-/* eslint-disable no-undef */
-// Shared background function for getSelf tests
-function backgroundGetSelf() {
- browser.management.getSelf().then(extInfo => {
- browser.test.sendMessage("management-getSelf", extInfo);
- }, error => {
- browser.test.notifyFail(`getSelf rejected with error: ${error}`);
- });
-}
-/* eslint-enable no-undef */
-
-add_task(function* test_management_get_self_complete() {
- const id = "get_self_test_complete@tests.mozilla.com";
- const permissions = ["management", "cookies"];
- const hostPermissions = ["*://example.org/", "https://foo.example.org/"];
-
- let manifest = {
- applications: {
- gecko: {
- id,
- update_url: "https://updates.mozilla.com/",
- },
- },
- name: "test extension name",
- short_name: "test extension short name",
- description: "test extension description",
- version: "1.0",
- homepage_url: "http://www.example.com/",
- options_ui: {
- "page": "get_self_options.html",
- },
- icons: {
- "16": "icons/icon-16.png",
- "48": "icons/icon-48.png",
- },
- permissions: [...permissions, ...hostPermissions],
- };
-
- let extension = ExtensionTestUtils.loadExtension({
- manifest,
- background: backgroundGetSelf,
- useAddonManager: "temporary",
- });
- yield extension.startup();
- let extInfo = yield extension.awaitMessage("management-getSelf");
-
- equal(extInfo.id, id, "getSelf returned the expected id");
- equal(extInfo.installType, "development", "getSelf returned the expected installType");
- for (let prop of ["name", "description", "version"]) {
- equal(extInfo[prop], manifest[prop], `getSelf returned the expected ${prop}`);
- }
- equal(extInfo.shortName, manifest.short_name, "getSelf returned the expected shortName");
- equal(extInfo.mayDisable, true, "getSelf returned the expected value for mayDisable");
- equal(extInfo.enabled, true, "getSelf returned the expected value for enabled");
- equal(extInfo.homepageUrl, manifest.homepage_url, "getSelf returned the expected homepageUrl");
- equal(extInfo.updateUrl, manifest.applications.gecko.update_url, "getSelf returned the expected updateUrl");
- ok(extInfo.optionsUrl.endsWith(manifest.options_ui.page), "getSelf returned the expected optionsUrl");
- for (let [index, size] of Object.keys(manifest.icons).sort().entries()) {
- equal(extInfo.icons[index].size, +size, "getSelf returned the expected icon size");
- equal(extInfo.icons[index].url, manifest.icons[size], "getSelf returned the expected icon url");
- }
- deepEqual(extInfo.permissions.sort(), permissions.sort(), "getSelf returned the expected permissions");
- deepEqual(extInfo.hostPermissions.sort(), hostPermissions.sort(), "getSelf returned the expected hostPermissions");
- equal(extInfo.installType, "development", "getSelf returned the expected installType");
- yield extension.unload();
-});
-
-add_task(function* test_management_get_self_minimal() {
- const id = "get_self_test_minimal@tests.mozilla.com";
-
- let manifest = {
- applications: {
- gecko: {
- id,
- },
- },
- name: "test extension name",
- version: "1.0",
- };
-
- let extension = ExtensionTestUtils.loadExtension({
- manifest,
- background: backgroundGetSelf,
- useAddonManager: "temporary",
- });
- yield extension.startup();
- let extInfo = yield extension.awaitMessage("management-getSelf");
-
- equal(extInfo.id, id, "getSelf returned the expected id");
- equal(extInfo.installType, "development", "getSelf returned the expected installType");
- for (let prop of ["name", "version"]) {
- equal(extInfo[prop], manifest[prop], `getSelf returned the expected ${prop}`);
- }
- for (let prop of ["shortName", "description", "optionsUrl"]) {
- equal(extInfo[prop], "", `getSelf returned the expected ${prop}`);
- }
- for (let prop of ["homepageUrl", " updateUrl", "icons"]) {
- equal(Reflect.getOwnPropertyDescriptor(extInfo, prop), undefined, `getSelf did not return a ${prop} property`);
- }
- for (let prop of ["permissions", "hostPermissions"]) {
- deepEqual(extInfo[prop], [], `getSelf returned the expected ${prop}`);
- }
- yield extension.unload();
-});
-
-add_task(function* test_management_get_self_permanent() {
- const id = "get_self_test_permanent@tests.mozilla.com";
-
- let manifest = {
- applications: {
- gecko: {
- id,
- },
- },
- name: "test extension name",
- version: "1.0",
- };
-
- let extension = ExtensionTestUtils.loadExtension({
- manifest,
- background: backgroundGetSelf,
- useAddonManager: "permanent",
- });
- yield extension.startup();
- let extInfo = yield extension.awaitMessage("management-getSelf");
-
- equal(extInfo.id, id, "getSelf returned the expected id");
- equal(extInfo.installType, "normal", "getSelf returned the expected installType");
- yield extension.unload();
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_filepointer.js b/toolkit/mozapps/extensions/test/xpcshell/test_filepointer.js
index 406489e40..cb661e495 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_filepointer.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_filepointer.js
@@ -40,7 +40,7 @@ var addon2 = {
const profileDir = gProfD.clone();
profileDir.append("extensions");
-profileDir.create(AM_Ci.nsIFile.DIRECTORY_TYPE, 0o755);
+profileDir.create(AM_Ci.nsIFile.DIRECTORY_TYPE, 0755);
const sourceDir = gProfD.clone();
sourceDir.append("source");
@@ -123,7 +123,7 @@ function run_test_1() {
do_check_eq(uri.spec, rootUri);
uri = a1.getResourceURI("install.rdf");
do_check_eq(uri.spec, rootUri + "install.rdf");
-
+
// Check that upgrade is disabled for addons installed by file-pointers.
do_check_eq(a1.permissions & AddonManager.PERM_CAN_UPGRADE, 0);
run_test_2();
@@ -247,9 +247,9 @@ function run_test_5() {
restartManager();
AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
- "addon2@tests.mozilla.org"], function([a1_2, a2_2]) {
- do_check_eq(a1_2, null);
- do_check_eq(a2_2, null);
+ "addon2@tests.mozilla.org"], function([a1, a2]) {
+ do_check_eq(a1, null);
+ do_check_eq(a2, null);
let source = sourceDir.clone();
source.append(addon1.id);
@@ -283,8 +283,8 @@ function run_test_6() {
restartManager();
- AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1_2) {
- do_check_eq(a1_2, null);
+ AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
+ do_check_eq(a1, null);
do_execute_soon(run_test_7);
});
@@ -309,11 +309,11 @@ function run_test_7() {
restartManager();
- AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1_2) {
- do_check_neq(a1_2, null);
- do_check_eq(a1_2.version, "2.0");
+ AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
+ do_check_neq(a1, null);
+ do_check_eq(a1.version, "2.0");
- a1_2.uninstall();
+ a1.uninstall();
do_execute_soon(run_test_8);
});
@@ -336,11 +336,11 @@ function run_test_8() {
restartManager();
- AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1_2) {
- do_check_neq(a1_2, null);
- do_check_eq(a1_2.version, "2.0");
+ AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
+ do_check_neq(a1, null);
+ do_check_eq(a1.version, "2.0");
- a1_2.uninstall();
+ a1.uninstall();
do_execute_soon(run_test_9);
});
@@ -364,8 +364,8 @@ function run_test_9() {
restartManager();
- AddonManager.getAddonByID(addon1.id, function(a1_2) {
- do_check_eq(a1_2, null);
+ AddonManager.getAddonByID(addon1.id, function(a1) {
+ do_check_eq(a1, null);
let pointer = profileDir.clone();
pointer.append(addon1.id);
@@ -395,7 +395,7 @@ function run_test_10() {
do_check_eq(uri.spec, rootUri);
uri = a1.getResourceURI("install.rdf");
do_check_eq(uri.spec, rootUri + "install.rdf");
-
+
// Check that upgrade is disabled for addons installed by file-pointers.
do_check_eq(a1.permissions & AddonManager.PERM_CAN_UPGRADE, 0);
end_test();
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_fuel.js b/toolkit/mozapps/extensions/test/xpcshell/test_fuel.js
index 0c3035f76..800933220 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_fuel.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_fuel.js
@@ -101,7 +101,7 @@ function run_test() {
// PREF TESTING
// Reset the install event preference, so that we can test it again later
- // inspector.prefs.get("install-event-fired").reset();
+ //inspector.prefs.get("install-event-fired").reset();
// test the value of the preference root
do_check_eq(extensions.all[0].prefs.root, "extensions.addon1@tests.mozilla.org.");
@@ -129,7 +129,7 @@ function run_test() {
// test resetting a pref [since there is no default value, the pref should disappear]
inspector.prefs.get(testdata.dummy).reset();
- itemValue = inspector.prefs.getValue(testdata.dummy, "default");
+ var itemValue = inspector.prefs.getValue(testdata.dummy, "default");
do_check_eq(itemValue, "default");
// test to see if a non-existant property exists
@@ -141,7 +141,6 @@ function run_test() {
});
}
-var gLastEvent;
function onGenericEvent(event) {
gLastEvent = event.type;
}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_getresource.js b/toolkit/mozapps/extensions/test/xpcshell/test_getresource.js
index c83638d54..4dce15aec 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_getresource.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_getresource.js
@@ -76,9 +76,9 @@ function run_test() {
}
AddonManager.getInstallForFile(do_get_addon("test_getresource"),
- callback_soon(function(aInstall_2) {
+ callback_soon(function(aInstall) {
do_check_false(a1.hasResource("icon.png"));
- do_check_true(aInstall_2.addon.hasResource("icon.png"));
+ do_check_true(aInstall.addon.hasResource("icon.png"));
restartManager();
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Device.js b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Device.js
index 9b0eb54a7..5f781edf4 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Device.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Device.js
@@ -2,14 +2,11 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-// This should eventually be moved to head_addons.js
-var { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
-
// Test whether a machine which differs only on device ID, but otherwise
// exactly matches the blacklist entry, is not blocked.
// Uses test_gfxBlacklist.xml
-Cu.import("resource://testing-common/httpd.js");
+Components.utils.import("resource://testing-common/httpd.js");
var gTestserver = new HttpServer();
gTestserver.start(-1);
@@ -17,8 +14,8 @@ gPort = gTestserver.identity.primaryPort;
mapFile("/data/test_gfxBlacklist.xml", gTestserver);
function get_platform() {
- var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
- .getService(Ci.nsIXULRuntime);
+ var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
+ .getService(Components.interfaces.nsIXULRuntime);
return xulRuntime.OS;
}
@@ -32,7 +29,12 @@ function load_blocklist(file) {
// Performs the initial setup
function run_test() {
- var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
+ try {
+ var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
+ } catch (e) {
+ do_test_finished();
+ return;
+ }
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
@@ -58,7 +60,7 @@ function run_test() {
case "Darwin":
gfxInfo.spoofVendorID("0xabcd");
gfxInfo.spoofDeviceID("0x9876");
- gfxInfo.spoofOSVersion(0x1090);
+ gfxInfo.spoofOSVersion(0x1050);
break;
case "Android":
gfxInfo.spoofVendorID("abcd");
@@ -80,9 +82,6 @@ function run_test() {
status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS);
do_check_eq(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
- status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_CANVAS2D_ACCELERATION);
- do_check_eq(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
-
gTestserver.stop(do_test_finished);
}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_DriverNew.js b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_DriverNew.js
index f8b783ff2..802fe11e2 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_DriverNew.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_DriverNew.js
@@ -2,14 +2,11 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-// This should eventually be moved to head_addons.js
-var { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
-
// Test whether a new-enough driver bypasses the blacklist, even if the rest of
// the attributes match the blacklist entry.
// Uses test_gfxBlacklist.xml
-Cu.import("resource://testing-common/httpd.js");
+Components.utils.import("resource://testing-common/httpd.js");
var gTestserver = new HttpServer();
gTestserver.start(-1);
@@ -17,8 +14,8 @@ gPort = gTestserver.identity.primaryPort;
mapFile("/data/test_gfxBlacklist.xml", gTestserver);
function get_platform() {
- var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
- .getService(Ci.nsIXULRuntime);
+ var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
+ .getService(Components.interfaces.nsIXULRuntime);
return xulRuntime.OS;
}
@@ -32,7 +29,12 @@ function load_blocklist(file) {
// Performs the initial setup
function run_test() {
- var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
+ try {
+ var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
+ } catch (e) {
+ do_test_finished();
+ return;
+ }
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverNew.js b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverNew.js
index 1b3410e87..08e87c38c 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverNew.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverNew.js
@@ -2,14 +2,11 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-// This should eventually be moved to head_addons.js
-var { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
-
// Test whether a machine which is newer than the equal
// blacklist entry is allowed.
// Uses test_gfxBlacklist.xml
-Cu.import("resource://testing-common/httpd.js");
+Components.utils.import("resource://testing-common/httpd.js");
var gTestserver = new HttpServer();
gTestserver.start(-1);
@@ -17,8 +14,8 @@ gPort = gTestserver.identity.primaryPort;
mapFile("/data/test_gfxBlacklist.xml", gTestserver);
function get_platform() {
- var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
- .getService(Ci.nsIXULRuntime);
+ var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
+ .getService(Components.interfaces.nsIXULRuntime);
return xulRuntime.OS;
}
@@ -32,7 +29,12 @@ function load_blocklist(file) {
// Performs the initial setup
function run_test() {
- var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
+ try {
+ var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
+ } catch (e) {
+ do_test_finished();
+ return;
+ }
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
@@ -56,7 +58,7 @@ function run_test() {
do_test_finished();
return;
case "Darwin":
- // We don't support driver versions on OS X.
+ // We don't support driver versions on Darwin.
do_test_finished();
return;
case "Android":
@@ -66,7 +68,7 @@ function run_test() {
break;
}
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "15.0", "8");
+ createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "3", "8");
startupManager();
do_test_pending();
@@ -80,36 +82,6 @@ function run_test() {
status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS);
do_check_eq(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
- status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_11_LAYERS);
- do_check_eq(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
-
- status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_OPENGL_LAYERS);
- do_check_eq(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
-
- status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_11_ANGLE);
- do_check_eq(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
-
- status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_HARDWARE_VIDEO_DECODING);
- do_check_eq(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
-
- status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_WEBRTC_HW_ACCELERATION);
- do_check_eq(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
-
- status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_WEBRTC_HW_ACCELERATION_DECODE);
- do_check_eq(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
-
- status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_WEBRTC_HW_ACCELERATION_ENCODE);
- do_check_eq(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
-
- status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_WEBGL_MSAA);
- do_check_eq(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
-
- status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_WEBGL_ANGLE);
- do_check_eq(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
-
- status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_CANVAS2D_ACCELERATION);
- do_check_eq(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
-
gTestserver.stop(do_test_finished);
}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverOld.js b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverOld.js
index 248c9e7f6..73253c89b 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverOld.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_DriverOld.js
@@ -2,14 +2,11 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-// This should eventually be moved to head_addons.js
-var { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
-
// Test whether a machine which is older than the equal
// blacklist entry is correctly allowed.
// Uses test_gfxBlacklist.xml
-Cu.import("resource://testing-common/httpd.js");
+Components.utils.import("resource://testing-common/httpd.js");
var gTestserver = new HttpServer();
gTestserver.start(-1);
@@ -17,8 +14,8 @@ gPort = gTestserver.identity.primaryPort;
mapFile("/data/test_gfxBlacklist.xml", gTestserver);
function get_platform() {
- var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
- .getService(Ci.nsIXULRuntime);
+ var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
+ .getService(Components.interfaces.nsIXULRuntime);
return xulRuntime.OS;
}
@@ -32,7 +29,12 @@ function load_blocklist(file) {
// Performs the initial setup
function run_test() {
- var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
+ try {
+ var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
+ } catch (e) {
+ do_test_finished();
+ return;
+ }
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_OK.js b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_OK.js
index 8b8928bb8..2dde268a3 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_OK.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Equal_OK.js
@@ -2,14 +2,11 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-// This should eventually be moved to head_addons.js
-var { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
-
// Test whether a machine which exactly matches the equal
// blacklist entry is successfully blocked.
// Uses test_gfxBlacklist.xml
-Cu.import("resource://testing-common/httpd.js");
+Components.utils.import("resource://testing-common/httpd.js");
var gTestserver = new HttpServer();
gTestserver.start(-1);
@@ -17,8 +14,8 @@ gPort = gTestserver.identity.primaryPort;
mapFile("/data/test_gfxBlacklist.xml", gTestserver);
function get_platform() {
- var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
- .getService(Ci.nsIXULRuntime);
+ var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
+ .getService(Components.interfaces.nsIXULRuntime);
return xulRuntime.OS;
}
@@ -32,7 +29,12 @@ function load_blocklist(file) {
// Performs the initial setup
function run_test() {
- var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
+ try {
+ var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
+ } catch (e) {
+ do_test_finished();
+ return;
+ }
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_DriverOld.js b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_DriverOld.js
index bd5858023..fd3145f5a 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_DriverOld.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_DriverOld.js
@@ -2,14 +2,11 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-// This should eventually be moved to head_addons.js
-var { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
-
// Test whether a machine which is lower than the greater-than-or-equal
// blacklist entry is allowed.
// Uses test_gfxBlacklist.xml
-Cu.import("resource://testing-common/httpd.js");
+Components.utils.import("resource://testing-common/httpd.js");
var gTestserver = new HttpServer();
gTestserver.start(-1);
@@ -17,8 +14,8 @@ gPort = gTestserver.identity.primaryPort;
mapFile("/data/test_gfxBlacklist.xml", gTestserver);
function get_platform() {
- var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
- .getService(Ci.nsIXULRuntime);
+ var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
+ .getService(Components.interfaces.nsIXULRuntime);
return xulRuntime.OS;
}
@@ -32,7 +29,12 @@ function load_blocklist(file) {
// Performs the initial setup
function run_test() {
- var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
+ try {
+ var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
+ } catch (e) {
+ do_test_finished();
+ return;
+ }
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_OK.js b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_OK.js
index b5c5ed2a6..0c2c65572 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_OK.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_GTE_OK.js
@@ -2,14 +2,11 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-// This should eventually be moved to head_addons.js
-var { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
-
// Test whether a machine which exactly matches the greater-than-or-equal
// blacklist entry is successfully blocked.
// Uses test_gfxBlacklist.xml
-Cu.import("resource://testing-common/httpd.js");
+Components.utils.import("resource://testing-common/httpd.js");
var gTestserver = new HttpServer();
gTestserver.start(-1);
@@ -17,8 +14,8 @@ gPort = gTestserver.identity.primaryPort;
mapFile("/data/test_gfxBlacklist.xml", gTestserver);
function get_platform() {
- var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
- .getService(Ci.nsIXULRuntime);
+ var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
+ .getService(Components.interfaces.nsIXULRuntime);
return xulRuntime.OS;
}
@@ -32,7 +29,12 @@ function load_blocklist(file) {
// Performs the initial setup
function run_test() {
- var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
+ try {
+ var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
+ } catch (e) {
+ do_test_finished();
+ return;
+ }
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_No_Comparison.js b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_No_Comparison.js
index ff37e6676..61372cff8 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_No_Comparison.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_No_Comparison.js
@@ -2,14 +2,11 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-// This should eventually be moved to head_addons.js
-var { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
-
// Test whether a machine which exactly matches the blacklist entry is
// successfully blocked.
// Uses test_gfxBlacklist.xml
-Cu.import("resource://testing-common/httpd.js");
+Components.utils.import("resource://testing-common/httpd.js");
var gTestserver = new HttpServer();
gTestserver.start(-1);
@@ -17,8 +14,8 @@ gPort = gTestserver.identity.primaryPort;
mapFile("/data/test_gfxBlacklist.xml", gTestserver);
function get_platform() {
- var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
- .getService(Ci.nsIXULRuntime);
+ var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
+ .getService(Components.interfaces.nsIXULRuntime);
return xulRuntime.OS;
}
@@ -32,7 +29,12 @@ function load_blocklist(file) {
// Performs the initial setup
function run_test() {
- var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
+ try {
+ var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
+ } catch (e) {
+ do_test_finished();
+ return;
+ }
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
@@ -54,7 +56,7 @@ function run_test() {
case "Linux":
break;
case "Darwin":
- gfxInfo.spoofOSVersion(0x1090);
+ gfxInfo.spoofOSVersion(0x1050);
break;
case "Android":
break;
@@ -67,15 +69,13 @@ function run_test() {
function checkBlacklist()
{
- var driverVersion = gfxInfo.adapterDriverVersion;
- if (driverVersion) {
- var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
- do_check_eq(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DEVICE);
-
- // Make sure unrelated features aren't affected
- status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS);
- do_check_eq(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
- }
+ var status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D);
+ do_check_eq(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DEVICE);
+
+ // Make sure unrelated features aren't affected
+ status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS);
+ do_check_eq(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
+
gTestserver.stop(do_test_finished);
}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OK.js b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OK.js
index 72b2a2bdc..dcd578dfb 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OK.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OK.js
@@ -2,14 +2,11 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-// This should eventually be moved to head_addons.js
-var { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
-
// Test whether a machine which exactly matches the blacklist entry is
// successfully blocked.
// Uses test_gfxBlacklist.xml
-Cu.import("resource://testing-common/httpd.js");
+Components.utils.import("resource://testing-common/httpd.js");
var gTestserver = new HttpServer();
gTestserver.start(-1);
@@ -17,8 +14,8 @@ gPort = gTestserver.identity.primaryPort;
mapFile("/data/test_gfxBlacklist.xml", gTestserver);
function get_platform() {
- var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
- .getService(Ci.nsIXULRuntime);
+ var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
+ .getService(Components.interfaces.nsIXULRuntime);
return xulRuntime.OS;
}
@@ -32,7 +29,12 @@ function load_blocklist(file) {
// Performs the initial setup
function run_test() {
- var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
+ try {
+ var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
+ } catch (e) {
+ do_test_finished();
+ return;
+ }
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
@@ -58,7 +60,7 @@ function run_test() {
case "Darwin":
gfxInfo.spoofVendorID("0xabcd");
gfxInfo.spoofDeviceID("0x1234");
- gfxInfo.spoofOSVersion(0x1090);
+ gfxInfo.spoofOSVersion(0x1050);
break;
case "Android":
gfxInfo.spoofVendorID("abcd");
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OS.js b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OS.js
index fa0deb19a..81edc9cd1 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OS.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OS.js
@@ -2,14 +2,11 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-// This should eventually be moved to head_addons.js
-var { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
-
// Test whether a machine which differs only on OS version, but otherwise
// exactly matches the blacklist entry, is not blocked.
// Uses test_gfxBlacklist.xml
-Cu.import("resource://testing-common/httpd.js");
+Components.utils.import("resource://testing-common/httpd.js");
var gTestserver = new HttpServer();
gTestserver.start(-1);
@@ -17,8 +14,8 @@ gPort = gTestserver.identity.primaryPort;
mapFile("/data/test_gfxBlacklist.xml", gTestserver);
function get_platform() {
- var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
- .getService(Ci.nsIXULRuntime);
+ var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
+ .getService(Components.interfaces.nsIXULRuntime);
return xulRuntime.OS;
}
@@ -32,7 +29,12 @@ function load_blocklist(file) {
// Performs the initial setup
function run_test() {
- var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
+ try {
+ var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
+ } catch (e) {
+ do_test_finished();
+ return;
+ }
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
@@ -58,7 +60,8 @@ function run_test() {
case "Darwin":
gfxInfo.spoofVendorID("0xabcd");
gfxInfo.spoofDeviceID("0x1234");
- gfxInfo.spoofOSVersion(0x1080);
+ // Snow Leopard
+ gfxInfo.spoofOSVersion(0x1060);
break;
case "Android":
// On Android, the driver version is used as the OS version (because
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_match.js b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_match.js
index f01329b45..3472c6d7e 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_match.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_match.js
@@ -2,22 +2,18 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-// This should eventually be moved to head_addons.js
-var { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
-
// Test whether new OS versions are matched properly.
// Uses test_gfxBlacklist_OS.xml
-Cu.import("resource://testing-common/httpd.js");
+Components.utils.import("resource://testing-common/httpd.js");
var gTestserver = new HttpServer();
gTestserver.start(-1);
gPort = gTestserver.identity.primaryPort;
-mapFile("/data/test_gfxBlacklist_OSVersion.xml", gTestserver);
function get_platform() {
- var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
- .getService(Ci.nsIXULRuntime);
+ var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
+ .getService(Components.interfaces.nsIXULRuntime);
return xulRuntime.OS;
}
@@ -31,7 +27,12 @@ function load_blocklist(file) {
// Performs the initial setup
function run_test() {
- var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
+ try {
+ var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
+ } catch (e) {
+ do_test_finished();
+ return;
+ }
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
@@ -58,7 +59,7 @@ function run_test() {
return;
case "Darwin":
// Mountain Lion
- gfxInfo.spoofOSVersion(0x1090);
+ gfxInfo.spoofOSVersion(0x1080);
break;
case "Android":
// On Android, the driver version is used as the OS version (because
@@ -91,5 +92,5 @@ function run_test() {
do_execute_soon(checkBlacklist);
}, "blocklist-data-gfxItems", false);
- load_blocklist("test_gfxBlacklist_OSVersion.xml");
+ load_blocklist("test_gfxBlacklist_OS.xml");
}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_mismatch_DriverVersion.js b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_mismatch_DriverVersion.js
index 4b1069dc6..fb25b9509 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_mismatch_DriverVersion.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_mismatch_DriverVersion.js
@@ -2,23 +2,19 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-// This should eventually be moved to head_addons.js
-var { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
-
// Test whether blocklists specifying new OSeswcorrectly don't block if driver
// versions are appropriately up-to-date.
// Uses test_gfxBlacklist_OS.xml
-Cu.import("resource://testing-common/httpd.js");
+Components.utils.import("resource://testing-common/httpd.js");
var gTestserver = new HttpServer();
gTestserver.start(-1);
gPort = gTestserver.identity.primaryPort;
-mapFile("/data/test_gfxBlacklist_OSVersion.xml", gTestserver);
function get_platform() {
- var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
- .getService(Ci.nsIXULRuntime);
+ var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
+ .getService(Components.interfaces.nsIXULRuntime);
return xulRuntime.OS;
}
@@ -32,7 +28,12 @@ function load_blocklist(file) {
// Performs the initial setup
function run_test() {
- var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
+ try {
+ var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
+ } catch (e) {
+ do_test_finished();
+ return;
+ }
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
@@ -58,6 +59,7 @@ function run_test() {
do_test_finished();
return;
case "Darwin":
+ // Mountain Lion
gfxInfo.spoofOSVersion(0x1080);
break;
case "Android":
@@ -91,5 +93,5 @@ function run_test() {
do_execute_soon(checkBlacklist);
}, "blocklist-data-gfxItems", false);
- load_blocklist("test_gfxBlacklist_OSVersion.xml");
+ load_blocklist("test_gfxBlacklist_OS.xml");
}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_mismatch_OSVersion.js b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_mismatch_OSVersion.js
index 0c5a0dcb7..4fb162262 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_mismatch_OSVersion.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_OSVersion_mismatch_OSVersion.js
@@ -2,23 +2,19 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-// This should eventually be moved to head_addons.js
-var { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
-
// Test whether old OS versions are not matched when the blacklist contains
// only new OS versions.
// Uses test_gfxBlacklist_OS.xml
-Cu.import("resource://testing-common/httpd.js");
+Components.utils.import("resource://testing-common/httpd.js");
var gTestserver = new HttpServer();
gTestserver.start(-1);
gPort = gTestserver.identity.primaryPort;
-mapFile("/data/test_gfxBlacklist_OSVersion.xml", gTestserver);
function get_platform() {
- var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
- .getService(Ci.nsIXULRuntime);
+ var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
+ .getService(Components.interfaces.nsIXULRuntime);
return xulRuntime.OS;
}
@@ -32,7 +28,12 @@ function load_blocklist(file) {
// Performs the initial setup
function run_test() {
- var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
+ try {
+ var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
+ } catch (e) {
+ do_test_finished();
+ return;
+ }
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
@@ -59,7 +60,7 @@ function run_test() {
return;
case "Darwin":
// Lion
- gfxInfo.spoofOSVersion(0x1080);
+ gfxInfo.spoofOSVersion(0x1070);
break;
case "Android":
// On Android, the driver version is used as the OS version (because
@@ -92,5 +93,5 @@ function run_test() {
do_execute_soon(checkBlacklist);
}, "blocklist-data-gfxItems", false);
- load_blocklist("test_gfxBlacklist_OSVersion.xml");
+ load_blocklist("test_gfxBlacklist_OS.xml");
}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Vendor.js b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Vendor.js
index 868c48149..a5d1c71cf 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Vendor.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Vendor.js
@@ -2,14 +2,11 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-// This should eventually be moved to head_addons.js
-var { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
-
// Test whether a machine which differs only on vendor, but otherwise
// exactly matches the blacklist entry, is not blocked.
// Uses test_gfxBlacklist.xml
-Cu.import("resource://testing-common/httpd.js");
+Components.utils.import("resource://testing-common/httpd.js");
var gTestserver = new HttpServer();
gTestserver.start(-1);
@@ -17,8 +14,8 @@ gPort = gTestserver.identity.primaryPort;
mapFile("/data/test_gfxBlacklist.xml", gTestserver);
function get_platform() {
- var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
- .getService(Ci.nsIXULRuntime);
+ var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
+ .getService(Components.interfaces.nsIXULRuntime);
return xulRuntime.OS;
}
@@ -32,7 +29,12 @@ function load_blocklist(file) {
// Performs the initial setup
function run_test() {
- var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
+ try {
+ var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
+ } catch (e) {
+ do_test_finished();
+ return;
+ }
// We can't do anything if we can't spoof the stuff we need.
if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
@@ -58,7 +60,7 @@ function run_test() {
case "Darwin":
gfxInfo.spoofVendorID("0xdcba");
gfxInfo.spoofDeviceID("0x1234");
- gfxInfo.spoofOSVersion(0x1090);
+ gfxInfo.spoofOSVersion(0x1050);
break;
case "Android":
gfxInfo.spoofVendorID("dcba");
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Version.js b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Version.js
deleted file mode 100755
index 48174b772..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_Version.js
+++ /dev/null
@@ -1,145 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-var { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
-
-// Test whether a machine which exactly matches the blacklist entry is
-// successfully blocked.
-// Uses test_gfxBlacklist_AllOS.xml
-
-Cu.import("resource://testing-common/httpd.js");
-
-var gTestserver = new HttpServer();
-gTestserver.start(-1);
-gPort = gTestserver.identity.primaryPort;
-mapFile("/data/test_gfxBlacklist_AllOS.xml", gTestserver);
-
-function get_platform() {
- var xulRuntime = Cc["@mozilla.org/xre/app-info;1"]
- .getService(Ci.nsIXULRuntime);
- return xulRuntime.OS;
-}
-
-function load_blocklist(file) {
- Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" +
- gPort + "/data/" + file);
- var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
- getService(Ci.nsITimerCallback);
- blocklist.notify(null);
-}
-
-// Performs the initial setup
-function run_test() {
- var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
-
- // We can't do anything if we can't spoof the stuff we need.
- if (!(gfxInfo instanceof Ci.nsIGfxInfoDebug)) {
- do_test_finished();
- return;
- }
-
- gfxInfo.QueryInterface(Ci.nsIGfxInfoDebug);
-
- // Set the vendor/device ID, etc, to match the test file.
- switch (get_platform()) {
- case "WINNT":
- gfxInfo.spoofVendorID("0xabcd");
- gfxInfo.spoofDeviceID("0x1234");
- gfxInfo.spoofDriverVersion("8.52.322.2201");
- // Windows 7
- gfxInfo.spoofOSVersion(0x60001);
- break;
- case "Linux":
- gfxInfo.spoofVendorID("0xabcd");
- gfxInfo.spoofDeviceID("0x1234");
- break;
- case "Darwin":
- gfxInfo.spoofVendorID("0xabcd");
- gfxInfo.spoofDeviceID("0x1234");
- gfxInfo.spoofOSVersion(0x1090);
- break;
- case "Android":
- gfxInfo.spoofVendorID("abcd");
- gfxInfo.spoofDeviceID("asdf");
- gfxInfo.spoofDriverVersion("5");
- break;
- }
-
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "15.0", "8");
- startupManager();
-
- do_test_pending();
-
- function checkBlacklist()
- {
- var failureId = {};
- var status;
-
- status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT2D, failureId);
- do_check_eq(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
- do_check_eq(failureId.value, "FEATURE_FAILURE_DL_BLACKLIST_g1");
-
- status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_9_LAYERS, failureId);
- do_check_eq(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
- do_check_eq(failureId.value, "FEATURE_FAILURE_DL_BLACKLIST_g2");
-
- status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_10_LAYERS, failureId);
- do_check_eq(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
- do_check_eq(failureId.value, "");
-
- status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_10_1_LAYERS, failureId);
- do_check_eq(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
- do_check_eq(failureId.value, "");
-
- // These four pass on Linux independent of the blocklist XML file as the
- // try machines don't have support.
- status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_OPENGL_LAYERS);
- do_check_eq(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
-
- status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_WEBGL_OPENGL, failureId);
- do_check_eq(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
- do_check_eq(failureId.value, "FEATURE_FAILURE_DL_BLACKLIST_g11");
-
- status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_WEBGL_ANGLE, failureId);
- do_check_eq(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
- do_check_eq(failureId.value, "FEATURE_FAILURE_DL_BLACKLIST_NO_ID");
-
- status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_WEBGL_MSAA, failureId);
- do_check_eq(status, Ci.nsIGfxInfo.FEATURE_BLOCKED_DRIVER_VERSION);
-
- status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_STAGEFRIGHT, failureId);
- do_check_eq(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
-
- status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_WEBRTC_HW_ACCELERATION, failureId);
- do_check_eq(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
-
- status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_WEBRTC_HW_ACCELERATION_ENCODE, failureId);
- do_check_eq(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
-
- status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_WEBRTC_HW_ACCELERATION_DECODE, failureId);
- do_check_eq(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
-
- status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_11_LAYERS, failureId);
- do_check_eq(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
-
- status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_HARDWARE_VIDEO_DECODING, failureId);
- do_check_eq(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
-
- status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DIRECT3D_11_ANGLE, failureId);
- do_check_eq(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
-
- status = gfxInfo.getFeatureStatus(Ci.nsIGfxInfo.FEATURE_DX_INTEROP2, failureId);
- do_check_eq(status, Ci.nsIGfxInfo.FEATURE_STATUS_OK);
-
- gTestserver.stop(do_test_finished);
- }
-
- Services.obs.addObserver(function(aSubject, aTopic, aData) {
- // If we wait until after we go through the event loop, gfxInfo is sure to
- // have processed the gfxItems event.
- do_execute_soon(checkBlacklist);
- }, "blocklist-data-gfxItems", false);
-
- load_blocklist("test_gfxBlacklist_AllOS.xml");
-}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_prefs.js b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_prefs.js
index fbb992879..bb0e55e2c 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_prefs.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gfxBlacklist_prefs.js
@@ -2,8 +2,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-var { classes: Cc, interfaces: Ci } = Components;
-
// Test whether the blacklist succesfully adds and removes the prefs that store
// its decisions when the remote blacklist is changed.
// Uses test_gfxBlacklist.xml and test_gfxBlacklist2.xml
@@ -14,7 +12,6 @@ var gTestserver = new HttpServer();
gTestserver.start(-1);
gPort = gTestserver.identity.primaryPort;
mapFile("/data/test_gfxBlacklist.xml", gTestserver);
-mapFile("/data/test_gfxBlacklist2.xml", gTestserver);
function get_platform() {
var xulRuntime = Components.classes["@mozilla.org/xre/app-info;1"]
@@ -63,7 +60,7 @@ function run_test() {
case "Darwin":
gfxInfo.spoofVendorID("0xabcd");
gfxInfo.spoofDeviceID("0x1234");
- gfxInfo.spoofOSVersion(0x1090);
+ gfxInfo.spoofOSVersion(0x1050);
break;
case "Android":
gfxInfo.spoofVendorID("abcd");
@@ -123,7 +120,7 @@ function run_test() {
try {
prefs.getIntPref("gfx.blacklist.direct2d");
exists = true;
- } catch (e) {}
+ } catch(e) {}
do_check_false(exists);
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_gmpProvider.js b/toolkit/mozapps/extensions/test/xpcshell/test_gmpProvider.js
index 545d7d666..8de3ab4a2 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_gmpProvider.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_gmpProvider.js
@@ -3,19 +3,14 @@
"use strict";
-var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
-var GMPScope = Cu.import("resource://gre/modules/addons/GMPProvider.jsm");
-Cu.import("resource://gre/modules/AppConstants.jsm");
-Cu.import("resource://gre/modules/UpdateUtils.jsm");
+const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
+let GMPScope = Cu.import("resource://gre/modules/addons/GMPProvider.jsm");
XPCOMUtils.defineLazyGetter(this, "pluginsBundle",
() => Services.strings.createBundle("chrome://global/locale/plugins.properties"));
-XPCOMUtils.defineLazyModuleGetter(this, "FileUtils",
- "resource://gre/modules/FileUtils.jsm");
-
-var gMockAddons = new Map();
-var gMockEmeAddons = new Map();
+let gMockAddons = new Map();
+let gMockEmeAddons = new Map();
for (let plugin of GMPScope.GMP_PLUGINS) {
let mockAddon = Object.freeze({
@@ -24,28 +19,22 @@ for (let plugin of GMPScope.GMP_PLUGINS) {
isInstalled: false,
nameId: plugin.name,
descriptionId: plugin.description,
- missingKey: plugin.missingKey,
- missingFilesKey: plugin.missingFilesKey,
});
gMockAddons.set(mockAddon.id, mockAddon);
- if (mockAddon.id == "gmp-widevinecdm" ||
- mockAddon.id.indexOf("gmp-eme-") == 0) {
+ if (mockAddon.id.indexOf("gmp-eme-") == 0) {
gMockEmeAddons.set(mockAddon.id, mockAddon);
}
}
-var gInstalledAddonId = "";
-var gPrefs = Services.prefs;
-var gGetKey = GMPScope.GMPPrefs.getPrefKey;
+let gInstalledAddonId = "";
+let gPrefs = Services.prefs;
+let gGetKey = GMPScope.GMPPrefs.getPrefKey;
function MockGMPInstallManager() {
}
MockGMPInstallManager.prototype = {
- checkForAddons: () => Promise.resolve({
- usedFallback: true,
- gmpAddons: [...gMockAddons.values()]
- }),
+ checkForAddons: () => Promise.resolve([...gMockAddons.values()]),
installAddon: addon => {
gInstalledAddonId = addon.id;
@@ -62,9 +51,7 @@ function run_test() {
gPrefs.setIntPref(GMPScope.GMPPrefs.KEY_LOGGING_LEVEL, 0);
gPrefs.setBoolPref(GMPScope.GMPPrefs.KEY_EME_ENABLED, true);
for (let addon of gMockAddons.values()) {
- gPrefs.setBoolPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_VISIBLE, addon.id),
- true);
- gPrefs.setBoolPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_FORCE_SUPPORTED, addon.id),
+ gPrefs.setBoolPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_FORCEVISIBLE, addon.id),
true);
}
GMPScope.GMPProvider.shutdown();
@@ -229,42 +216,11 @@ add_task(function* test_autoUpdatePrefPersistance() {
}
});
-function createMockPluginFilesIfNeeded(aFile, aPluginId) {
- function createFile(aFileName) {
- let f = aFile.clone();
- f.append(aFileName);
- if (!f.exists()) {
- f.create(Ci.nsIFile.NORMAL_FILE_TYPE, FileUtils.PERMS_FILE);
- }
- }
-
- let id = aPluginId.substring(4);
- let libName = AppConstants.DLL_PREFIX + id + AppConstants.DLL_SUFFIX;
-
- createFile(libName);
- if (aPluginId == "gmp-widevinecdm") {
- createFile("manifest.json");
- } else {
- createFile(id + ".info");
- }
- if (aPluginId == "gmp-eme-adobe")
- createFile(id + ".voucher");
-}
-
-// Array.includes() is only in Nightly channel, so polyfill so we don't fail
-// on other branches.
-if (![].includes) {
- Array.prototype.includes = function(element) {
- return Object(this).indexOf(element) != -1;
- }
-}
-
add_task(function* test_pluginRegistration() {
const TEST_VERSION = "1.2.3.4";
- let profD = do_get_profile();
for (let addon of gMockAddons.values()) {
- let file = profD.clone();
+ let file = Services.dirsvc.get("ProfD", Ci.nsIFile);
file.append(addon.id);
file.append(TEST_VERSION);
@@ -273,58 +229,18 @@ add_task(function* test_pluginRegistration() {
let clearPaths = () => { addedPaths = []; removedPaths = []; }
let MockGMPService = {
- addPluginDirectory: path => {
- if (!addedPaths.includes(path)) {
- addedPaths.push(path);
- }
- },
- removePluginDirectory: path => {
- if (!removedPaths.includes(path)) {
- removedPaths.push(path);
- }
- },
- removeAndDeletePluginDirectory: path => {
- if (!removedPaths.includes(path)) {
- removedPaths.push(path);
- }
- },
+ addPluginDirectory: path => addedPaths.push(path),
+ removePluginDirectory: path => removedPaths.push(path),
+ removeAndDeletePluginDirectory: path => removedPaths.push(path),
};
- GMPScope.gmpService = MockGMPService;
+ GMPScope.gmpService = MockGMPService;
gPrefs.setBoolPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_ENABLED, addon.id), true);
- // Test that plugin registration fails if the plugin dynamic library and
- // info files are not present.
+ // Check that the plugin gets registered after startup.
gPrefs.setCharPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_VERSION, addon.id),
- TEST_VERSION);
- clearPaths();
- yield promiseRestartManager();
- Assert.equal(addedPaths.indexOf(file.path), -1);
- Assert.deepEqual(removedPaths, [file.path]);
-
- // Create dummy GMP library/info files, and test that plugin registration
- // succeeds during startup, now that we've added GMP info/lib files.
- createMockPluginFilesIfNeeded(file, addon.id);
-
- gPrefs.setCharPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_VERSION, addon.id),
- TEST_VERSION);
- clearPaths();
- yield promiseRestartManager();
- Assert.notEqual(addedPaths.indexOf(file.path), -1);
- Assert.deepEqual(removedPaths, []);
-
- // Setting the ABI to something invalid should cause plugin to be removed at startup.
- clearPaths();
- gPrefs.setCharPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_ABI, addon.id), "invalid-ABI");
- yield promiseRestartManager();
- Assert.equal(addedPaths.indexOf(file.path), -1);
- Assert.deepEqual(removedPaths, [file.path]);
-
- // Setting the ABI to expected ABI should cause registration at startup.
+ TEST_VERSION);
clearPaths();
- gPrefs.setCharPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_VERSION, addon.id),
- TEST_VERSION);
- gPrefs.setCharPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_ABI, addon.id), UpdateUtils.ABI);
yield promiseRestartManager();
Assert.notEqual(addedPaths.indexOf(file.path), -1);
Assert.deepEqual(removedPaths, []);
@@ -343,7 +259,7 @@ add_task(function* test_pluginRegistration() {
// Changing the pref mid-session should cause unregistration and registration.
gPrefs.setCharPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_VERSION, addon.id),
- TEST_VERSION);
+ TEST_VERSION);
clearPaths();
const TEST_VERSION_2 = "5.6.7.8";
let file2 = Services.dirsvc.get("ProfD", Ci.nsIFile);
@@ -356,7 +272,7 @@ add_task(function* test_pluginRegistration() {
// Disabling the plugin should cause unregistration.
gPrefs.setCharPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_VERSION, addon.id),
- TEST_VERSION);
+ TEST_VERSION);
clearPaths();
gPrefs.setBoolPref(gGetKey(GMPScope.GMPPrefs.KEY_PLUGIN_ENABLED, addon.id), false);
Assert.deepEqual(addedPaths, []);
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_hasbinarycomponents.js b/toolkit/mozapps/extensions/test/xpcshell/test_hasbinarycomponents.js
index 925e63626..598e06ed0 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_hasbinarycomponents.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_hasbinarycomponents.js
@@ -12,7 +12,7 @@ function run_test() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "2");
startupManager();
-
+
installAllFiles([do_get_addon("test_chromemanifest_1"),
do_get_addon("test_chromemanifest_2"),
do_get_addon("test_chromemanifest_3"),
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_hotfix.js b/toolkit/mozapps/extensions/test/xpcshell/test_hotfix.js
deleted file mode 100644
index c9303897f..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_hotfix.js
+++ /dev/null
@@ -1,309 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-// This verifies that hotfix installation works
-
-// The test extension uses an insecure update url.
-Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
-// Ignore any certificate requirements the app has set
-Services.prefs.setBoolPref("extensions.hotfix.cert.checkAttributes", false);
-
-Components.utils.import("resource://testing-common/httpd.js");
-var testserver = new HttpServer();
-testserver.start(-1);
-gPort = testserver.identity.primaryPort;
-testserver.registerDirectory("/addons/", do_get_file("addons"));
-mapFile("/data/test_hotfix_1.rdf", testserver);
-mapFile("/data/test_hotfix_2.rdf", testserver);
-mapFile("/data/test_hotfix_3.rdf", testserver);
-
-const profileDir = gProfD.clone();
-profileDir.append("extensions");
-
-function run_test() {
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
-
- startupManager();
-
- do_test_pending();
- run_test_1();
-}
-
-function end_test() {
- testserver.stop(do_test_finished);
-}
-
-// Test that background updates find and install any available hotfix
-function run_test_1() {
- Services.prefs.setCharPref("extensions.hotfix.id", "hotfix@tests.mozilla.org");
- Services.prefs.setCharPref("extensions.update.background.url", "http://localhost:" +
- gPort + "/data/test_hotfix_1.rdf");
-
- prepare_test({
- "hotfix@tests.mozilla.org": [
- "onInstalling"
- ]
- }, [
- "onNewInstall",
- "onDownloadStarted",
- "onDownloadEnded",
- "onInstallStarted",
- "onInstallEnded",
- ], callback_soon(check_test_1));
-
- // We don't need to wait on the promise, just waiting for the install to finish is enough.
- AddonManagerInternal.backgroundUpdateCheck();
-}
-
-function check_test_1() {
- restartManager();
-
- AddonManager.getAddonByID("hotfix@tests.mozilla.org", function(aAddon) {
- do_check_neq(aAddon, null);
- do_check_eq(aAddon.version, "1.0");
-
- aAddon.uninstall();
- do_execute_soon(run_test_2);
- });
-}
-
-// Don't install an already used hotfix
-function run_test_2() {
- restartManager();
-
- AddonManager.addInstallListener({
- onNewInstall: function() {
- do_throw("Should not have seen a new install created");
- }
- });
-
- // Run the background update
- AddonManagerInternal.backgroundUpdateCheck().then(run_test_3);
-}
-
-// Install a newer hotfix
-function run_test_3() {
- restartManager();
- Services.prefs.setCharPref("extensions.hotfix.url", "http://localhost:" +
- gPort + "/data/test_hotfix_2.rdf");
-
- prepare_test({
- "hotfix@tests.mozilla.org": [
- "onInstalling"
- ]
- }, [
- "onNewInstall",
- "onDownloadStarted",
- "onDownloadEnded",
- "onInstallStarted",
- "onInstallEnded",
- ], callback_soon(check_test_3));
-
- AddonManagerInternal.backgroundUpdateCheck();
-}
-
-function check_test_3() {
- restartManager();
-
- AddonManager.getAddonByID("hotfix@tests.mozilla.org", function(aAddon) {
- do_check_neq(aAddon, null);
- do_check_eq(aAddon.version, "2.0");
-
- aAddon.uninstall();
- do_execute_soon(run_test_4);
- });
-}
-
-// Don't install an incompatible hotfix
-function run_test_4() {
- restartManager();
-
- Services.prefs.setCharPref("extensions.hotfix.url", "http://localhost:" +
- gPort + "/data/test_hotfix_3.rdf");
-
- AddonManager.addInstallListener({
- onNewInstall: function() {
- do_throw("Should not have seen a new install created");
- }
- });
-
- AddonManagerInternal.backgroundUpdateCheck().then(run_test_5);
-}
-
-// Don't install an older hotfix
-function run_test_5() {
- restartManager();
-
- Services.prefs.setCharPref("extensions.hotfix.url", "http://localhost:" +
- gPort + "/data/test_hotfix_1.rdf");
-
- AddonManager.addInstallListener({
- onNewInstall: function() {
- do_throw("Should not have seen a new install created");
- }
- });
-
- AddonManagerInternal.backgroundUpdateCheck().then(run_test_6);
-}
-
-// Don't re-download an already pending install
-function run_test_6() {
- restartManager();
-
- Services.prefs.setCharPref("extensions.hotfix.lastVersion", "0");
- Services.prefs.setCharPref("extensions.hotfix.url", "http://localhost:" +
- gPort + "/data/test_hotfix_1.rdf");
-
- prepare_test({
- "hotfix@tests.mozilla.org": [
- "onInstalling"
- ]
- }, [
- "onNewInstall",
- "onDownloadStarted",
- "onDownloadEnded",
- "onInstallStarted",
- "onInstallEnded",
- ], callback_soon(check_test_6));
-
- AddonManagerInternal.backgroundUpdateCheck();
-}
-
-function check_test_6() {
- AddonManager.addInstallListener({
- onNewInstall: function() {
- do_throw("Should not have seen a new install created");
- }
- });
-
- AddonManagerInternal.backgroundUpdateCheck()
- .then(promiseRestartManager)
- .then(() => promiseAddonByID("hotfix@tests.mozilla.org"))
- .then(aAddon => {
- aAddon.uninstall();
- run_test_7();
- });
-}
-
-// Start downloading again if something cancels the install
-function run_test_7() {
- restartManager();
-
- Services.prefs.setCharPref("extensions.hotfix.lastVersion", "0");
-
- prepare_test({
- "hotfix@tests.mozilla.org": [
- "onInstalling"
- ]
- }, [
- "onNewInstall",
- "onDownloadStarted",
- "onDownloadEnded",
- "onInstallStarted",
- "onInstallEnded",
- ], check_test_7);
-
- AddonManagerInternal.backgroundUpdateCheck();
-}
-
-function check_test_7(aInstall) {
- prepare_test({
- "hotfix@tests.mozilla.org": [
- "onOperationCancelled"
- ]
- }, [
- "onInstallCancelled",
- ]);
-
- aInstall.cancel();
-
- prepare_test({
- "hotfix@tests.mozilla.org": [
- "onInstalling"
- ]
- }, [
- "onNewInstall",
- "onDownloadStarted",
- "onDownloadEnded",
- "onInstallStarted",
- "onInstallEnded",
- ], callback_soon(finish_test_7));
-
- AddonManagerInternal.backgroundUpdateCheck();
-}
-
-function finish_test_7() {
- restartManager();
-
- AddonManager.getAddonByID("hotfix@tests.mozilla.org", function(aAddon) {
- do_check_neq(aAddon, null);
- do_check_eq(aAddon.version, "1.0");
-
- aAddon.uninstall();
- do_execute_soon(run_test_8);
- });
-}
-
-// Cancel a pending install when a newer version is already available
-function run_test_8() {
- restartManager();
-
- Services.prefs.setCharPref("extensions.hotfix.lastVersion", "0");
- Services.prefs.setCharPref("extensions.hotfix.url", "http://localhost:" +
- gPort + "/data/test_hotfix_1.rdf");
-
- prepare_test({
- "hotfix@tests.mozilla.org": [
- "onInstalling"
- ]
- }, [
- "onNewInstall",
- "onDownloadStarted",
- "onDownloadEnded",
- "onInstallStarted",
- "onInstallEnded",
- ], check_test_8);
-
- AddonManagerInternal.backgroundUpdateCheck();
-}
-
-function check_test_8() {
- Services.prefs.setCharPref("extensions.hotfix.url", "http://localhost:" +
- gPort + "/data/test_hotfix_2.rdf");
-
- prepare_test({
- "hotfix@tests.mozilla.org": [
- "onOperationCancelled",
- "onInstalling"
- ]
- }, [
- "onNewInstall",
- "onDownloadStarted",
- "onDownloadEnded",
- "onInstallStarted",
- "onInstallCancelled",
- "onInstallEnded",
- ], finish_test_8);
-
- AddonManagerInternal.backgroundUpdateCheck();
-}
-
-function finish_test_8() {
- AddonManager.getAllInstalls(callback_soon(function(aInstalls) {
- do_check_eq(aInstalls.length, 1);
- do_check_eq(aInstalls[0].version, "2.0");
-
- restartManager();
-
- AddonManager.getAddonByID("hotfix@tests.mozilla.org", callback_soon(function(aAddon) {
- do_check_neq(aAddon, null);
- do_check_eq(aAddon.version, "2.0");
-
- aAddon.uninstall();
- restartManager();
-
- end_test();
- }));
- }));
-}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_hotfix_cert.js b/toolkit/mozapps/extensions/test/xpcshell/test_hotfix_cert.js
deleted file mode 100644
index 42ee59740..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_hotfix_cert.js
+++ /dev/null
@@ -1,167 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-// This verifies that hotfix installation works
-const PREF_EM_HOTFIX_ID = "extensions.hotfix.id";
-const PREF_EM_HOTFIX_LASTVERSION = "extensions.hotfix.lastVersion";
-const PREF_EM_HOTFIX_URL = "extensions.hotfix.url";
-const PREF_EM_CERT_CHECKATTRIBUTES = "extensions.hotfix.cert.checkAttributes";
-const PREF_EM_HOTFIX_CERTS = "extensions.hotfix.certs.";
-
-// Derived from "openssl x509 -in firefox-hotfix.crt -fingerprint -sha1"
-const GOOD_FINGERPRINT = "39:E7:2B:7A:5B:CF:37:78:F9:5D:4A:E0:53:2D:2F:3D:68:53:C5:60";
-const BAD_FINGERPRINT = "40:E7:2B:7A:5B:CF:37:78:F9:5D:4A:E0:53:2D:2F:3D:68:53:C5:60";
-
-Components.utils.import("resource://testing-common/httpd.js");
-var testserver = new HttpServer();
-testserver.start(-1);
-gPort = testserver.identity.primaryPort;
-testserver.registerDirectory("/data/", do_get_file("data"));
-
-// The test extension uses an insecure update url.
-Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
-// Ignore any certificate requirements the app has set
-Services.prefs.setBoolPref(PREF_EM_CERT_CHECKATTRIBUTES, true);
-Services.prefs.setCharPref(PREF_EM_HOTFIX_URL, "http://localhost:" + gPort + "/hotfix.rdf");
-// Clear out all hotfix cert prefs to make sure only the test prefs apply.
-var defaults = Services.prefs.getDefaultBranch("");
-defaults.deleteBranch(PREF_EM_HOTFIX_CERTS);
-
-/*
- * Register an addon install listener and return a promise that:
- * resolves with the AddonInstall object if the install succeeds
- * rejects with the AddonInstall if the install fails
- */
-function promiseInstallListener() {
- return new Promise((resolve, reject) => {
- let listener = {
- onDownloadFailed: ai => {
- AddonManager.removeInstallListener(listener);
- reject(ai);
- },
- onInstallEnded: ai => {
- AddonManager.removeInstallListener(listener);
- resolve(ai);
- },
- onDownloadCancelled: ai => {
- AddonManager.removeInstallListener(listener);
- reject(ai);
- }
- };
- AddonManager.addInstallListener(listener);
- });
-}
-
-function promiseSuccessfulInstall() {
- return promiseInstallListener().then(
- aInstall => {
- do_check_true(true);
- do_check_eq(aInstall.addon.id, Services.prefs.getCharPref(PREF_EM_HOTFIX_ID));
- aInstall.addon.uninstall();
- Services.prefs.clearUserPref(PREF_EM_HOTFIX_LASTVERSION);
- },
- aInstall => {
- do_throw("Install should not have failed");
- });
-}
-
-function promiseFailedInstall() {
- return promiseInstallListener().then(
- aInstall => {
- do_throw("Install should not have succeeded");
- aInstall.addon.uninstall();
- Services.prefs.clearUserPref(PREF_EM_HOTFIX_LASTVERSION);
- },
- aInstall => {
- do_check_true(true);
- });
-}
-
-var tryInstallHotfix = Task.async(function*(id, file, installListener) {
- Services.prefs.setCharPref(PREF_EM_HOTFIX_ID, id);
-
- testserver.registerPathHandler("/hotfix.rdf", function(request, response) {
- response.write(createUpdateRDF({
- [id]: [{
- version: "1.0",
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "0",
- maxVersion: "*",
- updateLink: "http://localhost:" + gPort + "/data/signing_checks/" + file,
- }]
- }]
- }));
- });
-
- yield Promise.all([
- installListener,
- AddonManagerPrivate.backgroundUpdateCheck()
- ]);
-
- testserver.registerPathHandler("/hotfix.rdf", null);
- Services.prefs.clearUserPref(PREF_EM_HOTFIX_ID);
-});
-
-// Test valid AMO hotfix signed add-ons doesn't work if the fingerprint pref is wrong
-add_task(function* amo_signed_hotfix() {
- Services.prefs.setCharPref(PREF_EM_HOTFIX_CERTS + "1.sha1Fingerprint", BAD_FINGERPRINT);
-
- yield tryInstallHotfix("firefox-hotfix@mozilla.org",
- "hotfix_good.xpi",
- promiseFailedInstall());
-});
-
-// Test valid AMO hotfix signed add-ons works
-add_task(function* amo_signed_hotfix() {
- Services.prefs.setCharPref(PREF_EM_HOTFIX_CERTS + "1.sha1Fingerprint", GOOD_FINGERPRINT);
-
- yield tryInstallHotfix("firefox-hotfix@mozilla.org",
- "hotfix_good.xpi",
- promiseSuccessfulInstall());
-});
-
-// A hotfix altered after signing should fail
-add_task(function* amo_broken_hotfix() {
- yield tryInstallHotfix("firefox-hotfix@mozilla.org",
- "hotfix_broken.xpi",
- promiseFailedInstall());
-});
-
-// Test an add-on with the wrong ID but signed by the right cert fails
-add_task(function* amo_wrongID_rightcert() {
- yield tryInstallHotfix("test@tests.mozilla.org",
- "hotfix_badid.xpi",
- promiseFailedInstall());
-});
-
-// It shouldn't matter that it requested the ID matching the cert to begin with
-// if the embedded cert's ID doesn't match the add-on's ID
-add_task(function* amo_wrongID_rightcert2() {
- yield tryInstallHotfix("firefox-hotfix@mozilla.org",
- "hotfix_badid.xpi",
- promiseFailedInstall());
-});
-
-// Test something signed by a regular AMO cert doesn't work
-add_task(function* amo_signed_addon() {
- yield tryInstallHotfix("test@tests.mozilla.org",
- "signed_bootstrap_1.xpi",
- promiseFailedInstall());
-});
-
-// Test totally unsigned add-on fails
-add_task(function* unsigned() {
- yield tryInstallHotfix("test@tests.mozilla.org",
- "unsigned_bootstrap_2.xpi",
- promiseFailedInstall());
-});
-
-function run_test() {
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "2");
-
- startupManager();
-
- run_next_test();
-}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_install.js b/toolkit/mozapps/extensions/test/xpcshell/test_install.js
index 60af3a9fd..16db604c5 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_install.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_install.js
@@ -3,9 +3,14 @@
*/
// This verifies that add-ons can be installed from XPI files
-var Cc = Components.classes;
-var Ci = Components.interfaces;
-var Cu = Components.utils;
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+const Cu = Components.utils;
+
+// Maximum error in file modification times. Some file systems don't store
+// modification times exactly. As long as we are closer than this then it
+// still passes.
+const MAX_TIME_DIFFERENCE = 3000;
// install.rdf size, icon.png, icon64.png size
const ADDON1_SIZE = 705 + 16 + 16;
@@ -140,8 +145,6 @@ function check_test_1(installSyncGUID) {
else {
let iconFile = uri.QueryInterface(AM_Ci.nsIFileURL).file;
do_check_true(iconFile.exists());
- // Make the iconFile predictably old.
- iconFile.lastModifiedTime = Date.now() - MAKE_FILE_OLD_DIFFERENCE;
}
// Make the pending install have a sensible date
@@ -186,23 +189,14 @@ function check_test_1(installSyncGUID) {
do_check_true(a1.hasResource("install.rdf"));
do_check_false(a1.hasResource("foo.bar"));
- let uri2 = do_get_addon_root_uri(profileDir, "addon1@tests.mozilla.org");
- do_check_eq(a1.getResourceURI("install.rdf").spec, uri2 + "install.rdf");
- do_check_eq(a1.iconURL, uri2 + "icon.png");
- do_check_eq(a1.icon64URL, uri2 + "icon64.png");
-
- // Ensure that extension bundle (or icon if unpacked) has updated
- // lastModifiedDate.
- let testURI = a1.getResourceURI(TEST_UNPACKED ? "icon.png" : "");
- let testFile = testURI.QueryInterface(Components.interfaces.nsIFileURL).file;
- do_check_true(testFile.exists());
- difference = testFile.lastModifiedTime - Date.now();
- do_check_true(Math.abs(difference) < MAX_TIME_DIFFERENCE);
+ let uri = do_get_addon_root_uri(profileDir, "addon1@tests.mozilla.org");
+ do_check_eq(a1.getResourceURI("install.rdf").spec, uri + "install.rdf");
+ do_check_eq(a1.iconURL, uri + "icon.png");
+ do_check_eq(a1.icon64URL, uri + "icon64.png");
a1.uninstall();
- let { id, version } = a1;
restartManager();
- do_check_not_in_crash_annotation(id, version);
+ do_check_not_in_crash_annotation(a1.id, a1.version);
do_execute_soon(run_test_2);
}));
@@ -233,7 +227,7 @@ function run_test_2() {
], check_test_2);
install.addListener({
- onDownloadProgress: function() {
+ onDownloadProgress: function(install) {
do_execute_soon(function() {
Components.utils.forceGC();
});
@@ -387,8 +381,8 @@ function check_test_5(install) {
do_check_eq(installs[0].addon, olda2.pendingUpgrade);
restartManager();
- AddonManager.getInstallsByTypes(null, function(installs2) {
- do_check_eq(installs2.length, 0);
+ AddonManager.getInstallsByTypes(null, function(installs) {
+ do_check_eq(installs.length, 0);
AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) {
do_check_neq(a2, null);
@@ -656,8 +650,6 @@ function run_test_11() {
"onNewInstall",
"onNewInstall",
"onNewInstall",
- "onNewInstall",
- "onNewInstall",
"onNewInstall"
]);
@@ -665,22 +657,11 @@ function run_test_11() {
ensure_test_completed();
do_check_neq(install, null);
do_check_neq(install.linkedInstalls, null);
- do_check_eq(install.linkedInstalls.length, 5);
+ do_check_eq(install.linkedInstalls.length, 3);
// Might be in any order so sort them based on ID
let installs = [install].concat(install.linkedInstalls);
installs.sort(function(a, b) {
- if (a.state != b.state) {
- if (a.state == AddonManager.STATE_DOWNLOAD_FAILED)
- return 1;
- else if (b.state == AddonManager.STATE_DOWNLOAD_FAILED)
- return -1;
- }
-
- // Don't care what order the failed installs show up in
- if (a.state == AddonManager.STATE_DOWNLOAD_FAILED)
- return 0;
-
if (a.addon.id < b.addon.id)
return -1;
if (a.addon.id > b.addon.id)
@@ -728,12 +709,6 @@ function run_test_11() {
do_check_true(hasFlag(installs[3].addon.operationsRequiringRestart,
AddonManager.OP_NEEDS_RESTART_INSTALL));
- do_check_eq(installs[4].state, AddonManager.STATE_DOWNLOAD_FAILED);
- do_check_eq(installs[4].error, AddonManager.ERROR_CORRUPT_FILE);
-
- do_check_eq(installs[5].state, AddonManager.STATE_DOWNLOAD_FAILED);
- do_check_eq(installs[5].error, AddonManager.ERROR_CORRUPT_FILE);
-
AddonManager.getAllInstalls(function(aInstalls) {
do_check_eq(aInstalls.length, 4);
@@ -840,8 +815,6 @@ function run_test_12() {
"onNewInstall",
"onNewInstall",
"onNewInstall",
- "onNewInstall",
- "onNewInstall",
"onDownloadEnded"
],
"addon4@tests.mozilla.org": [
@@ -866,22 +839,11 @@ function run_test_12() {
}
function check_test_12() {
- do_check_eq(gInstall.linkedInstalls.length, 5);
+ do_check_eq(gInstall.linkedInstalls.length, 3);
// Might be in any order so sort them based on ID
let installs = [gInstall].concat(gInstall.linkedInstalls);
installs.sort(function(a, b) {
- if (a.state != b.state) {
- if (a.state == AddonManager.STATE_DOWNLOAD_FAILED)
- return 1;
- else if (b.state == AddonManager.STATE_DOWNLOAD_FAILED)
- return -1;
- }
-
- // Don't care what order the failed installs show up in
- if (a.state == AddonManager.STATE_DOWNLOAD_FAILED)
- return 0;
-
if (a.addon.id < b.addon.id)
return -1;
if (a.addon.id > b.addon.id)
@@ -921,12 +883,6 @@ function check_test_12() {
do_check_eq(installs[3].name, "Multi Test 4");
do_check_eq(installs[3].state, AddonManager.STATE_INSTALLED);
- do_check_eq(installs[4].state, AddonManager.STATE_DOWNLOAD_FAILED);
- do_check_eq(installs[4].error, AddonManager.ERROR_CORRUPT_FILE);
-
- do_check_eq(installs[5].state, AddonManager.STATE_DOWNLOAD_FAILED);
- do_check_eq(installs[5].error, AddonManager.ERROR_CORRUPT_FILE);
-
restartManager();
AddonManager.getAddonsByIDs(["addon4@tests.mozilla.org",
@@ -1148,26 +1104,26 @@ function run_test_16() {
do_check_true(a2.userDisabled);
do_check_false(a2.isActive);
- let url_2 = "http://localhost:" + gPort + "/addons/test_install2_2.xpi";
- AddonManager.getInstallForURL(url_2, function(aInstall_2) {
- aInstall_2.addListener({
+ let url = "http://localhost:" + gPort + "/addons/test_install2_2.xpi";
+ AddonManager.getInstallForURL(url, function(aInstall) {
+ aInstall.addListener({
onInstallEnded: function() {
do_execute_soon(function install2_2_ended() {
- do_check_true(aInstall_2.addon.userDisabled);
+ do_check_true(aInstall.addon.userDisabled);
restartManager();
- AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2_2) {
- do_check_true(a2_2.userDisabled);
- do_check_false(a2_2.isActive);
+ AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) {
+ do_check_true(a2.userDisabled);
+ do_check_false(a2.isActive);
- a2_2.uninstall();
+ a2.uninstall();
do_execute_soon(run_test_17);
});
});
}
});
- aInstall_2.install();
+ aInstall.install();
}, "application/x-xpinstall");
});
});
@@ -1194,29 +1150,29 @@ function run_test_17() {
do_check_false(a2.userDisabled);
do_check_true(a2.isActive);
- let url_2 = "http://localhost:" + gPort + "/addons/test_install2_2.xpi";
- AddonManager.getInstallForURL(url_2, function(aInstall_2) {
- aInstall_2.addListener({
+ let url = "http://localhost:" + gPort + "/addons/test_install2_2.xpi";
+ AddonManager.getInstallForURL(url, function(aInstall) {
+ aInstall.addListener({
onInstallStarted: function() {
- do_check_false(aInstall_2.addon.userDisabled);
- aInstall_2.addon.userDisabled = true;
+ do_check_false(aInstall.addon.userDisabled);
+ aInstall.addon.userDisabled = true;
},
onInstallEnded: function() {
do_execute_soon(function install2_2_ended2() {
restartManager();
- AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2_2) {
- do_check_true(a2_2.userDisabled);
- do_check_false(a2_2.isActive);
+ AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) {
+ do_check_true(a2.userDisabled);
+ do_check_false(a2.isActive);
- a2_2.uninstall();
+ a2.uninstall();
do_execute_soon(run_test_18);
});
});
}
});
- aInstall_2.install();
+ aInstall.install();
}, "application/x-xpinstall");
});
});
@@ -1246,29 +1202,29 @@ function run_test_18() {
do_check_true(a2.userDisabled);
do_check_false(a2.isActive);
- let url_2 = "http://localhost:" + gPort + "/addons/test_install2_2.xpi";
- AddonManager.getInstallForURL(url_2, function(aInstall_2) {
- aInstall_2.addListener({
+ let url = "http://localhost:" + gPort + "/addons/test_install2_2.xpi";
+ AddonManager.getInstallForURL(url, function(aInstall) {
+ aInstall.addListener({
onInstallStarted: function() {
- do_check_true(aInstall_2.addon.userDisabled);
- aInstall_2.addon.userDisabled = false;
+ do_check_true(aInstall.addon.userDisabled);
+ aInstall.addon.userDisabled = false;
},
onInstallEnded: function() {
do_execute_soon(function install_2_2_ended3() {
restartManager();
- AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2_2) {
- do_check_false(a2_2.userDisabled);
- do_check_true(a2_2.isActive);
+ AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) {
+ do_check_false(a2.userDisabled);
+ do_check_true(a2.isActive);
- a2_2.uninstall();
+ a2.uninstall();
do_execute_soon(run_test_18_1);
});
});
}
});
- aInstall_2.install();
+ aInstall.install();
}, "application/x-xpinstall");
});
});
@@ -1292,7 +1248,7 @@ function run_test_18_1() {
let url = "http://localhost:" + gPort + "/addons/test_install2_1.xpi";
AddonManager.getInstallForURL(url, function(aInstall) {
aInstall.addListener({
- onInstallEnded: function(unused, aAddon) {
+ onInstallEnded: function(aInstall, aAddon) {
do_execute_soon(function test18_1_install_ended() {
do_check_neq(aAddon.fullDescription, "Repository description");
@@ -1320,7 +1276,7 @@ function run_test_19() {
let url = "http://localhost:" + gPort + "/addons/test_install2_1.xpi";
AddonManager.getInstallForURL(url, function(aInstall) {
aInstall.addListener({
- onInstallEnded: function(unused, aAddon) {
+ onInstallEnded: function(aInstall, aAddon) {
do_execute_soon(function test19_install_ended() {
do_check_eq(aAddon.fullDescription, "Repository description");
@@ -1346,7 +1302,7 @@ function run_test_20() {
let url = "http://localhost:" + gPort + "/addons/test_install2_1.xpi";
AddonManager.getInstallForURL(url, function(aInstall) {
aInstall.addListener({
- onInstallEnded: function(unused, aAddon) {
+ onInstallEnded: function(aInstall, aAddon) {
do_execute_soon(function test20_install_ended() {
do_check_eq(aAddon.fullDescription, "Repository description");
@@ -1633,8 +1589,8 @@ function run_test_26() {
let url = "http://localhost:" + gPort + "/redirect?/addons/test_install1.xpi";
AddonManager.getInstallForURL(url, function(aInstall) {
aInstall.addListener({
- onDownloadProgress: function(aDownloadProgressInstall) {
- aDownloadProgressInstall.cancel();
+ onDownloadProgress: function(aInstall) {
+ aInstall.cancel();
}
});
@@ -1791,7 +1747,7 @@ function run_test_29() {
}
function check_test_29(install) {
- // ensure_test_completed();
+ //ensure_test_completed();
do_check_eq(install.state, AddonManager.STATE_DOWNLOADED);
do_check_neq(install.addon, null);
do_check_false(install.addon.isCompatible);
@@ -1799,45 +1755,7 @@ function check_test_29(install) {
prepare_test({}, [
"onDownloadCancelled"
- ], run_test_30);
+ ], do_test_finished);
install.cancel();
return false;
}
-
-// Tests that a multi-package XPI with no add-ons inside shows up as a
-// corrupt file
-function run_test_30() {
- prepare_test({ }, [
- "onNewInstall"
- ]);
-
- AddonManager.getInstallForFile(do_get_addon("test_install7"), function(install) {
- ensure_test_completed();
-
- do_check_neq(install, null);
- do_check_eq(install.state, AddonManager.STATE_DOWNLOAD_FAILED);
- do_check_eq(install.error, AddonManager.ERROR_CORRUPT_FILE);
- do_check_eq(install.linkedInstalls, null);
-
- run_test_31();
- });
-}
-
-// Tests that a multi-package XPI with no valid add-ons inside shows up as a
-// corrupt file
-function run_test_31() {
- prepare_test({ }, [
- "onNewInstall"
- ]);
-
- AddonManager.getInstallForFile(do_get_addon("test_install8"), function(install) {
- ensure_test_completed();
-
- do_check_neq(install, null);
- do_check_eq(install.state, AddonManager.STATE_DOWNLOAD_FAILED);
- do_check_eq(install.error, AddonManager.ERROR_CORRUPT_FILE);
- do_check_eq(install.linkedInstalls, null);
-
- end_test();
- });
-}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_install_from_sources.js b/toolkit/mozapps/extensions/test/xpcshell/test_install_from_sources.js
deleted file mode 100644
index 18bb7d74e..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_install_from_sources.js
+++ /dev/null
@@ -1,80 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-const ID = "bootstrap1@tests.mozilla.org";
-createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "42");
-startupManager();
-
-BootstrapMonitor.init();
-
-// Partial list of bootstrap reasons from XPIProvider.jsm
-const BOOTSTRAP_REASONS = {
- ADDON_INSTALL: 5,
- ADDON_UPGRADE: 7,
- ADDON_DOWNGRADE: 8,
-};
-
-// Install an unsigned add-on with no existing add-on present.
-// Restart and make sure it is still around.
-add_task(function*() {
- let extInstallCalled = false;
- AddonManager.addInstallListener({
- onExternalInstall: (aInstall) => {
- do_check_eq(aInstall.id, ID);
- do_check_eq(aInstall.version, "1.0");
- extInstallCalled = true;
- },
- });
-
- let installingCalled = false;
- let installedCalled = false;
- AddonManager.addAddonListener({
- onInstalling: (aInstall) => {
- do_check_eq(aInstall.id, ID);
- do_check_eq(aInstall.version, "1.0");
- installingCalled = true;
- },
- onInstalled: (aInstall) => {
- do_check_eq(aInstall.id, ID);
- do_check_eq(aInstall.version, "1.0");
- installedCalled = true;
- },
- onInstallStarted: (aInstall) => {
- do_throw("onInstallStarted called unexpectedly");
- }
- });
-
- yield AddonManager.installAddonFromSources(do_get_file("data/from_sources/"));
-
- do_check_true(extInstallCalled);
- do_check_true(installingCalled);
- do_check_true(installedCalled);
-
- let install = BootstrapMonitor.checkAddonInstalled(ID, "1.0");
- equal(install.reason, BOOTSTRAP_REASONS.ADDON_INSTALL);
- BootstrapMonitor.checkAddonStarted(ID, "1.0");
-
- let addon = yield promiseAddonByID(ID);
-
- do_check_neq(addon, null);
- do_check_eq(addon.version, "1.0");
- do_check_eq(addon.name, "Test Bootstrap 1");
- do_check_true(addon.isCompatible);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.type, "extension");
- do_check_eq(addon.signedState, mozinfo.addon_signing ? AddonManager.SIGNEDSTATE_SIGNED : AddonManager.SIGNEDSTATE_NOT_REQUIRED);
-
- yield promiseRestartManager();
-
- install = BootstrapMonitor.checkAddonInstalled(ID, "1.0");
- equal(install.reason, BOOTSTRAP_REASONS.ADDON_INSTALL);
- BootstrapMonitor.checkAddonStarted(ID, "1.0");
-
- addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
-
- yield promiseRestartManager();
-});
-
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_install_strictcompat.js b/toolkit/mozapps/extensions/test/xpcshell/test_install_strictcompat.js
index 77f806ba2..0c7003d59 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_install_strictcompat.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_install_strictcompat.js
@@ -3,9 +3,14 @@
*/
// This verifies that add-ons can be installed from XPI files
-var Cc = Components.classes;
-var Ci = Components.interfaces;
-var Cu = Components.utils;
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+const Cu = Components.utils;
+
+// Maximum error in file modification times. Some file systems don't store
+// modification times exactly. As long as we are closer than this then it
+// still passes.
+const MAX_TIME_DIFFERENCE = 3000;
// install.rdf size, icon.png, icon64.png size
const ADDON1_SIZE = 705 + 16 + 16;
@@ -177,13 +182,13 @@ function check_test_1() {
do_check_true(a1.hasResource("install.rdf"));
do_check_false(a1.hasResource("foo.bar"));
- let root_uri = do_get_addon_root_uri(profileDir, "addon1@tests.mozilla.org");
- do_check_eq(a1.getResourceURI("install.rdf").spec, root_uri + "install.rdf");
- do_check_eq(a1.iconURL, root_uri + "icon.png");
- do_check_eq(a1.icon64URL, root_uri + "icon64.png");
+ let uri = do_get_addon_root_uri(profileDir, "addon1@tests.mozilla.org");
+ do_check_eq(a1.getResourceURI("install.rdf").spec, uri + "install.rdf");
+ do_check_eq(a1.iconURL, uri + "icon.png");
+ do_check_eq(a1.icon64URL, uri + "icon64.png");
a1.uninstall();
- do_execute_soon(function() { run_test_2(a1) });
+ do_execute_soon(function(){run_test_2(a1)});
});
});
}));
@@ -192,9 +197,8 @@ function check_test_1() {
// Tests that an install from a url downloads.
function run_test_2(aAddon) {
- let { id, version } = aAddon;
restartManager();
- do_check_not_in_crash_annotation(id, version);
+ do_check_not_in_crash_annotation(aAddon.id, aAddon.version);
let url = "http://localhost:4444/addons/test_install2_1.xpi";
AddonManager.getInstallForURL(url, function(install) {
@@ -216,7 +220,7 @@ function run_test_2(aAddon) {
], check_test_2);
install.addListener({
- onDownloadProgress: function() {
+ onDownloadProgress: function(install) {
do_execute_soon(function() {
Components.utils.forceGC();
});
@@ -369,8 +373,8 @@ function check_test_5(install) {
do_check_eq(installs[0].addon, olda2.pendingUpgrade);
restartManager();
- AddonManager.getInstallsByTypes(null, function(installs2) {
- do_check_eq(installs2.length, 0);
+ AddonManager.getInstallsByTypes(null, function(installs) {
+ do_check_eq(installs.length, 0);
AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) {
do_check_neq(a2, null);
@@ -635,8 +639,6 @@ function run_test_11() {
"onNewInstall",
"onNewInstall",
"onNewInstall",
- "onNewInstall",
- "onNewInstall",
"onNewInstall"
]);
@@ -644,22 +646,11 @@ function run_test_11() {
ensure_test_completed();
do_check_neq(install, null);
do_check_neq(install.linkedInstalls, null);
- do_check_eq(install.linkedInstalls.length, 5);
+ do_check_eq(install.linkedInstalls.length, 3);
// Might be in any order so sort them based on ID
let installs = [install].concat(install.linkedInstalls);
installs.sort(function(a, b) {
- if (a.state != b.state) {
- if (a.state == AddonManager.STATE_DOWNLOAD_FAILED)
- return 1;
- else if (b.state == AddonManager.STATE_DOWNLOAD_FAILED)
- return -1;
- }
-
- // Don't care what order the failed installs show up in
- if (a.state == AddonManager.STATE_DOWNLOAD_FAILED)
- return 0;
-
if (a.addon.id < b.addon.id)
return -1;
if (a.addon.id > b.addon.id)
@@ -707,12 +698,6 @@ function run_test_11() {
do_check_true(hasFlag(installs[3].addon.operationsRequiringRestart,
AddonManager.OP_NEEDS_RESTART_INSTALL));
- do_check_eq(installs[4].state, AddonManager.STATE_DOWNLOAD_FAILED);
- do_check_eq(installs[4].error, AddonManager.ERROR_CORRUPT_FILE);
-
- do_check_eq(installs[5].state, AddonManager.STATE_DOWNLOAD_FAILED);
- do_check_eq(installs[5].error, AddonManager.ERROR_CORRUPT_FILE);
-
AddonManager.getAllInstalls(function(aInstalls) {
do_check_eq(aInstalls.length, 4);
@@ -821,8 +806,6 @@ function run_test_12() {
"onNewInstall",
"onNewInstall",
"onNewInstall",
- "onNewInstall",
- "onNewInstall",
"onDownloadEnded"
],
"addon4@tests.mozilla.org": [
@@ -847,22 +830,11 @@ function run_test_12() {
}
function check_test_12() {
- do_check_eq(gInstall.linkedInstalls.length, 5);
+ do_check_eq(gInstall.linkedInstalls.length, 3);
// Might be in any order so sort them based on ID
let installs = [gInstall].concat(gInstall.linkedInstalls);
installs.sort(function(a, b) {
- if (a.state != b.state) {
- if (a.state == AddonManager.STATE_DOWNLOAD_FAILED)
- return 1;
- else if (b.state == AddonManager.STATE_DOWNLOAD_FAILED)
- return -1;
- }
-
- // Don't care what order the failed installs show up in
- if (a.state == AddonManager.STATE_DOWNLOAD_FAILED)
- return 0;
-
if (a.addon.id < b.addon.id)
return -1;
if (a.addon.id > b.addon.id)
@@ -902,12 +874,6 @@ function check_test_12() {
do_check_eq(installs[3].name, "Multi Test 4");
do_check_eq(installs[3].state, AddonManager.STATE_INSTALLED);
- do_check_eq(installs[4].state, AddonManager.STATE_DOWNLOAD_FAILED);
- do_check_eq(installs[4].error, AddonManager.ERROR_CORRUPT_FILE);
-
- do_check_eq(installs[5].state, AddonManager.STATE_DOWNLOAD_FAILED);
- do_check_eq(installs[5].error, AddonManager.ERROR_CORRUPT_FILE);
-
restartManager();
AddonManager.getAddonsByIDs(["addon4@tests.mozilla.org",
@@ -1129,26 +1095,26 @@ function run_test_16() {
do_check_true(a2.userDisabled);
do_check_false(a2.isActive);
- let url_2 = "http://localhost:4444/addons/test_install2_2.xpi";
- AddonManager.getInstallForURL(url_2, function(aInstall_2) {
- aInstall_2.addListener({
+ let url = "http://localhost:4444/addons/test_install2_2.xpi";
+ AddonManager.getInstallForURL(url, function(aInstall) {
+ aInstall.addListener({
onInstallEnded: function() {
do_execute_soon(function test16_install2() {
- do_check_true(aInstall_2.addon.userDisabled);
+ do_check_true(aInstall.addon.userDisabled);
restartManager();
- AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2_2) {
- do_check_true(a2_2.userDisabled);
- do_check_false(a2_2.isActive);
+ AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) {
+ do_check_true(a2.userDisabled);
+ do_check_false(a2.isActive);
- a2_2.uninstall();
+ a2.uninstall();
do_execute_soon(run_test_17);
});
});
}
});
- aInstall_2.install();
+ aInstall.install();
}, "application/x-xpinstall");
});
});
@@ -1166,7 +1132,7 @@ function run_test_17() {
AddonManager.getInstallForURL(url, function(aInstall) {
aInstall.addListener({
onInstallEnded: function() {
- do_execute_soon(function() {
+ do_execute_soon(function test17_install1() {
do_check_false(aInstall.addon.userDisabled);
restartManager();
@@ -1175,29 +1141,29 @@ function run_test_17() {
do_check_false(a2.userDisabled);
do_check_true(a2.isActive);
- let url_2 = "http://localhost:4444/addons/test_install2_2.xpi";
- AddonManager.getInstallForURL(url_2, function(aInstall_2) {
- aInstall_2.addListener({
+ let url = "http://localhost:4444/addons/test_install2_2.xpi";
+ AddonManager.getInstallForURL(url, function(aInstall) {
+ aInstall.addListener({
onInstallStarted: function() {
- do_check_false(aInstall_2.addon.userDisabled);
- aInstall_2.addon.userDisabled = true;
+ do_check_false(aInstall.addon.userDisabled);
+ aInstall.addon.userDisabled = true;
},
onInstallEnded: function() {
- do_execute_soon(function() {
+ do_execute_soon(function test17_install1() {
restartManager();
- AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2_2) {
- do_check_true(a2_2.userDisabled);
- do_check_false(a2_2.isActive);
+ AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) {
+ do_check_true(a2.userDisabled);
+ do_check_false(a2.isActive);
- a2_2.uninstall();
+ a2.uninstall();
do_execute_soon(run_test_18);
});
});
}
});
- aInstall_2.install();
+ aInstall.install();
}, "application/x-xpinstall");
});
});
@@ -1227,29 +1193,29 @@ function run_test_18() {
do_check_true(a2.userDisabled);
do_check_false(a2.isActive);
- let url_2 = "http://localhost:4444/addons/test_install2_2.xpi";
- AddonManager.getInstallForURL(url_2, function(aInstall_2) {
- aInstall_2.addListener({
+ let url = "http://localhost:4444/addons/test_install2_2.xpi";
+ AddonManager.getInstallForURL(url, function(aInstall) {
+ aInstall.addListener({
onInstallStarted: function() {
- do_check_true(aInstall_2.addon.userDisabled);
- aInstall_2.addon.userDisabled = false;
+ do_check_true(aInstall.addon.userDisabled);
+ aInstall.addon.userDisabled = false;
},
onInstallEnded: function() {
do_execute_soon(function test18_install2() {
restartManager();
- AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2_2) {
- do_check_false(a2_2.userDisabled);
- do_check_true(a2_2.isActive);
+ AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) {
+ do_check_false(a2.userDisabled);
+ do_check_true(a2.isActive);
- a2_2.uninstall();
+ a2.uninstall();
do_execute_soon(run_test_18_1);
});
});
}
});
- aInstall_2.install();
+ aInstall.install();
}, "application/x-xpinstall");
});
});
@@ -1273,7 +1239,7 @@ function run_test_18_1() {
let url = "http://localhost:4444/addons/test_install2_1.xpi";
AddonManager.getInstallForURL(url, function(aInstall) {
aInstall.addListener({
- onInstallEnded: function(unused, aAddon) {
+ onInstallEnded: function(aInstall, aAddon) {
do_execute_soon(function test18_install() {
do_check_neq(aAddon.fullDescription, "Repository description");
@@ -1301,7 +1267,7 @@ function run_test_19() {
let url = "http://localhost:4444/addons/test_install2_1.xpi";
AddonManager.getInstallForURL(url, function(aInstall) {
aInstall.addListener({
- onInstallEnded: function(unused, aAddon) {
+ onInstallEnded: function(aInstall, aAddon) {
do_execute_soon(function test19_install() {
do_check_eq(aAddon.fullDescription, "Repository description");
@@ -1327,7 +1293,7 @@ function run_test_20() {
let url = "http://localhost:4444/addons/test_install2_1.xpi";
AddonManager.getInstallForURL(url, function(aInstall) {
aInstall.addListener({
- onInstallEnded: function(unused, aAddon) {
+ onInstallEnded: function(aInstall, aAddon) {
do_execute_soon(function test20_install() {
do_check_eq(aAddon.fullDescription, "Repository description");
@@ -1614,8 +1580,8 @@ function run_test_26() {
let url = "http://localhost:4444/redirect?/addons/test_install1.xpi";
AddonManager.getInstallForURL(url, function(aInstall) {
aInstall.addListener({
- onDownloadProgress: function(aDownloadProgressInstall) {
- aDownloadProgressInstall.cancel();
+ onDownloadProgress: function(aInstall) {
+ aInstall.cancel();
}
});
@@ -1684,43 +1650,5 @@ function finish_test_27(aInstall) {
ensure_test_completed();
- run_test_30();
-}
-
-// Tests that a multi-package XPI with no add-ons inside shows up as a
-// corrupt file
-function run_test_30() {
- prepare_test({ }, [
- "onNewInstall"
- ]);
-
- AddonManager.getInstallForFile(do_get_addon("test_install7"), function(install) {
- ensure_test_completed();
-
- do_check_neq(install, null);
- do_check_eq(install.state, AddonManager.STATE_DOWNLOAD_FAILED);
- do_check_eq(install.error, AddonManager.ERROR_CORRUPT_FILE);
- do_check_eq(install.linkedInstalls, null);
-
- run_test_31();
- });
-}
-
-// Tests that a multi-package XPI with no valid add-ons inside shows up as a
-// corrupt file
-function run_test_31() {
- prepare_test({ }, [
- "onNewInstall"
- ]);
-
- AddonManager.getInstallForFile(do_get_addon("test_install8"), function(install) {
- ensure_test_completed();
-
- do_check_neq(install, null);
- do_check_eq(install.state, AddonManager.STATE_DOWNLOAD_FAILED);
- do_check_eq(install.error, AddonManager.ERROR_CORRUPT_FILE);
- do_check_eq(install.linkedInstalls, null);
-
- end_test();
- });
+ end_test();
}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_isDebuggable.js b/toolkit/mozapps/extensions/test/xpcshell/test_isDebuggable.js
index 87f2856b0..d4f8a482b 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_isDebuggable.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_isDebuggable.js
@@ -17,7 +17,7 @@ var IDS = [
function run_test() {
do_test_pending();
-
+
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "2");
startupManager();
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_json_updatecheck.js b/toolkit/mozapps/extensions/test/xpcshell/test_json_updatecheck.js
deleted file mode 100644
index adf789afb..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_json_updatecheck.js
+++ /dev/null
@@ -1,372 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-"use strict";
-
-// This verifies that AddonUpdateChecker works correctly for JSON
-// update manifests, particularly for behavior which does not
-// cleanly overlap with RDF manifests.
-
-const TOOLKIT_ID = "toolkit@mozilla.org";
-const TOOLKIT_MINVERSION = "42.0a1";
-
-createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "42.0a2", "42.0a2");
-
-Components.utils.import("resource://gre/modules/addons/AddonUpdateChecker.jsm");
-
-let testserver = createHttpServer();
-gPort = testserver.identity.primaryPort;
-
-let gUpdateManifests = {};
-
-function mapManifest(aPath, aManifestData) {
- gUpdateManifests[aPath] = aManifestData;
- testserver.registerPathHandler(aPath, serveManifest);
-}
-
-function serveManifest(request, response) {
- let manifest = gUpdateManifests[request.path];
-
- response.setHeader("Content-Type", manifest.contentType, false);
- response.write(manifest.data);
-}
-
-const extensionsDir = gProfD.clone();
-extensionsDir.append("extensions");
-
-
-function checkUpdates(aData) {
- // Registers JSON update manifest for it with the testing server,
- // checks for updates, and yields the list of updates on
- // success.
-
- let extension = aData.manifestExtension || "json";
-
- let path = `/updates/${aData.id}.${extension}`;
- let updateUrl = `http://localhost:${gPort}${path}`
-
- let addonData = {};
- if ("updates" in aData)
- addonData.updates = aData.updates;
-
- let manifestJSON = {
- "addons": {
- [aData.id]: addonData
- }
- };
-
- mapManifest(path.replace(/\?.*/, ""),
- { data: JSON.stringify(manifestJSON),
- contentType: aData.contentType || "application/json" });
-
-
- return new Promise((resolve, reject) => {
- AddonUpdateChecker.checkForUpdates(aData.id, aData.updateKey, updateUrl, {
- onUpdateCheckComplete: resolve,
-
- onUpdateCheckError: function(status) {
- reject(new Error("Update check failed with status " + status));
- }
- });
- });
-}
-
-
-add_task(function* test_default_values() {
- // Checks that the appropriate defaults are used for omitted values.
-
- startupManager();
-
- let updates = yield checkUpdates({
- id: "updatecheck-defaults@tests.mozilla.org",
- version: "0.1",
- updates: [{
- version: "0.2"
- }]
- });
-
- equal(updates.length, 1);
- let update = updates[0];
-
- equal(update.targetApplications.length, 1);
- let targetApp = update.targetApplications[0];
-
- equal(targetApp.id, TOOLKIT_ID);
- equal(targetApp.minVersion, TOOLKIT_MINVERSION);
- equal(targetApp.maxVersion, "*");
-
- equal(update.version, "0.2");
- equal(update.multiprocessCompatible, true, "multiprocess_compatible flag");
- equal(update.strictCompatibility, false, "inferred strictConpatibility flag");
- equal(update.updateURL, null, "updateURL");
- equal(update.updateHash, null, "updateHash");
- equal(update.updateInfoURL, null, "updateInfoURL");
-
- // If there's no applications property, we default to using one
- // containing "gecko". If there is an applications property, but
- // it doesn't contain "gecko", the update is skipped.
- updates = yield checkUpdates({
- id: "updatecheck-defaults@tests.mozilla.org",
- version: "0.1",
- updates: [{
- version: "0.2",
- applications: { "foo": {} }
- }]
- });
-
- equal(updates.length, 0);
-
- // Updates property is also optional. No updates, but also no error.
- updates = yield checkUpdates({
- id: "updatecheck-defaults@tests.mozilla.org",
- version: "0.1",
- });
-
- equal(updates.length, 0);
-});
-
-
-add_task(function* test_explicit_values() {
- // Checks that the appropriate explicit values are used when
- // provided.
-
- let updates = yield checkUpdates({
- id: "updatecheck-explicit@tests.mozilla.org",
- version: "0.1",
- updates: [{
- version: "0.2",
- update_link: "https://example.com/foo.xpi",
- update_hash: "sha256:0",
- update_info_url: "https://example.com/update_info.html",
- multiprocess_compatible: false,
- applications: {
- gecko: {
- strict_min_version: "42.0a2.xpcshell",
- strict_max_version: "43.xpcshell"
- }
- }
- }]
- });
-
- equal(updates.length, 1);
- let update = updates[0];
-
- equal(update.targetApplications.length, 1);
- let targetApp = update.targetApplications[0];
-
- equal(targetApp.id, TOOLKIT_ID);
- equal(targetApp.minVersion, "42.0a2.xpcshell");
- equal(targetApp.maxVersion, "43.xpcshell");
-
- equal(update.version, "0.2");
- equal(update.multiprocessCompatible, false, "multiprocess_compatible flag");
- equal(update.strictCompatibility, true, "inferred strictCompatibility flag");
- equal(update.updateURL, "https://example.com/foo.xpi", "updateURL");
- equal(update.updateHash, "sha256:0", "updateHash");
- equal(update.updateInfoURL, "https://example.com/update_info.html", "updateInfoURL");
-});
-
-
-add_task(function* test_secure_hashes() {
- // Checks that only secure hash functions are accepted for
- // non-secure update URLs.
-
- let hashFunctions = ["sha512",
- "sha256",
- "sha1",
- "md5",
- "md4",
- "xxx"];
-
- let updateItems = hashFunctions.map((hash, idx) => ({
- version: `0.${idx}`,
- update_link: `http://localhost:${gPort}/updates/${idx}-${hash}.xpi`,
- update_hash: `${hash}:08ac852190ecd81f40a514ea9299fe9143d9ab5e296b97e73fb2a314de49648a`,
- }));
-
- let { messages, result: updates } = yield promiseConsoleOutput(() => {
- return checkUpdates({
- id: "updatecheck-hashes@tests.mozilla.org",
- version: "0.1",
- updates: updateItems
- });
- });
-
- equal(updates.length, hashFunctions.length);
-
- updates = updates.filter(update => update.updateHash || update.updateURL);
- equal(updates.length, 2, "expected number of update hashes were accepted");
-
- ok(updates[0].updateHash.startsWith("sha512:"), "sha512 hash is present");
- ok(updates[0].updateURL);
-
- ok(updates[1].updateHash.startsWith("sha256:"), "sha256 hash is present");
- ok(updates[1].updateURL);
-
- messages = messages.filter(msg => /Update link.*not secure.*strong enough hash \(needs to be sha256 or sha512\)/.test(msg.message));
- equal(messages.length, hashFunctions.length - 2, "insecure hashes generated the expected warning");
-});
-
-
-add_task(function* test_strict_compat() {
- // Checks that strict compatibility is enabled for strict max
- // versions other than "*", but not for advisory max versions.
- // Also, ensure that strict max versions take precedence over
- // advisory versions.
-
- let { messages, result: updates } = yield promiseConsoleOutput(() => {
- return checkUpdates({
- id: "updatecheck-strict@tests.mozilla.org",
- version: "0.1",
- updates: [
- { version: "0.2",
- applications: { gecko: { strict_max_version: "*" } } },
- { version: "0.3",
- applications: { gecko: { strict_max_version: "43" } } },
- { version: "0.4",
- applications: { gecko: { advisory_max_version: "43" } } },
- { version: "0.5",
- applications: { gecko: { advisory_max_version: "43",
- strict_max_version: "44" } } },
- ]
- });
- });
-
- equal(updates.length, 4, "all update items accepted");
-
- equal(updates[0].targetApplications[0].maxVersion, "*");
- equal(updates[0].strictCompatibility, false);
-
- equal(updates[1].targetApplications[0].maxVersion, "43");
- equal(updates[1].strictCompatibility, true);
-
- equal(updates[2].targetApplications[0].maxVersion, "43");
- equal(updates[2].strictCompatibility, false);
-
- equal(updates[3].targetApplications[0].maxVersion, "44");
- equal(updates[3].strictCompatibility, true);
-
- messages = messages.filter(msg => /Ignoring 'advisory_max_version'.*'strict_max_version' also present/.test(msg.message));
- equal(messages.length, 1, "mix of advisory_max_version and strict_max_version generated the expected warning");
-});
-
-
-add_task(function* test_update_url_security() {
- // Checks that update links to privileged URLs are not accepted.
-
- let { messages, result: updates } = yield promiseConsoleOutput(() => {
- return checkUpdates({
- id: "updatecheck-security@tests.mozilla.org",
- version: "0.1",
- updates: [
- { version: "0.2",
- update_link: "chrome://browser/content/browser.xul",
- update_hash: "sha256:08ac852190ecd81f40a514ea9299fe9143d9ab5e296b97e73fb2a314de49648a" },
- { version: "0.3",
- update_link: "http://example.com/update.xpi",
- update_hash: "sha256:18ac852190ecd81f40a514ea9299fe9143d9ab5e296b97e73fb2a314de49648a" },
- ]
- });
- });
-
- equal(updates.length, 2, "both updates were processed");
- equal(updates[0].updateURL, null, "privileged update URL was removed");
- equal(updates[1].updateURL, "http://example.com/update.xpi", "safe update URL was accepted");
-
- messages = messages.filter(msg => /http:\/\/localhost.*\/updates\/.*may not load or link to chrome:/.test(msg.message));
- equal(messages.length, 1, "privileged upate URL generated the expected console message");
-});
-
-
-add_task(function* test_no_update_key() {
- // Checks that updates fail when an update key has been specified.
-
- let { messages } = yield promiseConsoleOutput(function* () {
- yield Assert.rejects(
- checkUpdates({
- id: "updatecheck-updatekey@tests.mozilla.org",
- version: "0.1",
- updateKey: "ayzzx=",
- updates: [
- { version: "0.2" },
- { version: "0.3" },
- ]
- }),
- null, "updated expected to fail");
- });
-
- messages = messages.filter(msg => /Update keys are not supported for JSON update manifests/.test(msg.message));
- equal(messages.length, 1, "got expected update-key-unsupported error");
-});
-
-
-add_task(function* test_type_detection() {
- // Checks that JSON update manifests are detected correctly
- // regardless of extension or MIME type.
-
- let tests = [
- { contentType: "application/json",
- extension: "json",
- valid: true },
- { contentType: "application/json",
- extension: "php",
- valid: true },
- { contentType: "text/plain",
- extension: "json",
- valid: true },
- { contentType: "application/octet-stream",
- extension: "json",
- valid: true },
- { contentType: "text/plain",
- extension: "json?foo=bar",
- valid: true },
- { contentType: "text/plain",
- extension: "php",
- valid: true },
- { contentType: "text/plain",
- extension: "rdf",
- valid: true },
- { contentType: "application/json",
- extension: "rdf",
- valid: true },
- { contentType: "text/xml",
- extension: "json",
- valid: true },
- { contentType: "application/rdf+xml",
- extension: "json",
- valid: true },
- ];
-
- for (let [i, test] of tests.entries()) {
- let { messages } = yield promiseConsoleOutput(function *() {
- let id = `updatecheck-typedetection-${i}@tests.mozilla.org`;
- let updates;
- try {
- updates = yield checkUpdates({
- id: id,
- version: "0.1",
- contentType: test.contentType,
- manifestExtension: test.extension,
- updates: [{ version: "0.2" }]
- });
- } catch (e) {
- ok(!test.valid, "update manifest correctly detected as RDF");
- return;
- }
-
- ok(test.valid, "update manifest correctly detected as JSON");
- equal(updates.length, 1, "correct number of updates");
- equal(updates[0].id, id, "update is for correct extension");
- });
-
- if (test.valid) {
- // Make sure we don't get any XML parsing errors from the
- // XMLHttpRequest machinery.
- ok(!messages.some(msg => /not well-formed/.test(msg.message)),
- "expect XMLHttpRequest not to attempt XML parsing");
- }
-
- messages = messages.filter(msg => /Update manifest was not valid XML/.test(msg.message));
- equal(messages.length, !test.valid, "expected number of XML parsing errors");
- }
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_locked.js b/toolkit/mozapps/extensions/test/xpcshell/test_locked.js
index 86457eab1..d16c1019d 100755..100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_locked.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_locked.js
@@ -361,12 +361,7 @@ add_task(function* run_test_1() {
// Restarting will actually apply changes to extensions.ini which will
// then be put into the in-memory database when we next fail to load the
// real thing
- try {
- shutdownManager();
- } catch (e) {
- // We're expecting an error here.
- }
- startupManager(false);
+ restartManager();
// Shouldn't have seen any startup changes
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
@@ -445,11 +440,7 @@ add_task(function* run_test_1() {
// After allowing access to the original DB things should go back to as
// they were previously
- try {
- shutdownManager();
- } catch (e) {
- // We're expecting an error here.
- }
+ shutdownManager();
do_print("Unlocking " + gExtensionsJSON.path);
yield file.close();
gExtensionsJSON.permissions = filePermissions;
@@ -530,12 +521,6 @@ add_task(function* run_test_1() {
do_check_false(t2.appDisabled);
do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isThemeInAddonsList(profileDir, t2.id));
-
- try {
- shutdownManager();
- } catch (e) {
- // We're expecting an error here.
- }
});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_locked2.js b/toolkit/mozapps/extensions/test/xpcshell/test_locked2.js
index 4a62c585f..10b13c9f6 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_locked2.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_locked2.js
@@ -71,7 +71,7 @@ var addon5 = {
const profileDir = gProfD.clone();
profileDir.append("extensions");
-add_task(function*() {
+add_task(function() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "2");
@@ -217,12 +217,7 @@ add_task(function*() {
// After allowing access to the original DB things should still be
// back how they were before the lock
- let shutdownError;
- try {
- shutdownManager();
- } catch (e) {
- shutdownError = e;
- }
+ shutdownManager();
yield file.close();
gExtensionsJSON.permissions = filePermissions;
startupManager();
@@ -231,7 +226,7 @@ add_task(function*() {
// readable, so our changes were saved. On Windows,
// these things happened when we had no access to the database so
// they are seen as external changes when we get the database back
- if (shutdownError) {
+ if (gXPISaveError) {
do_print("Previous XPI save failed");
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED,
["addon6@tests.mozilla.org"]);
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_locked_strictcompat.js b/toolkit/mozapps/extensions/test/xpcshell/test_locked_strictcompat.js
index 9e17b4c8b..907c611dd 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_locked_strictcompat.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_locked_strictcompat.js
@@ -362,12 +362,7 @@ add_task(function* run_test_1() {
// Restarting will actually apply changes to extensions.ini which will
// then be put into the in-memory database when we next fail to load the
// real thing
- try {
- shutdownManager();
- } catch (e) {
- // We're expecting an error here.
- }
- startupManager(false);
+ restartManager();
// Shouldn't have seen any startup changes
check_startup_changes(AddonManager.STARTUP_CHANGE_INSTALLED, []);
@@ -446,12 +441,7 @@ add_task(function* run_test_1() {
// After allowing access to the original DB things should go back to as
// back how they were before the lock
- let shutdownError;
- try {
- shutdownManager();
- } catch (e) {
- shutdownError = e;
- }
+ shutdownManager();
do_print("Unlocking " + gExtensionsJSON.path);
yield file.close();
gExtensionsJSON.permissions = filePermissions;
@@ -491,7 +481,7 @@ add_task(function* run_test_1() {
// remember that this extension was changed to disabled. On Windows we
// couldn't replace the old DB so we read the older version of the DB
// where the extension is enabled
- if (shutdownError) {
+ if (gXPISaveError) {
do_print("XPI save failed");
do_check_true(a3.isActive);
do_check_false(a3.appDisabled);
@@ -553,12 +543,6 @@ add_task(function* run_test_1() {
do_check_false(t2.appDisabled);
do_check_eq(t2.pendingOperations, AddonManager.PENDING_NONE);
do_check_true(isThemeInAddonsList(profileDir, t2.id));
-
- try {
- shutdownManager();
- } catch (e) {
- // An error is expected here.
- }
});
function run_test() {
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_manifest.js b/toolkit/mozapps/extensions/test/xpcshell/test_manifest.js
index 85279ba5d..061a3a6b2 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_manifest.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_manifest.js
@@ -243,7 +243,7 @@ function run_test() {
maxVersion: "1"
}],
name: "Test Addon 18"
- }, profileDir, undefined, "options.xul");
+ }, profileDir, null, "options.xul");
writeInstallRDFForExtension({
id: "addon19@tests.mozilla.org",
@@ -305,7 +305,7 @@ function run_test() {
maxVersion: "1"
}],
name: "Test Addon 23"
- }, profileDir, undefined, "options.xul");
+ }, profileDir, null, "options.xul");
writeInstallRDFForExtension({
id: "addon24@tests.mozilla.org",
@@ -316,7 +316,7 @@ function run_test() {
maxVersion: "1"
}],
name: "Test Addon 24"
- }, profileDir, undefined, "options.xul");
+ }, profileDir, null, "options.xul");
writeInstallRDFForExtension({
id: "addon25@tests.mozilla.org",
@@ -340,7 +340,7 @@ function run_test() {
maxVersion: "1"
}],
name: "Test Addon 26"
- }, profileDir, undefined, "options.xul");
+ }, profileDir, null, "options.xul");
do_test_pending();
startupManager();
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_mapURIToAddonID.js b/toolkit/mozapps/extensions/test/xpcshell/test_mapURIToAddonID.js
index 1dd05064e..a6f9c8052 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_mapURIToAddonID.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_mapURIToAddonID.js
@@ -19,8 +19,6 @@ userExtDir.append("extensions2");
userExtDir.append(gAppInfo.ID);
registerDirectory("XREUSysExt", userExtDir.parent);
-BootstrapMonitor.init();
-
function TestProvider(result) {
this.result = result;
}
@@ -33,7 +31,7 @@ TestProvider.prototype = {
if (aURI.spec === this.uri.spec) {
return this.id;
}
- throw Components.Exception("Not mapped", this.result);
+ throw Components.Exception("Not mapped", result);
}
};
@@ -52,6 +50,18 @@ function check_mapping(uri, id) {
do_check_eq(val.value, id);
}
+function resetPrefs() {
+ Services.prefs.setIntPref("bootstraptest.active_version", -1);
+}
+
+function waitForPref(aPref, aCallback) {
+ function prefChanged() {
+ Services.prefs.removeObserver(aPref, prefChanged);
+ aCallback();
+ }
+ Services.prefs.addObserver(aPref, prefChanged, false);
+}
+
function getActiveVersion() {
return Services.prefs.getIntPref("bootstraptest.active_version");
}
@@ -59,6 +69,8 @@ function getActiveVersion() {
function run_test() {
do_test_pending();
+ resetPrefs();
+
run_test_early();
}
@@ -83,10 +95,8 @@ function run_test_early() {
"resource://gre/modules/addons/XPIProvider.jsm", {});
// Make the early API call.
- // AddonManager still misses its provider and so doesn't work yet.
+ do_check_null(s.XPIProvider.mapURIToAddonID(uri));
do_check_null(AddonManager.mapURIToAddonID(uri));
- // But calling XPIProvider directly works immediately
- do_check_eq(s.XPIProvider.mapURIToAddonID(uri), id);
// Actually start up the manager.
startupManager(false);
@@ -138,7 +148,7 @@ function run_test_1() {
let uri = addon.getResourceURI(".");
check_mapping(uri, addon.id);
- BootstrapMonitor.promiseAddonStartup("bootstrap1@tests.mozilla.org").then(function() {
+ waitForPref("bootstraptest.active_version", function() {
run_test_2(uri);
});
});
@@ -248,38 +258,8 @@ function run_test_7() {
let uri = b1.getResourceURI(".");
check_mapping(uri, b1.id);
- do_execute_soon(run_test_8);
- });
-}
-
-// Tests that temporary addon-on URIs are mappable after install and uninstall
-function run_test_8() {
- prepare_test({
- "bootstrap2@tests.mozilla.org": [
- ["onInstalling", false],
- "onInstalled"
- ]
- }, [
- "onExternalInstall",
- ], function(b2) {
- let uri = b2.getResourceURI(".");
- check_mapping(uri, b2.id);
-
- prepare_test({
- "bootstrap2@tests.mozilla.org": [
- ["onUninstalling", false],
- "onUninstalled"
- ]
- });
-
- b2.uninstall();
- ensure_test_completed();
-
- check_mapping(uri, b2.id);
-
do_execute_soon(run_test_invalidarg);
});
- AddonManager.installTemporaryAddon(do_get_addon("test_bootstrap2_1"));
}
// Tests that the AddonManager will bail when mapURIToAddonID is called with an
@@ -299,12 +279,11 @@ function run_test_invalidarg() {
AddonManager.mapURIToAddonID(test);
throw new Error("Shouldn't be able to map the URI in question");
}
+ catch (ex if ex.result) {
+ do_check_eq(ex.result, Components.results.NS_ERROR_INVALID_ARG);
+ }
catch (ex) {
- if (ex.result) {
- do_check_eq(ex.result, Components.results.NS_ERROR_INVALID_ARG);
- } else {
- do_throw(ex);
- }
+ do_throw(ex);
}
}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_metadata_update.js b/toolkit/mozapps/extensions/test/xpcshell/test_metadata_update.js
index dbf5db485..a87b3f45b 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_metadata_update.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_metadata_update.js
@@ -23,12 +23,12 @@ Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
// None of this works without the add-on repository cache
Services.prefs.setBoolPref("extensions.getAddons.cache.enabled", true);
-var Cc = Components.classes;
-var Ci = Components.interfaces;
-var Cu = Components.utils;
-var Cr = Components.results;
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+const Cu = Components.utils;
+const Cr = Components.results;
-Cu.import("resource://testing-common/MockRegistrar.jsm");
+Cu.import("resource://testing-common/httpd.js");
var testserver;
const profileDir = gProfD.clone();
@@ -37,6 +37,7 @@ profileDir.append("extensions");
// This will be called to show the compatibility update dialog.
var WindowWatcher = {
expected: false,
+ arguments: null,
openWindow: function(parent, url, name, features, args) {
do_check_true(Services.startup.interrupted);
@@ -54,7 +55,18 @@ var WindowWatcher = {
}
}
-MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher);
+var WindowWatcherFactory = {
+ createInstance: function createInstance(outer, iid) {
+ if (outer != null)
+ throw Components.results.NS_ERROR_NO_AGGREGATION;
+ return WindowWatcher.QueryInterface(iid);
+ }
+};
+
+var registrar = Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar);
+registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
+ "Fake Window Watcher",
+ "@mozilla.org/embedcomp/window-watcher;1", WindowWatcherFactory);
// Return Date.now() in seconds, rounded
function now() {
@@ -68,9 +80,10 @@ add_task(function* checkFirstMetadata() {
Services.prefs.setBoolPref(PREF_EM_SHOW_MISMATCH_UI, true);
// Create and configure the HTTP server.
- testserver = createHttpServer();
+ testserver = new HttpServer();
testserver.registerDirectory("/data/", do_get_file("data"));
testserver.registerDirectory("/addons/", do_get_file("addons"));
+ testserver.start(-1);
gPort = testserver.identity.primaryPort;
const BASE_URL = "http://localhost:" + gPort;
const GETADDONS_RESULTS = BASE_URL + "/data/test_AddonRepository_cache.xml";
@@ -157,3 +170,15 @@ add_task(function* upgrade_young_pref_lastupdate() {
yield promiseRestartManager("2");
do_check_false(WindowWatcher.expected);
});
+
+
+
+add_task(function* cleanup() {
+ return new Promise((resolve, reject) => {
+ testserver.stop(resolve);
+ });
+});
+
+function run_test() {
+ run_next_test();
+}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_migrate1.js b/toolkit/mozapps/extensions/test/xpcshell/test_migrate1.js
index 8c13593b9..b3cae5283 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_migrate1.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_migrate1.js
@@ -163,7 +163,6 @@ function run_test() {
do_check_true(a1.isActive);
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
do_check_false(a1.hasBinaryComponents);
- do_check_true(a1.seen);
// addon2 was user disabled and app enabled in the old extensions.rdf
do_check_neq(a2, null);
@@ -172,7 +171,6 @@ function run_test() {
do_check_false(a2.isActive);
do_check_false(isExtensionInAddonsList(profileDir, a2.id));
do_check_false(a2.hasBinaryComponents);
- do_check_true(a2.seen);
// addon3 was pending user disable and app disabled in the old extensions.rdf
do_check_neq(a3, null);
@@ -181,7 +179,6 @@ function run_test() {
do_check_false(a3.isActive);
do_check_false(isExtensionInAddonsList(profileDir, a3.id));
do_check_false(a3.hasBinaryComponents);
- do_check_true(a3.seen);
// addon4 was pending user enable and app disabled in the old extensions.rdf
do_check_neq(a4, null);
@@ -190,7 +187,6 @@ function run_test() {
do_check_false(a4.isActive);
do_check_false(isExtensionInAddonsList(profileDir, a4.id));
do_check_false(a4.hasBinaryComponents);
- do_check_true(a4.seen);
// addon5 was disabled and compatible but a new version has been installed
// since, it should still be disabled but should be incompatible
@@ -200,13 +196,36 @@ function run_test() {
do_check_false(a5.isActive);
do_check_false(isExtensionInAddonsList(profileDir, a5.id));
do_check_false(a5.hasBinaryComponents);
- do_check_true(a5.seen);
- // addon6, addon7 and addon8 will have been lost as they were staged in the
- // pre-Firefox 4.0 directory
- do_check_eq(a6, null);
- do_check_eq(a7, null);
- do_check_eq(a8, null);
+ // addon6 should be installed and compatible and packed unless unpacking is
+ // forced
+ do_check_neq(a6, null);
+ do_check_false(a6.userDisabled);
+ do_check_false(a6.appDisabled);
+ do_check_true(a6.isActive);
+ do_check_true(isExtensionInAddonsList(profileDir, a6.id));
+ if (Services.prefs.getBoolPref("extensions.alwaysUnpack"))
+ do_check_eq(a6.getResourceURI("install.rdf").scheme, "file");
+ else
+ do_check_eq(a6.getResourceURI("install.rdf").scheme, "jar");
+ do_check_false(a6.hasBinaryComponents);
+
+ // addon7 should be installed and compatible and unpacked
+ do_check_neq(a7, null);
+ do_check_false(a7.userDisabled);
+ do_check_false(a7.appDisabled);
+ do_check_true(a7.isActive);
+ do_check_true(isExtensionInAddonsList(profileDir, a7.id));
+ do_check_eq(a7.getResourceURI("install.rdf").scheme, "file");
+ do_check_false(a7.hasBinaryComponents);
+
+ // addon8 should be installed and compatible and have binary components
+ do_check_neq(a8, null);
+ do_check_false(a8.userDisabled);
+ do_check_false(a8.appDisabled);
+ do_check_true(a8.isActive);
+ do_check_true(isExtensionInAddonsList(profileDir, a8.id));
+ do_check_true(a8.hasBinaryComponents);
// Theme 1 was previously enabled
do_check_neq(t1, null);
@@ -215,16 +234,16 @@ function run_test() {
do_check_true(t1.isActive);
do_check_true(isThemeInAddonsList(profileDir, t1.id));
do_check_false(hasFlag(t1.permissions, AddonManager.PERM_CAN_ENABLE));
- do_check_true(t1.seen);
// Theme 2 was previously disabled
- do_check_neq(t2, null);
+ do_check_neq(t1, null);
do_check_true(t2.userDisabled);
do_check_false(t2.appDisabled);
do_check_false(t2.isActive);
do_check_false(isThemeInAddonsList(profileDir, t2.id));
do_check_true(hasFlag(t2.permissions, AddonManager.PERM_CAN_ENABLE));
- do_check_true(t2.seen);
+
+ do_check_false(stagedXPIs.exists());
do_execute_soon(do_test_finished);
});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_migrate2.js b/toolkit/mozapps/extensions/test/xpcshell/test_migrate2.js
index cc7336713..c213bace7 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_migrate2.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_migrate2.js
@@ -203,7 +203,6 @@ function run_test() {
do_check_true(a1.isActive);
do_check_false(a1.strictCompatibility);
do_check_false(a1.foreignInstall);
- do_check_true(a1.seen);
// addon2 was disabled in the database
do_check_neq(a2, null);
do_check_true(a2.userDisabled);
@@ -211,7 +210,6 @@ function run_test() {
do_check_false(a2.isActive);
do_check_false(a2.strictCompatibility);
do_check_false(a2.foreignInstall);
- do_check_true(a2.seen);
// addon3 was pending-disable in the database
do_check_neq(a3, null);
do_check_true(a3.userDisabled);
@@ -219,7 +217,6 @@ function run_test() {
do_check_false(a3.isActive);
do_check_false(a3.strictCompatibility);
do_check_false(a3.foreignInstall);
- do_check_true(a3.seen);
// addon4 was pending-enable in the database
do_check_neq(a4, null);
do_check_false(a4.userDisabled);
@@ -227,7 +224,6 @@ function run_test() {
do_check_true(a4.isActive);
do_check_true(a4.strictCompatibility);
do_check_false(a4.foreignInstall);
- do_check_true(a4.seen);
// addon5 was enabled in the database but needed a compatibility update
do_check_neq(a5, null);
do_check_false(a5.userDisabled);
@@ -235,7 +231,6 @@ function run_test() {
do_check_true(a5.isActive);
do_check_false(a5.strictCompatibility);
do_check_false(a5.foreignInstall);
- do_check_true(a5.seen);
// addon6 was disabled and compatible but a new version has been installed
// since, it should still be disabled but should be incompatible
do_check_neq(a6, null);
@@ -244,7 +239,6 @@ function run_test() {
do_check_false(a6.isActive);
do_check_false(a6.strictCompatibility);
do_check_false(a6.foreignInstall);
- do_check_true(a6.seen);
// addon7 is in the global install location so should be a foreignInstall
do_check_neq(a7, null);
do_check_false(a7.userDisabled);
@@ -252,7 +246,6 @@ function run_test() {
do_check_true(a7.isActive);
do_check_false(a7.strictCompatibility);
do_check_true(a7.foreignInstall);
- do_check_true(a7.seen);
// addon8 is in the user install location so should be a foreignInstall
do_check_neq(a8, null);
do_check_false(a8.userDisabled);
@@ -260,7 +253,6 @@ function run_test() {
do_check_true(a8.isActive);
do_check_false(a8.strictCompatibility);
do_check_true(a8.foreignInstall);
- do_check_true(a8.seen);
do_execute_soon(do_test_finished);
});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_migrate3.js b/toolkit/mozapps/extensions/test/xpcshell/test_migrate3.js
index 71bd66603..f27d53c3f 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_migrate3.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_migrate3.js
@@ -118,19 +118,19 @@ function run_test() {
previewURL: "http://localhost/data/preview.png",
iconURL: "http://localhost/data/icon.png"
}]));
- Services.prefs.setCharPref("lightweightThemes.selectedThemeID", "1");
+ Services.prefs.setBoolPref("lightweightThemes.isThemeSelected", true);
let stagedXPIs = profileDir.clone();
stagedXPIs.append("staged-xpis");
stagedXPIs.append("addon6@tests.mozilla.org");
- stagedXPIs.create(AM_Ci.nsIFile.DIRECTORY_TYPE, 0o755);
+ stagedXPIs.create(AM_Ci.nsIFile.DIRECTORY_TYPE, 0755);
let addon6 = do_get_addon("test_migrate6");
addon6.copyTo(stagedXPIs, "tmp.xpi");
stagedXPIs = stagedXPIs.parent;
stagedXPIs.append("addon7@tests.mozilla.org");
- stagedXPIs.create(AM_Ci.nsIFile.DIRECTORY_TYPE, 0o755);
+ stagedXPIs.create(AM_Ci.nsIFile.DIRECTORY_TYPE, 0755);
let addon7 = do_get_addon("test_migrate7");
addon7.copyTo(stagedXPIs, "tmp.xpi");
@@ -166,7 +166,6 @@ function run_test() {
do_check_false(a1.appDisabled);
do_check_true(a1.isActive);
do_check_true(isExtensionInAddonsList(profileDir, a1.id));
- do_check_true(a1.seen);
// addon2 was user disabled and app enabled in the old extensions.rdf
do_check_neq(a2, null);
@@ -174,7 +173,6 @@ function run_test() {
do_check_false(a2.appDisabled);
do_check_false(a2.isActive);
do_check_false(isExtensionInAddonsList(profileDir, a2.id));
- do_check_true(a2.seen);
// addon3 was pending user disable and app disabled in the old extensions.rdf
do_check_neq(a3, null);
@@ -182,7 +180,6 @@ function run_test() {
do_check_true(a3.appDisabled);
do_check_false(a3.isActive);
do_check_false(isExtensionInAddonsList(profileDir, a3.id));
- do_check_true(a3.seen);
// addon4 was pending user enable and app disabled in the old extensions.rdf
do_check_neq(a4, null);
@@ -190,7 +187,6 @@ function run_test() {
do_check_true(a4.appDisabled);
do_check_false(a4.isActive);
do_check_false(isExtensionInAddonsList(profileDir, a4.id));
- do_check_true(a4.seen);
// addon5 was disabled and compatible but a new version has been installed
// since, it should still be disabled but should be incompatible
@@ -199,12 +195,26 @@ function run_test() {
do_check_true(a5.appDisabled);
do_check_false(a5.isActive);
do_check_false(isExtensionInAddonsList(profileDir, a5.id));
- do_check_true(a5.seen);
- // addon6 and addon7 will have been lost as they were staged in the
- // pre-Firefox 4.0 directory
- do_check_eq(a6, null);
- do_check_eq(a7, null);
+ // addon6 should be installed and compatible and packed unless unpacking is
+ // forced
+ do_check_neq(a6, null);
+ do_check_false(a6.userDisabled);
+ do_check_false(a6.appDisabled);
+ do_check_true(a6.isActive);
+ do_check_true(isExtensionInAddonsList(profileDir, a6.id));
+ if (Services.prefs.getBoolPref("extensions.alwaysUnpack"))
+ do_check_eq(a6.getResourceURI("install.rdf").scheme, "file");
+ else
+ do_check_eq(a6.getResourceURI("install.rdf").scheme, "jar");
+
+ // addon7 should be installed and compatible and unpacked
+ do_check_neq(a7, null);
+ do_check_false(a7.userDisabled);
+ do_check_false(a7.appDisabled);
+ do_check_true(a7.isActive);
+ do_check_true(isExtensionInAddonsList(profileDir, a7.id));
+ do_check_eq(a7.getResourceURI("install.rdf").scheme, "file");
// Theme 1 was previously disabled
do_check_neq(t1, null);
@@ -213,16 +223,16 @@ function run_test() {
do_check_false(t1.isActive);
do_check_true(isThemeInAddonsList(profileDir, t1.id));
do_check_true(hasFlag(t1.permissions, AddonManager.PERM_CAN_ENABLE));
- do_check_true(t1.seen);
// Theme 2 was previously disabled
- do_check_neq(t2, null);
+ do_check_neq(t1, null);
do_check_true(t2.userDisabled);
do_check_false(t2.appDisabled);
do_check_false(t2.isActive);
do_check_false(isThemeInAddonsList(profileDir, t2.id));
do_check_true(hasFlag(t2.permissions, AddonManager.PERM_CAN_ENABLE));
- do_check_true(t2.seen);
+
+ do_check_false(stagedXPIs.exists());
do_execute_soon(do_test_finished);
});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_migrate4.js b/toolkit/mozapps/extensions/test/xpcshell/test_migrate4.js
index fad015886..b2903ead7 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_migrate4.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_migrate4.js
@@ -98,7 +98,7 @@ var defaultTheme = {
const profileDir = gProfD.clone();
profileDir.append("extensions");
-var oldSyncGUIDs = {};
+let oldSyncGUIDs = {};
function prepare_profile() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
@@ -132,7 +132,7 @@ function prepare_profile() {
a6.userDisabled = true;
a9.userDisabled = false;
- for (let addon of [a1, a2, a3, a4, a5, a6]) {
+ for each (let addon in [a1, a2, a3, a4, a5, a6]) {
oldSyncGUIDs[addon.id] = addon.syncGUID;
}
@@ -141,18 +141,18 @@ function prepare_profile() {
AddonManager.getInstallForURL("http://localhost:" + gPort + "/addons/test_migrate4_7.xpi", function(aInstall7) {
completeAllInstalls([aInstall6, aInstall7], function() {
restartManager();
-
+
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]) {
- a3_2.userDisabled = true;
- a4_2.userDisabled = false;
-
- a5_2.findUpdates({
+ function([a1, a2, a3, a4, a5, a6]) {
+ a3.userDisabled = true;
+ a4.userDisabled = false;
+
+ a5.findUpdates({
onUpdateFinished: function() {
do_execute_soon(perform_migration);
}
@@ -168,16 +168,11 @@ function prepare_profile() {
function perform_migration() {
shutdownManager();
-
+
// Turn on disabling for all scopes
Services.prefs.setIntPref("extensions.autoDisableScopes", 15);
- changeXPIDBVersion(1, data => {
- // Delete the seen property from all add-ons to make sure it defaults to true
- for (let addon of data.addons) {
- delete addon.seen;
- }
- });
+ changeXPIDBVersion(1);
Services.prefs.setIntPref("extensions.databaseSchema", 1);
gAppInfo.version = "2"
@@ -210,7 +205,6 @@ function test_results() {
do_check_true(a1.isActive);
do_check_eq(a1.applyBackgroundUpdates, AddonManager.AUTOUPDATE_DEFAULT);
do_check_true(a1.foreignInstall);
- do_check_true(a1.seen);
do_check_false(a1.hasBinaryComponents);
do_check_false(a1.strictCompatibility);
@@ -222,7 +216,6 @@ function test_results() {
do_check_false(a2.isActive);
do_check_eq(a2.applyBackgroundUpdates, AddonManager.AUTOUPDATE_DISABLE);
do_check_true(a2.foreignInstall);
- do_check_true(a2.seen);
do_check_false(a2.hasBinaryComponents);
do_check_false(a2.strictCompatibility);
@@ -234,7 +227,6 @@ function test_results() {
do_check_false(a3.isActive);
do_check_eq(a3.applyBackgroundUpdates, AddonManager.AUTOUPDATE_ENABLE);
do_check_true(a3.foreignInstall);
- do_check_true(a3.seen);
do_check_false(a3.hasBinaryComponents);
do_check_false(a3.strictCompatibility);
@@ -246,7 +238,6 @@ function test_results() {
do_check_true(a4.isActive);
do_check_eq(a4.applyBackgroundUpdates, AddonManager.AUTOUPDATE_DEFAULT);
do_check_true(a4.foreignInstall);
- do_check_true(a4.seen);
do_check_false(a4.hasBinaryComponents);
do_check_true(a4.strictCompatibility);
@@ -257,7 +248,6 @@ function test_results() {
do_check_true(a5.isActive);
do_check_eq(a4.applyBackgroundUpdates, AddonManager.AUTOUPDATE_DEFAULT);
do_check_true(a5.foreignInstall);
- do_check_true(a5.seen);
do_check_false(a5.hasBinaryComponents);
do_check_false(a5.strictCompatibility);
@@ -270,7 +260,6 @@ function test_results() {
do_check_false(a6.isActive);
do_check_eq(a6.applyBackgroundUpdates, AddonManager.AUTOUPDATE_DEFAULT);
do_check_true(a6.foreignInstall);
- do_check_true(a6.seen);
do_check_eq(a6.sourceURI.spec, "http://localhost:" + gPort + "/addons/test_migrate4_6.xpi");
do_check_eq(a6.releaseNotesURI.spec, "http://example.com/updateInfo.xhtml");
do_check_false(a6.hasBinaryComponents);
@@ -284,7 +273,6 @@ function test_results() {
do_check_true(a7.isActive);
do_check_eq(a7.applyBackgroundUpdates, AddonManager.AUTOUPDATE_DEFAULT);
do_check_false(a7.foreignInstall);
- do_check_true(a7.seen);
do_check_eq(a7.sourceURI.spec, "http://localhost:" + gPort + "/addons/test_migrate4_7.xpi");
do_check_eq(a7.releaseNotesURI, null);
do_check_false(a7.hasBinaryComponents);
@@ -296,7 +284,6 @@ function test_results() {
do_check_false(a8.appDisabled);
do_check_true(a8.isActive);
do_check_false(a8.foreignInstall);
- do_check_true(a8.seen);
do_check_true(a8.hasBinaryComponents);
do_check_false(a8.strictCompatibility);
@@ -306,7 +293,6 @@ function test_results() {
do_check_false(a9.appDisabled);
do_check_true(a9.isActive);
do_check_false(a9.foreignInstall);
- do_check_true(a9.seen);
do_check_false(a9.hasBinaryComponents);
do_check_true(a9.strictCompatibility);
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_migrate5.js b/toolkit/mozapps/extensions/test/xpcshell/test_migrate5.js
index 885cd5a7c..0109dcf92 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_migrate5.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_migrate5.js
@@ -1,139 +1,139 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-// Checks that we fail to migrate but still start up ok when there is a SQLITE database
-// with no useful data in it.
-
-const PREF_GENERAL_SKINS_SELECTEDSKIN = "general.skins.selectedSkin";
-
-var addon1 = {
- id: "addon1@tests.mozilla.org",
- version: "1.0",
- name: "Test 1",
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "1"
- }]
-};
-
-var addon2 = {
- id: "addon2@tests.mozilla.org",
- version: "2.0",
- name: "Test 5",
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "0",
- maxVersion: "0"
- }]
-};
-
-var defaultTheme = {
- id: "default@tests.mozilla.org",
- version: "2.0",
- name: "Default theme",
- internalName: "classic/1.0",
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "1"
- }]
-};
-
-var theme1 = {
- id: "theme1@tests.mozilla.org",
- version: "2.0",
- name: "Test theme",
- internalName: "theme1/1.0",
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "1"
- }]
-};
-
-const profileDir = gProfD.clone();
-profileDir.append("extensions");
-
-function run_test() {
- do_test_pending();
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
-
- writeInstallRDFForExtension(addon1, profileDir);
- writeInstallRDFForExtension(addon2, profileDir);
- writeInstallRDFForExtension(defaultTheme, profileDir);
- writeInstallRDFForExtension(theme1, profileDir);
-
- Services.prefs.setCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN, "theme1/1.0");
-
- // Write out a broken database (no userDisabled field)
- let dbfile = gProfD.clone();
- dbfile.append("extensions.sqlite");
- let db = AM_Cc["@mozilla.org/storage/service;1"].
- getService(AM_Ci.mozIStorageService).
- openDatabase(dbfile);
- db.createTable("addon", "internal_id INTEGER PRIMARY KEY AUTOINCREMENT, " +
- "id TEXT, location TEXT, version TEXT, active INTEGER, " +
- "installDate INTEGER");
- db.createTable("targetApplication", "addon_internal_id INTEGER, " +
- "id TEXT, minVersion TEXT, maxVersion TEXT");
- let stmt = db.createStatement("INSERT INTO addon VALUES (NULL, :id, :location, " +
- ":version, :active, :installDate)");
-
- let internal_ids = {};
-
- [["addon1@tests.mozilla.org", "app-profile", "1.0", "1", "0"],
- ["addon2@tests.mozilla.org", "app-profile", "2.0", "0", "0"],
- ["default@tests.mozilla.org", "app-profile", "2.0", "1", "0"],
- ["theme1@tests.mozilla.org", "app-profile", "2.0", "0", "0"]].forEach(function(a) {
- stmt.params.id = a[0];
- stmt.params.location = a[1];
- stmt.params.version = a[2];
- stmt.params.active = a[3];
- stmt.params.installDate = a[4];
- stmt.execute();
- internal_ids[a[0]] = db.lastInsertRowID;
- });
- stmt.finalize();
-
- db.schemaVersion = 100;
- Services.prefs.setIntPref("extensions.databaseSchema", 100);
- db.close();
-
- startupManager();
- check_startup_changes("installed", []);
- check_startup_changes("updated", []);
- check_startup_changes("uninstalled", []);
- check_startup_changes("disabled", []);
- check_startup_changes("enabled", []);
-
- AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
- "addon2@tests.mozilla.org",
- "default@tests.mozilla.org",
- "theme1@tests.mozilla.org"],
- function([a1, a2, d, t1]) {
- do_check_neq(a1, null);
- do_check_false(a1.userDisabled);
- do_check_false(a1.appDisabled);
- do_check_true(a1.isActive);
-
- do_check_neq(a2, null);
- do_check_false(a2.userDisabled);
- do_check_true(a2.appDisabled);
- do_check_false(a2.isActive);
-
- // Should have enabled the selected theme
- do_check_neq(t1, null);
- do_check_false(t1.userDisabled);
- do_check_false(t1.appDisabled);
- do_check_true(t1.isActive);
-
- do_check_neq(d, null);
- do_check_true(d.userDisabled);
- do_check_false(d.appDisabled);
- do_check_false(d.isActive);
-
- do_execute_soon(do_test_finished);
- });
-}
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+// Checks that we fail to migrate but still start up ok when there is a SQLITE database
+// with no useful data in it.
+
+const PREF_GENERAL_SKINS_SELECTEDSKIN = "general.skins.selectedSkin";
+
+var addon1 = {
+ id: "addon1@tests.mozilla.org",
+ version: "1.0",
+ name: "Test 1",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "1",
+ maxVersion: "1"
+ }]
+};
+
+var addon2 = {
+ id: "addon2@tests.mozilla.org",
+ version: "2.0",
+ name: "Test 5",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "0",
+ maxVersion: "0"
+ }]
+};
+
+var defaultTheme = {
+ id: "default@tests.mozilla.org",
+ version: "2.0",
+ name: "Default theme",
+ internalName: "classic/1.0",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "1",
+ maxVersion: "1"
+ }]
+};
+
+var theme1 = {
+ id: "theme1@tests.mozilla.org",
+ version: "2.0",
+ name: "Test theme",
+ internalName: "theme1/1.0",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "1",
+ maxVersion: "1"
+ }]
+};
+
+const profileDir = gProfD.clone();
+profileDir.append("extensions");
+
+function run_test() {
+ do_test_pending();
+ createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
+
+ writeInstallRDFForExtension(addon1, profileDir);
+ writeInstallRDFForExtension(addon2, profileDir);
+ writeInstallRDFForExtension(defaultTheme, profileDir);
+ writeInstallRDFForExtension(theme1, profileDir);
+
+ Services.prefs.setCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN, "theme1/1.0");
+
+ // Write out a broken database (no userDisabled field)
+ let dbfile = gProfD.clone();
+ dbfile.append("extensions.sqlite");
+ let db = AM_Cc["@mozilla.org/storage/service;1"].
+ getService(AM_Ci.mozIStorageService).
+ openDatabase(dbfile);
+ db.createTable("addon", "internal_id INTEGER PRIMARY KEY AUTOINCREMENT, " +
+ "id TEXT, location TEXT, version TEXT, active INTEGER, " +
+ "installDate INTEGER");
+ db.createTable("targetApplication", "addon_internal_id INTEGER, " +
+ "id TEXT, minVersion TEXT, maxVersion TEXT");
+ let stmt = db.createStatement("INSERT INTO addon VALUES (NULL, :id, :location, " +
+ ":version, :active, :installDate)");
+
+ let internal_ids = {};
+
+ [["addon1@tests.mozilla.org", "app-profile", "1.0", "1", "0"],
+ ["addon2@tests.mozilla.org", "app-profile", "2.0", "0", "0"],
+ ["default@tests.mozilla.org", "app-profile", "2.0", "1", "0"],
+ ["theme1@tests.mozilla.org", "app-profile", "2.0", "0", "0"]].forEach(function(a) {
+ stmt.params.id = a[0];
+ stmt.params.location = a[1];
+ stmt.params.version = a[2];
+ stmt.params.active = a[3];
+ stmt.params.installDate = a[4];
+ stmt.execute();
+ internal_ids[a[0]] = db.lastInsertRowID;
+ });
+ stmt.finalize();
+
+ db.schemaVersion = 100;
+ Services.prefs.setIntPref("extensions.databaseSchema", 100);
+ db.close();
+
+ startupManager();
+ check_startup_changes("installed", []);
+ check_startup_changes("updated", []);
+ check_startup_changes("uninstalled", []);
+ check_startup_changes("disabled", []);
+ check_startup_changes("enabled", []);
+
+ AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
+ "addon2@tests.mozilla.org",
+ "default@tests.mozilla.org",
+ "theme1@tests.mozilla.org"],
+ function([a1, a2, d, t1]) {
+ do_check_neq(a1, null);
+ do_check_false(a1.userDisabled);
+ do_check_false(a1.appDisabled);
+ do_check_true(a1.isActive);
+
+ do_check_neq(a2, null);
+ do_check_false(a2.userDisabled);
+ do_check_true(a2.appDisabled);
+ do_check_false(a2.isActive);
+
+ // Should have enabled the selected theme
+ do_check_neq(t1, null);
+ do_check_false(t1.userDisabled);
+ do_check_false(t1.appDisabled);
+ do_check_true(t1.isActive);
+
+ do_check_neq(d, null);
+ do_check_true(d.userDisabled);
+ do_check_false(d.appDisabled);
+ do_check_false(d.isActive);
+
+ do_execute_soon(do_test_finished);
+ });
+}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_migrateAddonRepository.js b/toolkit/mozapps/extensions/test/xpcshell/test_migrateAddonRepository.js
index d9cfc8790..ad8bd5bca 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_migrateAddonRepository.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_migrateAddonRepository.js
@@ -3,7 +3,7 @@
*/
const EXPECTED_SCHEMA_VERSION = 4;
-var dbfile;
+let dbfile;
function run_test() {
do_test_pending();
@@ -59,21 +59,21 @@ function run_test() {
"caption TEXT, " +
"PRIMARY KEY (addon_internal_id, num)");
- let insertStmt = db.createStatement("INSERT INTO addon (id) VALUES (:id)");
- insertStmt.params.id = "test1@tests.mozilla.org";
- insertStmt.execute();
- insertStmt.finalize();
+ let stmt = db.createStatement("INSERT INTO addon (id) VALUES (:id)");
+ stmt.params.id = "test1@tests.mozilla.org";
+ stmt.execute();
+ stmt.finalize();
- insertStmt = db.createStatement("INSERT INTO screenshot VALUES " +
+ stmt = db.createStatement("INSERT INTO screenshot VALUES " +
"(:addon_internal_id, :num, :url, :thumbnailURL, :caption)");
- insertStmt.params.addon_internal_id = 1;
- insertStmt.params.num = 0;
- insertStmt.params.url = "http://localhost/full1-1.png";
- insertStmt.params.thumbnailURL = "http://localhost/thumbnail1-1.png";
- insertStmt.params.caption = "Caption 1 - 1";
- insertStmt.execute();
- insertStmt.finalize();
+ stmt.params.addon_internal_id = 1;
+ stmt.params.num = 0;
+ stmt.params.url = "http://localhost/full1-1.png";
+ stmt.params.thumbnailURL = "http://localhost/thumbnail1-1.png";
+ stmt.params.caption = "Caption 1 - 1";
+ stmt.execute();
+ stmt.finalize();
db.schemaVersion = 1;
db.close();
@@ -108,15 +108,15 @@ function run_test() {
let internalID = db.lastInsertRowID;
db.executeSimpleSQL("INSERT INTO compatibility_override (addon_internal_id, num, type) VALUES('" + internalID + "', '1', 'incompatible')");
- let selectStmt = db.createStatement("SELECT COUNT(*) AS count FROM compatibility_override");
- selectStmt.executeStep();
- do_check_eq(selectStmt.row.count, 1);
- selectStmt.reset();
+ let stmt = db.createStatement("SELECT COUNT(*) AS count FROM compatibility_override");
+ stmt.executeStep();
+ do_check_eq(stmt.row.count, 1);
+ stmt.reset();
db.executeSimpleSQL("DELETE FROM addon");
- selectStmt.executeStep();
- do_check_eq(selectStmt.row.count, 0);
- selectStmt.finalize();
+ stmt.executeStep();
+ do_check_eq(stmt.row.count, 0);
+ stmt.finalize();
db.close();
do_test_finished();
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_migrate_max_version.js b/toolkit/mozapps/extensions/test/xpcshell/test_migrate_max_version.js
index 171ac411e..133c3a199 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_migrate_max_version.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_migrate_max_version.js
@@ -80,7 +80,7 @@ add_test(function before_rebuild() {
});
});
-// now shut down, remove the JSON database,
+// now shut down, remove the JSON database,
// start up again, and make sure the data didn't migrate this time
add_test(function rebuild_again() {
shutdownManager();
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_multiprocessCompatible.js b/toolkit/mozapps/extensions/test/xpcshell/test_multiprocessCompatible.js
index 4cd103fa6..ab5a976cc 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_multiprocessCompatible.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_multiprocessCompatible.js
@@ -53,8 +53,7 @@ function build_test(multiprocessCompatible, bootstrap, updateMultiprocessCompati
let xpifile = createTempXPIFile(addonData);
let install = yield new Promise(resolve => AddonManager.getInstallForFile(xpifile, resolve));
- do_check_eq(install.addon.multiprocessCompatible, !!multiprocessCompatible);
- do_check_eq(install.addon.mpcOptedOut, multiprocessCompatible === false)
+ do_check_eq(install.addon.multiprocessCompatible, multiprocessCompatible);
yield promiseCompleteAllInstalls([install]);
if (!bootstrap) {
@@ -65,18 +64,17 @@ function build_test(multiprocessCompatible, bootstrap, updateMultiprocessCompati
let addon = yield promiseAddonByID(addonData.id);
do_check_neq(addon, null);
- do_check_eq(addon.multiprocessCompatible, !!multiprocessCompatible);
- do_check_eq(addon.mpcOptedOut, multiprocessCompatible === false);
+ do_check_eq(addon.multiprocessCompatible, multiprocessCompatible);
yield promiseFindAddonUpdates(addon);
// Should have applied the compatibility change
- do_check_eq(addon.multiprocessCompatible, !!expectedMPC);
+ do_check_eq(addon.multiprocessCompatible, expectedMPC);
yield promiseRestartManager();
addon = yield promiseAddonByID(addonData.id);
// Should have persisted the compatibility change
- do_check_eq(addon.multiprocessCompatible, !!expectedMPC);
+ do_check_eq(addon.multiprocessCompatible, expectedMPC);
if (!bootstrap) {
do_check_true(isExtensionInAddonsList(profileDir, addonData.id));
do_check_eq(isItemMarkedMPIncompatible(addonData.id), !multiprocessCompatible);
@@ -95,7 +93,7 @@ function build_test(multiprocessCompatible, bootstrap, updateMultiprocessCompati
* The update saying the add-on should or should not support multiprocess (or not say anything at all)
*/
for (let bootstrap of [false, true]) {
- for (let multiprocessCompatible of [undefined, false, true]) {
+ for (let multiprocessCompatible of [false, true]) {
for (let updateMultiprocessCompatible of [undefined, false, true]) {
add_task(build_test(multiprocessCompatible, bootstrap, updateMultiprocessCompatible));
}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_no_addons.js b/toolkit/mozapps/extensions/test/xpcshell/test_no_addons.js
index a2ea5301e..ae75fbb43 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_no_addons.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_no_addons.js
@@ -8,7 +8,7 @@
Components.utils.import("resource://gre/modules/Promise.jsm");
// Load XPI Provider to get schema version ID
-var XPIScope = Components.utils.import("resource://gre/modules/addons/XPIProvider.jsm");
+let XPIScope = Components.utils.import("resource://gre/modules/addons/XPIProvider.jsm");
const DB_SCHEMA = XPIScope.DB_SCHEMA;
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
@@ -33,7 +33,7 @@ function checkString(aPref, aValue) {
do_check_eq(Services.prefs.getCharPref(aPref), aValue)
}
catch (e) {
- // OK
+ //OK
}
}
@@ -56,14 +56,14 @@ function check_empty_state() {
// bootstrap add-ons preference is not found
// add-on directory state preference is an empty array
// no pending operations
-add_task(function* first_run() {
+add_task(function first_run() {
startupManager();
check_empty_state();
yield true;
});
// Now do something that causes a DB load, and re-check
-function* trigger_db_load() {
+function trigger_db_load() {
let addonDefer = Promise.defer();
AddonManager.getAddonsByTypes(['extension'], addonDefer.resolve);
let addonList = yield addonDefer.promise;
@@ -72,11 +72,11 @@ function* trigger_db_load() {
check_empty_state();
yield true;
-}
+};
add_task(trigger_db_load);
// Now restart the manager and check again
-add_task(function* restart_and_recheck() {
+add_task(function restart_and_recheck() {
restartManager();
check_empty_state();
yield true;
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_nodisable_hidden.js b/toolkit/mozapps/extensions/test/xpcshell/test_nodisable_hidden.js
deleted file mode 100644
index 2d11e9c5b..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_nodisable_hidden.js
+++ /dev/null
@@ -1,107 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-// This test verifies that hidden add-ons cannot be user disabled.
-
-// for normal add-ons
-const profileDir = FileUtils.getDir("ProfD", ["extensions"]);
-// for system add-ons
-const distroDir = FileUtils.getDir("ProfD", ["sysfeatures"], true);
-registerDirectory("XREAppFeat", distroDir);
-
-const NORMAL_ID = "normal@tests.mozilla.org";
-const SYSTEM_ID = "system@tests.mozilla.org";
-
-createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "42");
-
-// normal add-ons can be user disabled.
-add_task(function*() {
-
- writeInstallRDFToDir({
- id: NORMAL_ID,
- version: "1.0",
- bootstrap: true,
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "1"
- }],
- name: "Test disabling hidden add-ons, non-hidden add-on case.",
- }, profileDir, NORMAL_ID);
-
- startupManager();
-
- let addon = yield promiseAddonByID(NORMAL_ID);
- do_check_neq(addon, null);
- do_check_eq(addon.version, "1.0");
- do_check_eq(addon.name, "Test disabling hidden add-ons, non-hidden add-on case.");
- do_check_true(addon.isCompatible);
- do_check_false(addon.appDisabled);
- do_check_false(addon.userDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.type, "extension");
-
- // normal add-ons can be disabled by the user.
- addon.userDisabled = true;
-
- do_check_neq(addon, null);
- do_check_eq(addon.version, "1.0");
- do_check_eq(addon.name, "Test disabling hidden add-ons, non-hidden add-on case.");
- do_check_true(addon.isCompatible);
- do_check_false(addon.appDisabled);
- do_check_true(addon.userDisabled);
- do_check_false(addon.isActive);
- do_check_eq(addon.type, "extension");
-
- addon.uninstall();
-
- shutdownManager();
-});
-
-// system add-ons can never be user disabled.
-add_task(function*() {
-
- writeInstallRDFToDir({
- id: SYSTEM_ID,
- version: "1.0",
- bootstrap: true,
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "1"
- }],
- name: "Test disabling hidden add-ons, hidden system add-on case.",
- }, distroDir, SYSTEM_ID);
-
- startupManager();
-
- let addon = yield promiseAddonByID(SYSTEM_ID);
- do_check_neq(addon, null);
- do_check_eq(addon.version, "1.0");
- do_check_eq(addon.name, "Test disabling hidden add-ons, hidden system add-on case.");
- do_check_true(addon.isCompatible);
- do_check_false(addon.appDisabled);
- do_check_false(addon.userDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.type, "extension");
-
- // system add-ons cannot be disabled by the user.
- try {
- addon.userDisabled = true;
- do_throw("Expected addon.userDisabled on a hidden add-on to throw!");
- } catch (e) {
- do_check_eq(e.message, `Cannot disable hidden add-on ${SYSTEM_ID}`);
- }
-
- do_check_neq(addon, null);
- do_check_eq(addon.version, "1.0");
- do_check_eq(addon.name, "Test disabling hidden add-ons, hidden system add-on case.");
- do_check_true(addon.isCompatible);
- do_check_false(addon.appDisabled);
- do_check_false(addon.userDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.type, "extension");
-
- shutdownManager();
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_overrideblocklist.js b/toolkit/mozapps/extensions/test/xpcshell/test_overrideblocklist.js
index c39e432bd..8a6bedea1 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_overrideblocklist.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_overrideblocklist.js
@@ -16,19 +16,19 @@ const NEW_TSTAMP = 1396046918000;
const gAppDir = FileUtils.getFile(KEY_APPDIR, []);
-var oldAddon = {
+let oldAddon = {
id: "old@tests.mozilla.org",
version: 1
}
-var newAddon = {
+let newAddon = {
id: "new@tests.mozilla.org",
version: 1
}
-var ancientAddon = {
+let ancientAddon = {
id: "ancient@tests.mozilla.org",
version: 1
}
-var invalidAddon = {
+let invalidAddon = {
id: "invalid@tests.mozilla.org",
version: 1
}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_pass_symbol.js b/toolkit/mozapps/extensions/test/xpcshell/test_pass_symbol.js
deleted file mode 100644
index 657601e45..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_pass_symbol.js
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-const PASS_PREF = "symboltest.instanceid.pass";
-const FAIL_BOGUS_PREF = "symboltest.instanceid.fail_bogus";
-const FAIL_ID_PREF = "symboltest.instanceid.fail_bogus";
-const ADDON_ID = "test_symbol@tests.mozilla.org";
-
-createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "42");
-startupManager();
-
-BootstrapMonitor.init();
-
-// symbol is passed when add-on is installed
-add_task(function*() {
- for (let pref of [PASS_PREF, FAIL_BOGUS_PREF, FAIL_ID_PREF])
- Services.prefs.clearUserPref(pref);
-
- yield promiseInstallAllFiles([do_get_addon("test_symbol")], true);
-
- let addon = yield promiseAddonByID(ADDON_ID);
-
- do_check_neq(addon, null);
- do_check_eq(addon.version, "1.0");
- do_check_eq(addon.name, "Test Symbol");
- do_check_true(addon.isCompatible);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.type, "extension");
-
- // most of the test is in bootstrap.js in the addon because BootstrapMonitor
- // currently requires the objects in `data` to be serializable, and we
- // need a real reference to the symbol to test this.
- do_execute_soon(function() {
- // give the startup time to run
- do_check_true(Services.prefs.getBoolPref(PASS_PREF));
- do_check_true(Services.prefs.getBoolPref(FAIL_BOGUS_PREF));
- do_check_true(Services.prefs.getBoolPref(FAIL_ID_PREF));
- });
-
- yield promiseRestartManager();
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_permissions.js b/toolkit/mozapps/extensions/test/xpcshell/test_permissions.js
index 48fef406f..11463768f 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_permissions.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_permissions.js
@@ -1,86 +1,86 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-Components.utils.import("resource://gre/modules/NetUtil.jsm");
-
-// Checks that permissions set in preferences are correctly imported but can
-// be removed by the user.
-
-const XPI_MIMETYPE = "application/x-xpinstall";
-
-function newPrincipal(uri) {
- return Services.scriptSecurityManager.createCodebasePrincipal(NetUtil.newURI(uri), {});
-}
-
-function run_test() {
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "2");
-
- Services.prefs.setCharPref("xpinstall.whitelist.add", "https://test1.com,https://test2.com");
- Services.prefs.setCharPref("xpinstall.whitelist.add.36", "https://test3.com,https://www.test4.com");
- Services.prefs.setCharPref("xpinstall.whitelist.add.test5", "https://test5.com");
-
- Services.perms.add(NetUtil.newURI("https://www.test9.com"), "install",
- AM_Ci.nsIPermissionManager.ALLOW_ACTION);
-
- startupManager();
-
- do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
- newPrincipal("http://test1.com")));
- do_check_true(AddonManager.isInstallAllowed(XPI_MIMETYPE,
- newPrincipal("https://test1.com")));
- do_check_true(AddonManager.isInstallAllowed(XPI_MIMETYPE,
- newPrincipal("https://www.test2.com")));
- do_check_true(AddonManager.isInstallAllowed(XPI_MIMETYPE,
- newPrincipal("https://test3.com")));
- do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
- newPrincipal("https://test4.com")));
- do_check_true(AddonManager.isInstallAllowed(XPI_MIMETYPE,
- newPrincipal("https://www.test4.com")));
- do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
- newPrincipal("http://www.test5.com")));
- do_check_true(AddonManager.isInstallAllowed(XPI_MIMETYPE,
- newPrincipal("https://www.test5.com")));
-
- do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
- newPrincipal("http://www.test6.com")));
- do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
- newPrincipal("https://www.test6.com")));
- do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
- newPrincipal("https://test7.com")));
- do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
- newPrincipal("https://www.test8.com")));
-
- // This should remain unaffected
- do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
- newPrincipal("http://www.test9.com")));
- do_check_true(AddonManager.isInstallAllowed(XPI_MIMETYPE,
- newPrincipal("https://www.test9.com")));
-
- Services.perms.removeAll();
-
- do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
- newPrincipal("https://test1.com")));
- do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
- newPrincipal("https://www.test2.com")));
- do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
- newPrincipal("https://test3.com")));
- do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
- newPrincipal("https://www.test4.com")));
- do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
- newPrincipal("https://www.test5.com")));
-
- // Upgrade the application and verify that the permissions are still not there
- restartManager("2");
-
- do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
- newPrincipal("https://test1.com")));
- do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
- newPrincipal("https://www.test2.com")));
- do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
- newPrincipal("https://test3.com")));
- do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
- newPrincipal("https://www.test4.com")));
- do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
- newPrincipal("https://www.test5.com")));
-}
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+Components.utils.import("resource://gre/modules/NetUtil.jsm");
+
+// Checks that permissions set in preferences are correctly imported but can
+// be removed by the user.
+
+const XPI_MIMETYPE = "application/x-xpinstall";
+
+function newPrincipal(uri) {
+ return Services.scriptSecurityManager.getNoAppCodebasePrincipal(NetUtil.newURI(uri));
+}
+
+function run_test() {
+ createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "2");
+
+ Services.prefs.setCharPref("xpinstall.whitelist.add", "test1.com,test2.com");
+ Services.prefs.setCharPref("xpinstall.whitelist.add.36", "test3.com,www.test4.com");
+ Services.prefs.setCharPref("xpinstall.whitelist.add.test5", "test5.com");
+
+ Services.perms.add(NetUtil.newURI("https://www.test9.com"), "install",
+ AM_Ci.nsIPermissionManager.ALLOW_ACTION);
+
+ startupManager();
+
+ do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
+ newPrincipal("http://test1.com")));
+ do_check_true(AddonManager.isInstallAllowed(XPI_MIMETYPE,
+ newPrincipal("https://test1.com")));
+ do_check_true(AddonManager.isInstallAllowed(XPI_MIMETYPE,
+ newPrincipal("https://www.test2.com")));
+ do_check_true(AddonManager.isInstallAllowed(XPI_MIMETYPE,
+ newPrincipal("https://test3.com")));
+ do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
+ newPrincipal("https://test4.com")));
+ do_check_true(AddonManager.isInstallAllowed(XPI_MIMETYPE,
+ newPrincipal("https://www.test4.com")));
+ do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
+ newPrincipal("http://www.test5.com")));
+ do_check_true(AddonManager.isInstallAllowed(XPI_MIMETYPE,
+ newPrincipal("https://www.test5.com")));
+
+ do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
+ newPrincipal("http://www.test6.com")));
+ do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
+ newPrincipal("https://www.test6.com")));
+ do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
+ newPrincipal("https://test7.com")));
+ do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
+ newPrincipal("https://www.test8.com")));
+
+ // This should remain unaffected
+ do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
+ newPrincipal("http://www.test9.com")));
+ do_check_true(AddonManager.isInstallAllowed(XPI_MIMETYPE,
+ newPrincipal("https://www.test9.com")));
+
+ Services.perms.removeAll();
+
+ do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
+ newPrincipal("https://test1.com")));
+ do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
+ newPrincipal("https://www.test2.com")));
+ do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
+ newPrincipal("https://test3.com")));
+ do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
+ newPrincipal("https://www.test4.com")));
+ do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
+ newPrincipal("https://www.test5.com")));
+
+ // Upgrade the application and verify that the permissions are still not there
+ restartManager("2");
+
+ do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
+ newPrincipal("https://test1.com")));
+ do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
+ newPrincipal("https://www.test2.com")));
+ do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
+ newPrincipal("https://test3.com")));
+ do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
+ newPrincipal("https://www.test4.com")));
+ do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
+ newPrincipal("https://www.test5.com")));
+}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_permissions_prefs.js b/toolkit/mozapps/extensions/test/xpcshell/test_permissions_prefs.js
index 576f04a65..ae1373214 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_permissions_prefs.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_permissions_prefs.js
@@ -1,74 +1,74 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-// Tests that xpinstall.[whitelist|blacklist].add preferences are emptied when
-// converted into permissions.
-
-const PREF_XPI_WHITELIST_PERMISSIONS = "xpinstall.whitelist.add";
-const PREF_XPI_BLACKLIST_PERMISSIONS = "xpinstall.blacklist.add";
-
-function newPrincipal(uri) {
- return Services.scriptSecurityManager.createCodebasePrincipal(NetUtil.newURI(uri), {});
-}
-
-function do_check_permission_prefs(preferences) {
- // Check preferences were emptied
- for (let pref of preferences) {
- try {
- do_check_eq(Services.prefs.getCharPref(pref), "");
- }
- catch (e) {
- // Successfully emptied
- }
- }
-}
-
-function clear_imported_preferences_cache() {
- let scope = Components.utils.import("resource://gre/modules/PermissionsUtils.jsm", {});
- scope.gImportedPrefBranches.clear();
-}
-
-function run_test() {
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
-
- // Create own preferences to test
- Services.prefs.setCharPref("xpinstall.whitelist.add.EMPTY", "");
- Services.prefs.setCharPref("xpinstall.whitelist.add.TEST", "http://whitelist.example.com");
- Services.prefs.setCharPref("xpinstall.blacklist.add.EMPTY", "");
- Services.prefs.setCharPref("xpinstall.blacklist.add.TEST", "http://blacklist.example.com");
-
- // Get list of preferences to check
- var whitelistPreferences = Services.prefs.getChildList(PREF_XPI_WHITELIST_PERMISSIONS, {});
- var blacklistPreferences = Services.prefs.getChildList(PREF_XPI_BLACKLIST_PERMISSIONS, {});
- var preferences = whitelistPreferences.concat(blacklistPreferences);
-
- startupManager();
-
- // Permissions are imported lazily - act as thought we're checking an install,
- // to trigger on-deman importing of the permissions.
- AddonManager.isInstallAllowed("application/x-xpinstall", newPrincipal("http://example.com/file.xpi"));
- do_check_permission_prefs(preferences);
-
-
- // Import can also be triggerred by an observer notification by any other area
- // of code, such as a permissions management UI.
-
- // First, request to flush all permissions
- clear_imported_preferences_cache();
- Services.prefs.setCharPref("xpinstall.whitelist.add.TEST2", "https://whitelist2.example.com");
- Services.obs.notifyObservers(null, "flush-pending-permissions", "install");
- do_check_permission_prefs(preferences);
-
- // Then, request to flush just install permissions
- clear_imported_preferences_cache();
- Services.prefs.setCharPref("xpinstall.whitelist.add.TEST3", "https://whitelist3.example.com");
- Services.obs.notifyObservers(null, "flush-pending-permissions", "");
- do_check_permission_prefs(preferences);
-
- // And a request to flush some other permissions sholdn't flush install permissions
- clear_imported_preferences_cache();
- Services.prefs.setCharPref("xpinstall.whitelist.add.TEST4", "https://whitelist4.example.com");
- Services.obs.notifyObservers(null, "flush-pending-permissions", "lolcats");
- do_check_eq(Services.prefs.getCharPref("xpinstall.whitelist.add.TEST4"), "https://whitelist4.example.com");
-}
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+// Tests that xpinstall.[whitelist|blacklist].add preferences are emptied when
+// converted into permissions.
+
+const PREF_XPI_WHITELIST_PERMISSIONS = "xpinstall.whitelist.add";
+const PREF_XPI_BLACKLIST_PERMISSIONS = "xpinstall.blacklist.add";
+
+function newPrincipal(uri) {
+ return Services.scriptSecurityManager.getNoAppCodebasePrincipal(NetUtil.newURI(uri));
+}
+
+function do_check_permission_prefs(preferences) {
+ // Check preferences were emptied
+ for (let pref of preferences) {
+ try {
+ do_check_eq(Services.prefs.getCharPref(pref), "");
+ }
+ catch (e) {
+ // Successfully emptied
+ }
+ }
+}
+
+function clear_imported_preferences_cache() {
+ let scope = Components.utils.import("resource://gre/modules/PermissionsUtils.jsm", {});
+ scope.gImportedPrefBranches.clear();
+}
+
+function run_test() {
+ createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
+
+ // Create own preferences to test
+ Services.prefs.setCharPref("xpinstall.whitelist.add.EMPTY", "");
+ Services.prefs.setCharPref("xpinstall.whitelist.add.TEST", "whitelist.example.com");
+ Services.prefs.setCharPref("xpinstall.blacklist.add.EMPTY", "");
+ Services.prefs.setCharPref("xpinstall.blacklist.add.TEST", "blacklist.example.com");
+
+ // Get list of preferences to check
+ var whitelistPreferences = Services.prefs.getChildList(PREF_XPI_WHITELIST_PERMISSIONS, {});
+ var blacklistPreferences = Services.prefs.getChildList(PREF_XPI_BLACKLIST_PERMISSIONS, {});
+ var preferences = whitelistPreferences.concat(blacklistPreferences);
+
+ startupManager();
+
+ // Permissions are imported lazily - act as thought we're checking an install,
+ // to trigger on-deman importing of the permissions.
+ AddonManager.isInstallAllowed("application/x-xpinstall", newPrincipal("http://example.com/file.xpi"));
+ do_check_permission_prefs(preferences);
+
+
+ // Import can also be triggerred by an observer notification by any other area
+ // of code, such as a permissions management UI.
+
+ // First, request to flush all permissions
+ clear_imported_preferences_cache();
+ Services.prefs.setCharPref("xpinstall.whitelist.add.TEST2", "whitelist2.example.com");
+ Services.obs.notifyObservers(null, "flush-pending-permissions", "install");
+ do_check_permission_prefs(preferences);
+
+ // Then, request to flush just install permissions
+ clear_imported_preferences_cache();
+ Services.prefs.setCharPref("xpinstall.whitelist.add.TEST3", "whitelist3.example.com");
+ Services.obs.notifyObservers(null, "flush-pending-permissions", "");
+ do_check_permission_prefs(preferences);
+
+ // And a request to flush some other permissions sholdn't flush install permissions
+ clear_imported_preferences_cache();
+ Services.prefs.setCharPref("xpinstall.whitelist.add.TEST4", "whitelist4.example.com");
+ Services.obs.notifyObservers(null, "flush-pending-permissions", "lolcats");
+ do_check_eq(Services.prefs.getCharPref("xpinstall.whitelist.add.TEST4"), "whitelist4.example.com");
+}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_pluginBlocklistCtp.js b/toolkit/mozapps/extensions/test/xpcshell/test_pluginBlocklistCtp.js
index 563b7434c..8d7e944e2 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_pluginBlocklistCtp.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_pluginBlocklistCtp.js
@@ -161,7 +161,6 @@ function run_test() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9");
Services.prefs.setCharPref("extensions.blocklist.url", "http://localhost:" + gPort + "/data/test_pluginBlocklistCtp.xml");
- Services.prefs.setBoolPref("plugin.load_flash_only", false);
startupManager();
gPluginHost = Components.classes["@mozilla.org/plugin/host;1"].getService(Components.interfaces.nsIPluginHost);
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_pluginInfoURL.js b/toolkit/mozapps/extensions/test/xpcshell/test_pluginInfoURL.js
index e5acb28a4..e140f021a 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_pluginInfoURL.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_pluginInfoURL.js
@@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-var Ci = Components.interfaces;
+const Ci = Components.interfaces;
Components.utils.import("resource://gre/modules/Services.jsm");
/**
@@ -30,9 +30,7 @@ MockPlugin.prototype = {
const PLUGINS = [
new MockPlugin('test_with_infoURL', '5', Ci.nsIPluginTag.STATE_ENABLED),
new MockPlugin('test_with_altInfoURL', '5', Ci.nsIPluginTag.STATE_ENABLED),
- new MockPlugin('test_no_infoURL', '5', Ci.nsIPluginTag.STATE_ENABLED),
- new MockPlugin('test_newVersion', '1', Ci.nsIPluginTag.STATE_ENABLED),
- new MockPlugin('test_newVersion', '3', Ci.nsIPluginTag.STATE_ENABLED)
+ new MockPlugin('test_no_infoURL', '5', Ci.nsIPluginTag.STATE_ENABLED)
];
/**
@@ -80,11 +78,3 @@ add_task(function* test_infoURL_missing() {
Assert.strictEqual(Services.blocklist.getPluginInfoURL(PLUGINS[2]), null,
'Should be null when no infoURL tag is available.');
});
-
-add_task(function* test_intoURL_newVersion() {
- let testInfoURL = 'http://test.url2.com/';
- Assert.strictEqual(Services.blocklist.getPluginInfoURL(PLUGINS[3]),
- testInfoURL, 'Old plugin should match');
- Assert.strictEqual(Services.blocklist.getPluginInfoURL(PLUGINS[4]),
- null, 'New plugin should not match');
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_pluginchange.js b/toolkit/mozapps/extensions/test/xpcshell/test_pluginchange.js
index 05e17b35e..d3e33dac3 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_pluginchange.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_pluginchange.js
@@ -1,283 +1,292 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-const LIST_UPDATED_TOPIC = "plugins-list-updated";
-
-// We need to use the same algorithm for generating IDs for plugins
-var { getIDHashForString } = Components.utils.import("resource://gre/modules/addons/PluginProvider.jsm");
-var { MockRegistrar } = Components.utils.import("resource://testing-common/MockRegistrar.jsm");
-
-function PluginTag(name, description) {
- this.name = name;
- this.description = description;
-}
-
-PluginTag.prototype = {
- name: null,
- description: null,
- version: "1.0",
- filename: null,
- fullpath: null,
- disabled: false,
- blocklisted: false,
- clicktoplay: false,
-
- mimeTypes: [],
-
- getMimeTypes: function(count) {
- count.value = this.mimeTypes.length;
- return this.mimeTypes;
- }
-};
-
-const PLUGINS = [
- // A standalone plugin
- new PluginTag("Java", "A mock Java plugin"),
-
- // A plugin made up of two plugin files
- new PluginTag("Flash", "A mock Flash plugin"),
- new PluginTag("Flash", "A mock Flash plugin")
-];
-
-const gPluginHost = {
- // nsIPluginHost
- getPluginTags: function(count) {
- count.value = PLUGINS.length;
- return PLUGINS;
- },
-
- QueryInterface: XPCOMUtils.generateQI([AM_Ci.nsIPluginHost])
-};
-
-MockRegistrar.register("@mozilla.org/plugin/host;1", gPluginHost);
-
-// This verifies that when the list of plugins changes the add-ons manager
-// correctly updates
-function run_test() {
- do_test_pending();
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
-
- Services.prefs.setBoolPref("media.gmp-provider.enabled", false);
-
- startupManager();
- AddonManager.addAddonListener(AddonListener);
- AddonManager.addInstallListener(InstallListener);
-
- run_test_1();
-}
-
-function end_test() {
- do_execute_soon(do_test_finished);
-}
-
-function sortAddons(addons) {
- addons.sort(function(a, b) {
- return a.name.localeCompare(b.name);
- });
-}
-
-// Basic check that the mock object works
-function run_test_1() {
- AddonManager.getAddonsByTypes(["plugin"], function(addons) {
- sortAddons(addons);
-
- do_check_eq(addons.length, 2);
-
- do_check_eq(addons[0].name, "Flash");
- do_check_false(addons[0].userDisabled);
- do_check_eq(addons[1].name, "Java");
- do_check_false(addons[1].userDisabled);
-
- run_test_2();
- });
-}
-
-// No change to the list should not trigger any events or changes in the API
-function run_test_2() {
- // Reorder the list a bit
- let tag = PLUGINS[0];
- PLUGINS[0] = PLUGINS[2];
- PLUGINS[2] = PLUGINS[1];
- PLUGINS[1] = tag;
-
- Services.obs.notifyObservers(null, LIST_UPDATED_TOPIC, null);
-
- AddonManager.getAddonsByTypes(["plugin"], function(addons) {
- sortAddons(addons);
-
- do_check_eq(addons.length, 2);
-
- do_check_eq(addons[0].name, "Flash");
- do_check_false(addons[0].userDisabled);
- do_check_eq(addons[1].name, "Java");
- do_check_false(addons[1].userDisabled);
-
- run_test_3();
- });
-}
-
-// Tests that a newly detected plugin shows up in the API and sends out events
-function run_test_3() {
- let tag = new PluginTag("Quicktime", "A mock Quicktime plugin");
- PLUGINS.push(tag);
- let id = getIDHashForString(tag.name + tag.description);
-
- let test_params = {};
- test_params[id] = [
- ["onInstalling", false],
- "onInstalled"
- ];
-
- prepare_test(test_params, [
- "onExternalInstall"
- ]);
-
- Services.obs.notifyObservers(null, LIST_UPDATED_TOPIC, null);
-
- ensure_test_completed();
-
- AddonManager.getAddonsByTypes(["plugin"], function(addons) {
- sortAddons(addons);
-
- do_check_eq(addons.length, 3);
-
- do_check_eq(addons[0].name, "Flash");
- do_check_false(addons[0].userDisabled);
- do_check_eq(addons[1].name, "Java");
- do_check_false(addons[1].userDisabled);
- do_check_eq(addons[2].name, "Quicktime");
- do_check_false(addons[2].userDisabled);
-
- run_test_4();
- });
-}
-
-// Tests that a removed plugin disappears from in the API and sends out events
-function run_test_4() {
- let tag = PLUGINS.splice(1, 1)[0];
- let id = getIDHashForString(tag.name + tag.description);
-
- let test_params = {};
- test_params[id] = [
- ["onUninstalling", false],
- "onUninstalled"
- ];
-
- prepare_test(test_params);
-
- Services.obs.notifyObservers(null, LIST_UPDATED_TOPIC, null);
-
- ensure_test_completed();
-
- AddonManager.getAddonsByTypes(["plugin"], function(addons) {
- sortAddons(addons);
-
- do_check_eq(addons.length, 2);
-
- do_check_eq(addons[0].name, "Flash");
- do_check_false(addons[0].userDisabled);
- do_check_eq(addons[1].name, "Quicktime");
- do_check_false(addons[1].userDisabled);
-
- run_test_5();
- });
-}
-
-// Removing part of the flash plugin should have no effect
-function run_test_5() {
- PLUGINS.splice(0, 1);
-
- Services.obs.notifyObservers(null, LIST_UPDATED_TOPIC, null);
-
- ensure_test_completed();
-
- AddonManager.getAddonsByTypes(["plugin"], function(addons) {
- sortAddons(addons);
-
- do_check_eq(addons.length, 2);
-
- do_check_eq(addons[0].name, "Flash");
- do_check_false(addons[0].userDisabled);
- do_check_eq(addons[1].name, "Quicktime");
- do_check_false(addons[1].userDisabled);
-
- run_test_6();
- });
-}
-
-// Replacing flash should be detected
-function run_test_6() {
- let oldTag = PLUGINS.splice(0, 1)[0];
- let newTag = new PluginTag("Flash 2", "A new crash-free Flash!");
- newTag.disabled = true;
- PLUGINS.push(newTag);
-
- let test_params = {};
- test_params[getIDHashForString(oldTag.name + oldTag.description)] = [
- ["onUninstalling", false],
- "onUninstalled"
- ];
- test_params[getIDHashForString(newTag.name + newTag.description)] = [
- ["onInstalling", false],
- "onInstalled"
- ];
-
- prepare_test(test_params, [
- "onExternalInstall"
- ]);
-
- Services.obs.notifyObservers(null, LIST_UPDATED_TOPIC, null);
-
- ensure_test_completed();
-
- AddonManager.getAddonsByTypes(["plugin"], function(addons) {
- sortAddons(addons);
-
- do_check_eq(addons.length, 2);
-
- do_check_eq(addons[0].name, "Flash 2");
- do_check_true(addons[0].userDisabled);
- do_check_eq(addons[1].name, "Quicktime");
- do_check_false(addons[1].userDisabled);
-
- run_test_7();
- });
-}
-
-// If new tags are detected and the disabled state changes then we should send
-// out appropriate notifications
-function run_test_7() {
- PLUGINS[0] = new PluginTag("Quicktime", "A mock Quicktime plugin");
- PLUGINS[0].disabled = true;
- PLUGINS[1] = new PluginTag("Flash 2", "A new crash-free Flash!");
-
- let test_params = {};
- test_params[getIDHashForString(PLUGINS[0].name + PLUGINS[0].description)] = [
- ["onDisabling", false],
- "onDisabled"
- ];
- test_params[getIDHashForString(PLUGINS[1].name + PLUGINS[1].description)] = [
- ["onEnabling", false],
- "onEnabled"
- ];
-
- prepare_test(test_params);
-
- Services.obs.notifyObservers(null, LIST_UPDATED_TOPIC, null);
-
- ensure_test_completed();
-
- AddonManager.getAddonsByTypes(["plugin"], function(addons) {
- sortAddons(addons);
-
- do_check_eq(addons.length, 2);
-
- do_check_eq(addons[0].name, "Flash 2");
- do_check_false(addons[0].userDisabled);
- do_check_eq(addons[1].name, "Quicktime");
- do_check_true(addons[1].userDisabled);
-
- end_test();
- });
-}
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+const LIST_UPDATED_TOPIC = "plugins-list-updated";
+
+// We need to use the same algorithm for generating IDs for plugins
+var { getIDHashForString } = Components.utils.import("resource://gre/modules/addons/PluginProvider.jsm");
+
+function PluginTag(name, description) {
+ this.name = name;
+ this.description = description;
+}
+
+PluginTag.prototype = {
+ name: null,
+ description: null,
+ version: "1.0",
+ filename: null,
+ fullpath: null,
+ disabled: false,
+ blocklisted: false,
+ clicktoplay: false,
+
+ mimeTypes: [],
+
+ getMimeTypes: function(count) {
+ count.value = this.mimeTypes.length;
+ return this.mimeTypes;
+ }
+};
+
+PLUGINS = [
+ // A standalone plugin
+ new PluginTag("Java", "A mock Java plugin"),
+
+ // A plugin made up of two plugin files
+ new PluginTag("Flash", "A mock Flash plugin"),
+ new PluginTag("Flash", "A mock Flash plugin")
+];
+
+gPluginHost = {
+ // nsIPluginHost
+ getPluginTags: function(count) {
+ count.value = PLUGINS.length;
+ return PLUGINS;
+ },
+
+ QueryInterface: XPCOMUtils.generateQI([AM_Ci.nsIPluginHost])
+};
+
+var PluginHostFactory = {
+ createInstance: function (outer, iid) {
+ if (outer != null)
+ throw Components.results.NS_ERROR_NO_AGGREGATION;
+ return gPluginHost.QueryInterface(iid);
+ }
+};
+
+var registrar = Components.manager.QueryInterface(AM_Ci.nsIComponentRegistrar);
+registrar.registerFactory(Components.ID("{aa6f9fef-cbe2-4d55-a2fa-dcf5482068b9}"), "PluginHost",
+ "@mozilla.org/plugin/host;1", PluginHostFactory);
+
+// This verifies that when the list of plugins changes the add-ons manager
+// correctly updates
+function run_test() {
+ do_test_pending();
+ createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
+
+ Services.prefs.setBoolPref("media.gmp-provider.enabled", false);
+
+ startupManager();
+ AddonManager.addAddonListener(AddonListener);
+ AddonManager.addInstallListener(InstallListener);
+
+ run_test_1();
+}
+
+function end_test() {
+ do_execute_soon(do_test_finished);
+}
+
+function sortAddons(addons) {
+ addons.sort(function(a, b) {
+ return a.name.localeCompare(b.name);
+ });
+}
+
+// Basic check that the mock object works
+function run_test_1() {
+ AddonManager.getAddonsByTypes(["plugin"], function(addons) {
+ sortAddons(addons);
+
+ do_check_eq(addons.length, 2);
+
+ do_check_eq(addons[0].name, "Flash");
+ do_check_false(addons[0].userDisabled);
+ do_check_eq(addons[1].name, "Java");
+ do_check_false(addons[1].userDisabled);
+
+ run_test_2();
+ });
+}
+
+// No change to the list should not trigger any events or changes in the API
+function run_test_2() {
+ // Reorder the list a bit
+ let tag = PLUGINS[0];
+ PLUGINS[0] = PLUGINS[2];
+ PLUGINS[2] = PLUGINS[1];
+ PLUGINS[1] = tag;
+
+ Services.obs.notifyObservers(null, LIST_UPDATED_TOPIC, null);
+
+ AddonManager.getAddonsByTypes(["plugin"], function(addons) {
+ sortAddons(addons);
+
+ do_check_eq(addons.length, 2);
+
+ do_check_eq(addons[0].name, "Flash");
+ do_check_false(addons[0].userDisabled);
+ do_check_eq(addons[1].name, "Java");
+ do_check_false(addons[1].userDisabled);
+
+ run_test_3();
+ });
+}
+
+// Tests that a newly detected plugin shows up in the API and sends out events
+function run_test_3() {
+ let tag = new PluginTag("Quicktime", "A mock Quicktime plugin");
+ PLUGINS.push(tag);
+ let id = getIDHashForString(tag.name + tag.description);
+
+ let test_params = {};
+ test_params[id] = [
+ ["onInstalling", false],
+ "onInstalled"
+ ];
+
+ prepare_test(test_params, [
+ "onExternalInstall"
+ ]);
+
+ Services.obs.notifyObservers(null, LIST_UPDATED_TOPIC, null);
+
+ ensure_test_completed();
+
+ AddonManager.getAddonsByTypes(["plugin"], function(addons) {
+ sortAddons(addons);
+
+ do_check_eq(addons.length, 3);
+
+ do_check_eq(addons[0].name, "Flash");
+ do_check_false(addons[0].userDisabled);
+ do_check_eq(addons[1].name, "Java");
+ do_check_false(addons[1].userDisabled);
+ do_check_eq(addons[2].name, "Quicktime");
+ do_check_false(addons[2].userDisabled);
+
+ run_test_4();
+ });
+}
+
+// Tests that a removed plugin disappears from in the API and sends out events
+function run_test_4() {
+ let tag = PLUGINS.splice(1, 1)[0];
+ let id = getIDHashForString(tag.name + tag.description);
+
+ let test_params = {};
+ test_params[id] = [
+ ["onUninstalling", false],
+ "onUninstalled"
+ ];
+
+ prepare_test(test_params);
+
+ Services.obs.notifyObservers(null, LIST_UPDATED_TOPIC, null);
+
+ ensure_test_completed();
+
+ AddonManager.getAddonsByTypes(["plugin"], function(addons) {
+ sortAddons(addons);
+
+ do_check_eq(addons.length, 2);
+
+ do_check_eq(addons[0].name, "Flash");
+ do_check_false(addons[0].userDisabled);
+ do_check_eq(addons[1].name, "Quicktime");
+ do_check_false(addons[1].userDisabled);
+
+ run_test_5();
+ });
+}
+
+// Removing part of the flash plugin should have no effect
+function run_test_5() {
+ PLUGINS.splice(0, 1);
+
+ Services.obs.notifyObservers(null, LIST_UPDATED_TOPIC, null);
+
+ ensure_test_completed();
+
+ AddonManager.getAddonsByTypes(["plugin"], function(addons) {
+ sortAddons(addons);
+
+ do_check_eq(addons.length, 2);
+
+ do_check_eq(addons[0].name, "Flash");
+ do_check_false(addons[0].userDisabled);
+ do_check_eq(addons[1].name, "Quicktime");
+ do_check_false(addons[1].userDisabled);
+
+ run_test_6();
+ });
+}
+
+// Replacing flash should be detected
+function run_test_6() {
+ let oldTag = PLUGINS.splice(0, 1)[0];
+ let newTag = new PluginTag("Flash 2", "A new crash-free Flash!");
+ newTag.disabled = true;
+ PLUGINS.push(newTag);
+
+ let test_params = {};
+ test_params[getIDHashForString(oldTag.name + oldTag.description)] = [
+ ["onUninstalling", false],
+ "onUninstalled"
+ ];
+ test_params[getIDHashForString(newTag.name + newTag.description)] = [
+ ["onInstalling", false],
+ "onInstalled"
+ ];
+
+ prepare_test(test_params, [
+ "onExternalInstall"
+ ]);
+
+ Services.obs.notifyObservers(null, LIST_UPDATED_TOPIC, null);
+
+ ensure_test_completed();
+
+ AddonManager.getAddonsByTypes(["plugin"], function(addons) {
+ sortAddons(addons);
+
+ do_check_eq(addons.length, 2);
+
+ do_check_eq(addons[0].name, "Flash 2");
+ do_check_true(addons[0].userDisabled);
+ do_check_eq(addons[1].name, "Quicktime");
+ do_check_false(addons[1].userDisabled);
+
+ run_test_7();
+ });
+}
+
+// If new tags are detected and the disabled state changes then we should send
+// out appropriate notifications
+function run_test_7() {
+ PLUGINS[0] = new PluginTag("Quicktime", "A mock Quicktime plugin");
+ PLUGINS[0].disabled = true;
+ PLUGINS[1] = new PluginTag("Flash 2", "A new crash-free Flash!");
+
+ let test_params = {};
+ test_params[getIDHashForString(PLUGINS[0].name + PLUGINS[0].description)] = [
+ ["onDisabling", false],
+ "onDisabled"
+ ];
+ test_params[getIDHashForString(PLUGINS[1].name + PLUGINS[1].description)] = [
+ ["onEnabling", false],
+ "onEnabled"
+ ];
+
+ prepare_test(test_params);
+
+ Services.obs.notifyObservers(null, LIST_UPDATED_TOPIC, null);
+
+ ensure_test_completed();
+
+ AddonManager.getAddonsByTypes(["plugin"], function(addons) {
+ sortAddons(addons);
+
+ do_check_eq(addons.length, 2);
+
+ do_check_eq(addons[0].name, "Flash 2");
+ do_check_false(addons[0].userDisabled);
+ do_check_eq(addons[1].name, "Quicktime");
+ do_check_true(addons[1].userDisabled);
+
+ end_test();
+ });
+}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_plugins.js b/toolkit/mozapps/extensions/test/xpcshell/test_plugins.js
index 3f0ac7ebe..5541bc946 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_plugins.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_plugins.js
@@ -2,8 +2,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
-var TEST_PLUGIN_DESCRIPTION = "Flash plug-in for testing purposes.";
-
// This verifies that plugins exist and can be enabled and disabled.
var gID = null;
@@ -11,8 +9,7 @@ function setTestPluginState(state) {
let tags = AM_Cc["@mozilla.org/plugin/host;1"].getService(AM_Ci.nsIPluginHost)
.getPluginTags();
for (let tag of tags) {
- do_print("Checking tag: " + tag.description);
- if (tag.description == TEST_PLUGIN_DESCRIPTION) {
+ if (tag.name == "Test Plug-in") {
tag.enabledState = state;
return;
}
@@ -24,7 +21,6 @@ function run_test() {
do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
Services.prefs.setBoolPref("plugins.click_to_play", true);
- Services.prefs.setBoolPref("plugin.load_flash_only", false);
setTestPluginState(AM_Ci.nsIPluginTag.STATE_CLICKTOPLAY);
@@ -42,21 +38,21 @@ function get_test_plugin() {
let dir = pluginEnum.getNext().QueryInterface(AM_Ci.nsILocalFile);
let plugin = dir.clone();
// OSX plugin
- plugin.append("npswftest.plugin");
+ plugin.append("Test.plugin");
if (plugin.exists()) {
plugin.normalize();
return plugin;
}
plugin = dir.clone();
// *nix plugin
- plugin.append("libnpswftest.so");
+ plugin.append("libnptest.so");
if (plugin.exists()) {
plugin.normalize();
return plugin;
}
// Windows plugin
plugin = dir.clone();
- plugin.append("npswftest.dll");
+ plugin.append("nptest.dll");
if (plugin.exists()) {
plugin.normalize();
return plugin;
@@ -102,7 +98,7 @@ function run_test_1() {
do_check_true(addons.length > 0);
addons.forEach(function(p) {
- if (p.description == TEST_PLUGIN_DESCRIPTION)
+ if (p.name == "Test Plug-in")
gID = p.id;
});
@@ -110,8 +106,12 @@ function run_test_1() {
AddonManager.getAddonByID(gID, function(p) {
do_check_neq(p, null);
- do_check_eq(p.name, "Shockwave Flash");
- do_check_eq(p.description, TEST_PLUGIN_DESCRIPTION);
+ do_check_eq(p.name, "Test Plug-in");
+ do_check_eq(p.description,
+ "Plug-in for testing purposes.\u2122 " +
+ "(\u0939\u093f\u0928\u094d\u0926\u0940 " +
+ "\u4e2d\u6587 " +
+ "\u0627\u0644\u0639\u0631\u0628\u064a\u0629)");
do_check_eq(p.creator, null);
do_check_eq(p.version, "1.0.0.0");
do_check_eq(p.type, "plugin");
@@ -156,14 +156,14 @@ function run_test_2(p) {
do_check_false(p.appDisabled);
do_check_false(p.isActive);
- AddonManager.getAddonByID(gID, function(p2) {
- do_check_neq(p2, null);
- do_check_true(p2.userDisabled);
- do_check_false(p2.appDisabled);
- do_check_false(p2.isActive);
- do_check_eq(p2.name, "Shockwave Flash");
+ AddonManager.getAddonByID(gID, function(p) {
+ do_check_neq(p, null);
+ do_check_true(p.userDisabled);
+ do_check_false(p.appDisabled);
+ do_check_false(p.isActive);
+ do_check_eq(p.name, "Test Plug-in");
- run_test_3(p2);
+ run_test_3(p);
});
}
@@ -184,12 +184,12 @@ function run_test_3(p) {
do_check_false(p.appDisabled);
do_check_true(p.isActive);
- AddonManager.getAddonByID(gID, function(p2) {
- do_check_neq(p2, null);
- do_check_false(p2.userDisabled);
- do_check_false(p2.appDisabled);
- do_check_true(p2.isActive);
- do_check_eq(p2.name, "Shockwave Flash");
+ AddonManager.getAddonByID(gID, function(p) {
+ do_check_neq(p, null);
+ do_check_false(p.userDisabled);
+ do_check_false(p.appDisabled);
+ do_check_true(p.isActive);
+ do_check_eq(p.name, "Test Plug-in");
do_execute_soon(run_test_4);
});
@@ -201,7 +201,7 @@ function run_test_4() {
AddonManager.getAddonByID(gID, function(p) {
do_check_neq(p, null);
- do_check_eq(p.name, "Shockwave Flash");
+ do_check_eq(p.name, "Test Plug-in");
Services.prefs.clearUserPref("plugins.click_to_play");
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_pref_properties.js b/toolkit/mozapps/extensions/test/xpcshell/test_pref_properties.js
index c6a10e7c1..9abffaab0 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_pref_properties.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_pref_properties.js
@@ -199,21 +199,6 @@ function run_test() {
gManagerEventsListener.shutdown();
- // AddonManager.hotfixID
- let hotfixID = "hotfix@tests.mozilla.org";
- Services.prefs.setCharPref("extensions.hotfix.id", hotfixID);
- do_check_eq(AddonManager.hotfixID, hotfixID);
- // Change the pref and make sure the property is updated
- hotfixID = "hotfix2@tests.mozilla.org";
- Services.prefs.setCharPref("extensions.hotfix.id", hotfixID);
- do_check_eq(AddonManager.hotfixID, hotfixID);
- // Test an invalid pref value
- hotfixID = 99;
- Services.prefs.deleteBranch("extensions.hotfix.id");
- Services.prefs.setIntPref("extensions.hotfix.id", hotfixID);
- do_check_eq(AddonManager.hotfixID, null);
- Services.prefs.clearUserPref("extensions.hotfix.id");
-
// After removing the listener, ensure we get no further events.
gManagerEventsListener.expect([]);
AddonManager.updateEnabled = false;
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_provider_markSafe.js b/toolkit/mozapps/extensions/test/xpcshell/test_provider_markSafe.js
index 228eb7d34..55d503f2c 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_provider_markSafe.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_provider_markSafe.js
@@ -1,6 +1,6 @@
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
-var startupOrder = [];
+let startupOrder = [];
function mockAddonProvider(name) {
let mockProvider = {
@@ -19,13 +19,11 @@ function mockAddonProvider(name) {
return false;
},
- get name() {
- return name;
- },
+ get name() name,
};
return mockProvider;
-}
+};
function run_test() {
run_next_test();
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_provider_shutdown.js b/toolkit/mozapps/extensions/test/xpcshell/test_provider_shutdown.js
index d210eb81d..f6de26241 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_provider_shutdown.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_provider_shutdown.js
@@ -18,9 +18,7 @@ function mockAddonProvider(aName) {
shutdownPromise: null,
shutdownResolve: null,
- get name() {
- return aName;
- },
+ get name() aName,
shutdown() {
this.shutdownResolve();
@@ -35,7 +33,7 @@ function mockAddonProvider(aName) {
mockProvider.shutdownResolve = resolve;
});
return mockProvider;
-}
+};
function run_test() {
run_next_test();
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_provider_unsafe_access_shutdown.js b/toolkit/mozapps/extensions/test/xpcshell/test_provider_unsafe_access_shutdown.js
index f90e38292..df717f5a5 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_provider_unsafe_access_shutdown.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_provider_unsafe_access_shutdown.js
@@ -1,6 +1,6 @@
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
-var shutdownOrder = [];
+let shutdownOrder = [];
function mockAddonProvider(name) {
let mockProvider = {
@@ -15,22 +15,19 @@ function mockAddonProvider(name) {
shutdownOrder.push(this.name);
if (this.shutdownCallback)
return this.shutdownCallback();
- return undefined;
},
getAddonByID(id, callback) {
if (this.hasShutdown) {
- this.unsafeAccess = true;
+ unsafeAccess = true;
}
callback(null);
},
- get name() {
- return name;
- },
+ get name() name,
};
return mockProvider;
-}
+};
function run_test() {
run_next_test();
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_provider_unsafe_access_startup.js b/toolkit/mozapps/extensions/test/xpcshell/test_provider_unsafe_access_startup.js
index 1193ddfe4..867dc9673 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_provider_unsafe_access_startup.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_provider_unsafe_access_startup.js
@@ -1,6 +1,6 @@
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
-var startupOrder = [];
+let startupOrder = [];
function mockAddonProvider(name) {
let mockProvider = {
@@ -17,18 +17,16 @@ function mockAddonProvider(name) {
},
getAddonByID(id, callback) {
if (!this.hasStarted) {
- this.unsafeAccess = true;
+ unsafeAccess = true;
}
callback(null);
},
- get name() {
- return name;
- },
+ get name() name,
};
return mockProvider;
-}
+};
function run_test() {
run_next_test();
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_proxies.js b/toolkit/mozapps/extensions/test/xpcshell/test_proxies.js
deleted file mode 100644
index 7b28c78f2..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_proxies.js
+++ /dev/null
@@ -1,240 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-// Tests the semantics of extension proxy files and symlinks
-
-Components.utils.import("resource://gre/modules/AppConstants.jsm");
-Components.utils.import("resource://gre/modules/osfile.jsm");
-
-var ADDONS = [
- {
- id: "proxy1@tests.mozilla.org",
- dirId: "proxy1@tests.mozilla.com",
- type: "proxy"
- },
- {
- id: "proxy2@tests.mozilla.org",
- type: "proxy"
- },
- {
- id: "symlink1@tests.mozilla.org",
- dirId: "symlink1@tests.mozilla.com",
- type: "symlink"
- },
- {
- id: "symlink2@tests.mozilla.org",
- type: "symlink"
- }
-];
-
-var METADATA = {
- version: "2.0",
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "2",
- maxVersion: "2"
- }]
-}
-
-const ios = AM_Cc["@mozilla.org/network/io-service;1"].getService(AM_Ci.nsIIOService);
-
-const LocalFile = Components.Constructor("@mozilla.org/file/local;1",
- "nsILocalFile", "initWithPath");
-const Process = Components.Constructor("@mozilla.org/process/util;1",
- "nsIProcess", "init");
-
-const gHaveSymlinks = AppConstants.platform != "win";
-
-
-function createSymlink(aSource, aDest) {
- if (aSource instanceof AM_Ci.nsIFile)
- aSource = aSource.path;
- if (aDest instanceof AM_Ci.nsIFile)
- aDest = aDest.path;
-
- return OS.File.unixSymLink(aSource, aDest);
-}
-
-function writeFile(aData, aFile) {
- if (!aFile.parent.exists())
- aFile.parent.create(AM_Ci.nsIFile.DIRECTORY_TYPE, 0o755);
-
- var fos = AM_Cc["@mozilla.org/network/file-output-stream;1"].
- createInstance(AM_Ci.nsIFileOutputStream);
- fos.init(aFile,
- FileUtils.MODE_WRONLY | FileUtils.MODE_CREATE | FileUtils.MODE_TRUNCATE,
- FileUtils.PERMS_FILE, 0);
- fos.write(aData, aData.length);
- fos.close();
-}
-
-function checkAddonsExist() {
- for (let addon of ADDONS) {
- let file = addon.directory.clone();
- file.append("install.rdf");
- do_check_true(file.exists(), Components.stack.caller);
- }
-}
-
-
-const profileDir = gProfD.clone();
-profileDir.append("extensions");
-
-
-function run_test() {
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "2");
-
- add_task(run_proxy_tests);
-
- if (gHaveSymlinks)
- add_task(run_symlink_tests);
-
- run_next_test();
-}
-
-function* run_proxy_tests() {
- if (!gHaveSymlinks) {
- ADDONS = ADDONS.filter(a => a.type != "symlink");
- }
-
- for (let addon of ADDONS) {
- addon.directory = gTmpD.clone();
- addon.directory.append(addon.id);
-
- addon.proxyFile = profileDir.clone();
- addon.proxyFile.append(addon.dirId || addon.id);
-
- METADATA.id = addon.id;
- METADATA.name = addon.id;
- writeInstallRDFToDir(METADATA, gTmpD);
-
- if (addon.type == "proxy") {
- writeFile(addon.directory.path, addon.proxyFile)
- }
- else if (addon.type == "symlink") {
- yield createSymlink(addon.directory, addon.proxyFile)
- }
- }
-
- startupManager();
-
- // Check that all add-ons original sources still exist after invalid
- // add-ons have been removed at startup.
- checkAddonsExist();
-
- return new Promise(resolve => {
- AddonManager.getAddonsByIDs(ADDONS.map(addon => addon.id), resolve);
- }).then(addons => {
- try {
- for (let [i, addon] of addons.entries()) {
- // Ensure that valid proxied add-ons were installed properly on
- // platforms that support the installation method.
- print(ADDONS[i].id,
- ADDONS[i].dirId,
- ADDONS[i].dirId != null,
- ADDONS[i].type == "symlink");
- do_check_eq(addon == null,
- ADDONS[i].dirId != null);
-
- if (addon != null) {
- let fixURL = url => {
- if (AppConstants.platform == "macosx")
- return url.replace(RegExp(`^file:///private/`), "file:///");
- return url;
- };
-
- // Check that proxied add-ons do not have upgrade permissions.
- do_check_eq(addon.permissions & AddonManager.PERM_CAN_UPGRADE, 0);
-
- // Check that getResourceURI points to the right place.
- do_check_eq(ios.newFileURI(ADDONS[i].directory).spec,
- fixURL(addon.getResourceURI().spec),
- `Base resource URL resolves as expected`);
-
- let file = ADDONS[i].directory.clone();
- file.append("install.rdf");
-
- do_check_eq(ios.newFileURI(file).spec,
- fixURL(addon.getResourceURI("install.rdf").spec),
- `Resource URLs resolve as expected`);
-
- addon.uninstall();
- }
- }
-
- // Check that original sources still exist after explicit uninstall.
- restartManager();
- checkAddonsExist();
-
- shutdownManager();
-
- // Check that all of the proxy files have been removed and remove
- // the original targets.
- for (let addon of ADDONS) {
- equal(addon.proxyFile.exists(), addon.dirId != null,
- `Proxy file ${addon.proxyFile.path} should exist?`);
- addon.directory.remove(true);
- try {
- addon.proxyFile.remove(false);
- } catch (e) {}
- }
- }
- catch (e) {
- do_throw(e);
- }
- });
-}
-
-function* run_symlink_tests() {
- // Check that symlinks are not followed out of a directory tree
- // when deleting an add-on.
-
- METADATA.id = "unpacked@test.mozilla.org";
- METADATA.name = METADATA.id;
- METADATA.unpack = "true";
-
- let tempDirectory = gTmpD.clone();
- tempDirectory.append(METADATA.id);
-
- let tempFile = tempDirectory.clone();
- tempFile.append("test.txt");
- tempFile.create(AM_Ci.nsIFile.NORMAL_FILE_TYPE, 0o644);
-
- let addonDirectory = profileDir.clone();
- addonDirectory.append(METADATA.id);
-
- writeInstallRDFToDir(METADATA, profileDir);
-
- let symlink = addonDirectory.clone();
- symlink.append(tempDirectory.leafName);
- yield createSymlink(tempDirectory, symlink);
-
- // Make sure that the symlink was created properly.
- let file = symlink.clone();
- file.append(tempFile.leafName);
- file.normalize();
- do_check_eq(file.path.replace(/^\/private\//, "/"), tempFile.path);
-
- startupManager();
-
- return new Promise(resolve => {
- AddonManager.getAddonByID(METADATA.id, resolve);
- }).then(addon => {
- do_check_neq(addon, null);
-
- addon.uninstall();
-
- restartManager();
- shutdownManager();
-
- // Check that the install directory is gone.
- do_check_false(addonDirectory.exists());
-
- // Check that the temp file is not gone.
- do_check_true(tempFile.exists());
-
- tempDirectory.remove(true);
- });
-}
-
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_proxy.js b/toolkit/mozapps/extensions/test/xpcshell/test_proxy.js
deleted file mode 100644
index c35870c9b..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_proxy.js
+++ /dev/null
@@ -1,106 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-const ID = "proxy1@tests.mozilla.org";
-
-createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "42");
-startupManager();
-
-BootstrapMonitor.init();
-
-// Ensure that a proxy file to an add-on with a valid manifest works.
-add_task(function*() {
- let tempdir = gTmpD.clone();
- writeInstallRDFToDir({
- id: ID,
- version: "1.0",
- bootstrap: true,
- unpack: true,
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "1"
- }],
- name: "Test Bootstrap 1 (proxy)",
- }, tempdir, ID, "bootstrap.js");
-
- let unpackedAddon = tempdir.clone();
- unpackedAddon.append(ID);
- do_get_file("data/test_proxy/bootstrap.js")
- .copyTo(unpackedAddon, "bootstrap.js");
-
- // create proxy file in profile/extensions dir
- let extensionsDir = gProfD.clone();
- extensionsDir.append("extensions");
- let proxyFile = writeProxyFileToDir(extensionsDir, unpackedAddon, ID);
-
- yield promiseRestartManager();
-
- BootstrapMonitor.checkAddonInstalled(ID, "1.0");
- BootstrapMonitor.checkAddonStarted(ID, "1.0");
-
- let addon = yield promiseAddonByID(ID);
-
- do_check_neq(addon, null);
- do_check_eq(addon.version, "1.0");
- do_check_eq(addon.name, "Test Bootstrap 1 (proxy)");
- do_check_true(addon.isCompatible);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.type, "extension");
- do_check_eq(addon.signedState, mozinfo.addon_signing ? AddonManager.SIGNEDSTATE_SIGNED : AddonManager.SIGNEDSTATE_NOT_REQUIRED);
-
- do_check_true(proxyFile.exists());
-
- addon.uninstall();
- unpackedAddon.remove(true);
-
- yield promiseRestartManager();
-});
-
-
-// Ensure that a proxy file to an add-on is not removed even
-// if the manifest file is invalid. See bug 1195353.
-add_task(function*() {
- let tempdir = gTmpD.clone();
-
- // use a mismatched ID to make this install.rdf invalid
- writeInstallRDFToDir({
- id: "bad-proxy1@tests.mozilla.org",
- version: "1.0",
- bootstrap: true,
- unpack: true,
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "1"
- }],
- name: "Test Bootstrap 1 (proxy)",
- }, tempdir, ID, "bootstrap.js");
-
- let unpackedAddon = tempdir.clone();
- unpackedAddon.append(ID);
- do_get_file("data/test_proxy/bootstrap.js")
- .copyTo(unpackedAddon, "bootstrap.js");
-
- // create proxy file in profile/extensions dir
- let extensionsDir = gProfD.clone();
- extensionsDir.append("extensions");
- let proxyFile = writeProxyFileToDir(extensionsDir, unpackedAddon, ID);
-
- yield promiseRestartManager();
-
- BootstrapMonitor.checkAddonNotInstalled(ID, "1.0");
- BootstrapMonitor.checkAddonNotStarted(ID, "1.0");
-
- let addon = yield promiseAddonByID(ID);
- do_check_eq(addon, null);
-
- do_check_true(proxyFile.exists());
-
- unpackedAddon.remove(true);
- proxyFile.remove(true);
-
- yield promiseRestartManager();
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_registry.js b/toolkit/mozapps/extensions/test/xpcshell/test_registry.js
index eab7af6b6..010250457 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_registry.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_registry.js
@@ -35,18 +35,11 @@ var addon2 = {
const addon1Dir = writeInstallRDFForExtension(addon1, gProfD, "addon1");
const addon2Dir = writeInstallRDFForExtension(addon2, gProfD, "addon2");
-let registry;
-
function run_test() {
// This test only works where there is a registry.
if (!("nsIWindowsRegKey" in AM_Ci))
return;
- registry = new MockRegistry();
- do_register_cleanup(() => {
- registry.shutdown();
- });
-
do_test_pending();
run_test_1();
@@ -54,12 +47,12 @@ function run_test() {
// Tests whether basic registry install works
function run_test_1() {
- registry.setValue(AM_Ci.nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE,
- "SOFTWARE\\Mozilla\\XPCShell\\Extensions",
- "addon1@tests.mozilla.org", addon1Dir.path);
- registry.setValue(AM_Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
- "SOFTWARE\\Mozilla\\XPCShell\\Extensions",
- "addon2@tests.mozilla.org", addon2Dir.path);
+ MockRegistry.setValue(AM_Ci.nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE,
+ "SOFTWARE\\Mozilla\\XPCShell\\Extensions",
+ "addon1@tests.mozilla.org", addon1Dir.path);
+ MockRegistry.setValue(AM_Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
+ "SOFTWARE\\Mozilla\\XPCShell\\Extensions",
+ "addon2@tests.mozilla.org", addon2Dir.path);
startupManager();
@@ -81,12 +74,12 @@ function run_test_1() {
// Tests whether uninstalling from the registry works
function run_test_2() {
- registry.setValue(AM_Ci.nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE,
- "SOFTWARE\\Mozilla\\XPCShell\\Extensions",
- "addon1@tests.mozilla.org", null);
- registry.setValue(AM_Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
- "SOFTWARE\\Mozilla\\XPCShell\\Extensions",
- "addon2@tests.mozilla.org", null);
+ MockRegistry.setValue(AM_Ci.nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE,
+ "SOFTWARE\\Mozilla\\XPCShell\\Extensions",
+ "addon1@tests.mozilla.org", null);
+ MockRegistry.setValue(AM_Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
+ "SOFTWARE\\Mozilla\\XPCShell\\Extensions",
+ "addon2@tests.mozilla.org", null);
restartManager();
@@ -101,12 +94,12 @@ function run_test_2() {
// Checks that the ID in the registry must match that in the install manifest
function run_test_3() {
- registry.setValue(AM_Ci.nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE,
- "SOFTWARE\\Mozilla\\XPCShell\\Extensions",
- "addon1@tests.mozilla.org", addon2Dir.path);
- registry.setValue(AM_Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
- "SOFTWARE\\Mozilla\\XPCShell\\Extensions",
- "addon2@tests.mozilla.org", addon1Dir.path);
+ MockRegistry.setValue(AM_Ci.nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE,
+ "SOFTWARE\\Mozilla\\XPCShell\\Extensions",
+ "addon1@tests.mozilla.org", addon2Dir.path);
+ MockRegistry.setValue(AM_Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
+ "SOFTWARE\\Mozilla\\XPCShell\\Extensions",
+ "addon2@tests.mozilla.org", addon1Dir.path);
restartManager();
@@ -124,26 +117,26 @@ function run_test_4() {
// Restarting with bad items in the registry should not force an EM restart
restartManager();
- registry.setValue(AM_Ci.nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE,
- "SOFTWARE\\Mozilla\\XPCShell\\Extensions",
- "addon1@tests.mozilla.org", null);
- registry.setValue(AM_Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
- "SOFTWARE\\Mozilla\\XPCShell\\Extensions",
- "addon2@tests.mozilla.org", null);
+ MockRegistry.setValue(AM_Ci.nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE,
+ "SOFTWARE\\Mozilla\\XPCShell\\Extensions",
+ "addon1@tests.mozilla.org", null);
+ MockRegistry.setValue(AM_Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
+ "SOFTWARE\\Mozilla\\XPCShell\\Extensions",
+ "addon2@tests.mozilla.org", null);
restartManager();
- registry.setValue(AM_Ci.nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE,
- "SOFTWARE\\Mozilla\\XPCShell\\Extensions",
- "addon1@tests.mozilla.org", addon1Dir.path);
+ MockRegistry.setValue(AM_Ci.nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE,
+ "SOFTWARE\\Mozilla\\XPCShell\\Extensions",
+ "addon1@tests.mozilla.org", addon1Dir.path);
restartManager();
- registry.setValue(AM_Ci.nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE,
- "SOFTWARE\\Mozilla\\XPCShell\\Extensions",
- "addon1@tests.mozilla.org", null);
- registry.setValue(AM_Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
- "SOFTWARE\\Mozilla\\XPCShell\\Extensions",
- "addon2@tests.mozilla.org", addon1Dir.path);
+ MockRegistry.setValue(AM_Ci.nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE,
+ "SOFTWARE\\Mozilla\\XPCShell\\Extensions",
+ "addon1@tests.mozilla.org", null);
+ MockRegistry.setValue(AM_Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
+ "SOFTWARE\\Mozilla\\XPCShell\\Extensions",
+ "addon2@tests.mozilla.org", addon1Dir.path);
writeInstallRDFForExtension(addon2, gProfD, "addon1");
restartManager();
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_reload.js b/toolkit/mozapps/extensions/test/xpcshell/test_reload.js
deleted file mode 100644
index 5873d1980..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_reload.js
+++ /dev/null
@@ -1,235 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "42");
-
-const sampleAddon = {
- id: "webextension1@tests.mozilla.org",
- name: "webextension_1",
-}
-
-const manifestSample = {
- id: "bootstrap1@tests.mozilla.org",
- version: "1.0",
- bootstrap: true,
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "1"
- }],
-};
-
-const { Management } = Components.utils.import("resource://gre/modules/Extension.jsm", {});
-
-function promiseAddonStartup() {
- return new Promise(resolve => {
- let listener = (extension) => {
- Management.off("startup", listener);
- resolve(extension);
- };
-
- Management.on("startup", listener);
- });
-}
-
-function* installAddon(fixtureName, addonID) {
- yield promiseInstallAllFiles([do_get_addon(fixtureName)]);
- return promiseAddonByID(addonID);
-}
-
-function* tearDownAddon(addon) {
- addon.uninstall();
- yield promiseShutdownManager();
-}
-
-add_task(function* test_reloading_a_temp_addon() {
- yield promiseRestartManager();
- yield AddonManager.installTemporaryAddon(do_get_addon(sampleAddon.name));
- const addon = yield promiseAddonByID(sampleAddon.id)
-
- var receivedOnUninstalled = false;
- var receivedOnUninstalling = false;
- var receivedOnInstalled = false;
- var receivedOnInstalling = false;
-
- const onReload = new Promise(resolve => {
- const listener = {
- onUninstalling: (addonObj) => {
- if (addonObj.id === sampleAddon.id) {
- receivedOnUninstalling = true;
- }
- },
- onUninstalled: (addonObj) => {
- if (addonObj.id === sampleAddon.id) {
- receivedOnUninstalled = true;
- }
- },
- onInstalling: (addonObj) => {
- receivedOnInstalling = true;
- equal(addonObj.id, sampleAddon.id);
- },
- onInstalled: (addonObj) => {
- receivedOnInstalled = true;
- equal(addonObj.id, sampleAddon.id);
- // This should be the last event called.
- AddonManager.removeAddonListener(listener);
- resolve();
- },
- }
- AddonManager.addAddonListener(listener);
- });
-
- yield addon.reload();
- yield onReload;
-
- // Make sure reload() doesn't trigger uninstall events.
- equal(receivedOnUninstalled, false, "reload should not trigger onUninstalled");
- equal(receivedOnUninstalling, false, "reload should not trigger onUninstalling");
-
- // Make sure reload() triggers install events, like an upgrade.
- equal(receivedOnInstalling, true, "reload should trigger onInstalling");
- equal(receivedOnInstalled, true, "reload should trigger onInstalled");
-
- yield tearDownAddon(addon);
-});
-
-add_task(function* test_can_reload_permanent_addon() {
- yield promiseRestartManager();
- const addon = yield installAddon(sampleAddon.name, sampleAddon.id);
-
- let disabledCalled = false;
- let enabledCalled = false;
- AddonManager.addAddonListener({
- onDisabled: (aAddon) => {
- do_check_false(enabledCalled);
- disabledCalled = true
- },
- onEnabled: (aAddon) => {
- do_check_true(disabledCalled);
- enabledCalled = true
- }
- })
-
- yield addon.reload();
-
- do_check_true(disabledCalled);
- do_check_true(enabledCalled);
-
- notEqual(addon, null);
- equal(addon.appDisabled, false);
- equal(addon.userDisabled, false);
-
- yield tearDownAddon(addon);
-});
-
-add_task(function* test_reload_to_invalid_version_fails() {
- yield promiseRestartManager();
- let tempdir = gTmpD.clone();
-
- // The initial version of the add-on will be compatible, and will therefore load
- const addonId = "invalid_version_cannot_be_reloaded@tests.mozilla.org";
- let manifest = {
- name: "invalid_version_cannot_be_reloaded",
- description: "test invalid_version_cannot_be_reloaded",
- manifest_version: 2,
- version: "1.0",
- applications: {
- gecko: {
- id: addonId,
- }
- },
- };
-
- let addonDir = yield promiseWriteWebManifestForExtension(manifest, tempdir, "invalid_version");
- yield AddonManager.installTemporaryAddon(addonDir);
- yield promiseAddonStartup();
-
- let addon = yield promiseAddonByID(addonId);
- notEqual(addon, null);
- equal(addon.id, addonId);
- equal(addon.version, "1.0");
- equal(addon.appDisabled, false);
- equal(addon.userDisabled, false);
- addonDir.remove(true);
-
- // update the manifest to make the add-on version incompatible, so the reload will reject
- manifest.applications.gecko.strict_min_version = "1";
- manifest.applications.gecko.strict_max_version = "1";
- manifest.version = "2.0";
-
- addonDir = yield promiseWriteWebManifestForExtension(manifest, tempdir, "invalid_version", false);
- let expectedMsg = new RegExp("Add-on invalid_version_cannot_be_reloaded@tests.mozilla.org is not compatible with application version. " +
- "add-on minVersion: 1. add-on maxVersion: 1.");
-
- yield Assert.rejects(addon.reload(),
- expectedMsg,
- "Reload rejects when application version does not fall between minVersion and maxVersion");
-
- let reloadedAddon = yield promiseAddonByID(addonId);
- notEqual(reloadedAddon, null);
- equal(reloadedAddon.id, addonId);
- equal(reloadedAddon.version, "1.0");
- equal(reloadedAddon.appDisabled, false);
- equal(reloadedAddon.userDisabled, false);
-
- yield tearDownAddon(reloadedAddon);
- addonDir.remove(true);
-});
-
-add_task(function* test_manifest_changes_are_refreshed() {
- yield promiseRestartManager();
- let tempdir = gTmpD.clone();
-
- const unpackedAddon = writeInstallRDFToDir(
- Object.assign({}, manifestSample, {
- name: "Test Bootstrap 1",
- }), tempdir, manifestSample.id, "bootstrap.js");
-
- yield AddonManager.installTemporaryAddon(unpackedAddon);
- const addon = yield promiseAddonByID(manifestSample.id);
- notEqual(addon, null);
- equal(addon.name, "Test Bootstrap 1");
-
- writeInstallRDFToDir(Object.assign({}, manifestSample, {
- name: "Test Bootstrap 1 (reloaded)",
- }), tempdir, manifestSample.id);
-
- yield addon.reload();
-
- const reloadedAddon = yield promiseAddonByID(manifestSample.id);
- notEqual(reloadedAddon, null);
- equal(reloadedAddon.name, "Test Bootstrap 1 (reloaded)");
-
- yield tearDownAddon(reloadedAddon);
- unpackedAddon.remove(true);
-});
-
-add_task(function* test_reload_fails_on_installation_errors() {
- yield promiseRestartManager();
- let tempdir = gTmpD.clone();
-
- const unpackedAddon = writeInstallRDFToDir(
- Object.assign({}, manifestSample, {
- name: "Test Bootstrap 1",
- }), tempdir, manifestSample.id, "bootstrap.js");
-
- yield AddonManager.installTemporaryAddon(unpackedAddon);
- const addon = yield promiseAddonByID(manifestSample.id);
- notEqual(addon, null);
-
- // Trigger an installation error with an empty manifest.
- writeInstallRDFToDir({}, tempdir, manifestSample.id);
-
- yield Assert.rejects(addon.reload(), /No ID in install manifest/);
-
- // The old add-on should be active. I.E. the broken reload will not
- // disturb it.
- const oldAddon = yield promiseAddonByID(manifestSample.id);
- notEqual(oldAddon, null);
- equal(oldAddon.isActive, true);
- equal(oldAddon.name, "Test Bootstrap 1");
-
- yield tearDownAddon(addon);
- unpackedAddon.remove(true);
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_schema_change.js b/toolkit/mozapps/extensions/test/xpcshell/test_schema_change.js
deleted file mode 100644
index 3d386f663..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_schema_change.js
+++ /dev/null
@@ -1,317 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-BootstrapMonitor.init();
-
-const PREF_DB_SCHEMA = "extensions.databaseSchema";
-
-const profileDir = gProfD.clone();
-profileDir.append("extensions");
-
-createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "49");
-startupManager();
-
-/**
- * Schema change with no application update reloads metadata.
- */
-add_task(function* schema_change() {
- const ID = "schema-change@tests.mozilla.org";
-
- let xpiFile = createTempXPIFile({
- id: ID,
- name: "Test Add-on",
- version: "1.0",
- bootstrap: true,
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "1.9.2"
- }]
- });
-
- yield promiseInstallAllFiles([xpiFile]);
-
- let addon = yield promiseAddonByID(ID);
-
- notEqual(addon, null, "Got an addon object as expected");
- equal(addon.version, "1.0", "Got the expected version");
-
- yield shutdownManager();
-
- xpiFile = createTempXPIFile({
- id: ID,
- name: "Test Add-on 2",
- version: "2.0",
- bootstrap: true,
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "1.9.2"
- }]
- });
-
- Services.prefs.setIntPref(PREF_DB_SCHEMA, 0);
-
- let file = profileDir.clone();
- file.append(`${ID}.xpi`);
-
- // Make sure the timestamp is unchanged, so it is not re-scanned for that reason.
- let timestamp = file.lastModifiedTime;
- xpiFile.moveTo(profileDir, `${ID}.xpi`);
-
- file.lastModifiedTime = timestamp;
-
- yield startupManager();
-
- addon = yield promiseAddonByID(ID);
- notEqual(addon, null, "Got an addon object as expected");
- equal(addon.version, "2.0", "Got the expected version");
-
- let waitUninstall = promiseAddonEvent("onUninstalled");
- addon.uninstall();
- yield waitUninstall;
-});
-
-/**
- * Application update with no schema change does not reload metadata.
- */
-add_task(function* schema_change() {
- const ID = "schema-change@tests.mozilla.org";
-
- let xpiFile = createTempXPIFile({
- id: ID,
- name: "Test Add-on",
- version: "1.0",
- bootstrap: true,
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "2"
- }]
- });
-
- yield promiseInstallAllFiles([xpiFile]);
-
- let addon = yield promiseAddonByID(ID);
-
- notEqual(addon, null, "Got an addon object as expected");
- equal(addon.version, "1.0", "Got the expected version");
-
- yield shutdownManager();
-
- xpiFile = createTempXPIFile({
- id: ID,
- name: "Test Add-on 2",
- version: "2.0",
- bootstrap: true,
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "2"
- }]
- });
-
- gAppInfo.version = "2";
- let file = profileDir.clone();
- file.append(`${ID}.xpi`);
-
- // Make sure the timestamp is unchanged, so it is not re-scanned for that reason.
- let timestamp = file.lastModifiedTime;
- xpiFile.moveTo(profileDir, `${ID}.xpi`);
-
- file.lastModifiedTime = timestamp;
-
- yield startupManager();
-
- addon = yield promiseAddonByID(ID);
- notEqual(addon, null, "Got an addon object as expected");
- equal(addon.version, "1.0", "Got the expected version");
-
- let waitUninstall = promiseAddonEvent("onUninstalled");
- addon.uninstall();
- yield waitUninstall;
-});
-
-/**
- * App update and a schema change causes a reload of the manifest.
- */
-add_task(function* schema_change_app_update() {
- const ID = "schema-change@tests.mozilla.org";
-
- let xpiFile = createTempXPIFile({
- id: ID,
- name: "Test Add-on",
- version: "1.0",
- bootstrap: true,
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "3"
- }]
- });
-
- yield promiseInstallAllFiles([xpiFile]);
-
- let addon = yield promiseAddonByID(ID);
-
- notEqual(addon, null, "Got an addon object as expected");
- equal(addon.version, "1.0", "Got the expected version");
-
- yield shutdownManager();
-
- xpiFile = createTempXPIFile({
- id: ID,
- name: "Test Add-on 2",
- version: "2.0",
- bootstrap: true,
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "3"
- }]
- });
-
- gAppInfo.version = "3";
- Services.prefs.setIntPref(PREF_DB_SCHEMA, 0);
-
- let file = profileDir.clone();
- file.append(`${ID}.xpi`);
-
- // Make sure the timestamp is unchanged, so it is not re-scanned for that reason.
- let timestamp = file.lastModifiedTime;
- xpiFile.moveTo(profileDir, `${ID}.xpi`);
-
- file.lastModifiedTime = timestamp;
-
- yield startupManager();
-
- addon = yield promiseAddonByID(ID);
- notEqual(addon, null, "Got an addon object as expected");
- equal(addon.appDisabled, false);
- equal(addon.version, "2.0", "Got the expected version");
-
- let waitUninstall = promiseAddonEvent("onUninstalled");
- addon.uninstall();
- yield waitUninstall;
-});
-
-/**
- * No schema change, no manifest reload.
- */
-add_task(function* schema_change() {
- const ID = "schema-change@tests.mozilla.org";
-
- let xpiFile = createTempXPIFile({
- id: ID,
- name: "Test Add-on",
- version: "1.0",
- bootstrap: true,
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "1.9.2"
- }]
- });
-
- yield promiseInstallAllFiles([xpiFile]);
-
- let addon = yield promiseAddonByID(ID);
-
- notEqual(addon, null, "Got an addon object as expected");
- equal(addon.version, "1.0", "Got the expected version");
-
- yield shutdownManager();
-
- xpiFile = createTempXPIFile({
- id: ID,
- name: "Test Add-on 2",
- version: "2.0",
- bootstrap: true,
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "1.9.2"
- }]
- });
-
- let file = profileDir.clone();
- file.append(`${ID}.xpi`);
-
- // Make sure the timestamp is unchanged, so it is not re-scanned for that reason.
- let timestamp = file.lastModifiedTime;
- xpiFile.moveTo(profileDir, `${ID}.xpi`);
-
- file.lastModifiedTime = timestamp;
-
- yield startupManager();
-
- addon = yield promiseAddonByID(ID);
- notEqual(addon, null, "Got an addon object as expected");
- equal(addon.version, "1.0", "Got the expected version");
-
- let waitUninstall = promiseAddonEvent("onUninstalled");
- addon.uninstall();
- yield waitUninstall;
-});
-
-/**
- * Modified timestamp on the XPI causes a reload of the manifest.
- */
-add_task(function* schema_change() {
- const ID = "schema-change@tests.mozilla.org";
-
- let xpiFile = createTempXPIFile({
- id: ID,
- name: "Test Add-on",
- version: "1.0",
- bootstrap: true,
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "1.9.2"
- }]
- });
-
- yield promiseInstallAllFiles([xpiFile]);
-
- let addon = yield promiseAddonByID(ID);
-
- notEqual(addon, null, "Got an addon object as expected");
- equal(addon.version, "1.0", "Got the expected version");
-
- yield shutdownManager();
-
- xpiFile = createTempXPIFile({
- id: ID,
- name: "Test Add-on 2",
- version: "2.0",
- bootstrap: true,
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "1.9.2"
- }]
- });
-
- xpiFile.moveTo(profileDir, `${ID}.xpi`);
-
- let file = profileDir.clone();
- file.append(`${ID}.xpi`);
-
- // Set timestamp in the future so manifest is re-scanned.
- let timestamp = new Date(Date.now() + 60000);
- xpiFile.moveTo(profileDir, `${ID}.xpi`);
-
- file.lastModifiedTime = timestamp;
-
- yield startupManager();
-
- addon = yield promiseAddonByID(ID);
- notEqual(addon, null, "Got an addon object as expected");
- equal(addon.version, "2.0", "Got the expected version");
-
- let waitUninstall = promiseAddonEvent("onUninstalled");
- addon.uninstall();
- yield waitUninstall;
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_seen.js b/toolkit/mozapps/extensions/test/xpcshell/test_seen.js
deleted file mode 100644
index e499e7339..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_seen.js
+++ /dev/null
@@ -1,211 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-const ID = "bootstrap1@tests.mozilla.org";
-
-let profileDir = gProfD.clone();
-profileDir.append("extensions");
-
-createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
-startupManager();
-
-// By default disable add-ons from the profile
-Services.prefs.setIntPref("extensions.autoDisableScopes", AddonManager.SCOPE_PROFILE);
-
-// Installing an add-on through the API should mark it as seen
-add_task(function*() {
- let install = yield new Promise(resolve => AddonManager.getInstallForFile(do_get_addon("test_bootstrap1_1"), resolve));
- yield promiseCompleteAllInstalls([install]);
- do_check_eq(install.state, AddonManager.STATE_INSTALLED);
- do_check_false(hasFlag(install.addon.pendingOperations, AddonManager.PENDING_INSTALL));
-
- let addon = install.addon;
- do_check_eq(addon.version, "1.0");
- do_check_false(addon.foreignInstall);
- do_check_true(addon.seen);
-
- yield promiseRestartManager();
-
- addon = yield promiseAddonByID(ID);
- do_check_false(addon.foreignInstall);
- do_check_true(addon.seen);
-
- // Installing an update should retain that
- install = yield new Promise(resolve => AddonManager.getInstallForFile(do_get_addon("test_bootstrap1_2"), resolve));
- yield promiseCompleteAllInstalls([install]);
- do_check_eq(install.state, AddonManager.STATE_INSTALLED);
- do_check_false(hasFlag(install.addon.pendingOperations, AddonManager.PENDING_INSTALL));
-
- addon = install.addon;
- do_check_eq(addon.version, "2.0");
- do_check_false(addon.foreignInstall);
- do_check_true(addon.seen);
-
- yield promiseRestartManager();
-
- addon = yield promiseAddonByID(ID);
- do_check_false(addon.foreignInstall);
- do_check_true(addon.seen);
-
- addon.uninstall();
- yield promiseShutdownManager();
-});
-
-// Sideloading an add-on should mark it as unseen
-add_task(function*() {
- let path = manuallyInstall(do_get_addon("test_bootstrap1_1"), profileDir, ID);
- // Make sure the startup code will detect sideloaded updates
- setExtensionModifiedTime(path, Date.now() - 10000);
-
- startupManager();
-
- let addon = yield promiseAddonByID(ID);
- do_check_eq(addon.version, "1.0");
- do_check_true(addon.foreignInstall);
- do_check_false(addon.seen);
-
- yield promiseRestartManager();
-
- addon = yield promiseAddonByID(ID);
- do_check_true(addon.foreignInstall);
- do_check_false(addon.seen);
-
- yield promiseShutdownManager();
-
- // Sideloading an update shouldn't change the state
- manuallyUninstall(profileDir, ID);
- manuallyInstall(do_get_addon("test_bootstrap1_2"), profileDir, ID);
- setExtensionModifiedTime(path, Date.now());
-
- startupManager();
-
- addon = yield promiseAddonByID(ID);
- do_check_eq(addon.version, "2.0");
- do_check_true(addon.foreignInstall);
- do_check_false(addon.seen);
-
- addon.uninstall();
- yield promiseShutdownManager();
-});
-
-// Sideloading an add-on should mark it as unseen
-add_task(function*() {
- let path = manuallyInstall(do_get_addon("test_bootstrap1_1"), profileDir, ID);
- // Make sure the startup code will detect sideloaded updates
- setExtensionModifiedTime(path, Date.now() - 10000);
-
- startupManager();
-
- let addon = yield promiseAddonByID(ID);
- do_check_eq(addon.version, "1.0");
- do_check_true(addon.foreignInstall);
- do_check_false(addon.seen);
-
- yield promiseRestartManager();
-
- addon = yield promiseAddonByID(ID);
- do_check_true(addon.foreignInstall);
- do_check_false(addon.seen);
-
- // Updating through the API shouldn't change the state
- let install = yield new Promise(resolve => AddonManager.getInstallForFile(do_get_addon("test_bootstrap1_2"), resolve));
- yield promiseCompleteAllInstalls([install]);
- do_check_eq(install.state, AddonManager.STATE_INSTALLED);
- do_check_false(hasFlag(install.addon.pendingOperations, AddonManager.PENDING_INSTALL));
-
- addon = install.addon;
- do_check_true(addon.foreignInstall);
- do_check_false(addon.seen);
-
- yield promiseRestartManager();
-
- addon = yield promiseAddonByID(ID);
- do_check_eq(addon.version, "2.0");
- do_check_true(addon.foreignInstall);
- do_check_false(addon.seen);
-
- addon.uninstall();
- yield promiseShutdownManager();
-});
-
-// Sideloading an add-on should mark it as unseen
-add_task(function*() {
- let path = manuallyInstall(do_get_addon("test_bootstrap1_1"), profileDir, ID);
- // Make sure the startup code will detect sideloaded updates
- setExtensionModifiedTime(path, Date.now() - 10000);
-
- startupManager();
-
- let addon = yield promiseAddonByID(ID);
- do_check_eq(addon.version, "1.0");
- do_check_true(addon.foreignInstall);
- do_check_false(addon.seen);
- addon.markAsSeen();
- do_check_true(addon.seen);
-
- yield promiseRestartManager();
-
- addon = yield promiseAddonByID(ID);
- do_check_true(addon.foreignInstall);
- do_check_true(addon.seen);
-
- yield promiseShutdownManager();
-
- // Sideloading an update shouldn't change the state
- manuallyUninstall(profileDir, ID);
- manuallyInstall(do_get_addon("test_bootstrap1_2"), profileDir, ID);
- setExtensionModifiedTime(path, Date.now());
-
- startupManager();
-
- addon = yield promiseAddonByID(ID);
- do_check_eq(addon.version, "2.0");
- do_check_true(addon.foreignInstall);
- do_check_true(addon.seen);
-
- addon.uninstall();
- yield promiseShutdownManager();
-});
-
-// Sideloading an add-on should mark it as unseen
-add_task(function*() {
- let path = manuallyInstall(do_get_addon("test_bootstrap1_1"), profileDir, ID);
- // Make sure the startup code will detect sideloaded updates
- setExtensionModifiedTime(path, Date.now() - 10000);
-
- startupManager();
-
- let addon = yield promiseAddonByID(ID);
- do_check_eq(addon.version, "1.0");
- do_check_true(addon.foreignInstall);
- do_check_false(addon.seen);
- addon.markAsSeen();
- do_check_true(addon.seen);
-
- yield promiseRestartManager();
-
- addon = yield promiseAddonByID(ID);
- do_check_true(addon.foreignInstall);
- do_check_true(addon.seen);
-
- // Updating through the API shouldn't change the state
- let install = yield new Promise(resolve => AddonManager.getInstallForFile(do_get_addon("test_bootstrap1_2"), resolve));
- yield promiseCompleteAllInstalls([install]);
- do_check_eq(install.state, AddonManager.STATE_INSTALLED);
- do_check_false(hasFlag(install.addon.pendingOperations, AddonManager.PENDING_INSTALL));
-
- addon = install.addon;
- do_check_true(addon.foreignInstall);
- do_check_true(addon.seen);
-
- yield promiseRestartManager();
-
- addon = yield promiseAddonByID(ID);
- do_check_eq(addon.version, "2.0");
- do_check_true(addon.foreignInstall);
- do_check_true(addon.seen);
-
- addon.uninstall();
- yield promiseShutdownManager();
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_seen_newprofile.js b/toolkit/mozapps/extensions/test/xpcshell/test_seen_newprofile.js
deleted file mode 100644
index 43ee18594..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_seen_newprofile.js
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-const ID = "bootstrap1@tests.mozilla.org";
-
-Services.prefs.setIntPref("extensions.enabledScopes",
- AddonManager.SCOPE_PROFILE + AddonManager.SCOPE_SYSTEM);
-
-createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
-
-BootstrapMonitor.init();
-
-const globalDir = gProfD.clone();
-globalDir.append("extensions2");
-globalDir.append(gAppInfo.ID);
-registerDirectory("XRESysSExtPD", globalDir.parent);
-const profileDir = gProfD.clone();
-profileDir.append("extensions");
-
-// By default disable add-ons from the system
-Services.prefs.setIntPref("extensions.autoDisableScopes", AddonManager.SCOPE_SYSTEM);
-
-// When new add-ons already exist in a system location when starting with a new
-// profile they should be marked as already seen.
-add_task(function*() {
- manuallyInstall(do_get_addon("test_bootstrap1_1"), globalDir, ID);
-
- startupManager();
-
- let addon = yield promiseAddonByID(ID);
- do_check_true(addon.foreignInstall);
- do_check_true(addon.seen);
- do_check_true(addon.userDisabled);
- do_check_false(addon.isActive);
-
- BootstrapMonitor.checkAddonInstalled(ID);
- BootstrapMonitor.checkAddonNotStarted(ID);
-
- yield promiseShutdownManager();
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_shutdown.js b/toolkit/mozapps/extensions/test/xpcshell/test_shutdown.js
index 725887bc1..a865824f0 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_shutdown.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_shutdown.js
@@ -4,15 +4,12 @@
// Verify that API functions fail if the Add-ons Manager isn't initialised.
-const IGNORE = ["getPreferredIconURL", "escapeAddonURI",
- "shouldAutoUpdate", "getStartupChanges",
+const IGNORE = ["escapeAddonURI", "shouldAutoUpdate", "getStartupChanges",
"addTypeListener", "removeTypeListener",
"addAddonListener", "removeAddonListener",
"addInstallListener", "removeInstallListener",
"addManagerListener", "removeManagerListener",
- "mapURIToAddonID", "shutdown", "init",
- "stateToString", "errorToString", "getUpgradeListener",
- "addUpgradeListener", "removeUpgradeListener"];
+ "mapURIToAddonID", "shutdown"];
const IGNORE_PRIVATE = ["AddonAuthor", "AddonCompatibilityOverride",
"AddonScreenshot", "AddonType", "startup", "shutdown",
@@ -21,8 +18,7 @@ const IGNORE_PRIVATE = ["AddonAuthor", "AddonCompatibilityOverride",
"recordTimestamp", "recordSimpleMeasure",
"recordException", "getSimpleMeasures", "simpleTimer",
"setTelemetryDetails", "getTelemetryDetails",
- "callNoUpdateListeners", "backgroundUpdateTimerHandler",
- "hasUpgradeListener", "getUpgradeListener"];
+ "callNoUpdateListeners", "backgroundUpdateTimerHandler"];
function test_functions() {
for (let prop in AddonManager) {
@@ -31,25 +27,9 @@ function test_functions() {
if (typeof AddonManager[prop] != "function")
continue;
- let args = [];
-
- // Getter functions need a callback and in some cases not having one will
- // throw before checking if the add-ons manager is initialized so pass in
- // an empty one.
- if (prop.startsWith("get")) {
- // For now all getter functions with more than one argument take the
- // callback in the second argument.
- if (AddonManager[prop].length > 1) {
- args.push(undefined, () => {});
- }
- else {
- args.push(() => {});
- }
- }
-
try {
do_print("AddonManager." + prop);
- AddonManager[prop](...args);
+ AddonManager[prop]();
do_throw(prop + " did not throw an exception");
}
catch (e) {
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_signed_inject.js b/toolkit/mozapps/extensions/test/xpcshell/test_signed_inject.js
deleted file mode 100644
index 3b96f40ba..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_signed_inject.js
+++ /dev/null
@@ -1,382 +0,0 @@
-// Enable signature checks for these tests
-gUseRealCertChecks = true;
-// Disable update security
-Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false);
-
-const DATA = "data/signing_checks/";
-const ADDONS = {
- bootstrap: {
- unsigned: "unsigned_bootstrap_2.xpi",
- badid: "signed_bootstrap_badid_2.xpi",
- signed: "signed_bootstrap_2.xpi",
- preliminary: "preliminary_bootstrap_2.xpi",
- },
- nonbootstrap: {
- unsigned: "unsigned_nonbootstrap_2.xpi",
- badid: "signed_nonbootstrap_badid_2.xpi",
- signed: "signed_nonbootstrap_2.xpi",
- }
-};
-const ID = "test@tests.mozilla.org";
-
-const profileDir = gProfD.clone();
-profileDir.append("extensions");
-
-// Deletes a file from the test add-on in the profile
-function breakAddon(file) {
- if (TEST_UNPACKED) {
- file.append("test.txt");
- file.remove(true);
- }
- else {
- var zipW = AM_Cc["@mozilla.org/zipwriter;1"].
- createInstance(AM_Ci.nsIZipWriter);
- zipW.open(file, FileUtils.MODE_RDWR | FileUtils.MODE_APPEND);
- zipW.removeEntry("test.txt", false);
- zipW.close();
- }
-}
-
-function resetPrefs() {
- Services.prefs.setIntPref("bootstraptest.active_version", -1);
- Services.prefs.setIntPref("bootstraptest.installed_version", -1);
- Services.prefs.setIntPref("bootstraptest.startup_reason", -1);
- Services.prefs.setIntPref("bootstraptest.shutdown_reason", -1);
- Services.prefs.setIntPref("bootstraptest.install_reason", -1);
- Services.prefs.setIntPref("bootstraptest.uninstall_reason", -1);
- Services.prefs.setIntPref("bootstraptest.startup_oldversion", -1);
- Services.prefs.setIntPref("bootstraptest.shutdown_newversion", -1);
- Services.prefs.setIntPref("bootstraptest.install_oldversion", -1);
- Services.prefs.setIntPref("bootstraptest.uninstall_newversion", -1);
-}
-
-function clearCache(file) {
- if (TEST_UNPACKED)
- return;
-
- Services.obs.notifyObservers(file, "flush-cache-entry", null);
-}
-
-function getActiveVersion() {
- return Services.prefs.getIntPref("bootstraptest.active_version");
-}
-
-function run_test() {
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "4", "4");
-
- // Start and stop the manager to initialise everything in the profile before
- // actual testing
- startupManager();
- shutdownManager();
- resetPrefs();
-
- run_next_test();
-}
-
-// Injecting into profile (bootstrap)
-add_task(function*() {
- let file = manuallyInstall(do_get_file(DATA + ADDONS.bootstrap.unsigned), profileDir, ID);
-
- startupManager();
-
- // Currently we leave the sideloaded add-on there but just don't run it
- let addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
- do_check_true(addon.appDisabled);
- do_check_false(addon.isActive);
- do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_MISSING);
- do_check_eq(getActiveVersion(), -1);
-
- addon.uninstall();
- yield promiseShutdownManager();
- resetPrefs();
-
- do_check_false(file.exists());
- clearCache(file);
-});
-
-add_task(function*() {
- let file = manuallyInstall(do_get_file(DATA + ADDONS.bootstrap.signed), profileDir, ID);
- breakAddon(file);
-
- startupManager();
-
- // Currently we leave the sideloaded add-on there but just don't run it
- let addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
- do_check_true(addon.appDisabled);
- do_check_false(addon.isActive);
- do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_BROKEN);
- do_check_eq(getActiveVersion(), -1);
-
- addon.uninstall();
- yield promiseShutdownManager();
- resetPrefs();
-
- do_check_false(file.exists());
- clearCache(file);
-});
-
-add_task(function*() {
- let file = manuallyInstall(do_get_file(DATA + ADDONS.bootstrap.badid), profileDir, ID);
-
- startupManager();
-
- // Currently we leave the sideloaded add-on there but just don't run it
- let addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
- do_check_true(addon.appDisabled);
- do_check_false(addon.isActive);
- do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_BROKEN);
- do_check_eq(getActiveVersion(), -1);
-
- addon.uninstall();
- yield promiseShutdownManager();
- resetPrefs();
-
- do_check_false(file.exists());
- clearCache(file);
-});
-
-// Installs a signed add-on then modifies it in place breaking its signing
-add_task(function*() {
- let file = manuallyInstall(do_get_file(DATA + ADDONS.bootstrap.signed), profileDir, ID);
-
- // Make it appear to come from the past so when we modify it later it is
- // detected during startup. Obviously malware can bypass this method of
- // detection but the periodic scan will catch that
- yield promiseSetExtensionModifiedTime(file.path, Date.now() - 600000);
-
- startupManager();
- let addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_SIGNED);
- do_check_eq(getActiveVersion(), 2);
-
- yield promiseShutdownManager();
- do_check_eq(getActiveVersion(), 0);
-
- clearCache(file);
- breakAddon(file);
- resetPrefs();
-
- startupManager();
-
- addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
- do_check_true(addon.appDisabled);
- do_check_false(addon.isActive);
- do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_BROKEN);
- do_check_eq(getActiveVersion(), -1);
-
- let ids = AddonManager.getStartupChanges(AddonManager.STARTUP_CHANGE_DISABLED);
- do_check_eq(ids.length, 1);
- do_check_eq(ids[0], ID);
-
- addon.uninstall();
- yield promiseShutdownManager();
- resetPrefs();
-
- do_check_false(file.exists());
- clearCache(file);
-});
-
-// Injecting into profile (non-bootstrap)
-add_task(function*() {
- let file = manuallyInstall(do_get_file(DATA + ADDONS.nonbootstrap.unsigned), profileDir, ID);
-
- startupManager();
-
- // Currently we leave the sideloaded add-on there but just don't run it
- let addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
- do_check_true(addon.appDisabled);
- do_check_false(addon.isActive);
- do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_MISSING);
- do_check_false(isExtensionInAddonsList(profileDir, ID));
-
- addon.uninstall();
- yield promiseRestartManager();
- yield promiseShutdownManager();
-
- do_check_false(file.exists());
- clearCache(file);
-});
-
-add_task(function*() {
- let file = manuallyInstall(do_get_file(DATA + ADDONS.nonbootstrap.signed), profileDir, ID);
- breakAddon(file);
-
- startupManager();
-
- // Currently we leave the sideloaded add-on there but just don't run it
- let addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
- do_check_true(addon.appDisabled);
- do_check_false(addon.isActive);
- do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_BROKEN);
- do_check_false(isExtensionInAddonsList(profileDir, ID));
-
- addon.uninstall();
- yield promiseRestartManager();
- yield promiseShutdownManager();
-
- do_check_false(file.exists());
- clearCache(file);
-});
-
-add_task(function*() {
- let file = manuallyInstall(do_get_file(DATA + ADDONS.nonbootstrap.badid), profileDir, ID);
-
- startupManager();
-
- // Currently we leave the sideloaded add-on there but just don't run it
- let addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
- do_check_true(addon.appDisabled);
- do_check_false(addon.isActive);
- do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_BROKEN);
- do_check_false(isExtensionInAddonsList(profileDir, ID));
-
- addon.uninstall();
- yield promiseRestartManager();
- yield promiseShutdownManager();
-
- do_check_false(file.exists());
- clearCache(file);
-});
-
-// Installs a signed add-on then modifies it in place breaking its signing
-add_task(function*() {
- let file = manuallyInstall(do_get_file(DATA + ADDONS.nonbootstrap.signed), profileDir, ID);
-
- // Make it appear to come from the past so when we modify it later it is
- // detected during startup. Obviously malware can bypass this method of
- // detection but the periodic scan will catch that
- yield promiseSetExtensionModifiedTime(file.path, Date.now() - 60000);
-
- startupManager();
- let addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_SIGNED);
- do_check_true(isExtensionInAddonsList(profileDir, ID));
-
- yield promiseShutdownManager();
-
- clearCache(file);
- breakAddon(file);
-
- startupManager();
-
- addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
- do_check_true(addon.appDisabled);
- do_check_false(addon.isActive);
- do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_BROKEN);
- do_check_false(isExtensionInAddonsList(profileDir, ID));
-
- let ids = AddonManager.getStartupChanges(AddonManager.STARTUP_CHANGE_DISABLED);
- do_check_eq(ids.length, 1);
- do_check_eq(ids[0], ID);
-
- addon.uninstall();
- yield promiseRestartManager();
- yield promiseShutdownManager();
-
- do_check_false(file.exists());
- clearCache(file);
-});
-
-// Stage install then modify before startup (non-bootstrap)
-add_task(function*() {
- startupManager();
- yield promiseInstallAllFiles([do_get_file(DATA + ADDONS.nonbootstrap.signed)]);
- yield promiseShutdownManager();
-
- let staged = profileDir.clone();
- staged.append("staged");
- staged.append(do_get_expected_addon_name(ID));
- do_check_true(staged.exists());
-
- breakAddon(staged);
- startupManager();
-
- // Should have refused to install the broken staged version
- let addon = yield promiseAddonByID(ID);
- do_check_eq(addon, null);
-
- clearCache(staged);
-
- yield promiseShutdownManager();
-});
-
-// Manufacture staged install (bootstrap)
-add_task(function*() {
- let stage = profileDir.clone();
- stage.append("staged");
-
- let file = manuallyInstall(do_get_file(DATA + ADDONS.bootstrap.signed), stage, ID);
- breakAddon(file);
-
- startupManager();
-
- // Should have refused to install the broken staged version
- let addon = yield promiseAddonByID(ID);
- do_check_eq(addon, null);
- do_check_eq(getActiveVersion(), -1);
-
- do_check_false(file.exists());
- clearCache(file);
-
- yield promiseShutdownManager();
- resetPrefs();
-});
-
-// Preliminarily-signed sideloaded add-ons should work
-add_task(function*() {
- let file = manuallyInstall(do_get_file(DATA + ADDONS.bootstrap.preliminary), profileDir, ID);
-
- startupManager();
-
- let addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_PRELIMINARY);
- do_check_eq(getActiveVersion(), 2);
-
- addon.uninstall();
- yield promiseShutdownManager();
- resetPrefs();
-
- do_check_false(file.exists());
- clearCache(file);
-});
-
-// Preliminarily-signed sideloaded add-ons should work via staged install
-add_task(function*() {
- let stage = profileDir.clone();
- stage.append("staged");
-
- let file = manuallyInstall(do_get_file(DATA + ADDONS.bootstrap.preliminary), stage, ID);
-
- startupManager();
-
- let addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_PRELIMINARY);
- do_check_eq(getActiveVersion(), 2);
-
- addon.uninstall();
- yield promiseShutdownManager();
- resetPrefs();
-
- do_check_false(file.exists());
- clearCache(file);
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_signed_install.js b/toolkit/mozapps/extensions/test/xpcshell/test_signed_install.js
deleted file mode 100644
index 19b07ac16..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_signed_install.js
+++ /dev/null
@@ -1,265 +0,0 @@
-// Enable signature checks for these tests
-gUseRealCertChecks = true;
-// Disable update security
-Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false);
-
-const DATA = "data/signing_checks/";
-const ADDONS = {
- bootstrap: {
- unsigned: "unsigned_bootstrap_2.xpi",
- badid: "signed_bootstrap_badid_2.xpi",
- preliminary: "preliminary_bootstrap_2.xpi",
- signed: "signed_bootstrap_2.xpi",
- },
-};
-const WORKING = "signed_bootstrap_1.xpi";
-const ID = "test@tests.mozilla.org";
-
-var gServer = createHttpServer(4444);
-
-// Creates an add-on with a broken signature by changing an existing file
-function createBrokenAddonModify(file) {
- let brokenFile = gTmpD.clone();
- brokenFile.append("broken.xpi");
- file.copyTo(brokenFile.parent, brokenFile.leafName);
-
- var stream = AM_Cc["@mozilla.org/io/string-input-stream;1"].
- createInstance(AM_Ci.nsIStringInputStream);
- stream.setData("FOOBAR", -1);
- var zipW = AM_Cc["@mozilla.org/zipwriter;1"].
- createInstance(AM_Ci.nsIZipWriter);
- zipW.open(brokenFile, FileUtils.MODE_RDWR | FileUtils.MODE_APPEND);
- zipW.removeEntry("test.txt", false);
- zipW.addEntryStream("test.txt", 0, AM_Ci.nsIZipWriter.COMPRESSION_NONE,
- stream, false);
- zipW.close();
-
- return brokenFile;
-}
-
-// Creates an add-on with a broken signature by adding a new file
-function createBrokenAddonAdd(file) {
- let brokenFile = gTmpD.clone();
- brokenFile.append("broken.xpi");
- file.copyTo(brokenFile.parent, brokenFile.leafName);
-
- var stream = AM_Cc["@mozilla.org/io/string-input-stream;1"].
- createInstance(AM_Ci.nsIStringInputStream);
- stream.setData("FOOBAR", -1);
- var zipW = AM_Cc["@mozilla.org/zipwriter;1"].
- createInstance(AM_Ci.nsIZipWriter);
- zipW.open(brokenFile, FileUtils.MODE_RDWR | FileUtils.MODE_APPEND);
- zipW.addEntryStream("test2.txt", 0, AM_Ci.nsIZipWriter.COMPRESSION_NONE,
- stream, false);
- zipW.close();
-
- return brokenFile;
-}
-
-// Creates an add-on with a broken signature by removing an existing file
-function createBrokenAddonRemove(file) {
- let brokenFile = gTmpD.clone();
- brokenFile.append("broken.xpi");
- file.copyTo(brokenFile.parent, brokenFile.leafName);
-
- var stream = AM_Cc["@mozilla.org/io/string-input-stream;1"].
- createInstance(AM_Ci.nsIStringInputStream);
- stream.setData("FOOBAR", -1);
- var zipW = AM_Cc["@mozilla.org/zipwriter;1"].
- createInstance(AM_Ci.nsIZipWriter);
- zipW.open(brokenFile, FileUtils.MODE_RDWR | FileUtils.MODE_APPEND);
- zipW.removeEntry("test.txt", false);
- zipW.close();
-
- return brokenFile;
-}
-
-function createInstall(url) {
- return new Promise(resolve => {
- AddonManager.getInstallForURL(url, resolve, "application/x-xpinstall");
- });
-}
-
-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));
- });
-}
-
-
-function* test_install_broken(file, expectedError) {
- gServer.registerFile("/" + file.leafName, file);
-
- let install = yield createInstall("http://localhost:4444/" + file.leafName);
- yield promiseCompleteAllInstalls([install]);
-
- do_check_eq(install.state, AddonManager.STATE_DOWNLOAD_FAILED);
- do_check_eq(install.error, expectedError);
- do_check_eq(install.addon, null);
-
- gServer.registerFile("/" + file.leafName, null);
-}
-
-function* test_install_working(file, expectedSignedState) {
- gServer.registerFile("/" + file.leafName, file);
-
- let install = yield createInstall("http://localhost:4444/" + file.leafName);
- yield promiseCompleteAllInstalls([install]);
-
- do_check_eq(install.state, AddonManager.STATE_INSTALLED);
- do_check_neq(install.addon, null);
- do_check_eq(install.addon.signedState, expectedSignedState);
-
- gServer.registerFile("/" + file.leafName, null);
-
- install.addon.uninstall();
-}
-
-function* test_update_broken(file, expectedError) {
- // First install the older version
- yield promiseInstallAllFiles([do_get_file(DATA + WORKING)]);
-
- gServer.registerFile("/" + file.leafName, file);
- serveUpdateRDF(file.leafName);
-
- let addon = yield promiseAddonByID(ID);
- let update = yield promiseFindAddonUpdates(addon);
- let install = update.updateAvailable;
- yield promiseCompleteAllInstalls([install]);
-
- do_check_eq(install.state, AddonManager.STATE_DOWNLOAD_FAILED);
- do_check_eq(install.error, expectedError);
- do_check_eq(install.addon, null);
-
- gServer.registerFile("/" + file.leafName, null);
- gServer.registerPathHandler("/update.rdf", null);
-
- addon.uninstall();
-}
-
-function* test_update_working(file, expectedSignedState) {
- // First install the older version
- yield promiseInstallAllFiles([do_get_file(DATA + WORKING)]);
-
- gServer.registerFile("/" + file.leafName, file);
- serveUpdateRDF(file.leafName);
-
- let addon = yield promiseAddonByID(ID);
- let update = yield promiseFindAddonUpdates(addon);
- let install = update.updateAvailable;
- yield promiseCompleteAllInstalls([install]);
-
- do_check_eq(install.state, AddonManager.STATE_INSTALLED);
- do_check_neq(install.addon, null);
- do_check_eq(install.addon.signedState, expectedSignedState);
-
- gServer.registerFile("/" + file.leafName, null);
- gServer.registerPathHandler("/update.rdf", null);
-
- install.addon.uninstall();
-}
-
-function run_test() {
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "4", "4");
- startupManager();
-
- run_next_test();
-}
-
-// Try to install a broken add-on
-add_task(function*() {
- let file = createBrokenAddonModify(do_get_file(DATA + ADDONS.bootstrap.signed));
- yield test_install_broken(file, AddonManager.ERROR_CORRUPT_FILE);
- file.remove(true);
-});
-
-add_task(function*() {
- let file = createBrokenAddonAdd(do_get_file(DATA + ADDONS.bootstrap.signed));
- yield test_install_broken(file, AddonManager.ERROR_CORRUPT_FILE);
- file.remove(true);
-});
-
-add_task(function*() {
- let file = createBrokenAddonRemove(do_get_file(DATA + ADDONS.bootstrap.signed));
- yield test_install_broken(file, AddonManager.ERROR_CORRUPT_FILE);
- file.remove(true);
-});
-
-// Try to install an add-on with an incorrect ID
-add_task(function*() {
- let file = do_get_file(DATA + ADDONS.bootstrap.badid);
- yield test_install_broken(file, AddonManager.ERROR_CORRUPT_FILE);
-});
-
-// Try to install an unsigned add-on
-add_task(function*() {
- let file = do_get_file(DATA + ADDONS.bootstrap.unsigned);
- yield test_install_broken(file, AddonManager.ERROR_SIGNEDSTATE_REQUIRED);
-});
-
-// Try to install a preliminarily reviewed add-on
-add_task(function*() {
- let file = do_get_file(DATA + ADDONS.bootstrap.preliminary);
- yield test_install_working(file, AddonManager.SIGNEDSTATE_PRELIMINARY);
-});
-
-// Try to install a signed add-on
-add_task(function*() {
- let file = do_get_file(DATA + ADDONS.bootstrap.signed);
- yield test_install_working(file, AddonManager.SIGNEDSTATE_SIGNED);
-});
-
-// Try to update to a broken add-on
-add_task(function*() {
- let file = createBrokenAddonModify(do_get_file(DATA + ADDONS.bootstrap.signed));
- yield test_update_broken(file, AddonManager.ERROR_CORRUPT_FILE);
- file.remove(true);
-});
-
-add_task(function*() {
- let file = createBrokenAddonAdd(do_get_file(DATA + ADDONS.bootstrap.signed));
- yield test_update_broken(file, AddonManager.ERROR_CORRUPT_FILE);
- file.remove(true);
-});
-
-add_task(function*() {
- let file = createBrokenAddonRemove(do_get_file(DATA + ADDONS.bootstrap.signed));
- yield test_update_broken(file, AddonManager.ERROR_CORRUPT_FILE);
- file.remove(true);
-});
-
-// Try to update to an add-on with an incorrect ID
-add_task(function*() {
- let file = do_get_file(DATA + ADDONS.bootstrap.badid);
- yield test_update_broken(file, AddonManager.ERROR_CORRUPT_FILE);
-});
-
-// Try to update to an unsigned add-on
-add_task(function*() {
- let file = do_get_file(DATA + ADDONS.bootstrap.unsigned);
- yield test_update_broken(file, AddonManager.ERROR_SIGNEDSTATE_REQUIRED);
-});
-
-// Try to update to a preliminarily reviewed add-on
-add_task(function*() {
- let file = do_get_file(DATA + ADDONS.bootstrap.preliminary);
- yield test_update_working(file, AddonManager.SIGNEDSTATE_PRELIMINARY);
-});
-
-// Try to update to a signed add-on
-add_task(function*() {
- let file = do_get_file(DATA + ADDONS.bootstrap.signed);
- yield test_update_working(file, AddonManager.SIGNEDSTATE_SIGNED);
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_signed_long.js b/toolkit/mozapps/extensions/test/xpcshell/test_signed_long.js
deleted file mode 100644
index b74d7804a..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_signed_long.js
+++ /dev/null
@@ -1,49 +0,0 @@
-// Disable update security
-Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false);
-
-gUseRealCertChecks = true;
-
-const DATA = "data/signing_checks/";
-
-const ID_63 = "123456789012345678901234567890123456789012345@tests.mozilla.org"
-const ID_64 = "1234567890123456789012345678901234567890123456@tests.mozilla.org"
-const ID_65 = "12345678901234567890123456789012345678901234568@tests.mozilla.org"
-
-function run_test() {
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
- startupManager();
-
- run_next_test();
-}
-
-// Installs the cases that should be working
-add_task(function* test_working() {
- yield promiseInstallAllFiles([do_get_file(DATA + "long_63_plain.xpi"),
- do_get_file(DATA + "long_64_plain.xpi"),
- do_get_file(DATA + "long_65_hash.xpi")]);
-
- let addons = yield promiseAddonsByIDs([ID_63, ID_64, ID_65]);
-
- for (let addon of addons) {
- do_check_neq(addon, null);
- do_check_true(addon.signedState > AddonManager.SIGNEDSTATE_MISSING);
-
- addon.uninstall();
- }
-});
-
-// Checks the cases that should be broken
-add_task(function* test_broken() {
- function promiseInstallForFile(file) {
- return new Promise(resolve => AddonManager.getInstallForFile(file, resolve));
- }
-
- let promises = [promiseInstallForFile(do_get_file(DATA + "long_63_hash.xpi")),
- promiseInstallForFile(do_get_file(DATA + "long_64_hash.xpi"))];
- let installs = yield Promise.all(promises);
-
- for (let install of installs) {
- do_check_eq(install.state, AddonManager.STATE_DOWNLOAD_FAILED);
- do_check_eq(install.error, AddonManager.ERROR_CORRUPT_FILE);
- }
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_signed_migrate.js b/toolkit/mozapps/extensions/test/xpcshell/test_signed_migrate.js
deleted file mode 100644
index 97e2ff79f..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_signed_migrate.js
+++ /dev/null
@@ -1,194 +0,0 @@
-// Enable signature checks for these tests
-gUseRealCertChecks = true;
-// Disable update security
-Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false);
-// Allow attempting to show the compatibility UI which should not happen
-Services.prefs.setBoolPref("extensions.showMismatchUI", true);
-
-const DATA = "data/signing_checks/";
-const ADDONS = {
- bootstrap: {
- unsigned: "unsigned_bootstrap_2.xpi",
- badid: "signed_bootstrap_badid_2.xpi",
- signed: "signed_bootstrap_2.xpi",
- },
- nonbootstrap: {
- unsigned: "unsigned_nonbootstrap_2.xpi",
- badid: "signed_nonbootstrap_badid_2.xpi",
- signed: "signed_nonbootstrap_2.xpi",
- }
-};
-const ID = "test@tests.mozilla.org";
-
-const profileDir = gProfD.clone();
-profileDir.append("extensions");
-
-// Override the window watcher
-var WindowWatcher = {
- sawAddon: false,
-
- openWindow: function(parent, url, name, features, args) {
- let ids = args.QueryInterface(AM_Ci.nsIVariant);
- this.sawAddon = ids.indexOf(ID) >= 0;
- },
-
- QueryInterface: function(iid) {
- if (iid.equals(AM_Ci.nsIWindowWatcher)
- || iid.equals(AM_Ci.nsISupports))
- return this;
-
- throw Components.results.NS_ERROR_NO_INTERFACE;
- }
-}
-
-MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher);
-
-function resetPrefs() {
- Services.prefs.setIntPref("bootstraptest.active_version", -1);
- Services.prefs.setIntPref("bootstraptest.installed_version", -1);
- Services.prefs.setIntPref("bootstraptest.startup_reason", -1);
- Services.prefs.setIntPref("bootstraptest.shutdown_reason", -1);
- Services.prefs.setIntPref("bootstraptest.install_reason", -1);
- Services.prefs.setIntPref("bootstraptest.uninstall_reason", -1);
- Services.prefs.setIntPref("bootstraptest.startup_oldversion", -1);
- Services.prefs.setIntPref("bootstraptest.shutdown_newversion", -1);
- Services.prefs.setIntPref("bootstraptest.install_oldversion", -1);
- Services.prefs.setIntPref("bootstraptest.uninstall_newversion", -1);
-}
-
-function getActiveVersion() {
- return Services.prefs.getIntPref("bootstraptest.active_version");
-}
-
-function run_test() {
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "4", "4");
-
- // Start and stop the manager to initialise everything in the profile before
- // actual testing
- startupManager();
- shutdownManager();
- resetPrefs();
-
- run_next_test();
-}
-
-// Removes the signedState field from add-ons in the json database to make it
-// look like the database was written with an older version of the application
-function stripDB() {
- let jData = loadJSON(gExtensionsJSON);
- jData.schemaVersion--;
-
- for (let addon of jData.addons)
- delete addon.signedState;
-
- saveJSON(jData, gExtensionsJSON);
-}
-
-function* test_breaking_migrate(addons, test, expectedSignedState) {
- // Startup as the old version
- gAppInfo.version = "4";
- startupManager(true);
-
- // Install the signed add-on
- yield promiseInstallAllFiles([do_get_file(DATA + addons.signed)]);
- // Restart to let non-restartless add-ons install fully
- yield promiseRestartManager();
- yield promiseShutdownManager();
- resetPrefs();
- stripDB();
-
- // Now replace it with the version to test. Doing this so quickly shouldn't
- // trigger the file modification code to detect the change by itself.
- manuallyUninstall(profileDir, ID);
- manuallyInstall(do_get_file(DATA + addons[test]), profileDir, ID);
-
- // Update the application
- gAppInfo.version = "5";
- startupManager(true);
-
- let addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
- do_check_true(addon.appDisabled);
- do_check_false(addon.isActive);
- do_check_eq(addon.signedState, expectedSignedState);
-
- // Add-on shouldn't be active
- if (addons == ADDONS.bootstrap)
- do_check_eq(getActiveVersion(), -1);
- else
- do_check_false(isExtensionInAddonsList(profileDir, ID));
-
- // Should have flagged the change during startup
- let changes = AddonManager.getStartupChanges(AddonManager.STARTUP_CHANGE_DISABLED);
- do_check_eq(changes.length, 1);
- do_check_eq(changes[0], ID);
-
- // Shouldn't have checked for updates for the add-on
- do_check_false(WindowWatcher.sawAddon);
- WindowWatcher.sawAddon = false;
-
- addon.uninstall();
- // Restart to let non-restartless add-ons uninstall fully
- yield promiseRestartManager();
- yield shutdownManager();
- resetPrefs();
-}
-
-function* test_working_migrate(addons, test, expectedSignedState) {
- // Startup as the old version
- gAppInfo.version = "4";
- startupManager(true);
-
- // Install the signed add-on
- yield promiseInstallAllFiles([do_get_file(DATA + addons.signed)]);
- // Restart to let non-restartless add-ons install fully
- yield promiseRestartManager();
- yield promiseShutdownManager();
- resetPrefs();
- stripDB();
-
- // Now replace it with the version to test. Doing this so quickly shouldn't
- // trigger the file modification code to detect the change by itself.
- manuallyUninstall(profileDir, ID);
- manuallyInstall(do_get_file(DATA + addons[test]), profileDir, ID);
-
- // Update the application
- gAppInfo.version = "5";
- startupManager(true);
-
- let addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.signedState, expectedSignedState);
-
- if (addons == ADDONS.bootstrap)
- do_check_eq(getActiveVersion(), 2);
- else
- do_check_true(isExtensionInAddonsList(profileDir, ID));
-
- // Shouldn't have checked for updates for the add-on
- do_check_false(WindowWatcher.sawAddon);
- WindowWatcher.sawAddon = false;
-
- addon.uninstall();
- // Restart to let non-restartless add-ons uninstall fully
- yield promiseRestartManager();
- yield shutdownManager();
- resetPrefs();
-}
-
-add_task(function*() {
- yield test_breaking_migrate(ADDONS.bootstrap, "unsigned", AddonManager.SIGNEDSTATE_MISSING);
- yield test_breaking_migrate(ADDONS.nonbootstrap, "unsigned", AddonManager.SIGNEDSTATE_MISSING);
-});
-
-add_task(function*() {
- yield test_breaking_migrate(ADDONS.bootstrap, "badid", AddonManager.SIGNEDSTATE_BROKEN);
- yield test_breaking_migrate(ADDONS.nonbootstrap, "badid", AddonManager.SIGNEDSTATE_BROKEN);
-});
-
-add_task(function*() {
- yield test_working_migrate(ADDONS.bootstrap, "signed", AddonManager.SIGNEDSTATE_SIGNED);
- yield test_working_migrate(ADDONS.nonbootstrap, "signed", AddonManager.SIGNEDSTATE_SIGNED);
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_signed_multi.js b/toolkit/mozapps/extensions/test/xpcshell/test_signed_multi.js
deleted file mode 100644
index 01de29088..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_signed_multi.js
+++ /dev/null
@@ -1,55 +0,0 @@
-// Enable signature checks for these tests
-gUseRealCertChecks = true;
-// Disable update security
-Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false);
-
-const DATA = "data/signing_checks/";
-
-// Each multi-package XPI contains one valid theme and one other add-on that
-// has the following error state:
-const ADDONS = {
- "multi_signed.xpi": 0,
- "multi_badid.xpi": AddonManager.ERROR_CORRUPT_FILE,
- "multi_broken.xpi": AddonManager.ERROR_CORRUPT_FILE,
- "multi_unsigned.xpi": AddonManager.ERROR_SIGNEDSTATE_REQUIRED,
-};
-
-function createInstall(filename) {
- return new Promise(resolve => {
- AddonManager.getInstallForFile(do_get_file(DATA + filename), resolve, "application/x-xpinstall");
- });
-}
-
-function run_test() {
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "4", "4");
- startupManager();
-
- run_next_test();
-}
-
-function* test_addon(filename) {
- do_print("Testing " + filename);
-
- let install = yield createInstall(filename);
- do_check_eq(install.state, AddonManager.STATE_DOWNLOADED);
- do_check_eq(install.error, 0);
-
- do_check_neq(install.linkedInstalls, null);
- do_check_eq(install.linkedInstalls.length, 1);
-
- let linked = install.linkedInstalls[0];
- do_print(linked.state);
- do_check_eq(linked.error, ADDONS[filename]);
- if (linked.error == 0) {
- do_check_eq(linked.state, AddonManager.STATE_DOWNLOADED);
- linked.cancel();
- }
- else {
- do_check_eq(linked.state, AddonManager.STATE_DOWNLOAD_FAILED);
- }
-
- install.cancel();
-}
-
-for (let filename of Object.keys(ADDONS))
- add_task(test_addon.bind(null, filename));
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_signed_updatepref.js b/toolkit/mozapps/extensions/test/xpcshell/test_signed_updatepref.js
deleted file mode 100644
index eb1bb78b3..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_signed_updatepref.js
+++ /dev/null
@@ -1,136 +0,0 @@
-// Disable update security
-Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false);
-gUseRealCertChecks = true;
-
-const DATA = "data/signing_checks/";
-const ID = "test@tests.mozilla.org";
-
-Components.utils.import("resource://testing-common/httpd.js");
-var gServer = new HttpServer();
-gServer.start();
-
-gServer.registerPathHandler("/update.rdf", function(request, response) {
- let updateData = {};
- updateData[ID] = [{
- version: "2.0",
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "4",
- maxVersion: "6"
- }]
- }];
-
- response.setStatusLine(request.httpVersion, 200, "OK");
- response.write(createUpdateRDF(updateData));
-});
-
-const SERVER = "127.0.0.1:" + gServer.identity.primaryPort;
-Services.prefs.setCharPref("extensions.update.background.url", "http://" + SERVER + "/update.rdf");
-
-function verifySignatures() {
- return new Promise(resolve => {
- let observer = (subject, topic, data) => {
- Services.obs.removeObserver(observer, "xpi-signature-changed");
- resolve(JSON.parse(data));
- }
- Services.obs.addObserver(observer, "xpi-signature-changed", false);
-
- do_print("Verifying signatures");
- let XPIscope = Components.utils.import("resource://gre/modules/addons/XPIProvider.jsm");
- XPIscope.XPIProvider.verifySignatures();
- });
-}
-
-function run_test() {
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "4", "4");
-
- // Start and stop the manager to initialise everything in the profile before
- // actual testing
- startupManager();
- shutdownManager();
-
- run_next_test();
-}
-
-// Updating the pref without changing the app version won't disable add-ons
-// immediately but will after a signing check
-add_task(function*() {
- Services.prefs.setBoolPref(PREF_XPI_SIGNATURES_REQUIRED, false);
- startupManager();
-
- // Install the signed add-on
- yield promiseInstallAllFiles([do_get_file(DATA + "unsigned_bootstrap_2.xpi")]);
-
- let addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_MISSING);
-
- yield promiseShutdownManager();
-
- Services.prefs.setBoolPref(PREF_XPI_SIGNATURES_REQUIRED, true);
-
- startupManager();
-
- addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_MISSING);
-
- // Update checks shouldn't affect the add-on
- yield AddonManagerInternal.backgroundUpdateCheck();
- addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_MISSING);
-
- let changes = yield verifySignatures();
-
- do_check_eq(changes.disabled.length, 1);
- do_check_eq(changes.disabled[0], ID);
-
- addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
- do_check_true(addon.appDisabled);
- do_check_false(addon.isActive);
- do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_MISSING);
-
- addon.uninstall();
-
- yield promiseShutdownManager();
-});
-
-// Updating the pref with changing the app version will disable add-ons
-// immediately
-add_task(function*() {
- Services.prefs.setBoolPref(PREF_XPI_SIGNATURES_REQUIRED, false);
- startupManager();
-
- // Install the signed add-on
- yield promiseInstallAllFiles([do_get_file(DATA + "unsigned_bootstrap_2.xpi")]);
-
- let addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_MISSING);
-
- yield promiseShutdownManager();
-
- Services.prefs.setBoolPref(PREF_XPI_SIGNATURES_REQUIRED, true);
- gAppInfo.version = 5.0
- startupManager(true);
-
- addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
- do_check_true(addon.appDisabled);
- do_check_false(addon.isActive);
- do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_MISSING);
-
- addon.uninstall();
-
- yield promiseShutdownManager();
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_signed_verify.js b/toolkit/mozapps/extensions/test/xpcshell/test_signed_verify.js
deleted file mode 100644
index 0b5b30d89..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_signed_verify.js
+++ /dev/null
@@ -1,234 +0,0 @@
-// Enable signature checks for these tests
-gUseRealCertChecks = true;
-// Disable update security
-Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false);
-
-const DATA = "data/signing_checks/";
-const GOOD = [
- ["signed_bootstrap_2.xpi", AddonManager.SIGNEDSTATE_SIGNED],
- ["signed_nonbootstrap_2.xpi", AddonManager.SIGNEDSTATE_SIGNED]
-];
-const BAD = [
- ["unsigned_bootstrap_2.xpi", AddonManager.SIGNEDSTATE_MISSING],
- ["signed_bootstrap_badid_2.xpi", AddonManager.SIGNEDSTATE_BROKEN],
- ["unsigned_nonbootstrap_2.xpi", AddonManager.SIGNEDSTATE_MISSING],
- ["signed_nonbootstrap_badid_2.xpi", AddonManager.SIGNEDSTATE_BROKEN],
-];
-const ID = "test@tests.mozilla.org";
-
-const profileDir = gProfD.clone();
-profileDir.append("extensions");
-
-function verifySignatures() {
- return new Promise(resolve => {
- let observer = (subject, topic, data) => {
- Services.obs.removeObserver(observer, "xpi-signature-changed");
- resolve(JSON.parse(data));
- }
- Services.obs.addObserver(observer, "xpi-signature-changed", false);
-
- do_print("Verifying signatures");
- let XPIscope = Components.utils.import("resource://gre/modules/addons/XPIProvider.jsm");
- XPIscope.XPIProvider.verifySignatures();
- });
-}
-
-function run_test() {
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "4", "4");
-
- run_next_test();
-}
-
-function verify_no_change([startFile, startState], [endFile, endState]) {
- add_task(function*() {
- do_print("A switch from " + startFile + " to " + endFile + " should cause no change.");
-
- // Install the first add-on
- manuallyInstall(do_get_file(DATA + startFile), profileDir, ID);
- startupManager();
-
- let addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
- let wasAppDisabled = addon.appDisabled;
- do_check_neq(addon.appDisabled, addon.isActive);
- do_check_eq(addon.pendingOperations, AddonManager.PENDING_NONE);
- do_check_eq(addon.signedState, startState);
-
- // Swap in the files from the next add-on
- manuallyUninstall(profileDir, ID);
- manuallyInstall(do_get_file(DATA + endFile), profileDir, ID);
-
- let events = {
- [ID]: []
- };
-
- if (startState != endState)
- events[ID].unshift(["onPropertyChanged", ["signedState"]]);
-
- prepare_test(events);
-
- // Trigger the check
- let changes = yield verifySignatures();
- do_check_eq(changes.enabled.length, 0);
- do_check_eq(changes.disabled.length, 0);
-
- do_check_eq(addon.appDisabled, wasAppDisabled);
- do_check_neq(addon.appDisabled, addon.isActive);
- do_check_eq(addon.pendingOperations, AddonManager.PENDING_NONE);
- do_check_eq(addon.signedState, endState);
-
- // Remove the add-on and restart to let it go away
- manuallyUninstall(profileDir, ID);
- yield promiseRestartManager();
- yield promiseShutdownManager();
- });
-}
-
-function verify_enables([startFile, startState], [endFile, endState]) {
- add_task(function*() {
- do_print("A switch from " + startFile + " to " + endFile + " should enable the add-on.");
-
- // Install the first add-on
- manuallyInstall(do_get_file(DATA + startFile), profileDir, ID);
- startupManager();
-
- let addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
- do_check_false(addon.isActive);
- do_check_eq(addon.pendingOperations, AddonManager.PENDING_NONE);
- do_check_eq(addon.signedState, startState);
-
- // Swap in the files from the next add-on
- manuallyUninstall(profileDir, ID);
- manuallyInstall(do_get_file(DATA + endFile), profileDir, ID);
-
- let needsRestart = hasFlag(addon.operationsRequiringRestart, AddonManager.OP_NEEDS_RESTART_ENABLE);
- do_print(needsRestart);
-
- let events = {};
- if (!needsRestart) {
- events[ID] = [
- ["onPropertyChanged", ["appDisabled"]],
- ["onEnabling", false],
- "onEnabled"
- ];
- }
- else {
- events[ID] = [
- ["onPropertyChanged", ["appDisabled"]],
- "onEnabling"
- ];
- }
-
- if (startState != endState)
- events[ID].unshift(["onPropertyChanged", ["signedState"]]);
-
- prepare_test(events);
-
- // Trigger the check
- let changes = yield verifySignatures();
- do_check_eq(changes.enabled.length, 1);
- do_check_eq(changes.enabled[0], ID);
- do_check_eq(changes.disabled.length, 0);
-
- do_check_false(addon.appDisabled);
- if (needsRestart)
- do_check_neq(addon.pendingOperations, AddonManager.PENDING_NONE);
- else
- do_check_true(addon.isActive);
- do_check_eq(addon.signedState, endState);
-
- ensure_test_completed();
-
- // Remove the add-on and restart to let it go away
- manuallyUninstall(profileDir, ID);
- yield promiseRestartManager();
- yield promiseShutdownManager();
- });
-}
-
-function verify_disables([startFile, startState], [endFile, endState]) {
- add_task(function*() {
- do_print("A switch from " + startFile + " to " + endFile + " should disable the add-on.");
-
- // Install the first add-on
- manuallyInstall(do_get_file(DATA + startFile), profileDir, ID);
- startupManager();
-
- let addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
- do_check_true(addon.isActive);
- do_check_eq(addon.pendingOperations, AddonManager.PENDING_NONE);
- do_check_eq(addon.signedState, startState);
-
- let needsRestart = hasFlag(addon.operationsRequiringRestart, AddonManager.OP_NEEDS_RESTART_DISABLE);
-
- // Swap in the files from the next add-on
- manuallyUninstall(profileDir, ID);
- manuallyInstall(do_get_file(DATA + endFile), profileDir, ID);
-
- let events = {};
- if (!needsRestart) {
- events[ID] = [
- ["onPropertyChanged", ["appDisabled"]],
- ["onDisabling", false],
- "onDisabled"
- ];
- }
- else {
- events[ID] = [
- ["onPropertyChanged", ["appDisabled"]],
- "onDisabling"
- ];
- }
-
- if (startState != endState)
- events[ID].unshift(["onPropertyChanged", ["signedState"]]);
-
- prepare_test(events);
-
- // Trigger the check
- let changes = yield verifySignatures();
- do_check_eq(changes.enabled.length, 0);
- do_check_eq(changes.disabled.length, 1);
- do_check_eq(changes.disabled[0], ID);
-
- do_check_true(addon.appDisabled);
- if (needsRestart)
- do_check_neq(addon.pendingOperations, AddonManager.PENDING_NONE);
- else
- do_check_false(addon.isActive);
- do_check_eq(addon.signedState, endState);
-
- ensure_test_completed();
-
- // Remove the add-on and restart to let it go away
- manuallyUninstall(profileDir, ID);
- yield promiseRestartManager();
- yield promiseShutdownManager();
- });
-}
-
-for (let start of GOOD) {
- for (let end of BAD) {
- verify_disables(start, end);
- }
-}
-
-for (let start of BAD) {
- for (let end of GOOD) {
- verify_enables(start, end);
- }
-}
-
-for (let start of GOOD) {
- for (let end of GOOD.filter(f => f != start)) {
- verify_no_change(start, end);
- }
-}
-
-for (let start of BAD) {
- for (let end of BAD.filter(f => f != start)) {
- verify_no_change(start, end);
- }
-}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_softblocked.js b/toolkit/mozapps/extensions/test/xpcshell/test_softblocked.js
deleted file mode 100644
index 260b536e1..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_softblocked.js
+++ /dev/null
@@ -1,109 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-const { utils: Cu, interfaces: Ci, classes: Cc, results: Cr } = Components;
-
-const URI_EXTENSION_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul";
-
-Cu.import("resource://gre/modules/NetUtil.jsm");
-Cu.import("resource://testing-common/MockRegistrar.jsm");
-
-// Allow insecure updates
-Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false)
-
-const testserver = createHttpServer();
-gPort = testserver.identity.primaryPort;
-testserver.registerDirectory("/data/", do_get_file("data"));
-
-// Don't need the full interface, attempts to call other methods will just
-// throw which is just fine
-var WindowWatcher = {
- openWindow: function(parent, url, name, features, openArgs) {
- // Should be called to list the newly blocklisted items
- do_check_eq(url, URI_EXTENSION_BLOCKLIST_DIALOG);
-
- // Simulate auto-disabling any softblocks
- var list = openArgs.wrappedJSObject.list;
- list.forEach(function(aItem) {
- if (!aItem.blocked)
- aItem.disable = true;
- });
-
- // run the code after the blocklist is closed
- Services.obs.notifyObservers(null, "addon-blocklist-closed", null);
- },
-
- QueryInterface: function(iid) {
- if (iid.equals(Ci.nsIWindowWatcher)
- || iid.equals(Ci.nsISupports))
- return this;
-
- throw Cr.NS_ERROR_NO_INTERFACE;
- }
-};
-
-MockRegistrar.register("@mozilla.org/embedcomp/window-watcher;1", WindowWatcher);
-
-const profileDir = gProfD.clone();
-profileDir.append("extensions");
-
-function load_blocklist(aFile) {
- return new Promise((resolve, reject) => {
- Services.obs.addObserver(function() {
- Services.obs.removeObserver(arguments.callee, "blocklist-updated");
-
- resolve();
- }, "blocklist-updated", false);
-
- Services.prefs.setCharPref("extensions.blocklist.url", `http://localhost:${gPort}/data/${aFile}`);
- var blocklist = Cc["@mozilla.org/extensions/blocklist;1"].
- getService(Ci.nsITimerCallback);
- blocklist.notify(null);
- });
-}
-
-function run_test() {
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
- run_next_test();
-}
-
-// Tests that an appDisabled add-on that becomes softBlocked remains disabled
-// when becoming appEnabled
-add_task(function* () {
- writeInstallRDFForExtension({
- id: "softblock1@tests.mozilla.org",
- version: "1.0",
- name: "Softblocked add-on",
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "2",
- maxVersion: "3"
- }]
- }, profileDir);
-
- startupManager();
-
- let s1 = yield promiseAddonByID("softblock1@tests.mozilla.org");
-
- // Make sure to mark it as previously enabled.
- s1.userDisabled = false;
-
- do_check_false(s1.softDisabled);
- do_check_true(s1.appDisabled);
- do_check_false(s1.isActive);
-
- yield load_blocklist("test_softblocked1.xml");
-
- do_check_true(s1.softDisabled);
- do_check_true(s1.appDisabled);
- do_check_false(s1.isActive);
-
- yield promiseRestartManager("2");
-
- s1 = yield promiseAddonByID("softblock1@tests.mozilla.org");
-
- do_check_true(s1.softDisabled);
- do_check_false(s1.appDisabled);
- do_check_false(s1.isActive);
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_sourceURI.js b/toolkit/mozapps/extensions/test/xpcshell/test_sourceURI.js
index db5e4f7cc..e78bb5074 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_sourceURI.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_sourceURI.js
@@ -54,10 +54,10 @@ function run_test() {
backgroundUpdate(function() {
restartManager();
- AddonManager.getAddonByID("addon@tests.mozilla.org", function(a2) {
- do_check_neq(a2, null);
- do_check_neq(a2.sourceURI, null);
- do_check_eq(a2.sourceURI.spec, "http://www.example.com/testaddon.xpi");
+ AddonManager.getAddonByID("addon@tests.mozilla.org", function(a) {
+ do_check_neq(a, null);
+ do_check_neq(a.sourceURI, null);
+ do_check_eq(a.sourceURI.spec, "http://www.example.com/testaddon.xpi");
do_test_finished();
});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_startup.js b/toolkit/mozapps/extensions/test/xpcshell/test_startup.js
index fdd00c1ad..181f8ee62 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_startup.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_startup.js
@@ -212,8 +212,6 @@ function run_test_1() {
do_check_eq(a1.scope, AddonManager.SCOPE_PROFILE);
do_check_eq(a1.sourceURI, null);
do_check_true(a1.foreignInstall);
- do_check_false(a1.userDisabled);
- do_check_true(a1.seen);
do_check_neq(a2, null);
do_check_eq(a2.id, "addon2@tests.mozilla.org");
@@ -228,8 +226,6 @@ function run_test_1() {
do_check_eq(a2.scope, AddonManager.SCOPE_PROFILE);
do_check_eq(a2.sourceURI, null);
do_check_true(a2.foreignInstall);
- do_check_false(a1.userDisabled);
- do_check_true(a1.seen);
do_check_neq(a3, null);
do_check_eq(a3.id, "addon3@tests.mozilla.org");
@@ -244,8 +240,6 @@ function run_test_1() {
do_check_eq(a3.scope, AddonManager.SCOPE_PROFILE);
do_check_eq(a3.sourceURI, null);
do_check_true(a3.foreignInstall);
- do_check_false(a1.userDisabled);
- do_check_true(a1.seen);
do_check_eq(a4, null);
do_check_false(isExtensionInAddonsList(profileDir, "addon4@tests.mozilla.org"));
@@ -830,17 +824,14 @@ function run_test_12() {
callback_soon(function([a1, a2, a3, a4, a5]) {
do_check_neq(a1, null);
do_check_false(a1.userDisabled);
- do_check_true(a1.seen);
do_check_true(a1.isActive);
do_check_neq(a2, null);
do_check_true(a2.userDisabled);
- do_check_false(a2.seen);
do_check_false(a2.isActive);
do_check_neq(a3, null);
do_check_false(a3.userDisabled);
- do_check_true(a3.seen);
do_check_true(a3.isActive);
var dest = profileDir.clone();
@@ -868,31 +859,28 @@ function run_test_12() {
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org",
"addon5@tests.mozilla.org"],
- function([a1_2, a2_2, a3_2, a4_2, a5_2]) {
- do_check_neq(a1_2, null);
- do_check_false(a1_2.userDisabled);
- do_check_true(a1_2.seen);
- do_check_true(a1_2.isActive);
-
- do_check_neq(a2_2, null);
- do_check_false(a2_2.userDisabled);
- do_check_true(a2_2.seen);
- do_check_true(a2_2.isActive);
-
- do_check_neq(a3_2, null);
- do_check_true(a3_2.userDisabled);
- do_check_false(a3_2.seen);
- do_check_false(a3_2.isActive);
-
- var dest2 = profileDir.clone();
- dest2.append(do_get_expected_addon_name("addon1@tests.mozilla.org"));
- dest2.remove(true);
- dest2 = userDir.clone();
- dest2.append(do_get_expected_addon_name("addon2@tests.mozilla.org"));
- dest2.remove(true);
- dest2 = globalDir.clone();
- dest2.append(do_get_expected_addon_name("addon3@tests.mozilla.org"));
- dest2.remove(true);
+ function([a1, a2, a3, a4, a5]) {
+ do_check_neq(a1, null);
+ do_check_false(a1.userDisabled);
+ do_check_true(a1.isActive);
+
+ do_check_neq(a2, null);
+ do_check_false(a2.userDisabled);
+ do_check_true(a2.isActive);
+
+ do_check_neq(a3, null);
+ do_check_true(a3.userDisabled);
+ do_check_false(a3.isActive);
+
+ var dest = profileDir.clone();
+ dest.append(do_get_expected_addon_name("addon1@tests.mozilla.org"));
+ dest.remove(true);
+ dest = userDir.clone();
+ dest.append(do_get_expected_addon_name("addon2@tests.mozilla.org"));
+ dest.remove(true);
+ dest = globalDir.clone();
+ dest.append(do_get_expected_addon_name("addon3@tests.mozilla.org"));
+ dest.remove(true);
restartManager();
@@ -909,21 +897,18 @@ function run_test_12() {
"addon3@tests.mozilla.org",
"addon4@tests.mozilla.org",
"addon5@tests.mozilla.org"],
- function([a1_3, a2_3, a3_3, a4_3, a5_3]) {
- do_check_neq(a1_3, null);
- do_check_false(a1_3.userDisabled);
- do_check_true(a1_3.seen);
- do_check_true(a1_3.isActive);
-
- do_check_neq(a2_3, null);
- do_check_true(a2_3.userDisabled);
- do_check_false(a2_3.seen);
- do_check_false(a2_3.isActive);
-
- do_check_neq(a3_3, null);
- do_check_true(a3_3.userDisabled);
- do_check_false(a3_3.seen);
- do_check_false(a3_3.isActive);
+ function([a1, a2, a3, a4, a5]) {
+ do_check_neq(a1, null);
+ do_check_false(a1.userDisabled);
+ do_check_true(a1.isActive);
+
+ do_check_neq(a2, null);
+ do_check_true(a2.userDisabled);
+ do_check_false(a2.isActive);
+
+ do_check_neq(a3, null);
+ do_check_true(a3.userDisabled);
+ do_check_false(a3.isActive);
do_execute_soon(end_test);
});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_strictcompatibility.js b/toolkit/mozapps/extensions/test/xpcshell/test_strictcompatibility.js
index cb6704936..788e1ef79 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_strictcompatibility.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_strictcompatibility.js
@@ -1,203 +1,203 @@
-/* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
-
-// Tests AddonManager.strictCompatibility and it's related preference,
-// extensions.strictCompatibility, and the strictCompatibility option in
-// install.rdf
-
-
-// Always compatible
-var addon1 = {
- id: "addon1@tests.mozilla.org",
- version: "1.0",
- name: "Test 1",
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "1"
- }]
-};
-
-// Incompatible in strict compatibility mode
-var addon2 = {
- id: "addon2@tests.mozilla.org",
- version: "1.0",
- name: "Test 2",
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "0.7",
- maxVersion: "0.8"
- }]
-};
-
-// Theme - always uses strict compatibility, so is always incompatible
-var addon3 = {
- id: "addon3@tests.mozilla.org",
- version: "1.0",
- name: "Test 3",
- internalName: "test-theme-3",
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "0.8",
- maxVersion: "0.9"
- }]
-};
-
-// Opt-in to strict compatibility - always incompatible
-var addon4 = {
- id: "addon4@tests.mozilla.org",
- version: "1.0",
- name: "Test 4",
- strictCompatibility: true,
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "0.8",
- maxVersion: "0.9"
- }]
-};
-
-// Addon from the future - would be marked as compatibile-by-default,
-// but minVersion is higher than the app version
-var addon5 = {
- id: "addon5@tests.mozilla.org",
- version: "1.0",
- name: "Test 5",
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "3",
- maxVersion: "5"
- }]
-};
-
-// Extremely old addon - maxVersion is less than the mimimum compat version
-// set in extensions.minCompatibleVersion
-var addon6 = {
- id: "addon6@tests.mozilla.org",
- version: "1.0",
- name: "Test 6",
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "0.1",
- maxVersion: "0.2"
- }]
-};
-
-// Dictionary - incompatible in strict compatibility mode
-var addon7= {
- id: "addon7@tests.mozilla.org",
- version: "1.0",
- name: "Test 7",
- type: "64",
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "0.8",
- maxVersion: "0.9"
- }]
-};
-
-
-
-const profileDir = gProfD.clone();
-profileDir.append("extensions");
-
-
-function do_check_compat_status(aStrict, aAddonCompat, aCallback) {
- do_check_eq(AddonManager.strictCompatibility, aStrict);
- 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",
- "addon7@tests.mozilla.org"],
- function([a1, a2, a3, a4, a5, a6, a7]) {
- do_check_neq(a1, null);
- do_check_eq(a1.isCompatible, aAddonCompat[0]);
- do_check_eq(a1.appDisabled, !aAddonCompat[0]);
- do_check_false(a1.strictCompatibility);
-
- do_check_neq(a2, null);
- do_check_eq(a2.isCompatible, aAddonCompat[1]);
- do_check_eq(a2.appDisabled, !aAddonCompat[1]);
- do_check_false(a2.strictCompatibility);
-
- do_check_neq(a3, null);
- do_check_eq(a3.isCompatible, aAddonCompat[2]);
- do_check_eq(a3.appDisabled, !aAddonCompat[2]);
- do_check_true(a3.strictCompatibility);
-
- do_check_neq(a4, null);
- do_check_eq(a4.isCompatible, aAddonCompat[3]);
- do_check_eq(a4.appDisabled, !aAddonCompat[3]);
- do_check_true(a4.strictCompatibility);
-
- do_check_neq(a5, null);
- do_check_eq(a5.isCompatible, aAddonCompat[4]);
- do_check_eq(a5.appDisabled, !aAddonCompat[4]);
- do_check_false(a5.strictCompatibility);
-
- do_check_neq(a6, null);
- do_check_eq(a6.isCompatible, aAddonCompat[5]);
- do_check_eq(a6.appDisabled, !aAddonCompat[5]);
- do_check_false(a6.strictCompatibility);
-
- do_check_neq(a7, null);
- do_check_eq(a7.isCompatible, aAddonCompat[6]);
- do_check_eq(a7.appDisabled, !aAddonCompat[6]);
- do_check_false(a7.strictCompatibility);
-
- do_execute_soon(aCallback);
- });
-}
-
-
-function run_test() {
- do_test_pending();
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
-
- writeInstallRDFForExtension(addon1, profileDir);
- writeInstallRDFForExtension(addon2, profileDir);
- writeInstallRDFForExtension(addon3, profileDir);
- writeInstallRDFForExtension(addon4, profileDir);
- writeInstallRDFForExtension(addon5, profileDir);
- writeInstallRDFForExtension(addon6, profileDir);
- writeInstallRDFForExtension(addon7, profileDir);
-
- Services.prefs.setCharPref(PREF_EM_MIN_COMPAT_APP_VERSION, "0.1");
-
- startupManager();
-
- // Should default to enabling strict compat.
- do_check_compat_status(true, [true, false, false, false, false, false, false], run_test_1);
-}
-
-function run_test_1() {
- do_print("Test 1");
- Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, false);
- do_check_compat_status(false, [true, true, false, false, false, true, true], run_test_2);
-}
-
-function run_test_2() {
- do_print("Test 2");
- restartManager();
- do_check_compat_status(false, [true, true, false, false, false, true, true], run_test_3);
-}
-
-function run_test_3() {
- do_print("Test 3");
- Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, true);
- do_check_compat_status(true, [true, false, false, false, false, false, false], run_test_4);
-}
-
-function run_test_4() {
- do_print("Test 4");
- restartManager();
- do_check_compat_status(true, [true, false, false, false, false, false, false], run_test_5);
-}
-
-function run_test_5() {
- do_print("Test 5");
- Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, false);
- Services.prefs.setCharPref(PREF_EM_MIN_COMPAT_APP_VERSION, "0.4");
- do_check_compat_status(false, [true, true, false, false, false, false, true], do_test_finished);
-}
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+// Tests AddonManager.strictCompatibility and it's related preference,
+// extensions.strictCompatibility, and the strictCompatibility option in
+// install.rdf
+
+
+// Always compatible
+var addon1 = {
+ id: "addon1@tests.mozilla.org",
+ version: "1.0",
+ name: "Test 1",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "1",
+ maxVersion: "1"
+ }]
+};
+
+// Incompatible in strict compatibility mode
+var addon2 = {
+ id: "addon2@tests.mozilla.org",
+ version: "1.0",
+ name: "Test 2",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "0.7",
+ maxVersion: "0.8"
+ }]
+};
+
+// Theme - always uses strict compatibility, so is always incompatible
+var addon3 = {
+ id: "addon3@tests.mozilla.org",
+ version: "1.0",
+ name: "Test 3",
+ internalName: "test-theme-3",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "0.8",
+ maxVersion: "0.9"
+ }]
+};
+
+// Opt-in to strict compatibility - always incompatible
+var addon4 = {
+ id: "addon4@tests.mozilla.org",
+ version: "1.0",
+ name: "Test 4",
+ strictCompatibility: true,
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "0.8",
+ maxVersion: "0.9"
+ }]
+};
+
+// Addon from the future - would be marked as compatibile-by-default,
+// but minVersion is higher than the app version
+var addon5 = {
+ id: "addon5@tests.mozilla.org",
+ version: "1.0",
+ name: "Test 5",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "3",
+ maxVersion: "5"
+ }]
+};
+
+// Extremely old addon - maxVersion is less than the mimimum compat version
+// set in extensions.minCompatibleVersion
+var addon6 = {
+ id: "addon6@tests.mozilla.org",
+ version: "1.0",
+ name: "Test 6",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "0.1",
+ maxVersion: "0.2"
+ }]
+};
+
+// Dictionary - incompatible in strict compatibility mode
+var addon7= {
+ id: "addon7@tests.mozilla.org",
+ version: "1.0",
+ name: "Test 7",
+ type: "64",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "0.8",
+ maxVersion: "0.9"
+ }]
+};
+
+
+
+const profileDir = gProfD.clone();
+profileDir.append("extensions");
+
+
+function do_check_compat_status(aStrict, aAddonCompat, aCallback) {
+ do_check_eq(AddonManager.strictCompatibility, aStrict);
+ 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",
+ "addon7@tests.mozilla.org"],
+ function([a1, a2, a3, a4, a5, a6, a7]) {
+ do_check_neq(a1, null);
+ do_check_eq(a1.isCompatible, aAddonCompat[0]);
+ do_check_eq(a1.appDisabled, !aAddonCompat[0]);
+ do_check_false(a1.strictCompatibility);
+
+ do_check_neq(a2, null);
+ do_check_eq(a2.isCompatible, aAddonCompat[1]);
+ do_check_eq(a2.appDisabled, !aAddonCompat[1]);
+ do_check_false(a2.strictCompatibility);
+
+ do_check_neq(a3, null);
+ do_check_eq(a3.isCompatible, aAddonCompat[2]);
+ do_check_eq(a3.appDisabled, !aAddonCompat[2]);
+ do_check_true(a3.strictCompatibility);
+
+ do_check_neq(a4, null);
+ do_check_eq(a4.isCompatible, aAddonCompat[3]);
+ do_check_eq(a4.appDisabled, !aAddonCompat[3]);
+ do_check_true(a4.strictCompatibility);
+
+ do_check_neq(a5, null);
+ do_check_eq(a5.isCompatible, aAddonCompat[4]);
+ do_check_eq(a5.appDisabled, !aAddonCompat[4]);
+ do_check_false(a5.strictCompatibility);
+
+ do_check_neq(a6, null);
+ do_check_eq(a6.isCompatible, aAddonCompat[5]);
+ do_check_eq(a6.appDisabled, !aAddonCompat[5]);
+ do_check_false(a6.strictCompatibility);
+
+ do_check_neq(a7, null);
+ do_check_eq(a7.isCompatible, aAddonCompat[6]);
+ do_check_eq(a7.appDisabled, !aAddonCompat[6]);
+ do_check_false(a7.strictCompatibility);
+
+ do_execute_soon(aCallback);
+ });
+}
+
+
+function run_test() {
+ do_test_pending();
+ createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
+
+ writeInstallRDFForExtension(addon1, profileDir);
+ writeInstallRDFForExtension(addon2, profileDir);
+ writeInstallRDFForExtension(addon3, profileDir);
+ writeInstallRDFForExtension(addon4, profileDir);
+ writeInstallRDFForExtension(addon5, profileDir);
+ writeInstallRDFForExtension(addon6, profileDir);
+ writeInstallRDFForExtension(addon7, profileDir);
+
+ Services.prefs.setCharPref(PREF_EM_MIN_COMPAT_APP_VERSION, "0.1");
+
+ startupManager();
+
+ // Should default to enabling strict compat.
+ do_check_compat_status(true, [true, false, false, false, false, false, false], run_test_1);
+}
+
+function run_test_1() {
+ do_print("Test 1");
+ Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, false);
+ do_check_compat_status(false, [true, true, false, false, false, true, true], run_test_2);
+}
+
+function run_test_2() {
+ do_print("Test 2");
+ restartManager();
+ do_check_compat_status(false, [true, true, false, false, false, true, true], run_test_3);
+}
+
+function run_test_3() {
+ do_print("Test 3");
+ Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, true);
+ do_check_compat_status(true, [true, false, false, false, false, false, false], run_test_4);
+}
+
+function run_test_4() {
+ do_print("Test 4");
+ restartManager();
+ do_check_compat_status(true, [true, false, false, false, false, false, false], run_test_5);
+}
+
+function run_test_5() {
+ do_print("Test 5");
+ Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, false);
+ Services.prefs.setCharPref(PREF_EM_MIN_COMPAT_APP_VERSION, "0.4");
+ do_check_compat_status(false, [true, true, false, false, false, false, true], do_test_finished);
+}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_switch_os.js b/toolkit/mozapps/extensions/test/xpcshell/test_switch_os.js
deleted file mode 100644
index 552d7cfae..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_switch_os.js
+++ /dev/null
@@ -1,52 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-Components.utils.import("resource://gre/modules/AppConstants.jsm");
-
-const ID = "bootstrap1@tests.mozilla.org";
-
-BootstrapMonitor.init();
-
-const profileDir = gProfD.clone();
-profileDir.append("extensions");
-
-createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
-
-add_task(function*() {
- startupManager();
-
- let install = yield new Promise(resolve => AddonManager.getInstallForFile(do_get_addon("test_bootstrap1_1"), resolve));
- yield promiseCompleteAllInstalls([install]);
-
- let addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
-
- BootstrapMonitor.checkAddonStarted(ID);
- do_check_false(addon.userDisabled);
- do_check_true(addon.isActive);
-
- yield promiseShutdownManager();
-
- BootstrapMonitor.checkAddonNotStarted(ID);
-
- let jData = loadJSON(gExtensionsJSON);
-
- for (let addonInstance of jData.addons) {
- if (addonInstance.id == ID) {
- // Set to something that would be an invalid descriptor for this platform
- addonInstance.descriptor = AppConstants.platform == "win" ? "/foo/bar" : "C:\\foo\\bar";
- }
- }
-
- saveJSON(jData, gExtensionsJSON);
-
- startupManager();
-
- addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
-
- BootstrapMonitor.checkAddonStarted(ID);
- do_check_false(addon.userDisabled);
- do_check_true(addon.isActive);
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_syncGUID.js b/toolkit/mozapps/extensions/test/xpcshell/test_syncGUID.js
index 385f58405..f1d6e0914 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_syncGUID.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_syncGUID.js
@@ -22,8 +22,6 @@ function run_test() {
run_next_test();
}
-const UUID_PATTERN = /^\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\}$/i;
-
add_test(function test_getter_and_setter() {
// Our test add-on requires a restart.
let listener = {
@@ -37,7 +35,7 @@ add_test(function test_getter_and_setter() {
do_check_neq(addon, null);
do_check_neq(addon.syncGUID, null);
- do_check_true(UUID_PATTERN.test(addon.syncGUID));
+ do_check_true(addon.syncGUID.length >= 9);
let oldGUID = addon.SyncGUID;
let newGUID = "foo";
@@ -113,7 +111,7 @@ add_test(function test_error_on_duplicate_syncguid_insert() {
AddonManager.addInstallListener(listener);
let getInstallCB = function(install) { install.install(); };
- for (let name of installNames) {
+ for each (let name in installNames) {
AddonManager.getInstallForFile(do_get_addon(name), getInstallCB);
}
});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_system_delay_update.js b/toolkit/mozapps/extensions/test/xpcshell/test_system_delay_update.js
deleted file mode 100644
index 35964c663..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_system_delay_update.js
+++ /dev/null
@@ -1,461 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-// This verifies that delaying a system add-on update works.
-
-Components.utils.import("resource://testing-common/httpd.js");
-const profileDir = gProfD.clone();
-profileDir.append("extensions");
-const tempdir = gTmpD.clone();
-
-const PREF_SYSTEM_ADDON_SET = "extensions.systemAddonSet";
-const PREF_SYSTEM_ADDON_UPDATE_URL = "extensions.systemAddon.update.url";
-
-const IGNORE_ID = "system_delay_ignore@tests.mozilla.org";
-const COMPLETE_ID = "system_delay_complete@tests.mozilla.org";
-const DEFER_ID = "system_delay_defer@tests.mozilla.org";
-const DEFER_ALSO_ID = "system_delay_defer_also@tests.mozilla.org";
-const NORMAL_ID = "system1@tests.mozilla.org";
-
-
-const TEST_IGNORE_PREF = "delaytest.ignore";
-
-const distroDir = FileUtils.getDir("ProfD", ["sysfeatures"], true);
-registerDirectory("XREAppFeat", distroDir);
-
-let testserver = new HttpServer();
-testserver.registerDirectory("/data/", do_get_file("data/system_addons"));
-testserver.start();
-let root = `${testserver.identity.primaryScheme}://${testserver.identity.primaryHost}:${testserver.identity.primaryPort}/data/`;
-Services.prefs.setCharPref(PREF_SYSTEM_ADDON_UPDATE_URL, root + "update.xml");
-
-
-// Note that we would normally use BootstrapMonitor but it currently requires
-// the objects in `data` to be serializable, and we need a real reference to the
-// `instanceID` symbol to test.
-
-createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "42");
-
-function promiseInstallPostponed(addonID1, addonID2) {
- return new Promise((resolve, reject) => {
- let seen = [];
- let listener = {
- onInstallFailed: () => {
- AddonManager.removeInstallListener(listener);
- reject("extension installation should not have failed");
- },
- onInstallEnded: (install) => {
- AddonManager.removeInstallListener(listener);
- reject(`extension installation should not have ended for ${install.addon.id}`);
- },
- onInstallPostponed: (install) => {
- seen.push(install.addon.id);
- if (seen.includes(addonID1) && seen.includes(addonID2)) {
- AddonManager.removeInstallListener(listener);
- resolve();
- }
- }
- };
-
- AddonManager.addInstallListener(listener);
- });
-}
-
-function promiseInstallResumed(addonID1, addonID2) {
- return new Promise((resolve, reject) => {
- let seenPostponed = [];
- let seenEnded = [];
- let listener = {
- onInstallFailed: () => {
- AddonManager.removeInstallListener(listener);
- reject("extension installation should not have failed");
- },
- onInstallEnded: (install) => {
- seenEnded.push(install.addon.id);
- if ((seenEnded.includes(addonID1) && seenEnded.includes(addonID2)) &&
- (seenPostponed.includes(addonID1) && seenPostponed.includes(addonID2))) {
- AddonManager.removeInstallListener(listener);
- resolve();
- }
- },
- onInstallPostponed: (install) => {
- seenPostponed.push(install.addon.id);
- }
- };
-
- AddonManager.addInstallListener(listener);
- });
-}
-
-function promiseInstallDeferred(addonID1, addonID2) {
- return new Promise((resolve, reject) => {
- let seenEnded = [];
- let listener = {
- onInstallFailed: () => {
- AddonManager.removeInstallListener(listener);
- reject("extension installation should not have failed");
- },
- onInstallEnded: (install) => {
- seenEnded.push(install.addon.id);
- if (seenEnded.includes(addonID1) && seenEnded.includes(addonID2)) {
- AddonManager.removeInstallListener(listener);
- resolve();
- }
- },
- onInstallPostponed: (install) => {
- AddonManager.removeInstallListener(listener);
- reject(`extension installation should not have been postponed for ${install.addon.id}`);
- }
- };
-
- AddonManager.addInstallListener(listener);
- });
-}
-
-
-// add-on registers upgrade listener, and ignores update.
-add_task(function*() {
- // discard system addon updates
- Services.prefs.setCharPref(PREF_SYSTEM_ADDON_SET, "");
-
- do_get_file("data/system_addons/system_delay_ignore.xpi").copyTo(distroDir, "system_delay_ignore@tests.mozilla.org.xpi");
- do_get_file("data/system_addons/system1_1.xpi").copyTo(distroDir, "system1@tests.mozilla.org.xpi");
-
- startupManager();
- let updateList = [
- { id: IGNORE_ID, version: "2.0", path: "system_delay_ignore_2.xpi" },
- { id: NORMAL_ID, version: "2.0", path: "system1_2.xpi" },
- ];
-
- let postponed = promiseInstallPostponed(IGNORE_ID, NORMAL_ID);
- yield installSystemAddons(yield buildSystemAddonUpdates(updateList, root), testserver);
- yield postponed;
-
- // addon upgrade has been delayed.
- let addon_postponed = yield promiseAddonByID(IGNORE_ID, NORMAL_ID);
- do_check_neq(addon_postponed, null);
- do_check_eq(addon_postponed.version, "1.0");
- do_check_eq(addon_postponed.name, "System Test Delay Update Ignore");
- do_check_true(addon_postponed.isCompatible);
- do_check_false(addon_postponed.appDisabled);
- do_check_true(addon_postponed.isActive);
- do_check_eq(addon_postponed.type, "extension");
- do_check_true(Services.prefs.getBoolPref(TEST_IGNORE_PREF));
-
- // other addons in the set are delayed as well.
- addon_postponed = yield promiseAddonByID(NORMAL_ID);
- do_check_neq(addon_postponed, null);
- do_check_eq(addon_postponed.version, "1.0");
- do_check_eq(addon_postponed.name, "System Add-on 1");
- do_check_true(addon_postponed.isCompatible);
- do_check_false(addon_postponed.appDisabled);
- do_check_true(addon_postponed.isActive);
- do_check_eq(addon_postponed.type, "extension");
-
- // restarting allows upgrades to proceed
- yield promiseRestartManager();
-
- let addon_upgraded = yield promiseAddonByID(IGNORE_ID);
- do_check_neq(addon_upgraded, null);
- do_check_eq(addon_upgraded.version, "2.0");
- do_check_eq(addon_upgraded.name, "System Test Delay Update Ignore");
- do_check_true(addon_upgraded.isCompatible);
- do_check_false(addon_upgraded.appDisabled);
- do_check_true(addon_upgraded.isActive);
- do_check_eq(addon_upgraded.type, "extension");
-
- addon_upgraded = yield promiseAddonByID(NORMAL_ID);
- do_check_neq(addon_upgraded, null);
- do_check_eq(addon_upgraded.version, "2.0");
- do_check_eq(addon_upgraded.name, "System Add-on 1");
- do_check_true(addon_upgraded.isCompatible);
- do_check_false(addon_upgraded.appDisabled);
- do_check_true(addon_upgraded.isActive);
- do_check_eq(addon_upgraded.type, "extension");
-
- yield shutdownManager();
-});
-
-// add-on registers upgrade listener, and allows update.
-add_task(function*() {
- // discard system addon updates
- Services.prefs.setCharPref(PREF_SYSTEM_ADDON_SET, "");
-
- do_get_file("data/system_addons/system_delay_complete.xpi").copyTo(distroDir, "system_delay_complete@tests.mozilla.org.xpi");
- do_get_file("data/system_addons/system1_1.xpi").copyTo(distroDir, "system1@tests.mozilla.org.xpi");
-
- startupManager();
-
- let updateList = [
- { id: COMPLETE_ID, version: "2.0", path: "system_delay_complete_2.xpi" },
- { id: NORMAL_ID, version: "2.0", path: "system1_2.xpi" },
- ];
-
- // initial state
- let addon_allowed = yield promiseAddonByID(COMPLETE_ID);
- do_check_neq(addon_allowed, null);
- do_check_eq(addon_allowed.version, "1.0");
- do_check_eq(addon_allowed.name, "System Test Delay Update Complete");
- do_check_true(addon_allowed.isCompatible);
- do_check_false(addon_allowed.appDisabled);
- do_check_true(addon_allowed.isActive);
- do_check_eq(addon_allowed.type, "extension");
-
- addon_allowed = yield promiseAddonByID(NORMAL_ID);
- do_check_neq(addon_allowed, null);
- do_check_eq(addon_allowed.version, "1.0");
- do_check_eq(addon_allowed.name, "System Add-on 1");
- do_check_true(addon_allowed.isCompatible);
- do_check_false(addon_allowed.appDisabled);
- do_check_true(addon_allowed.isActive);
- do_check_eq(addon_allowed.type, "extension");
-
- let resumed = promiseInstallResumed(COMPLETE_ID, NORMAL_ID);
- yield installSystemAddons(yield buildSystemAddonUpdates(updateList, root), testserver);
-
- // update is initially postponed, then resumed
- yield resumed;
-
- // addon upgrade has been allowed
- addon_allowed = yield promiseAddonByID(COMPLETE_ID);
- do_check_neq(addon_allowed, null);
- do_check_eq(addon_allowed.version, "2.0");
- do_check_eq(addon_allowed.name, "System Test Delay Update Complete");
- do_check_true(addon_allowed.isCompatible);
- do_check_false(addon_allowed.appDisabled);
- do_check_true(addon_allowed.isActive);
- do_check_eq(addon_allowed.type, "extension");
-
- // other upgrades in the set are allowed as well
- addon_allowed = yield promiseAddonByID(NORMAL_ID);
- do_check_neq(addon_allowed, null);
- do_check_eq(addon_allowed.version, "2.0");
- do_check_eq(addon_allowed.name, "System Add-on 1");
- do_check_true(addon_allowed.isCompatible);
- do_check_false(addon_allowed.appDisabled);
- do_check_true(addon_allowed.isActive);
- do_check_eq(addon_allowed.type, "extension");
-
- // restarting changes nothing
- yield promiseRestartManager();
-
- let addon_upgraded = yield promiseAddonByID(COMPLETE_ID);
- do_check_neq(addon_upgraded, null);
- do_check_eq(addon_upgraded.version, "2.0");
- do_check_eq(addon_upgraded.name, "System Test Delay Update Complete");
- do_check_true(addon_upgraded.isCompatible);
- do_check_false(addon_upgraded.appDisabled);
- do_check_true(addon_upgraded.isActive);
- do_check_eq(addon_upgraded.type, "extension");
-
- addon_upgraded = yield promiseAddonByID(NORMAL_ID);
- do_check_neq(addon_upgraded, null);
- do_check_eq(addon_upgraded.version, "2.0");
- do_check_eq(addon_upgraded.name, "System Add-on 1");
- do_check_true(addon_upgraded.isCompatible);
- do_check_false(addon_upgraded.appDisabled);
- do_check_true(addon_upgraded.isActive);
- do_check_eq(addon_upgraded.type, "extension");
-
- yield shutdownManager();
-});
-
-// add-on registers upgrade listener, initially defers update then allows upgrade
-add_task(function*() {
- // discard system addon updates
- Services.prefs.setCharPref(PREF_SYSTEM_ADDON_SET, "");
-
- do_get_file("data/system_addons/system_delay_defer.xpi").copyTo(distroDir, "system_delay_defer@tests.mozilla.org.xpi");
- do_get_file("data/system_addons/system1_1.xpi").copyTo(distroDir, "system1@tests.mozilla.org.xpi");
-
- startupManager();
-
- let updateList = [
- { id: DEFER_ID, version: "2.0", path: "system_delay_defer_2.xpi" },
- { id: NORMAL_ID, version: "2.0", path: "system1_2.xpi" },
- ];
-
- let postponed = promiseInstallPostponed(DEFER_ID, NORMAL_ID);
- yield installSystemAddons(yield buildSystemAddonUpdates(updateList, root), testserver);
- yield postponed;
-
- // upgrade is initially postponed
- let addon_postponed = yield promiseAddonByID(DEFER_ID);
- do_check_neq(addon_postponed, null);
- do_check_eq(addon_postponed.version, "1.0");
- do_check_eq(addon_postponed.name, "System Test Delay Update Defer");
- do_check_true(addon_postponed.isCompatible);
- do_check_false(addon_postponed.appDisabled);
- do_check_true(addon_postponed.isActive);
- do_check_eq(addon_postponed.type, "extension");
-
- // other addons in the set are postponed as well.
- addon_postponed = yield promiseAddonByID(NORMAL_ID);
- do_check_neq(addon_postponed, null);
- do_check_eq(addon_postponed.version, "1.0");
- do_check_eq(addon_postponed.name, "System Add-on 1");
- do_check_true(addon_postponed.isCompatible);
- do_check_false(addon_postponed.appDisabled);
- do_check_true(addon_postponed.isActive);
- do_check_eq(addon_postponed.type, "extension");
-
- let deferred = promiseInstallDeferred(DEFER_ID, NORMAL_ID);
- // add-on will not allow upgrade until fake event fires
- AddonManagerPrivate.callAddonListeners("onFakeEvent");
-
- yield deferred;
-
- // addon upgrade has been allowed
- let addon_allowed = yield promiseAddonByID(DEFER_ID);
- do_check_neq(addon_allowed, null);
- do_check_eq(addon_allowed.version, "2.0");
- do_check_eq(addon_allowed.name, "System Test Delay Update Defer");
- do_check_true(addon_allowed.isCompatible);
- do_check_false(addon_allowed.appDisabled);
- do_check_true(addon_allowed.isActive);
- do_check_eq(addon_allowed.type, "extension");
-
- // other addons in the set are allowed as well.
- addon_allowed = yield promiseAddonByID(NORMAL_ID);
- do_check_neq(addon_allowed, null);
- do_check_eq(addon_allowed.version, "2.0");
- do_check_eq(addon_allowed.name, "System Add-on 1");
- do_check_true(addon_allowed.isCompatible);
- do_check_false(addon_allowed.appDisabled);
- do_check_true(addon_allowed.isActive);
- do_check_eq(addon_allowed.type, "extension");
-
- // restarting changes nothing
- yield promiseRestartManager();
-
- let addon_upgraded = yield promiseAddonByID(DEFER_ID);
- do_check_neq(addon_upgraded, null);
- do_check_eq(addon_upgraded.version, "2.0");
- do_check_eq(addon_upgraded.name, "System Test Delay Update Defer");
- do_check_true(addon_upgraded.isCompatible);
- do_check_false(addon_upgraded.appDisabled);
- do_check_true(addon_upgraded.isActive);
- do_check_eq(addon_upgraded.type, "extension");
-
- addon_upgraded = yield promiseAddonByID(NORMAL_ID);
- do_check_neq(addon_upgraded, null);
- do_check_eq(addon_upgraded.version, "2.0");
- do_check_eq(addon_upgraded.name, "System Add-on 1");
- do_check_true(addon_upgraded.isCompatible);
- do_check_false(addon_upgraded.appDisabled);
- do_check_true(addon_upgraded.isActive);
- do_check_eq(addon_upgraded.type, "extension");
-
- yield shutdownManager();
-});
-
-// multiple add-ons registers upgrade listeners, initially defers then each unblock in turn.
-add_task(function*() {
- // discard system addon updates.
- Services.prefs.setCharPref(PREF_SYSTEM_ADDON_SET, "");
-
- do_get_file("data/system_addons/system_delay_defer.xpi").copyTo(distroDir, "system_delay_defer@tests.mozilla.org.xpi");
- do_get_file("data/system_addons/system_delay_defer_also.xpi").copyTo(distroDir, "system_delay_defer_also@tests.mozilla.org.xpi");
-
- startupManager();
-
- let updateList = [
- { id: DEFER_ID, version: "2.0", path: "system_delay_defer_2.xpi" },
- { id: DEFER_ALSO_ID, version: "2.0", path: "system_delay_defer_also_2.xpi" },
- ];
-
- let postponed = promiseInstallPostponed(DEFER_ID, DEFER_ALSO_ID);
- yield installSystemAddons(yield buildSystemAddonUpdates(updateList, root), testserver);
- yield postponed;
-
- // upgrade is initially postponed
- let addon_postponed = yield promiseAddonByID(DEFER_ID);
- do_check_neq(addon_postponed, null);
- do_check_eq(addon_postponed.version, "1.0");
- do_check_eq(addon_postponed.name, "System Test Delay Update Defer");
- do_check_true(addon_postponed.isCompatible);
- do_check_false(addon_postponed.appDisabled);
- do_check_true(addon_postponed.isActive);
- do_check_eq(addon_postponed.type, "extension");
-
- // other addons in the set are postponed as well.
- addon_postponed = yield promiseAddonByID(DEFER_ALSO_ID);
- do_check_neq(addon_postponed, null);
- do_check_eq(addon_postponed.version, "1.0");
- do_check_eq(addon_postponed.name, "System Test Delay Update Defer Also");
- do_check_true(addon_postponed.isCompatible);
- do_check_false(addon_postponed.appDisabled);
- do_check_true(addon_postponed.isActive);
- do_check_eq(addon_postponed.type, "extension");
-
- let deferred = promiseInstallDeferred(DEFER_ID, DEFER_ALSO_ID);
- // add-on will not allow upgrade until fake event fires
- AddonManagerPrivate.callAddonListeners("onFakeEvent");
-
- // Upgrade blockers still present.
- addon_postponed = yield promiseAddonByID(DEFER_ID);
- do_check_neq(addon_postponed, null);
- do_check_eq(addon_postponed.version, "1.0");
- do_check_eq(addon_postponed.name, "System Test Delay Update Defer");
- do_check_true(addon_postponed.isCompatible);
- do_check_false(addon_postponed.appDisabled);
- do_check_true(addon_postponed.isActive);
- do_check_eq(addon_postponed.type, "extension");
-
- addon_postponed = yield promiseAddonByID(DEFER_ALSO_ID);
- do_check_neq(addon_postponed, null);
- do_check_eq(addon_postponed.version, "1.0");
- do_check_eq(addon_postponed.name, "System Test Delay Update Defer Also");
- do_check_true(addon_postponed.isCompatible);
- do_check_false(addon_postponed.appDisabled);
- do_check_true(addon_postponed.isActive);
- do_check_eq(addon_postponed.type, "extension");
-
- AddonManagerPrivate.callAddonListeners("onOtherFakeEvent");
-
- yield deferred;
-
- // addon upgrade has been allowed
- let addon_allowed = yield promiseAddonByID(DEFER_ID);
- do_check_neq(addon_allowed, null);
- do_check_eq(addon_allowed.version, "2.0");
- do_check_eq(addon_allowed.name, "System Test Delay Update Defer");
- do_check_true(addon_allowed.isCompatible);
- do_check_false(addon_allowed.appDisabled);
- do_check_true(addon_allowed.isActive);
- do_check_eq(addon_allowed.type, "extension");
-
- // other addons in the set are allowed as well.
- addon_allowed = yield promiseAddonByID(DEFER_ALSO_ID);
- do_check_neq(addon_allowed, null);
- // do_check_eq(addon_allowed.version, "2.0");
- do_check_eq(addon_allowed.name, "System Test Delay Update Defer Also");
- do_check_true(addon_allowed.isCompatible);
- do_check_false(addon_allowed.appDisabled);
- do_check_true(addon_allowed.isActive);
- do_check_eq(addon_allowed.type, "extension");
-
- // restarting changes nothing
- yield promiseRestartManager();
-
- let addon_upgraded = yield promiseAddonByID(DEFER_ID);
- do_check_neq(addon_upgraded, null);
- do_check_eq(addon_upgraded.version, "2.0");
- do_check_eq(addon_upgraded.name, "System Test Delay Update Defer");
- do_check_true(addon_upgraded.isCompatible);
- do_check_false(addon_upgraded.appDisabled);
- do_check_true(addon_upgraded.isActive);
- do_check_eq(addon_upgraded.type, "extension");
-
- addon_upgraded = yield promiseAddonByID(DEFER_ALSO_ID);
- do_check_neq(addon_upgraded, null);
- do_check_eq(addon_upgraded.version, "2.0");
- do_check_eq(addon_upgraded.name, "System Test Delay Update Defer Also");
- do_check_true(addon_upgraded.isCompatible);
- do_check_false(addon_upgraded.appDisabled);
- do_check_true(addon_upgraded.isActive);
- do_check_eq(addon_upgraded.type, "extension");
-
- yield shutdownManager();
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_system_reset.js b/toolkit/mozapps/extensions/test/xpcshell/test_system_reset.js
deleted file mode 100644
index 31b7e5783..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_system_reset.js
+++ /dev/null
@@ -1,418 +0,0 @@
-// Tests that we reset to the default system add-ons correctly when switching
-// application versions
-const PREF_SYSTEM_ADDON_SET = "extensions.systemAddonSet";
-
-BootstrapMonitor.init();
-
-const updatesDir = FileUtils.getDir("ProfD", ["features"]);
-
-// Build the test sets
-var dir = FileUtils.getDir("ProfD", ["sysfeatures", "app1"], true);
-do_get_file("data/system_addons/system1_1.xpi").copyTo(dir, "system1@tests.mozilla.org.xpi");
-do_get_file("data/system_addons/system2_1.xpi").copyTo(dir, "system2@tests.mozilla.org.xpi");
-
-dir = FileUtils.getDir("ProfD", ["sysfeatures", "app2"], true);
-do_get_file("data/system_addons/system1_2.xpi").copyTo(dir, "system1@tests.mozilla.org.xpi");
-do_get_file("data/system_addons/system3_1.xpi").copyTo(dir, "system3@tests.mozilla.org.xpi");
-
-dir = FileUtils.getDir("ProfD", ["sysfeatures", "app3"], true);
-do_get_file("data/system_addons/system1_1_badcert.xpi").copyTo(dir, "system1@tests.mozilla.org.xpi");
-do_get_file("data/system_addons/system3_1.xpi").copyTo(dir, "system3@tests.mozilla.org.xpi");
-
-const distroDir = FileUtils.getDir("ProfD", ["sysfeatures", "app0"], true);
-registerDirectory("XREAppFeat", distroDir);
-
-createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "0");
-
-function makeUUID() {
- let uuidGen = AM_Cc["@mozilla.org/uuid-generator;1"].
- getService(AM_Ci.nsIUUIDGenerator);
- return uuidGen.generateUUID().toString();
-}
-
-function* check_installed(conditions) {
- for (let i = 0; i < conditions.length; i++) {
- let condition = conditions[i];
- let id = "system" + (i + 1) + "@tests.mozilla.org";
- let addon = yield promiseAddonByID(id);
-
- if (!("isUpgrade" in condition) || !("version" in condition)) {
- throw Error("condition must contain isUpgrade and version");
- }
- let isUpgrade = conditions[i].isUpgrade;
- let version = conditions[i].version;
-
- let expectedDir = isUpgrade ? updatesDir : distroDir;
-
- if (version) {
- // Add-on should be installed
- do_check_neq(addon, null);
- do_check_eq(addon.version, version);
- do_check_true(addon.isActive);
- do_check_false(addon.foreignInstall);
- do_check_true(addon.hidden);
- do_check_true(addon.isSystem);
- do_check_false(hasFlag(addon.permissions, AddonManager.PERM_CAN_UPGRADE));
- if (isUpgrade) {
- do_check_true(hasFlag(addon.permissions, AddonManager.PERM_CAN_UNINSTALL));
- } else {
- do_check_false(hasFlag(addon.permissions, AddonManager.PERM_CAN_UNINSTALL));
- }
-
- // Verify the add-ons file is in the right place
- let file = expectedDir.clone();
- file.append(id + ".xpi");
- do_check_true(file.exists());
- do_check_true(file.isFile());
-
- let uri = addon.getResourceURI(null);
- do_check_true(uri instanceof AM_Ci.nsIFileURL);
- do_check_eq(uri.file.path, file.path);
-
- if (isUpgrade) {
- do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_SYSTEM);
- }
-
- // Verify the add-on actually started
- BootstrapMonitor.checkAddonStarted(id, version);
- }
- else {
- if (isUpgrade) {
- // Add-on should not be installed
- do_check_eq(addon, null);
- }
- else {
- // Either add-on should not be installed or it shouldn't be active
- do_check_true(!addon || !addon.isActive);
- }
-
- BootstrapMonitor.checkAddonNotStarted(id);
-
- if (addon)
- BootstrapMonitor.checkAddonInstalled(id);
- else
- BootstrapMonitor.checkAddonNotInstalled(id);
- }
- }
-}
-
-// Test with a missing features directory
-add_task(function* test_missing_app_dir() {
- startupManager();
-
- let conditions = [
- { isUpgrade: false, version: null },
- { isUpgrade: false, version: null },
- { isUpgrade: false, version: null },
- ];
-
- yield check_installed(conditions);
-
- do_check_false(updatesDir.exists());
-
- yield promiseShutdownManager();
-});
-
-// Add some features in a new version
-add_task(function* test_new_version() {
- gAppInfo.version = "1";
- distroDir.leafName = "app1";
- startupManager();
-
- let conditions = [
- { isUpgrade: false, version: "1.0" },
- { isUpgrade: false, version: "1.0" },
- { isUpgrade: false, version: null },
- ];
-
- yield check_installed(conditions);
-
- do_check_false(updatesDir.exists());
-
- yield promiseShutdownManager();
-});
-
-// Another new version swaps one feature and upgrades another
-add_task(function* test_upgrade() {
- gAppInfo.version = "2";
- distroDir.leafName = "app2";
- startupManager();
-
- let conditions = [
- { isUpgrade: false, version: "2.0" },
- { isUpgrade: false, version: null },
- { isUpgrade: false, version: "1.0" },
- ];
-
- yield check_installed(conditions);
-
- do_check_false(updatesDir.exists());
-
- yield promiseShutdownManager();
-});
-
-// Downgrade
-add_task(function* test_downgrade() {
- gAppInfo.version = "1";
- distroDir.leafName = "app1";
- startupManager();
-
- let conditions = [
- { isUpgrade: false, version: "1.0" },
- { isUpgrade: false, version: "1.0" },
- { isUpgrade: false, version: null },
- ];
-
- yield check_installed(conditions);
-
- do_check_false(updatesDir.exists());
-
- yield promiseShutdownManager();
-});
-
-// Fake a mid-cycle install
-add_task(function* test_updated() {
- // Create a random dir to install into
- let dirname = makeUUID();
- FileUtils.getDir("ProfD", ["features", dirname], true);
- updatesDir.append(dirname);
-
- // Copy in the system add-ons
- let file = do_get_file("data/system_addons/system2_2.xpi");
- file.copyTo(updatesDir, "system2@tests.mozilla.org.xpi");
- file = do_get_file("data/system_addons/system3_2.xpi");
- file.copyTo(updatesDir, "system3@tests.mozilla.org.xpi");
-
- // Inject it into the system set
- let addonSet = {
- schema: 1,
- directory: updatesDir.leafName,
- addons: {
- "system2@tests.mozilla.org": {
- version: "2.0"
- },
- "system3@tests.mozilla.org": {
- version: "2.0"
- },
- }
- };
- Services.prefs.setCharPref(PREF_SYSTEM_ADDON_SET, JSON.stringify(addonSet));
-
- startupManager(false);
-
- let conditions = [
- { isUpgrade: false, version: "1.0" },
- { isUpgrade: true, version: "2.0" },
- { isUpgrade: true, version: "2.0" },
- ];
-
- yield check_installed(conditions);
-
- yield promiseShutdownManager();
-});
-
-// Entering safe mode should disable the updated system add-ons and use the
-// default system add-ons
-add_task(function* safe_mode_disabled() {
- gAppInfo.inSafeMode = true;
- startupManager(false);
-
- let conditions = [
- { isUpgrade: false, version: "1.0" },
- { isUpgrade: false, version: "1.0" },
- { isUpgrade: false, version: null },
- ];
-
- yield check_installed(conditions);
-
- yield promiseShutdownManager();
-});
-
-// Leaving safe mode should re-enable the updated system add-ons
-add_task(function* normal_mode_enabled() {
- gAppInfo.inSafeMode = false;
- startupManager(false);
-
- let conditions = [
- { isUpgrade: false, version: "1.0" },
- { isUpgrade: true, version: "2.0" },
- { isUpgrade: true, version: "2.0" },
- ];
-
- yield check_installed(conditions);
-
- yield promiseShutdownManager();
-});
-
-// An additional add-on in the directory should be ignored
-add_task(function* test_skips_additional() {
- // Copy in the system add-ons
- let file = do_get_file("data/system_addons/system4_1.xpi");
- file.copyTo(updatesDir, "system4@tests.mozilla.org.xpi");
-
- startupManager(false);
-
- let conditions = [
- { isUpgrade: false, version: "1.0" },
- { isUpgrade: true, version: "2.0" },
- { isUpgrade: true, version: "2.0" },
- ];
-
- yield check_installed(conditions);
-
- yield promiseShutdownManager();
-});
-
-// Missing add-on should revert to the default set
-add_task(function* test_revert() {
- manuallyUninstall(updatesDir, "system2@tests.mozilla.org");
-
- // With the add-on physically gone from disk we won't see uninstall events
- BootstrapMonitor.clear("system2@tests.mozilla.org");
-
- startupManager(false);
-
- // With system add-on 2 gone the updated set is now invalid so it reverts to
- // the default set which is system add-ons 1 and 2.
- let conditions = [
- { isUpgrade: false, version: "1.0" },
- { isUpgrade: false, version: "1.0" },
- { isUpgrade: false, version: null },
- ];
-
- yield check_installed(conditions);
-
- yield promiseShutdownManager();
-});
-
-// Putting it back will make the set work again
-add_task(function* test_reuse() {
- let file = do_get_file("data/system_addons/system2_2.xpi");
- file.copyTo(updatesDir, "system2@tests.mozilla.org.xpi");
-
- startupManager(false);
-
- let conditions = [
- { isUpgrade: false, version: "1.0" },
- { isUpgrade: true, version: "2.0" },
- { isUpgrade: true, version: "2.0" },
- ];
-
- yield check_installed(conditions);
-
- yield promiseShutdownManager();
-});
-
-// Making the pref corrupt should revert to the default set
-add_task(function* test_corrupt_pref() {
- Services.prefs.setCharPref(PREF_SYSTEM_ADDON_SET, "foo");
-
- startupManager(false);
-
- let conditions = [
- { isUpgrade: false, version: "1.0" },
- { isUpgrade: false, version: "1.0" },
- { isUpgrade: false, version: null },
- ];
-
- yield check_installed(conditions);
-
- yield promiseShutdownManager();
-});
-
-// An add-on with a bad certificate should cause us to use the default set
-add_task(function* test_bad_profile_cert() {
- let file = do_get_file("data/system_addons/system1_1_badcert.xpi");
- file.copyTo(updatesDir, "system1@tests.mozilla.org.xpi");
-
- // Inject it into the system set
- let addonSet = {
- schema: 1,
- directory: updatesDir.leafName,
- addons: {
- "system1@tests.mozilla.org": {
- version: "2.0"
- },
- "system2@tests.mozilla.org": {
- version: "1.0"
- },
- "system3@tests.mozilla.org": {
- version: "1.0"
- },
- }
- };
- Services.prefs.setCharPref(PREF_SYSTEM_ADDON_SET, JSON.stringify(addonSet));
-
- startupManager(false);
-
- let conditions = [
- { isUpgrade: false, version: "1.0" },
- { isUpgrade: false, version: "1.0" },
- { isUpgrade: false, version: null },
- ];
-
- yield check_installed(conditions);
-
- yield promiseShutdownManager();
-});
-
-// Switching to app defaults that contain a bad certificate should still work
-add_task(function* test_bad_app_cert() {
- gAppInfo.version = "3";
- distroDir.leafName = "app3";
- startupManager();
-
- // Add-on will still be present
- let addon = yield promiseAddonByID("system1@tests.mozilla.org");
- do_check_neq(addon, null);
- do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_NOT_REQUIRED);
-
- let conditions = [
- { isUpgrade: false, version: "1.0" },
- { isUpgrade: false, version: null },
- { isUpgrade: false, version: "1.0" },
- ];
-
- yield check_installed(conditions);
-
- yield promiseShutdownManager();
-});
-
-// A failed upgrade should revert to the default set.
-add_task(function* test_updated() {
- // Create a random dir to install into
- let dirname = makeUUID();
- FileUtils.getDir("ProfD", ["features", dirname], true);
- updatesDir.append(dirname);
-
- // Copy in the system add-ons
- let file = do_get_file("data/system_addons/system2_2.xpi");
- file.copyTo(updatesDir, "system2@tests.mozilla.org.xpi");
- file = do_get_file("data/system_addons/system_failed_update.xpi");
- file.copyTo(updatesDir, "system_failed_update@tests.mozilla.org.xpi");
-
- // Inject it into the system set
- let addonSet = {
- schema: 1,
- directory: updatesDir.leafName,
- addons: {
- "system2@tests.mozilla.org": {
- version: "2.0"
- },
- "system_failed_update@tests.mozilla.org": {
- version: "1.0"
- },
- }
- };
- Services.prefs.setCharPref(PREF_SYSTEM_ADDON_SET, JSON.stringify(addonSet));
-
- startupManager(false);
-
- let conditions = [
- { isUpgrade: false, version: "1.0" },
- ];
-
- yield check_installed(conditions);
-
- yield promiseShutdownManager();
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_system_update.js b/toolkit/mozapps/extensions/test/xpcshell/test_system_update.js
deleted file mode 100644
index c8e314427..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_system_update.js
+++ /dev/null
@@ -1,788 +0,0 @@
-// Tests that we reset to the default system add-ons correctly when switching
-// application versions
-const PREF_SYSTEM_ADDON_SET = "extensions.systemAddonSet";
-const PREF_SYSTEM_ADDON_UPDATE_URL = "extensions.systemAddon.update.url";
-const PREF_XPI_STATE = "extensions.xpiState";
-const PREF_APP_UPDATE_ENABLED = "app.update.enabled";
-
-Components.utils.import("resource://testing-common/httpd.js");
-const { computeHash } = Components.utils.import("resource://gre/modules/addons/ProductAddonChecker.jsm");
-
-BootstrapMonitor.init();
-
-const updatesDir = FileUtils.getDir("ProfD", ["features"], false);
-
-function getCurrentUpdatesDir() {
- let dir = updatesDir.clone();
- let set = JSON.parse(Services.prefs.getCharPref(PREF_SYSTEM_ADDON_SET));
- dir.append(set.directory);
- return dir;
-}
-
-function clearUpdatesDir() {
- // Delete any existing directories
- if (updatesDir.exists())
- updatesDir.remove(true);
-
- Services.prefs.clearUserPref(PREF_SYSTEM_ADDON_SET);
-}
-
-function buildPrefilledUpdatesDir() {
- clearUpdatesDir();
-
- // Build the test set
- let dir = FileUtils.getDir("ProfD", ["features", "prefilled"], true);
-
- do_get_file("data/system_addons/system2_2.xpi").copyTo(dir, "system2@tests.mozilla.org.xpi");
- do_get_file("data/system_addons/system3_2.xpi").copyTo(dir, "system3@tests.mozilla.org.xpi");
-
- // Mark these in the past so the startup file scan notices when files have changed properly
- FileUtils.getFile("ProfD", ["features", "prefilled", "system2@tests.mozilla.org.xpi"]).lastModifiedTime -= 10000;
- FileUtils.getFile("ProfD", ["features", "prefilled", "system3@tests.mozilla.org.xpi"]).lastModifiedTime -= 10000;
-
- Services.prefs.setCharPref(PREF_SYSTEM_ADDON_SET, JSON.stringify({
- schema: 1,
- directory: dir.leafName,
- addons: {
- "system2@tests.mozilla.org": {
- version: "2.0"
- },
- "system3@tests.mozilla.org": {
- version: "2.0"
- },
- }
- }));
-}
-
-let dir = FileUtils.getDir("ProfD", ["sysfeatures", "hidden"], true);
-do_get_file("data/system_addons/system1_1.xpi").copyTo(dir, "system1@tests.mozilla.org.xpi");
-do_get_file("data/system_addons/system2_1.xpi").copyTo(dir, "system2@tests.mozilla.org.xpi");
-
-dir = FileUtils.getDir("ProfD", ["sysfeatures", "prefilled"], true);
-do_get_file("data/system_addons/system2_2.xpi").copyTo(dir, "system2@tests.mozilla.org.xpi");
-do_get_file("data/system_addons/system3_2.xpi").copyTo(dir, "system3@tests.mozilla.org.xpi");
-
-const distroDir = FileUtils.getDir("ProfD", ["sysfeatures", "empty"], true);
-registerDirectory("XREAppFeat", distroDir);
-
-createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2");
-
-var testserver = new HttpServer();
-testserver.registerDirectory("/data/", do_get_file("data/system_addons"));
-testserver.start();
-var root = testserver.identity.primaryScheme + "://" +
- testserver.identity.primaryHost + ":" +
- testserver.identity.primaryPort + "/data/"
-Services.prefs.setCharPref(PREF_SYSTEM_ADDON_UPDATE_URL, root + "update.xml");
-
-function makeUUID() {
- let uuidGen = AM_Cc["@mozilla.org/uuid-generator;1"].
- getService(AM_Ci.nsIUUIDGenerator);
- return uuidGen.generateUUID().toString();
-}
-
-function* check_installed(conditions) {
- for (let i = 0; i < conditions.length; i++) {
- let condition = conditions[i];
- let id = "system" + (i + 1) + "@tests.mozilla.org";
- let addon = yield promiseAddonByID(id);
-
- if (!("isUpgrade" in condition) || !("version" in condition)) {
- throw Error("condition must contain isUpgrade and version");
- }
- let isUpgrade = conditions[i].isUpgrade;
- let version = conditions[i].version;
-
- let expectedDir = isUpgrade ? getCurrentUpdatesDir() : distroDir;
-
- if (version) {
- do_print(`Checking state of add-on ${id}, expecting version ${version}`);
-
- // Add-on should be installed
- do_check_neq(addon, null);
- do_check_eq(addon.version, version);
- do_check_true(addon.isActive);
- do_check_false(addon.foreignInstall);
- do_check_true(addon.hidden);
- do_check_true(addon.isSystem);
-
- // Verify the add-ons file is in the right place
- let file = expectedDir.clone();
- file.append(id + ".xpi");
- do_check_true(file.exists());
- do_check_true(file.isFile());
-
- let uri = addon.getResourceURI(null);
- do_check_true(uri instanceof AM_Ci.nsIFileURL);
- do_check_eq(uri.file.path, file.path);
-
- if (isUpgrade) {
- do_check_eq(addon.signedState, AddonManager.SIGNEDSTATE_SYSTEM);
- }
-
- // Verify the add-on actually started
- BootstrapMonitor.checkAddonStarted(id, version);
- }
- else {
- do_print(`Checking state of add-on ${id}, expecting it to be missing`);
-
- if (isUpgrade) {
- // Add-on should not be installed
- do_check_eq(addon, null);
- }
-
- BootstrapMonitor.checkAddonNotStarted(id);
-
- if (addon)
- BootstrapMonitor.checkAddonInstalled(id);
- else
- BootstrapMonitor.checkAddonNotInstalled(id);
- }
- }
-}
-
-
-/**
- * Defines the set of initial conditions to run each test against. Each should
- * define the following properties:
- *
- * setup: A task to setup the profile into the initial state.
- * initialState: The initial expected system add-on state after setup has run.
- */
-const TEST_CONDITIONS = {
- // Runs tests with no updated or default system add-ons initially installed
- blank: {
- setup: function*() {
- clearUpdatesDir();
- distroDir.leafName = "empty";
- },
- initialState: [
- { isUpgrade: false, version: null},
- { isUpgrade: false, version: null},
- { isUpgrade: false, version: null},
- { isUpgrade: false, version: null},
- { isUpgrade: false, version: null}
- ],
- },
- // Runs tests with default system add-ons installed
- withAppSet: {
- setup: function*() {
- clearUpdatesDir();
- distroDir.leafName = "prefilled";
- },
- initialState: [
- { isUpgrade: false, version: null},
- { isUpgrade: false, version: "2.0"},
- { isUpgrade: false, version: "2.0"},
- { isUpgrade: false, version: null},
- { isUpgrade: false, version: null}
- ]
- },
-
- // Runs tests with updated system add-ons installed
- withProfileSet: {
- setup: function*() {
- buildPrefilledUpdatesDir();
- distroDir.leafName = "empty";
- },
- initialState: [
- { isUpgrade: false, version: null},
- { isUpgrade: true, version: "2.0"},
- { isUpgrade: true, version: "2.0"},
- { isUpgrade: false, version: null},
- { isUpgrade: false, version: null}
- ]
- },
-
- // Runs tests with both default and updated system add-ons installed
- withBothSets: {
- setup: function*() {
- buildPrefilledUpdatesDir();
- distroDir.leafName = "hidden";
- },
- initialState: [
- { isUpgrade: false, version: "1.0"},
- { isUpgrade: true, version: "2.0"},
- { isUpgrade: true, version: "2.0"},
- { isUpgrade: false, version: null},
- { isUpgrade: false, version: null}
- ]
- },
-};
-
-
-/**
- * The tests to run. Each test must define an updateList or test. The following
- * properties are used:
- *
- * updateList: The set of add-ons the server should respond with.
- * test: A function to run to perform the update check (replaces
- * updateList)
- * fails: An optional property, if true the update check is expected to
- * fail.
- * finalState: An optional property, the expected final state of system add-ons,
- * if missing the test condition's initialState is used.
- */
-const TESTS = {
- // Test that a blank response does nothing
- blank: {
- updateList: null,
- },
-
- // Test that an empty list removes existing updates, leaving defaults.
- empty: {
- updateList: [],
- finalState: {
- blank: [
- { isUpgrade: false, version: null},
- { isUpgrade: false, version: null},
- { isUpgrade: false, version: null},
- { isUpgrade: false, version: null},
- { isUpgrade: false, version: null}
- ],
- withAppSet: [
- { isUpgrade: false, version: null},
- { isUpgrade: false, version: "2.0"},
- { isUpgrade: false, version: "2.0"},
- { isUpgrade: false, version: null},
- { isUpgrade: false, version: null}
- ],
- withProfileSet: [
- { isUpgrade: false, version: null},
- { isUpgrade: false, version: null},
- { isUpgrade: false, version: null},
- { isUpgrade: false, version: null},
- { isUpgrade: false, version: null}
- ],
- withBothSets: [
- { isUpgrade: false, version: "1.0"},
- { isUpgrade: false, version: "1.0"},
- { isUpgrade: false, version: null},
- { isUpgrade: false, version: null},
- // Set this to `true` to so `verify_state()` expects a blank profile dir
- { isUpgrade: true, version: null}
- ]
- },
- },
- // Tests that a new set of system add-ons gets installed
- newset: {
- updateList: [
- { id: "system4@tests.mozilla.org", version: "1.0", path: "system4_1.xpi" },
- { id: "system5@tests.mozilla.org", version: "1.0", path: "system5_1.xpi" }
- ],
- finalState: {
- blank: [
- { isUpgrade: false, version: null},
- { isUpgrade: false, version: null},
- { isUpgrade: false, version: null},
- { isUpgrade: true, version: "1.0"},
- { isUpgrade: true, version: "1.0"}
- ],
- withAppSet: [
- { isUpgrade: false, version: null},
- { isUpgrade: false, version: "2.0"},
- { isUpgrade: false, version: "2.0"},
- { isUpgrade: true, version: "1.0"},
- { isUpgrade: true, version: "1.0"}
- ],
- withProfileSet: [
- { isUpgrade: false, version: null},
- { isUpgrade: false, version: null},
- { isUpgrade: false, version: null},
- { isUpgrade: true, version: "1.0"},
- { isUpgrade: true, version: "1.0"}
- ],
- withBothSets: [
- { isUpgrade: false, version: "1.0"},
- { isUpgrade: false, version: "1.0"},
- { isUpgrade: false, version: null},
- { isUpgrade: true, version: "1.0"},
- { isUpgrade: true, version: "1.0"}
- ]
- }
- },
-
- // Tests that an upgraded set of system add-ons gets installed
- upgrades: {
- updateList: [
- { id: "system2@tests.mozilla.org", version: "3.0", path: "system2_3.xpi" },
- { id: "system3@tests.mozilla.org", version: "3.0", path: "system3_3.xpi" }
- ],
- finalState: {
- blank: [
- { isUpgrade: false, version: null},
- { isUpgrade: true, version: "3.0"},
- { isUpgrade: true, version: "3.0"},
- { isUpgrade: false, version: null},
- { isUpgrade: false, version: null}
- ],
- withAppSet: [
- { isUpgrade: false, version: null},
- { isUpgrade: true, version: "3.0"},
- { isUpgrade: true, version: "3.0"},
- { isUpgrade: false, version: null},
- { isUpgrade: false, version: null}
- ],
- withProfileSet: [
- { isUpgrade: false, version: null},
- { isUpgrade: true, version: "3.0"},
- { isUpgrade: true, version: "3.0"},
- { isUpgrade: false, version: null},
- { isUpgrade: false, version: null}
- ],
- withBothSets: [
- { isUpgrade: false, version: "1.0"},
- { isUpgrade: true, version: "3.0"},
- { isUpgrade: true, version: "3.0"},
- { isUpgrade: false, version: null},
- { isUpgrade: false, version: null}
- ]
- }
- },
-
- // Tests that a set of system add-ons, some new, some existing gets installed
- overlapping: {
- updateList: [
- { id: "system1@tests.mozilla.org", version: "2.0", path: "system1_2.xpi" },
- { id: "system2@tests.mozilla.org", version: "2.0", path: "system2_2.xpi" },
- { id: "system3@tests.mozilla.org", version: "3.0", path: "system3_3.xpi" },
- { id: "system4@tests.mozilla.org", version: "1.0", path: "system4_1.xpi" }
- ],
- finalState: {
- blank: [
- { isUpgrade: true, version: "2.0"},
- { isUpgrade: true, version: "2.0"},
- { isUpgrade: true, version: "3.0"},
- { isUpgrade: true, version: "1.0"},
- { isUpgrade: false, version: null}
- ],
- withAppSet: [
- { isUpgrade: true, version: "2.0"},
- { isUpgrade: true, version: "2.0"},
- { isUpgrade: true, version: "3.0"},
- { isUpgrade: true, version: "1.0"},
- { isUpgrade: false, version: null}
- ],
- withProfileSet: [
- { isUpgrade: true, version: "2.0"},
- { isUpgrade: true, version: "2.0"},
- { isUpgrade: true, version: "3.0"},
- { isUpgrade: true, version: "1.0"},
- { isUpgrade: false, version: null}
- ],
- withBothSets: [
- { isUpgrade: true, version: "2.0"},
- { isUpgrade: true, version: "2.0"},
- { isUpgrade: true, version: "3.0"},
- { isUpgrade: true, version: "1.0"},
- { isUpgrade: false, version: null}
- ]
- }
- },
-
- // Specifying an incorrect version should stop us updating anything
- badVersion: {
- fails: true,
- updateList: [
- { id: "system2@tests.mozilla.org", version: "4.0", path: "system2_3.xpi" },
- { id: "system3@tests.mozilla.org", version: "3.0", path: "system3_3.xpi" }
- ],
- },
-
- // Specifying an invalid size should stop us updating anything
- badSize: {
- fails: true,
- updateList: [
- { id: "system2@tests.mozilla.org", version: "3.0", path: "system2_3.xpi", size: 2 },
- { id: "system3@tests.mozilla.org", version: "3.0", path: "system3_3.xpi" }
- ],
- },
-
- // Specifying an incorrect hash should stop us updating anything
- badHash: {
- fails: true,
- updateList: [
- { id: "system2@tests.mozilla.org", version: "3.0", path: "system2_3.xpi" },
- { id: "system3@tests.mozilla.org", version: "3.0", path: "system3_3.xpi", hashFunction: "sha1", hashValue: "205a4c49bd513ebd30594e380c19e86bba1f83e2" }
- ],
- },
-
- // Correct sizes and hashes should work
- checkSizeHash: {
- updateList: [
- { id: "system2@tests.mozilla.org", version: "3.0", path: "system2_3.xpi", size: 4697 },
- { id: "system3@tests.mozilla.org", version: "3.0", path: "system3_3.xpi", hashFunction: "sha1", hashValue: "a4c7198d56deb315511c02937fd96c696de6cb84" },
- { id: "system5@tests.mozilla.org", version: "1.0", path: "system5_1.xpi", size: 4691, hashFunction: "sha1", hashValue: "6887b916a1a9a5338b0df4181f6187f5396861eb" }
- ],
- finalState: {
- blank: [
- { isUpgrade: false, version: null},
- { isUpgrade: true, version: "3.0"},
- { isUpgrade: true, version: "3.0"},
- { isUpgrade: false, version: null},
- { isUpgrade: true, version: "1.0"}
- ],
- withAppSet: [
- { isUpgrade: false, version: null},
- { isUpgrade: true, version: "3.0"},
- { isUpgrade: true, version: "3.0"},
- { isUpgrade: false, version: null},
- { isUpgrade: true, version: "1.0"}
- ],
- withProfileSet: [
- { isUpgrade: false, version: null},
- { isUpgrade: true, version: "3.0"},
- { isUpgrade: true, version: "3.0"},
- { isUpgrade: false, version: null},
- { isUpgrade: true, version: "1.0"}
- ],
- withBothSets: [
- { isUpgrade: false, version: "1.0"},
- { isUpgrade: true, version: "3.0"},
- { isUpgrade: true, version: "3.0"},
- { isUpgrade: false, version: null},
- { isUpgrade: true, version: "1.0"}
- ]
- }
- },
-
- // A bad certificate should stop updates
- badCert: {
- fails: true,
- updateList: [
- { id: "system1@tests.mozilla.org", version: "1.0", path: "system1_1_badcert.xpi" },
- { id: "system3@tests.mozilla.org", version: "1.0", path: "system3_1.xpi" }
- ],
- },
-
- // An unpacked add-on should stop updates.
- notPacked: {
- fails: true,
- updateList: [
- { id: "system6@tests.mozilla.org", version: "1.0", path: "system6_1_unpack.xpi" },
- { id: "system3@tests.mozilla.org", version: "1.0", path: "system3_1.xpi" }
- ],
- },
-
- // A non-bootstrap add-on should stop updates.
- notBootstrap: {
- fails: true,
- updateList: [
- { id: "system6@tests.mozilla.org", version: "1.0", path: "system6_2_notBootstrap.xpi" },
- { id: "system3@tests.mozilla.org", version: "1.0", path: "system3_1.xpi" }
- ],
- },
-
- // A non-multiprocess add-on should stop updates.
- notMultiprocess: {
- fails: true,
- updateList: [
- { id: "system6@tests.mozilla.org", version: "1.0", path: "system6_3_notMultiprocess.xpi" },
- { id: "system3@tests.mozilla.org", version: "1.0", path: "system3_1.xpi" }
- ],
- }
-}
-
-add_task(function* setup() {
- // Initialise the profile
- startupManager();
- yield promiseShutdownManager();
-})
-
-function* get_directories() {
- let subdirs = [];
-
- if (yield OS.File.exists(updatesDir.path)) {
- let iterator = new OS.File.DirectoryIterator(updatesDir.path);
- yield iterator.forEach(entry => {
- if (entry.isDir) {
- subdirs.push(entry);
- }
- });
- iterator.close();
- }
-
- return subdirs;
-}
-
-function* setup_conditions(setup) {
- do_print("Clearing existing database.");
- Services.prefs.clearUserPref(PREF_SYSTEM_ADDON_SET);
- distroDir.leafName = "empty";
- startupManager(false);
- yield promiseShutdownManager();
-
- do_print("Setting up conditions.");
- yield setup.setup();
-
- startupManager(false);
-
- // Make sure the initial state is correct
- do_print("Checking initial state.");
- yield check_installed(setup.initialState);
-}
-
-function* verify_state(initialState, finalState = undefined, alreadyUpgraded = false) {
- let expectedDirs = 0;
-
- // If the initial state was using the profile set then that directory will
- // still exist.
-
- if (initialState.some(a => a.isUpgrade)) {
- expectedDirs++;
- }
-
- if (finalState == undefined) {
- finalState = initialState;
- }
- else if (finalState.some(a => a.isUpgrade)) {
- // If the new state is using the profile then that directory will exist.
- expectedDirs++;
- }
-
- // Since upgrades are restartless now, the previous update dir hasn't been removed.
- if (alreadyUpgraded) {
- expectedDirs++;
- }
-
- do_print("Checking final state.");
-
- let dirs = yield get_directories();
- do_check_eq(dirs.length, expectedDirs);
-
- yield check_installed(...finalState);
-
- // Check that the new state is active after a restart
- yield promiseRestartManager();
- yield check_installed(finalState);
-}
-
-function* exec_test(setupName, testName) {
- let setup = TEST_CONDITIONS[setupName];
- let test = TESTS[testName];
-
- yield setup_conditions(setup);
-
- try {
- if ("test" in test) {
- yield test.test();
- }
- else {
- yield installSystemAddons(yield buildSystemAddonUpdates(test.updateList, root), testserver);
- }
-
- if (test.fails) {
- do_throw("Expected this test to fail");
- }
- }
- catch (e) {
- if (!test.fails) {
- do_throw(e);
- }
- }
-
- // some tests have a different expected combination of default
- // and updated add-ons.
- if (test.finalState && setupName in test.finalState) {
- yield verify_state(setup.initialState, test.finalState[setupName]);
- }
- else {
- yield verify_state(setup.initialState, test.finalState);
- }
-
- yield promiseShutdownManager();
-}
-
-add_task(function*() {
- for (let setup of Object.keys(TEST_CONDITIONS)) {
- for (let test of Object.keys(TESTS)) {
- do_print("Running test " + setup + " " + test);
-
- yield exec_test(setup, test);
- }
- }
-});
-
-// Some custom tests
-// Test that the update check is performed as part of the regular add-on update
-// check
-add_task(function* test_addon_update() {
- yield setup_conditions(TEST_CONDITIONS.blank);
-
- yield updateAllSystemAddons(yield buildSystemAddonUpdates([
- { id: "system2@tests.mozilla.org", version: "2.0", path: "system2_2.xpi" },
- { id: "system3@tests.mozilla.org", version: "2.0", path: "system3_2.xpi" }
- ], root), testserver);
-
- yield verify_state(TEST_CONDITIONS.blank.initialState, [
- {isUpgrade: false, version: null},
- {isUpgrade: true, version: "2.0"},
- {isUpgrade: true, version: "2.0"},
- {isUpgrade: false, version: null},
- {isUpgrade: false, version: null}
- ]);
-
- yield promiseShutdownManager();
-});
-
-// Disabling app updates should block system add-on updates
-add_task(function* test_app_update_disabled() {
- yield setup_conditions(TEST_CONDITIONS.blank);
-
- Services.prefs.setBoolPref(PREF_APP_UPDATE_ENABLED, false);
- yield updateAllSystemAddons(yield buildSystemAddonUpdates([
- { id: "system2@tests.mozilla.org", version: "2.0", path: "system2_2.xpi" },
- { id: "system3@tests.mozilla.org", version: "2.0", path: "system3_2.xpi" }
- ], root), testserver);
- Services.prefs.clearUserPref(PREF_APP_UPDATE_ENABLED);
-
- yield verify_state(TEST_CONDITIONS.blank.initialState);
-
- yield promiseShutdownManager();
-});
-
-// Safe mode should block system add-on updates
-add_task(function* test_safe_mode() {
- gAppInfo.inSafeMode = true;
-
- yield setup_conditions(TEST_CONDITIONS.blank);
-
- Services.prefs.setBoolPref(PREF_APP_UPDATE_ENABLED, false);
- yield updateAllSystemAddons(yield buildSystemAddonUpdates([
- { id: "system2@tests.mozilla.org", version: "2.0", path: "system2_2.xpi" },
- { id: "system3@tests.mozilla.org", version: "2.0", path: "system3_2.xpi" }
- ], root), testserver);
- Services.prefs.clearUserPref(PREF_APP_UPDATE_ENABLED);
-
- yield verify_state(TEST_CONDITIONS.blank.initialState);
-
- yield promiseShutdownManager();
-
- gAppInfo.inSafeMode = false;
-});
-
-// Tests that a set that matches the default set does nothing
-add_task(function* test_match_default() {
- yield setup_conditions(TEST_CONDITIONS.withAppSet);
-
- yield installSystemAddons(yield buildSystemAddonUpdates([
- { id: "system2@tests.mozilla.org", version: "2.0", path: "system2_2.xpi" },
- { id: "system3@tests.mozilla.org", version: "2.0", path: "system3_2.xpi" }
- ], root), testserver);
-
- // Shouldn't have installed an updated set
- yield verify_state(TEST_CONDITIONS.withAppSet.initialState);
-
- yield promiseShutdownManager();
-});
-
-// Tests that a set that matches the hidden default set works
-add_task(function* test_match_default_revert() {
- yield setup_conditions(TEST_CONDITIONS.withBothSets);
-
- yield installSystemAddons(yield buildSystemAddonUpdates([
- { id: "system1@tests.mozilla.org", version: "1.0", path: "system1_1.xpi" },
- { id: "system2@tests.mozilla.org", version: "1.0", path: "system2_1.xpi" }
- ], root), testserver);
-
- // This should revert to the default set instead of installing new versions
- // into an updated set.
- yield verify_state(TEST_CONDITIONS.withBothSets.initialState, [
- {isUpgrade: false, version: "1.0"},
- {isUpgrade: false, version: "1.0"},
- {isUpgrade: false, version: null},
- {isUpgrade: false, version: null},
- {isUpgrade: false, version: null}
- ]);
-
- yield promiseShutdownManager();
-});
-
-// Tests that a set that matches the current set works
-add_task(function* test_match_current() {
- yield setup_conditions(TEST_CONDITIONS.withBothSets);
-
- yield installSystemAddons(yield buildSystemAddonUpdates([
- { id: "system2@tests.mozilla.org", version: "2.0", path: "system2_2.xpi" },
- { id: "system3@tests.mozilla.org", version: "2.0", path: "system3_2.xpi" }
- ], root), testserver);
-
- // This should remain with the current set instead of creating a new copy
- let set = JSON.parse(Services.prefs.getCharPref(PREF_SYSTEM_ADDON_SET));
- do_check_eq(set.directory, "prefilled");
-
- yield verify_state(TEST_CONDITIONS.withBothSets.initialState);
-
- yield promiseShutdownManager();
-});
-
-// Tests that a set with a minor change doesn't re-download existing files
-add_task(function* test_no_download() {
- yield setup_conditions(TEST_CONDITIONS.withBothSets);
-
- // The missing file here is unneeded since there is a local version already
- yield installSystemAddons(yield buildSystemAddonUpdates([
- { id: "system2@tests.mozilla.org", version: "2.0", path: "missing.xpi" },
- { id: "system4@tests.mozilla.org", version: "1.0", path: "system4_1.xpi" }
- ], root), testserver);
-
- yield verify_state(TEST_CONDITIONS.withBothSets.initialState, [
- {isUpgrade: false, version: "1.0"},
- {isUpgrade: true, version: "2.0"},
- {isUpgrade: false, version: null},
- {isUpgrade: true, version: "1.0"},
- {isUpgrade: false, version: null}
- ]);
-
- yield promiseShutdownManager();
-});
-
-// Tests that a second update before a restart works
-add_task(function* test_double_update() {
- yield setup_conditions(TEST_CONDITIONS.withAppSet);
-
- yield installSystemAddons(yield buildSystemAddonUpdates([
- { id: "system2@tests.mozilla.org", version: "2.0", path: "system2_2.xpi" },
- { id: "system3@tests.mozilla.org", version: "1.0", path: "system3_1.xpi" }
- ], root), testserver);
-
- yield installSystemAddons(yield buildSystemAddonUpdates([
- { id: "system3@tests.mozilla.org", version: "2.0", path: "system3_2.xpi" },
- { id: "system4@tests.mozilla.org", version: "1.0", path: "system4_1.xpi" }
- ], root), testserver);
-
- yield verify_state(TEST_CONDITIONS.withAppSet.initialState, [
- {isUpgrade: false, version: null},
- {isUpgrade: false, version: "2.0"},
- {isUpgrade: true, version: "2.0"},
- {isUpgrade: true, version: "1.0"},
- {isUpgrade: false, version: null}
- ], true);
-
- yield promiseShutdownManager();
-});
-
-// A second update after a restart will delete the original unused set
-add_task(function* test_update_purges() {
- yield setup_conditions(TEST_CONDITIONS.withBothSets);
-
- yield installSystemAddons(yield buildSystemAddonUpdates([
- { id: "system2@tests.mozilla.org", version: "2.0", path: "system2_2.xpi" },
- { id: "system3@tests.mozilla.org", version: "1.0", path: "system3_1.xpi" }
- ], root), testserver);
-
- yield verify_state(TEST_CONDITIONS.withBothSets.initialState, [
- {isUpgrade: false, version: "1.0"},
- {isUpgrade: true, version: "2.0"},
- {isUpgrade: true, version: "1.0"},
- {isUpgrade: false, version: null},
- {isUpgrade: false, version: null}
- ]);
-
- yield installSystemAddons(yield buildSystemAddonUpdates(null), testserver);
-
- let dirs = yield get_directories();
- do_check_eq(dirs.length, 1);
-
- yield promiseShutdownManager();
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_temporary.js b/toolkit/mozapps/extensions/test/xpcshell/test_temporary.js
deleted file mode 100644
index ec9e25a0b..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_temporary.js
+++ /dev/null
@@ -1,760 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-const ID = "bootstrap1@tests.mozilla.org";
-const sampleRDFManifest = {
- id: ID,
- version: "1.0",
- bootstrap: true,
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "1"
- }],
- name: "Test Bootstrap 1 (temporary)",
-};
-
-createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "42");
-startupManager();
-
-const {Management} = Components.utils.import("resource://gre/modules/Extension.jsm", {});
-
-function promiseAddonStartup() {
- return new Promise(resolve => {
- let listener = (extension) => {
- Management.off("startup", listener);
- resolve(extension);
- };
-
- Management.on("startup", listener);
- });
-}
-
-BootstrapMonitor.init();
-
-// Partial list of bootstrap reasons from XPIProvider.jsm
-const BOOTSTRAP_REASONS = {
- ADDON_INSTALL: 5,
- ADDON_UPGRADE: 7,
- ADDON_DOWNGRADE: 8,
-};
-
-function waitForBootstrapEvent(expectedEvent, addonId) {
- return new Promise(resolve => {
- const observer = {
- observe: (subject, topic, data) => {
- const info = JSON.parse(data);
- const targetAddonId = info.data.id;
- if (targetAddonId === addonId && info.event === expectedEvent) {
- resolve(info);
- Services.obs.removeObserver(observer);
- } else {
- do_print(
- `Ignoring bootstrap event: ${info.event} for ${targetAddonId}`);
- }
- },
- };
- Services.obs.addObserver(observer, "bootstrapmonitor-event", false);
- });
-}
-
-// Install a temporary add-on with no existing add-on present.
-// Restart and make sure it has gone away.
-add_task(function*() {
- let extInstallCalled = false;
- AddonManager.addInstallListener({
- onExternalInstall: (aInstall) => {
- do_check_eq(aInstall.id, ID);
- do_check_eq(aInstall.version, "1.0");
- extInstallCalled = true;
- },
- });
-
- let installingCalled = false;
- let installedCalled = false;
- AddonManager.addAddonListener({
- onInstalling: (aInstall) => {
- do_check_eq(aInstall.id, ID);
- do_check_eq(aInstall.version, "1.0");
- installingCalled = true;
- },
- onInstalled: (aInstall) => {
- do_check_eq(aInstall.id, ID);
- do_check_eq(aInstall.version, "1.0");
- installedCalled = true;
- },
- onInstallStarted: (aInstall) => {
- do_throw("onInstallStarted called unexpectedly");
- }
- });
-
- yield AddonManager.installTemporaryAddon(do_get_addon("test_bootstrap1_1"));
-
- do_check_true(extInstallCalled);
- do_check_true(installingCalled);
- do_check_true(installedCalled);
-
- const install = BootstrapMonitor.checkAddonInstalled(ID, "1.0");
- equal(install.reason, BOOTSTRAP_REASONS.ADDON_INSTALL);
- BootstrapMonitor.checkAddonStarted(ID, "1.0");
-
- let addon = yield promiseAddonByID(ID);
-
- do_check_neq(addon, null);
- do_check_eq(addon.version, "1.0");
- do_check_eq(addon.name, "Test Bootstrap 1");
- do_check_true(addon.isCompatible);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.type, "extension");
- do_check_eq(addon.signedState, mozinfo.addon_signing ? AddonManager.SIGNEDSTATE_SIGNED : AddonManager.SIGNEDSTATE_NOT_REQUIRED);
-
- yield promiseRestartManager();
-
- BootstrapMonitor.checkAddonNotInstalled(ID);
- BootstrapMonitor.checkAddonNotStarted(ID);
-
- addon = yield promiseAddonByID(ID);
- do_check_eq(addon, null);
-
- yield promiseRestartManager();
-});
-
-// Install a temporary add-on over the top of an existing add-on.
-// Restart and make sure the existing add-on comes back.
-add_task(function*() {
- yield promiseInstallAllFiles([do_get_addon("test_bootstrap1_1")], true);
-
- BootstrapMonitor.checkAddonInstalled(ID, "1.0");
- BootstrapMonitor.checkAddonStarted(ID, "1.0");
-
- let addon = yield promiseAddonByID(ID);
-
- do_check_neq(addon, null);
- do_check_eq(addon.version, "1.0");
- do_check_eq(addon.name, "Test Bootstrap 1");
- do_check_true(addon.isCompatible);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.type, "extension");
- do_check_eq(addon.signedState, mozinfo.addon_signing ? AddonManager.SIGNEDSTATE_SIGNED : AddonManager.SIGNEDSTATE_NOT_REQUIRED);
-
- let tempdir = gTmpD.clone();
-
- // test that an unpacked add-on works too
- writeInstallRDFToDir({
- id: ID,
- version: "3.0",
- bootstrap: true,
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "1"
- }],
- name: "Test Bootstrap 1 (temporary)",
- }, tempdir, "bootstrap1@tests.mozilla.org", "bootstrap.js");
-
- let unpacked_addon = tempdir.clone();
- unpacked_addon.append(ID);
- do_get_file("data/test_temporary/bootstrap.js")
- .copyTo(unpacked_addon, "bootstrap.js");
-
- yield AddonManager.installTemporaryAddon(unpacked_addon);
-
- BootstrapMonitor.checkAddonInstalled(ID, "3.0");
- BootstrapMonitor.checkAddonStarted(ID, "3.0");
-
- addon = yield promiseAddonByID(ID);
-
- // temporary add-on is installed and started
- do_check_neq(addon, null);
- do_check_eq(addon.version, "3.0");
- do_check_eq(addon.name, "Test Bootstrap 1 (temporary)");
- do_check_true(addon.isCompatible);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.type, "extension");
- do_check_eq(addon.signedState, mozinfo.addon_signing ? AddonManager.SIGNEDSTATE_SIGNED : AddonManager.SIGNEDSTATE_NOT_REQUIRED);
-
- restartManager();
-
- BootstrapMonitor.checkAddonInstalled(ID, "1.0");
- BootstrapMonitor.checkAddonStarted(ID, "1.0");
-
- addon = yield promiseAddonByID(ID);
-
- // existing add-on is back
- do_check_neq(addon, null);
- do_check_eq(addon.version, "1.0");
- do_check_eq(addon.name, "Test Bootstrap 1");
- do_check_true(addon.isCompatible);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.type, "extension");
- do_check_eq(addon.signedState, mozinfo.addon_signing ? AddonManager.SIGNEDSTATE_SIGNED : AddonManager.SIGNEDSTATE_NOT_REQUIRED);
-
- unpacked_addon.remove(true);
-
- // on Windows XPI files will be locked by the JAR cache, skip this test there.
- if (!("nsIWindowsRegKey" in Components.interfaces)) {
- // test that a packed (XPI) add-on works
- writeInstallRDFToXPI({
- id: ID,
- version: "2.0",
- bootstrap: true,
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "1"
- }],
- name: "Test Bootstrap 1 (temporary)",
- }, tempdir, "bootstrap1@tests.mozilla.org");
-
- let packed_addon = tempdir.clone();
- packed_addon.append(ID + ".xpi");
-
- yield AddonManager.installTemporaryAddon(packed_addon);
-
- addon = yield promiseAddonByID(ID);
-
- // temporary add-on is installed and started
- do_check_neq(addon, null);
- do_check_eq(addon.version, "2.0");
- do_check_eq(addon.name, "Test Bootstrap 1 (temporary)");
- do_check_true(addon.isCompatible);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.type, "extension");
- do_check_eq(addon.signedState, mozinfo.addon_signing ? AddonManager.SIGNEDSTATE_SIGNED : AddonManager.SIGNEDSTATE_NOT_REQUIRED);
-
- restartManager();
-
- BootstrapMonitor.checkAddonInstalled(ID, "1.0");
- BootstrapMonitor.checkAddonStarted(ID, "1.0");
-
- addon = yield promiseAddonByID(ID);
-
- // existing add-on is back
- do_check_neq(addon, null);
- do_check_eq(addon.version, "1.0");
- do_check_eq(addon.name, "Test Bootstrap 1");
- do_check_true(addon.isCompatible);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.type, "extension");
- do_check_eq(addon.signedState, mozinfo.addon_signing ? AddonManager.SIGNEDSTATE_SIGNED : AddonManager.SIGNEDSTATE_NOT_REQUIRED);
-
- packed_addon.remove(false);
-
- // test that a webextension works
- let webext = createTempWebExtensionFile({
- manifest: {
- version: "4.0",
- name: "Test WebExtension 1 (temporary)",
- applications: {
- gecko: {
- id: ID
- }
- }
- }
- });
-
- yield Promise.all([
- AddonManager.installTemporaryAddon(webext),
- promiseAddonStartup(),
- ]);
- addon = yield promiseAddonByID(ID);
-
- // temporary add-on is installed and started
- do_check_neq(addon, null);
- do_check_eq(addon.version, "4.0");
- do_check_eq(addon.name, "Test WebExtension 1 (temporary)");
- do_check_true(addon.isCompatible);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.type, "extension");
- do_check_eq(addon.signedState, mozinfo.addon_signing ? AddonManager.SIGNEDSTATE_SIGNED : AddonManager.SIGNEDSTATE_NOT_REQUIRED);
-
- // test that re-loading a webextension works, using the same filename
- webext.remove(false);
- webext = createTempWebExtensionFile({
- manifest: {
- version: "5.0",
- name: "Test WebExtension 1 (temporary)",
- applications: {
- gecko: {
- id: ID
- }
- }
- }
- });
-
- yield Promise.all([
- AddonManager.installTemporaryAddon(webext),
- promiseAddonStartup(),
- ]);
- addon = yield promiseAddonByID(ID);
-
- // temporary add-on is installed and started
- do_check_neq(addon, null);
- do_check_eq(addon.version, "5.0");
- do_check_eq(addon.name, "Test WebExtension 1 (temporary)");
- do_check_true(addon.isCompatible);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.type, "extension");
- do_check_eq(addon.signedState, mozinfo.addon_signing ? AddonManager.SIGNEDSTATE_SIGNED : AddonManager.SIGNEDSTATE_NOT_REQUIRED);
-
- restartManager();
-
- BootstrapMonitor.checkAddonInstalled(ID, "1.0");
- BootstrapMonitor.checkAddonStarted(ID, "1.0");
-
- addon = yield promiseAddonByID(ID);
-
- // existing add-on is back
- do_check_neq(addon, null);
- do_check_eq(addon.version, "1.0");
- do_check_eq(addon.name, "Test Bootstrap 1");
- do_check_true(addon.isCompatible);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.type, "extension");
- do_check_eq(addon.signedState, mozinfo.addon_signing ? AddonManager.SIGNEDSTATE_SIGNED : AddonManager.SIGNEDSTATE_NOT_REQUIRED);
- }
-
- // remove original add-on
- addon.uninstall();
-
- BootstrapMonitor.checkAddonNotInstalled(ID);
- BootstrapMonitor.checkAddonNotStarted(ID);
-
- yield promiseRestartManager();
-});
-
-// Install a temporary add-on over the top of an existing add-on.
-// Uninstall it and make sure the existing add-on comes back.
-add_task(function*() {
- yield promiseInstallAllFiles([do_get_addon("test_bootstrap1_1")], true);
-
- BootstrapMonitor.checkAddonInstalled(ID, "1.0");
- BootstrapMonitor.checkAddonStarted(ID, "1.0");
-
- let tempdir = gTmpD.clone();
- writeInstallRDFToDir({
- id: ID,
- version: "2.0",
- bootstrap: true,
- unpack: true,
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "1"
- }],
- name: "Test Bootstrap 1 (temporary)",
- }, tempdir);
-
- let unpacked_addon = tempdir.clone();
- unpacked_addon.append(ID);
-
- let extInstallCalled = false;
- AddonManager.addInstallListener({
- onExternalInstall: (aInstall) => {
- do_check_eq(aInstall.id, ID);
- do_check_eq(aInstall.version, "2.0");
- extInstallCalled = true;
- },
- });
-
- let installingCalled = false;
- let installedCalled = false;
- AddonManager.addAddonListener({
- onInstalling: (aInstall) => {
- do_check_eq(aInstall.id, ID);
- if (!installingCalled)
- do_check_eq(aInstall.version, "2.0");
- installingCalled = true;
- },
- onInstalled: (aInstall) => {
- do_check_eq(aInstall.id, ID);
- if (!installedCalled)
- do_check_eq(aInstall.version, "2.0");
- installedCalled = true;
- },
- onInstallStarted: (aInstall) => {
- do_throw("onInstallStarted called unexpectedly");
- }
- });
-
- yield AddonManager.installTemporaryAddon(unpacked_addon);
-
- do_check_true(extInstallCalled);
- do_check_true(installingCalled);
- do_check_true(installedCalled);
-
- let addon = yield promiseAddonByID(ID);
-
- BootstrapMonitor.checkAddonNotInstalled(ID);
- BootstrapMonitor.checkAddonNotStarted(ID);
-
- // temporary add-on is installed and started
- do_check_neq(addon, null);
- do_check_eq(addon.version, "2.0");
- do_check_eq(addon.name, "Test Bootstrap 1 (temporary)");
- do_check_true(addon.isCompatible);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.type, "extension");
- do_check_eq(addon.signedState, mozinfo.addon_signing ? AddonManager.SIGNEDSTATE_SIGNED : AddonManager.SIGNEDSTATE_NOT_REQUIRED);
-
- addon.uninstall();
-
- addon = yield promiseAddonByID(ID);
-
- BootstrapMonitor.checkAddonInstalled(ID);
- BootstrapMonitor.checkAddonStarted(ID);
-
- // existing add-on is back
- do_check_neq(addon, null);
- do_check_eq(addon.version, "1.0");
- do_check_eq(addon.name, "Test Bootstrap 1");
- do_check_true(addon.isCompatible);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.type, "extension");
- do_check_eq(addon.signedState, mozinfo.addon_signing ? AddonManager.SIGNEDSTATE_SIGNED : AddonManager.SIGNEDSTATE_NOT_REQUIRED);
-
- unpacked_addon.remove(true);
- addon.uninstall();
-
- BootstrapMonitor.checkAddonNotInstalled(ID);
- BootstrapMonitor.checkAddonNotStarted(ID);
-
- yield promiseRestartManager();
-});
-
-// Install a temporary add-on as a version upgrade over the top of an
-// existing temporary add-on.
-add_task(function*() {
- const tempdir = gTmpD.clone();
-
- writeInstallRDFToDir(sampleRDFManifest, tempdir,
- "bootstrap1@tests.mozilla.org", "bootstrap.js");
-
- const unpackedAddon = tempdir.clone();
- unpackedAddon.append(ID);
- do_get_file("data/test_temporary/bootstrap.js")
- .copyTo(unpackedAddon, "bootstrap.js");
-
- yield AddonManager.installTemporaryAddon(unpackedAddon);
-
- // Increment the version number, re-install it, and make sure it
- // gets marked as an upgrade.
- writeInstallRDFToDir(Object.assign({}, sampleRDFManifest, {
- version: "2.0"
- }), tempdir, "bootstrap1@tests.mozilla.org");
-
- const onUninstall = waitForBootstrapEvent("uninstall", ID);
- const onInstall = waitForBootstrapEvent("install", ID);
- yield AddonManager.installTemporaryAddon(unpackedAddon);
-
- const uninstall = yield onUninstall;
- equal(uninstall.data.version, "1.0");
- equal(uninstall.reason, BOOTSTRAP_REASONS.ADDON_UPGRADE);
-
- const install = yield onInstall;
- equal(install.data.version, "2.0");
- equal(install.reason, BOOTSTRAP_REASONS.ADDON_UPGRADE);
-
- const addon = yield promiseAddonByID(ID);
- addon.uninstall();
-
- unpackedAddon.remove(true);
- yield promiseRestartManager();
-});
-
-// Install a temporary add-on as a version downgrade over the top of an
-// existing temporary add-on.
-add_task(function*() {
- const tempdir = gTmpD.clone();
-
- writeInstallRDFToDir(sampleRDFManifest, tempdir,
- "bootstrap1@tests.mozilla.org", "bootstrap.js");
-
- const unpackedAddon = tempdir.clone();
- unpackedAddon.append(ID);
- do_get_file("data/test_temporary/bootstrap.js")
- .copyTo(unpackedAddon, "bootstrap.js");
-
- yield AddonManager.installTemporaryAddon(unpackedAddon);
-
- // Decrement the version number, re-install, and make sure
- // it gets marked as a downgrade.
- writeInstallRDFToDir(Object.assign({}, sampleRDFManifest, {
- version: "0.8"
- }), tempdir, "bootstrap1@tests.mozilla.org");
-
- const onUninstall = waitForBootstrapEvent("uninstall", ID);
- const onInstall = waitForBootstrapEvent("install", ID);
- yield AddonManager.installTemporaryAddon(unpackedAddon);
-
- const uninstall = yield onUninstall;
- equal(uninstall.data.version, "1.0");
- equal(uninstall.reason, BOOTSTRAP_REASONS.ADDON_DOWNGRADE);
-
- const install = yield onInstall;
- equal(install.data.version, "0.8");
- equal(install.reason, BOOTSTRAP_REASONS.ADDON_DOWNGRADE);
-
- const addon = yield promiseAddonByID(ID);
- addon.uninstall();
-
- unpackedAddon.remove(true);
- yield promiseRestartManager();
-});
-
-// Installing a temporary add-on over an existing add-on with the same
-// version number should be installed as an upgrade.
-add_task(function*() {
- const tempdir = gTmpD.clone();
-
- writeInstallRDFToDir(sampleRDFManifest, tempdir,
- "bootstrap1@tests.mozilla.org", "bootstrap.js");
-
- const unpackedAddon = tempdir.clone();
- unpackedAddon.append(ID);
- do_get_file("data/test_temporary/bootstrap.js")
- .copyTo(unpackedAddon, "bootstrap.js");
-
- const onInitialInstall = waitForBootstrapEvent("install", ID);
- yield AddonManager.installTemporaryAddon(unpackedAddon);
-
- const initialInstall = yield onInitialInstall;
- equal(initialInstall.data.version, "1.0");
- equal(initialInstall.reason, BOOTSTRAP_REASONS.ADDON_INSTALL);
-
- // Install it again.
- const onUninstall = waitForBootstrapEvent("uninstall", ID);
- const onInstall = waitForBootstrapEvent("install", ID);
- yield AddonManager.installTemporaryAddon(unpackedAddon);
-
- const uninstall = yield onUninstall;
- equal(uninstall.data.version, "1.0");
- equal(uninstall.reason, BOOTSTRAP_REASONS.ADDON_UPGRADE);
-
- const reInstall = yield onInstall;
- equal(reInstall.data.version, "1.0");
- equal(reInstall.reason, BOOTSTRAP_REASONS.ADDON_UPGRADE);
-
- const addon = yield promiseAddonByID(ID);
- addon.uninstall();
-
- unpackedAddon.remove(true);
- yield promiseRestartManager();
-});
-
-// Install a temporary add-on over the top of an existing disabled add-on.
-// After restart, the existing add-on should continue to be installed and disabled.
-add_task(function*() {
- yield promiseInstallAllFiles([do_get_addon("test_bootstrap1_1")], true);
-
- BootstrapMonitor.checkAddonInstalled(ID, "1.0");
- BootstrapMonitor.checkAddonStarted(ID, "1.0");
-
- let addon = yield promiseAddonByID(ID);
-
- addon.userDisabled = true;
-
- BootstrapMonitor.checkAddonInstalled(ID, "1.0");
- BootstrapMonitor.checkAddonNotStarted(ID);
-
- let tempdir = gTmpD.clone();
- writeInstallRDFToDir({
- id: ID,
- version: "2.0",
- bootstrap: true,
- unpack: true,
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "1"
- }],
- name: "Test Bootstrap 1 (temporary)",
- }, tempdir, "bootstrap1@tests.mozilla.org", "bootstrap.js");
-
- let unpacked_addon = tempdir.clone();
- unpacked_addon.append(ID);
- do_get_file("data/test_temporary/bootstrap.js")
- .copyTo(unpacked_addon, "bootstrap.js");
-
- let extInstallCalled = false;
- AddonManager.addInstallListener({
- onExternalInstall: (aInstall) => {
- do_check_eq(aInstall.id, ID);
- do_check_eq(aInstall.version, "2.0");
- extInstallCalled = true;
- },
- });
-
- yield AddonManager.installTemporaryAddon(unpacked_addon);
-
- do_check_true(extInstallCalled);
-
- let tempAddon = yield promiseAddonByID(ID);
-
- BootstrapMonitor.checkAddonInstalled(ID, "2.0");
- BootstrapMonitor.checkAddonStarted(ID);
-
- // temporary add-on is installed and started
- do_check_neq(tempAddon, null);
- do_check_eq(tempAddon.version, "2.0");
- do_check_eq(tempAddon.name, "Test Bootstrap 1 (temporary)");
- do_check_true(tempAddon.isCompatible);
- do_check_false(tempAddon.appDisabled);
- do_check_true(tempAddon.isActive);
- do_check_eq(tempAddon.type, "extension");
- do_check_eq(tempAddon.signedState, mozinfo.addon_signing ? AddonManager.SIGNEDSTATE_SIGNED : AddonManager.SIGNEDSTATE_NOT_REQUIRED);
-
- tempAddon.uninstall();
- unpacked_addon.remove(true);
-
- addon.userDisabled = false;
- addon = yield promiseAddonByID(ID);
-
- BootstrapMonitor.checkAddonInstalled(ID, "1.0");
- BootstrapMonitor.checkAddonStarted(ID);
-
- // existing add-on is back
- do_check_neq(addon, null);
- do_check_eq(addon.version, "1.0");
- do_check_eq(addon.name, "Test Bootstrap 1");
- do_check_true(addon.isCompatible);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.type, "extension");
- do_check_eq(addon.signedState, mozinfo.addon_signing ? AddonManager.SIGNEDSTATE_SIGNED : AddonManager.SIGNEDSTATE_NOT_REQUIRED);
-
- addon.uninstall();
-
- BootstrapMonitor.checkAddonNotInstalled(ID);
- BootstrapMonitor.checkAddonNotStarted(ID);
-
- yield promiseRestartManager();
-});
-
-// Installing a temporary add-on over a non-restartless add-on should fail.
-add_task(function*() {
- yield promiseInstallAllFiles([do_get_addon("test_install1")], true);
-
- let non_restartless_ID = "addon1@tests.mozilla.org";
-
- BootstrapMonitor.checkAddonNotInstalled(non_restartless_ID);
- BootstrapMonitor.checkAddonNotStarted(non_restartless_ID);
-
- restartManager();
-
- BootstrapMonitor.checkAddonNotInstalled(non_restartless_ID);
- BootstrapMonitor.checkAddonNotStarted(non_restartless_ID);
-
- let addon = yield promiseAddonByID(non_restartless_ID);
-
- // non-restartless add-on is installed and started
- do_check_neq(addon, null);
- do_check_eq(addon.id, non_restartless_ID);
- do_check_eq(addon.version, "1.0");
- do_check_eq(addon.name, "Test 1");
- do_check_true(addon.isCompatible);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.type, "extension");
- do_check_eq(addon.signedState, mozinfo.addon_signing ? AddonManager.SIGNEDSTATE_SIGNED : AddonManager.SIGNEDSTATE_NOT_REQUIRED);
-
- let tempdir = gTmpD.clone();
- writeInstallRDFToDir({
- id: non_restartless_ID,
- version: "2.0",
- bootstrap: true,
- unpack: true,
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "1"
- }],
- name: "Test 1 (temporary)",
- }, tempdir);
-
- let unpacked_addon = tempdir.clone();
- unpacked_addon.append(non_restartless_ID);
-
- try {
- yield AddonManager.installTemporaryAddon(unpacked_addon);
- do_throw("Installing over a non-restartless add-on should return"
- + " a rejected promise");
- } catch (err) {
- do_check_eq(err.message,
- "Non-restartless add-on with ID addon1@tests.mozilla.org is"
- + " already installed");
- }
-
- unpacked_addon.remove(true);
- addon.uninstall();
-
- BootstrapMonitor.checkAddonNotInstalled(ID);
- BootstrapMonitor.checkAddonNotStarted(ID);
-
- yield promiseRestartManager();
-});
-
-// Installing a temporary add-on when there is already a temporary
-// add-on should fail.
-add_task(function*() {
- yield AddonManager.installTemporaryAddon(do_get_addon("test_bootstrap1_1"));
-
- let addon = yield promiseAddonByID(ID);
-
- BootstrapMonitor.checkAddonInstalled(ID, "1.0");
- BootstrapMonitor.checkAddonStarted(ID, "1.0");
-
- do_check_neq(addon, null);
- do_check_eq(addon.version, "1.0");
- do_check_eq(addon.name, "Test Bootstrap 1");
- do_check_true(addon.isCompatible);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_eq(addon.type, "extension");
- do_check_false(addon.isWebExtension);
- do_check_eq(addon.signedState, mozinfo.addon_signing ? AddonManager.SIGNEDSTATE_SIGNED : AddonManager.SIGNEDSTATE_NOT_REQUIRED);
-
- yield AddonManager.installTemporaryAddon(do_get_addon("test_bootstrap1_1"));
-
- BootstrapMonitor.checkAddonInstalled(ID, "1.0");
- BootstrapMonitor.checkAddonStarted(ID, "1.0");
-
- yield promiseRestartManager();
-
- BootstrapMonitor.checkAddonNotInstalled(ID);
- BootstrapMonitor.checkAddonNotStarted(ID);
-});
-
-// Check that a temporary add-on is marked as such.
-add_task(function*() {
- yield AddonManager.installTemporaryAddon(do_get_addon("test_bootstrap1_1"));
- const addon = yield promiseAddonByID(ID);
-
- notEqual(addon, null);
- equal(addon.temporarilyInstalled, true);
-
- yield promiseRestartManager();
-});
-
-// Check that a permanent add-on is not marked as temporarily installed.
-add_task(function*() {
- yield promiseInstallAllFiles([do_get_addon("test_bootstrap1_1")], true);
- const addon = yield promiseAddonByID(ID);
-
- notEqual(addon, null);
- equal(addon.temporarilyInstalled, false);
-
- yield promiseRestartManager();
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_theme.js b/toolkit/mozapps/extensions/test/xpcshell/test_theme.js
index 84d6f1d0d..f201c776d 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_theme.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_theme.js
@@ -95,12 +95,10 @@ function run_test() {
do_check_neq(d, null);
do_check_false(d.skinnable);
do_check_false(d.foreignInstall);
- do_check_eq(d.signedState, undefined);
do_check_neq(t1, null);
do_check_false(t1.userDisabled);
do_check_false(t1.appDisabled);
- do_check_eq(t1.signedState, undefined);
do_check_true(t1.isActive);
do_check_true(t1.skinnable);
do_check_true(t1.foreignInstall);
@@ -114,7 +112,6 @@ function run_test() {
do_check_neq(t2, null);
do_check_true(t2.userDisabled);
do_check_false(t2.appDisabled);
- do_check_eq(t2.signedState, undefined);
do_check_false(t2.isActive);
do_check_false(t2.skinnable);
do_check_true(t2.foreignInstall);
@@ -857,27 +854,27 @@ function run_test_15() {
do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "theme1/1.0");
AddonManager.getAddonsByIDs(["default@tests.mozilla.org",
"theme1@tests.mozilla.org"],
- callback_soon(function([d_2, t1_2]) {
- do_check_true(d_2.userDisabled);
- do_check_false(d_2.appDisabled);
- do_check_false(d_2.isActive);
+ callback_soon(function([d, t1]) {
+ do_check_true(d.userDisabled);
+ do_check_false(d.appDisabled);
+ do_check_false(d.isActive);
- do_check_false(t1_2.userDisabled);
- do_check_false(t1_2.appDisabled);
- do_check_true(t1_2.isActive);
+ do_check_false(t1.userDisabled);
+ do_check_false(t1.appDisabled);
+ do_check_true(t1.isActive);
restartManager("2");
do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "theme1/1.0");
AddonManager.getAddonsByIDs(["default@tests.mozilla.org",
- "theme1@tests.mozilla.org"], function([d_3, t1_3]) {
- do_check_true(d_3.userDisabled);
- do_check_false(d_3.appDisabled);
- do_check_false(d_3.isActive);
+ "theme1@tests.mozilla.org"], function([d, t1]) {
+ do_check_true(d.userDisabled);
+ do_check_false(d.appDisabled);
+ do_check_false(d.isActive);
- do_check_false(t1_3.userDisabled);
- do_check_false(t1_3.appDisabled);
- do_check_true(t1_3.isActive);
+ do_check_false(t1.userDisabled);
+ do_check_false(t1.appDisabled);
+ do_check_true(t1.isActive);
do_execute_soon(run_test_16);
});
@@ -943,14 +940,14 @@ function run_test_18() {
AddonManager.getAddonsByIDs(["default@tests.mozilla.org",
"theme1@tests.mozilla.org"],
- callback_soon(function([d_2, t1_2]) {
- do_check_true(d_2.userDisabled);
- do_check_false(d_2.appDisabled);
- do_check_false(d_2.isActive);
+ callback_soon(function([d, t1]) {
+ do_check_true(d.userDisabled);
+ do_check_false(d.appDisabled);
+ do_check_false(d.isActive);
- do_check_false(t1_2.userDisabled);
- do_check_false(t1_2.appDisabled);
- do_check_true(t1_2.isActive);
+ do_check_false(t1.userDisabled);
+ do_check_false(t1.appDisabled);
+ do_check_true(t1.isActive);
prepare_test({
"theme1@tests.mozilla.org": [
@@ -960,28 +957,28 @@ function run_test_18() {
"onEnabling",
]
});
- t1_2.userDisabled = true;
+ t1.userDisabled = true;
ensure_test_completed();
- do_check_false(d_2.userDisabled);
- do_check_false(d_2.appDisabled);
- do_check_false(d_2.isActive);
+ do_check_false(d.userDisabled);
+ do_check_false(d.appDisabled);
+ do_check_false(d.isActive);
- do_check_true(t1_2.userDisabled);
- do_check_false(t1_2.appDisabled);
- do_check_true(t1_2.isActive);
+ do_check_true(t1.userDisabled);
+ do_check_false(t1.appDisabled);
+ do_check_true(t1.isActive);
restartManager();
AddonManager.getAddonsByIDs(["default@tests.mozilla.org",
- "theme1@tests.mozilla.org"], function([d_3, t1_3]) {
- do_check_false(d_3.userDisabled);
- do_check_false(d_3.appDisabled);
- do_check_true(d_3.isActive);
+ "theme1@tests.mozilla.org"], function([d, t1]) {
+ do_check_false(d.userDisabled);
+ do_check_false(d.appDisabled);
+ do_check_true(d.isActive);
- do_check_true(t1_3.userDisabled);
- do_check_false(t1_3.appDisabled);
- do_check_false(t1_3.isActive);
+ do_check_true(t1.userDisabled);
+ do_check_false(t1.appDisabled);
+ do_check_false(t1.isActive);
do_execute_soon(run_test_19);
});
@@ -1089,51 +1086,7 @@ function run_test_21() {
p1.userDisabled = false;
ensure_test_completed();
- run_test_22();
- });
- }));
-}
-
-// Detecting a new add-on during the startup file check should not disable an
-// active lightweight theme
-function run_test_22() {
- restartManager();
-
- AddonManager.getAddonsByIDs(["default@tests.mozilla.org",
- "1@personas.mozilla.org"], function([d, p1]) {
- do_check_true(d.userDisabled);
- do_check_false(d.appDisabled);
- do_check_false(d.isActive);
-
- do_check_false(p1.userDisabled);
- do_check_false(p1.appDisabled);
- do_check_true(p1.isActive);
-
- writeInstallRDFForExtension({
- id: "theme3@tests.mozilla.org",
- version: "1.0",
- name: "Test 3",
- internalName: "theme3/1.0",
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "2"
- }]
- }, profileDir);
-
- restartManager();
-
- AddonManager.getAddonsByIDs(["default@tests.mozilla.org",
- "1@personas.mozilla.org"], function([d_2, p1_2]) {
- do_check_true(d_2.userDisabled);
- do_check_false(d_2.appDisabled);
- do_check_false(d_2.isActive);
-
- do_check_false(p1_2.userDisabled);
- do_check_false(p1_2.appDisabled);
- do_check_true(p1_2.isActive);
-
end_test();
});
- });
+ }));
}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_undothemeuninstall.js b/toolkit/mozapps/extensions/test/xpcshell/test_undothemeuninstall.js
index 36ca95aec..c804b3bd6 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_undothemeuninstall.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_undothemeuninstall.js
@@ -133,7 +133,7 @@ add_task(function* uninstallEnabledOffersUndo() {
do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "classic/1.0");
});
-// Tests that uninstalling an enabled theme can be undone
+//Tests that uninstalling an enabled theme can be undone
add_task(function* canUndoUninstallEnabled() {
writeInstallRDFForExtension(theme1, profileDir);
@@ -228,7 +228,7 @@ add_task(function* canUndoUninstallEnabled() {
yield promiseRestartManager();
});
-// Tests that uninstalling a disabled theme offers the option to undo
+//Tests that uninstalling a disabled theme offers the option to undo
add_task(function* uninstallDisabledOffersUndo() {
writeInstallRDFForExtension(theme1, profileDir);
@@ -283,7 +283,7 @@ add_task(function* uninstallDisabledOffersUndo() {
do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "classic/1.0");
});
-// Tests that uninstalling a disabled theme can be undone
+//Tests that uninstalling a disabled theme can be undone
add_task(function* canUndoUninstallDisabled() {
writeInstallRDFForExtension(theme1, profileDir);
@@ -362,11 +362,10 @@ add_task(function* canUndoUninstallDisabled() {
yield promiseRestartManager();
});
-// Tests that uninstalling an enabled lightweight theme offers the option to undo
+//Tests that uninstalling an enabled lightweight theme offers the option to undo
add_task(function* uninstallLWTOffersUndo() {
// skipped since lightweight themes don't support undoable uninstall yet
return;
- /*
LightweightThemeManager.currentTheme = dummyLWTheme("theme1");
let [ t1, d ] = yield promiseAddonsByIDs(["theme1@personas.mozilla.org",
@@ -419,5 +418,4 @@ add_task(function* uninstallLWTOffersUndo() {
do_check_eq(t1, null);
do_check_eq(Services.prefs.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN), "classic/1.0");
- */
});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_undouninstall.js b/toolkit/mozapps/extensions/test/xpcshell/test_undouninstall.js
index 4680a3c4a..a589361b6 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_undouninstall.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_undouninstall.js
@@ -253,7 +253,7 @@ add_task(function* uninstallInactiveIsCancellable() {
yield promiseRestartManager();
});
-// Test that an inactive item can be uninstalled
+//Test that an inactive item can be uninstalled
add_task(function* uninstallInactive() {
let a1 = yield promiseAddonByID("addon1@tests.mozilla.org");
@@ -335,7 +335,7 @@ add_task(function* uninstallRestartless() {
BootstrapMonitor.checkAddonNotStarted(ID);
});
-// Tests that an enabled restartless add-on can be uninstalled and then cancelled
+//Tests that an enabled restartless add-on can be uninstalled and then cancelled
add_task(function* cancelUninstallOfRestartless() {
prepare_test({
"undouninstall1@tests.mozilla.org": [
@@ -350,7 +350,7 @@ add_task(function* cancelUninstallOfRestartless() {
yield promiseInstallAllFiles([do_get_addon("test_undouninstall1")]);
ensure_test_completed();
- let a1 = yield promiseAddonByID(ID);
+ a1 = yield promiseAddonByID(ID);
do_check_neq(a1, null);
BootstrapMonitor.checkAddonInstalled(ID, "1.0");
@@ -547,7 +547,7 @@ add_task(function* uninstallDisabledRestartless() {
do_check_eq(getUninstallReason(ID), ADDON_UNINSTALL);
});
-// Tests that a disabled restartless add-on can be uninstalled and then cancelled
+//Tests that a disabled restartless add-on can be uninstalled and then cancelled
add_task(function* cancelUninstallDisabledRestartless() {
prepare_test({
"undouninstall1@tests.mozilla.org": [
@@ -633,8 +633,8 @@ add_task(function* cancelUninstallDisabledRestartless() {
a1.uninstall();
});
-// Tests that reinstalling a disabled restartless add-on waiting to be
-// uninstalled aborts the uninstall and leaves the add-on disabled
+//Tests that reinstalling a disabled restartless add-on waiting to be
+//uninstalled aborts the uninstall and leaves the add-on disabled
add_task(function* reinstallDisabledAddonAwaitingUninstall() {
yield promiseInstallAllFiles([do_get_addon("test_undouninstall1")]);
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_update.js b/toolkit/mozapps/extensions/test/xpcshell/test_update.js
index 4db488ab5..b7e32d59f 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_update.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_update.js
@@ -23,1178 +23,400 @@ const PARAMS = "?%REQ_VERSION%/%ITEM_ID%/%ITEM_VERSION%/%ITEM_MAXAPPVERSION%/" +
var gInstallDate;
-var testserver = createHttpServer();
+Components.utils.import("resource://testing-common/httpd.js");
+var testserver = new HttpServer();
+testserver.start(-1);
gPort = testserver.identity.primaryPort;
mapFile("/data/test_update.rdf", testserver);
-mapFile("/data/test_update.json", testserver);
mapFile("/data/test_update.xml", testserver);
testserver.registerDirectory("/addons/", do_get_file("addons"));
const profileDir = gProfD.clone();
profileDir.append("extensions");
-var originalSyncGUID;
+let originalSyncGUID;
function run_test() {
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
-
+ createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
Services.prefs.setBoolPref(PREF_MATCH_OS_LOCALE, false);
Services.prefs.setCharPref(PREF_SELECTED_LOCALE, "fr-FR");
- run_next_test();
-}
-
-let testParams = [
- { updateFile: "test_update.rdf",
- appId: "xpcshell@tests.mozilla.org" },
- { updateFile: "test_update.json",
- 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);
-
- 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);
-
- startupManager();
-
- 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) {
- do_check_neq(a1, null);
- do_check_eq(a1.version, "1.0");
- do_check_eq(a1.applyBackgroundUpdates, AddonManager.AUTOUPDATE_DEFAULT);
- do_check_eq(a1.releaseNotesURI, null);
- do_check_true(a1.foreignInstall);
- do_check_neq(a1.syncGUID, null);
+ writeInstallRDFForExtension({
+ id: "addon1@tests.mozilla.org",
+ version: "1.0",
+ updateURL: "http://localhost:" + gPort + "/data/test_update.rdf",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "1",
+ maxVersion: "1"
+ }],
+ name: "Test Addon 1",
+ }, profileDir);
- originalSyncGUID = a1.syncGUID;
- a1.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DEFAULT;
+ writeInstallRDFForExtension({
+ id: "addon2@tests.mozilla.org",
+ version: "1.0",
+ updateURL: "http://localhost:" + gPort + "/data/test_update.rdf",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "0",
+ maxVersion: "0"
+ }],
+ name: "Test Addon 2",
+ }, profileDir);
- prepare_test({
- "addon1@tests.mozilla.org": [
- ["onPropertyChanged", ["applyBackgroundUpdates"]]
- ]
- });
- a1.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE;
- check_test_completed();
+ writeInstallRDFForExtension({
+ id: "addon3@tests.mozilla.org",
+ version: "1.0",
+ updateURL: "http://localhost:" + gPort + "/data/test_update.rdf",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "5",
+ maxVersion: "5"
+ }],
+ name: "Test Addon 3",
+ }, profileDir);
- a1.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE;
+ startupManager();
- prepare_test({}, [
- "onNewInstall",
- ]);
+ do_test_pending();
+ run_test_1();
+}
- a1.findUpdates({
- onNoCompatibilityUpdateAvailable: function(addon) {
- ok(false, "Should not have seen onNoCompatibilityUpdateAvailable notification");
- },
+function end_test() {
+ testserver.stop(do_test_finished);
+}
- onUpdateAvailable: function(addon, install) {
- ensure_test_completed();
-
- AddonManager.getAllInstalls(function(aInstalls) {
- do_check_eq(aInstalls.length, 1);
- do_check_eq(aInstalls[0], install);
-
- do_check_eq(addon, a1);
- do_check_eq(install.name, addon.name);
- do_check_eq(install.version, "2.0");
- do_check_eq(install.state, AddonManager.STATE_AVAILABLE);
- do_check_eq(install.existingAddon, addon);
- do_check_eq(install.releaseNotesURI.spec, "http://example.com/updateInfo.xhtml");
-
- // Verify that another update check returns the same AddonInstall
- a1.findUpdates({
- onNoCompatibilityUpdateAvailable: function() {
- ok(false, "Should not have seen onNoCompatibilityUpdateAvailable notification");
- },
-
- onUpdateAvailable: function(newAddon, newInstall) {
- AddonManager.getAllInstalls(function(aInstalls2) {
- do_check_eq(aInstalls2.length, 1);
- do_check_eq(aInstalls2[0], install);
- do_check_eq(newAddon, addon);
- do_check_eq(newInstall, install);
-
- prepare_test({}, [
- "onDownloadStarted",
- "onDownloadEnded",
- ], check_test_1);
- install.install();
- });
- },
+// Verify that an update is available and can be installed.
+function run_test_1() {
+ AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
+ do_check_neq(a1, null);
+ do_check_eq(a1.version, "1.0");
+ do_check_eq(a1.applyBackgroundUpdates, AddonManager.AUTOUPDATE_DEFAULT);
+ do_check_eq(a1.releaseNotesURI, null);
+ do_check_true(a1.foreignInstall);
+ do_check_neq(a1.syncGUID, null);
- onNoUpdateAvailable: function() {
- ok(false, "Should not have seen onNoUpdateAvailable notification");
- }
- }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
- });
- },
+ originalSyncGUID = a1.syncGUID;
+ a1.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DEFAULT;
- onNoUpdateAvailable: function(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();
- do_check_eq(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: function(addon) {
- ok(false, "Should not have seen onNoCompatibilityUpdateAvailable notification");
+ do_throw("Should not have seen onNoCompatibilityUpdateAvailable notification");
},
- onUpdateAvailable: function() {
- ok(false, "Should find no available update when one is already downloading");
- },
+ onUpdateAvailable: function(addon, install) {
+ ensure_test_completed();
- onNoUpdateAvailable: function(addon) {
AddonManager.getAllInstalls(function(aInstalls) {
do_check_eq(aInstalls.length, 1);
do_check_eq(aInstalls[0], install);
- prepare_test({
- "addon1@tests.mozilla.org": [
- "onInstalling"
- ]
- }, [
- "onInstallStarted",
- "onInstallEnded",
- ], check_test_2);
- install.install();
+ do_check_eq(addon, a1);
+ do_check_eq(install.name, addon.name);
+ do_check_eq(install.version, "2.0");
+ do_check_eq(install.state, AddonManager.STATE_AVAILABLE);
+ do_check_eq(install.existingAddon, addon);
+ do_check_eq(install.releaseNotesURI.spec, "http://example.com/updateInfo.xhtml");
+
+ // Verify that another update check returns the same AddonInstall
+ a1.findUpdates({
+ onNoCompatibilityUpdateAvailable: function(addon) {
+ do_throw("Should not have seen onNoCompatibilityUpdateAvailable notification");
+ },
+
+ onUpdateAvailable: function(newAddon, newInstall) {
+ AddonManager.getAllInstalls(function(aInstalls) {
+ do_check_eq(aInstalls.length, 1);
+ do_check_eq(aInstalls[0], install);
+ do_check_eq(newAddon, addon);
+ do_check_eq(newInstall, install);
+
+ prepare_test({}, [
+ "onDownloadStarted",
+ "onDownloadEnded",
+ ], check_test_1);
+ install.install();
+ });
+ },
+
+ onNoUpdateAvailable: function(addon) {
+ do_throw("Should not have seen onNoUpdateAvailable notification");
+ }
+ }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
});
+ },
+
+ onNoUpdateAvailable: function(addon) {
+ do_throw("Should not have seen onNoUpdateAvailable notification");
}
}, AddonManager.UPDATE_WHEN_USER_REQUESTED);
- };
-
- check_test_2 = () => {
- ensure_test_completed();
-
- AddonManager.getAddonByID("addon1@tests.mozilla.org", callback_soon(function(olda1) {
- do_check_neq(olda1, null);
- do_check_eq(olda1.version, "1.0");
- do_check_true(isExtensionInAddonsList(profileDir, olda1.id));
-
- shutdownManager();
-
- startupManager();
-
- do_check_true(isExtensionInAddonsList(profileDir, "addon1@tests.mozilla.org"));
-
- AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
- do_check_neq(a1, null);
- do_check_eq(a1.version, "2.0");
- do_check_true(isExtensionInAddonsList(profileDir, a1.id));
- do_check_eq(a1.applyBackgroundUpdates, AddonManager.AUTOUPDATE_DISABLE);
- do_check_eq(a1.releaseNotesURI.spec, "http://example.com/updateInfo.xhtml");
- do_check_true(a1.foreignInstall);
- do_check_neq(a1.syncGUID, null);
- do_check_eq(originalSyncGUID, a1.syncGUID);
-
- // Make sure that the extension lastModifiedTime was updated.
- let testURI = a1.getResourceURI(TEST_UNPACKED ? "install.rdf" : "");
- let testFile = testURI.QueryInterface(Components.interfaces.nsIFileURL).file;
- let difference = testFile.lastModifiedTime - Date.now();
- do_check_true(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) {
- do_check_neq(a2, null);
- do_check_true(a2.isActive);
- do_check_true(a2.isCompatible);
- do_check_false(a2.appDisabled);
- do_check_true(a2.isCompatibleWith("0", "0"));
-
- a2.findUpdates({
- onCompatibilityUpdateAvailable: function(addon) {
- do_check_true(a2.isCompatible);
- do_check_false(a2.appDisabled);
- do_check_true(a2.isActive);
- },
-
- onUpdateAvailable: function(addon, install) {
- ok(false, "Should not have seen an available update");
- },
-
- onNoUpdateAvailable: function(addon) {
- do_check_eq(addon, a2);
- do_execute_soon(check_test_3);
- }
- }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
- });
- });
-
- check_test_3 = () => {
- restartManager();
- AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) {
- do_check_neq(a2, null);
- do_check_true(a2.isActive);
- do_check_true(a2.isCompatible);
- do_check_false(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) {
- do_check_neq(a3, null);
- do_check_false(a3.isActive);
- do_check_false(a3.isCompatible);
- do_check_true(a3.appDisabled);
- do_check_true(a3.isCompatibleWith("5", "5"));
- do_check_false(a3.isCompatibleWith("2", "2"));
-
- a3.findUpdates({
- sawUpdate: false,
- onCompatibilityUpdateAvailable: function(addon) {
- ok(false, "Should not have seen compatibility information");
- },
-
- onNoCompatibilityUpdateAvailable: function(addon) {
- this.sawUpdate = true;
- },
-
- onUpdateAvailable: function(addon, install) {
- ok(false, "Should not have seen an available update");
- },
-
- onNoUpdateAvailable: function(addon) {
- do_check_true(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) {
- do_check_neq(a3, null);
- do_check_false(a3.isActive);
- do_check_false(a3.isCompatible);
- do_check_true(a3.appDisabled);
- do_check_true(a3.isCompatibleWith("5", "5"));
- do_check_false(a3.isCompatibleWith("2", "2"));
-
- a3.findUpdates({
- sawUpdate: false,
- onCompatibilityUpdateAvailable: function(addon) {
- do_check_false(a3.isCompatible);
- do_check_true(a3.appDisabled);
- do_check_false(a3.isActive);
- this.sawUpdate = true;
- },
-
- onNoCompatibilityUpdateAvailable: function(addon) {
- ok(false, "Should have seen some compatibility information");
- },
-
- onUpdateAvailable: function(addon, install) {
- ok(false, "Should not have seen an available update");
- },
-
- onNoUpdateAvailable: function(addon) {
- do_check_true(this.sawUpdate);
- do_execute_soon(check_test_5);
- }
- }, AddonManager.UPDATE_WHEN_USER_REQUESTED, "3.0", "3.0");
- });
});
+}
- check_test_5 = () => {
- restartManager();
- AddonManager.getAddonByID("addon3@tests.mozilla.org", function(a3) {
- do_check_neq(a3, null);
- do_check_false(a3.isActive);
- do_check_false(a3.isCompatible);
- do_check_true(a3.appDisabled);
-
- a3.uninstall();
- run_next_test();
- });
- }
+function check_test_1(install) {
+ ensure_test_completed();
+ do_check_eq(install.state, AddonManager.STATE_DOWNLOADED);
+ run_test_2(install);
+ return false;
+}
- // Test that background update checks work
- let continue_test_6;
- add_test(function run_test_6() {
- restartManager();
+// Continue installing the update.
+function run_test_2(install) {
+ // Verify that another update check returns no new update
+ install.existingAddon.findUpdates({
+ onNoCompatibilityUpdateAvailable: function(addon) {
+ do_throw("Should not have seen onNoCompatibilityUpdateAvailable notification");
+ },
+
+ onUpdateAvailable: function(addon, install) {
+ do_throw("Should find no available update when one is already downloading");
+ },
+
+ onNoUpdateAvailable: function(addon) {
+ AddonManager.getAllInstalls(function(aInstalls) {
+ do_check_eq(aInstalls.length, 1);
+ do_check_eq(aInstalls[0], install);
+
+ prepare_test({
+ "addon1@tests.mozilla.org": [
+ "onInstalling"
+ ]
+ }, [
+ "onInstallStarted",
+ "onInstallEnded",
+ ], check_test_2);
+ install.install();
+ });
+ }
+ }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
+}
- 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();
+function check_test_2() {
+ ensure_test_completed();
- prepare_test({}, [
- "onNewInstall",
- "onDownloadStarted",
- "onDownloadEnded"
- ], continue_test_6);
+ AddonManager.getAddonByID("addon1@tests.mozilla.org", callback_soon(function(olda1) {
+ do_check_neq(olda1, null);
+ do_check_eq(olda1.version, "1.0");
+ do_check_true(isExtensionInAddonsList(profileDir, olda1.id));
- AddonManagerInternal.backgroundUpdateCheck();
- });
-
- let check_test_6;
- continue_test_6 = (install) => {
- do_check_neq(install.existingAddon, null);
- do_check_eq(install.existingAddon.id, "addon1@tests.mozilla.org");
+ shutdownManager();
- prepare_test({
- "addon1@tests.mozilla.org": [
- "onInstalling"
- ]
- }, [
- "onInstallStarted",
- "onInstallEnded",
- ], callback_soon(check_test_6));
- }
+ startupManager();
- check_test_6 = (install) => {
- do_check_eq(install.existingAddon.pendingUpgrade.install, install);
+ do_check_true(isExtensionInAddonsList(profileDir, olda1.id));
- restartManager();
AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
do_check_neq(a1, null);
do_check_eq(a1.version, "2.0");
+ do_check_true(isExtensionInAddonsList(profileDir, a1.id));
+ do_check_eq(a1.applyBackgroundUpdates, AddonManager.AUTOUPDATE_DISABLE);
do_check_eq(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) {
- do_check_neq(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));
-
- do_check_eq(req_version, "2");
-
- switch (item_id) {
- case "addon1@tests.mozilla.org":
- do_check_eq(item_version, "5.0");
- do_check_eq(item_maxappversion, "2");
- do_check_eq(item_status, "userEnabled");
- do_check_eq(app_version, "1");
- do_check_eq(update_type, "97");
- break;
- case "addon2@tests.mozilla.org":
- do_check_eq(item_version, "67.0.5b1");
- do_check_eq(item_maxappversion, "3");
- do_check_eq(item_status, "userDisabled");
- do_check_eq(app_version, "1");
- do_check_eq(update_type, "49");
- break;
- case "addon3@tests.mozilla.org":
- do_check_eq(item_version, "1.3+");
- do_check_eq(item_maxappversion, "0");
- do_check_eq(item_status, "userEnabled");
- do_check_eq(app_version, "1");
- do_check_eq(update_type, "112");
- break;
- case "addon4@tests.mozilla.org":
- do_check_eq(item_version, "0.5ab6");
- do_check_eq(item_maxappversion, "5");
- do_check_eq(item_status, "userEnabled");
- do_check_eq(app_version, "2");
- do_check_eq(update_type, "98");
- break;
- case "addon5@tests.mozilla.org":
- do_check_eq(item_version, "1.0");
- do_check_eq(item_maxappversion, "1");
- do_check_eq(item_status, "userEnabled");
- do_check_eq(app_version, "1");
- do_check_eq(update_type, "35");
- break;
- case "addon6@tests.mozilla.org":
- do_check_eq(item_version, "1.0");
- do_check_eq(item_maxappversion, "1");
- do_check_eq(item_status, "userEnabled");
- do_check_eq(app_version, "1");
- do_check_eq(update_type, "99");
- break;
- default:
- ok(false, "Update request for unexpected add-on " + item_id);
- }
-
- do_check_eq(app_id, "xpcshell@tests.mozilla.org");
- do_check_eq(current_app_version, "1");
- do_check_eq(app_os, "XPCShell");
- do_check_eq(app_abi, "noarch-spidermonkey");
- do_check_eq(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: function(addon, error) {
- if (--count == 0)
- do_execute_soon(next_test);
- }
- };
-
- let updateListener = {
- onUpdateAvailable: function(addon, update) {
- // Dummy so the update checker knows we care about new versions
- },
-
- onUpdateFinished: function(addon, error) {
- if (--count == 0)
- do_execute_soon(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) {
- do_check_true(a4.isActive, "addon4 is active");
- do_check_true(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: function(addon) {
- do_check_true(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: function(addon) {
- do_check_true(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) {
- do_check_true(a4.isActive);
- do_check_true(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) {
- do_check_neq(a7, null);
- do_check_true(a7.isActive);
- do_check_true(a7.isCompatible);
- do_check_false(a7.appDisabled);
- do_check_true(a7.isCompatibleWith("0", "0"));
-
- a7.findUpdates({
- sawUpdate: false,
- onNoCompatibilityUpdateAvailable: function(addon) {
- ok(false, "Should have seen compatibility information");
- },
-
- onUpdateAvailable: function(addon, install) {
- ok(false, "Should not have seen an available update");
- },
-
- onUpdateFinished: function(addon) {
- do_check_true(addon.isCompatible);
- do_execute_soon(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) {
- do_check_neq(a7, null);
- do_check_true(a7.isActive);
- do_check_true(a7.isCompatible);
- do_check_false(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: function(aInstall) {
- let id = aInstall.existingAddon.id;
- ok((id == "addon1@tests.mozilla.org" || id == "addon8@tests.mozilla.org"),
- "Saw unexpected onNewInstall for " + id);
- },
-
- onDownloadStarted: function(aInstall) {
- do_check_eq(aInstall.existingAddon.id, "addon1@tests.mozilla.org");
- },
-
- onDownloadEnded: function(aInstall) {
- do_check_eq(aInstall.existingAddon.id, "addon1@tests.mozilla.org");
- },
-
- onDownloadFailed: function(aInstall) {
- ok(false, "Should not have seen onDownloadFailed event");
- },
-
- onDownloadCancelled: function(aInstall) {
- ok(false, "Should not have seen onDownloadCancelled event");
- },
-
- onInstallStarted: function(aInstall) {
- do_check_eq(aInstall.existingAddon.id, "addon1@tests.mozilla.org");
- },
-
- onInstallEnded: function(aInstall) {
- do_check_eq(aInstall.existingAddon.id, "addon1@tests.mozilla.org");
- do_check_eq(aInstall.existingAddon.pendingUpgrade.install, aInstall);
-
- do_execute_soon(check_test_14);
- },
-
- onInstallFailed: function(aInstall) {
- ok(false, "Should not have seen onInstallFailed event");
- },
-
- onInstallCancelled: function(aInstall) {
- ok(false, "Should not have seen onInstallCancelled event");
- },
- });
-
- AddonManagerInternal.backgroundUpdateCheck();
- });
- });
+ do_check_true(a1.foreignInstall);
+ do_check_neq(a1.syncGUID, null);
+ do_check_eq(originalSyncGUID, a1.syncGUID);
- check_test_14 = () => {
- restartManager();
- AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
- "addon8@tests.mozilla.org"], function([a1, a8]) {
- do_check_neq(a1, null);
- do_check_eq(a1.version, "2.0");
a1.uninstall();
-
- do_check_neq(a8, null);
- do_check_eq(a8.version, "1.0");
- a8.uninstall();
-
- run_next_test();
+ do_execute_soon(run_test_3);
});
- }
-
- // 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();
- do_check_false(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: function(aInstall) {
- let id = aInstall.existingAddon.id;
- ok((id == "addon1@tests.mozilla.org" || id == "addon8@tests.mozilla.org"),
- "Saw unexpected onNewInstall for " + id);
- },
-
- onDownloadStarted: function(aInstall) {
- do_check_eq(aInstall.existingAddon.id, "addon1@tests.mozilla.org");
- },
-
- onDownloadEnded: function(aInstall) {
- do_check_eq(aInstall.existingAddon.id, "addon1@tests.mozilla.org");
- },
-
- onDownloadFailed: function(aInstall) {
- ok(false, "Should not have seen onDownloadFailed event");
- },
+ }));
+}
- onDownloadCancelled: function(aInstall) {
- ok(false, "Should not have seen onDownloadCancelled event");
- },
- onInstallStarted: function(aInstall) {
- do_check_eq(aInstall.existingAddon.id, "addon1@tests.mozilla.org");
- },
-
- onInstallEnded: function(aInstall) {
- do_check_eq(aInstall.existingAddon.id, "addon1@tests.mozilla.org");
- do_execute_soon(check_test_15);
- },
+// Check that an update check finds compatibility updates and applies them
+function run_test_3() {
+ restartManager();
- onInstallFailed: function(aInstall) {
- ok(false, "Should not have seen onInstallFailed event");
- },
+ AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) {
+ do_check_neq(a2, null);
+ do_check_true(a2.isActive);
+ do_check_true(a2.isCompatible);
+ do_check_false(a2.appDisabled);
+ do_check_true(a2.isCompatibleWith("0"));
+
+ a2.findUpdates({
+ onCompatibilityUpdateAvailable: function(addon) {
+ do_check_true(a2.isCompatible);
+ do_check_false(a2.appDisabled);
+ do_check_true(a2.isActive);
+ },
- onInstallCancelled: function(aInstall) {
- ok(false, "Should not have seen onInstallCancelled event");
- },
- });
+ onUpdateAvailable: function(addon, install) {
+ do_throw("Should not have seen an available update");
+ },
- AddonManagerInternal.backgroundUpdateCheck();
- });
+ onNoUpdateAvailable: function(addon) {
+ do_check_eq(addon, a2);
+ do_execute_soon(check_test_3);
+ }
+ }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
});
+}
- check_test_15 = () => {
- restartManager();
- AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
- "addon8@tests.mozilla.org"], function([a1, a8]) {
- do_check_neq(a1, null);
- do_check_eq(a1.version, "2.0");
- a1.uninstall();
-
- do_check_eq(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: function() {
- do_execute_soon(function install_2_1_ended() {
- restartManager();
-
- AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a1) {
- do_check_neq(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: function() {
- do_execute_soon(function install_2_2_ended() {
- restartManager();
-
- AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) {
- do_check_neq(a2.syncGUID, null);
- do_check_eq(oldGUID, a2.syncGUID);
-
- a2.uninstall();
- run_next_test();
- });
- });
- }
- });
- aInstall_2.install();
- }, "application/x-xpinstall");
- });
- });
- }
- });
- aInstall.install();
- }, "application/x-xpinstall");
+function check_test_3() {
+ restartManager();
+ AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) {
+ do_check_neq(a2, null);
+ do_check_true(a2.isActive);
+ do_check_true(a2.isCompatible);
+ do_check_false(a2.appDisabled);
+ a2.uninstall();
+
+ run_test_4();
});
+}
- // 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: function(aInstall) {
- equal(aInstall.existingAddon.id, "addon9@tests.mozilla.org",
- "Saw unexpected onNewInstall for " + aInstall.existingAddon.id);
- do_check_eq(aInstall.version, "3.0");
+// Checks that we see no compatibility information when there is none.
+function run_test_4() {
+ AddonManager.getAddonByID("addon3@tests.mozilla.org", function(a3) {
+ do_check_neq(a3, null);
+ do_check_false(a3.isActive);
+ do_check_false(a3.isCompatible);
+ do_check_true(a3.appDisabled);
+ do_check_true(a3.isCompatibleWith("5"));
+ do_check_false(a3.isCompatibleWith("2"));
+
+ a3.findUpdates({
+ sawUpdate: false,
+ onCompatibilityUpdateAvailable: function(addon) {
+ do_throw("Should not have seen compatibility information");
},
- onDownloadFailed: function(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.xml");
- Services.prefs.setCharPref(PREF_GETADDONS_BYIDS_PERFORMANCE,
- "http://localhost:" + gPort + "/data/test_update.xml");
- 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) {
- do_check_neq(a10, null);
-
- a10.findUpdates({
- onNoCompatibilityUpdateAvailable: function() {
- ok(false, "Should have seen compatibility information");
- },
+ onNoCompatibilityUpdateAvailable: function(addon) {
+ this.sawUpdate = true;
+ },
- onUpdateAvailable: function() {
- ok(false, "Should not have seen an available update");
- },
+ onUpdateAvailable: function(addon, install) {
+ do_throw("Should not have seen an available update");
+ },
- onUpdateFinished: function() {
- a10.uninstall();
- run_next_test();
- }
- }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
- });
+ onNoUpdateAvailable: function(addon) {
+ do_check_true(this.sawUpdate);
+ run_test_5();
+ }
+ }, 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) {
- do_check_neq(a11, null);
+// Checks that compatibility info for future apps are detected but don't make
+// the item compatibile.
+function run_test_5() {
+ AddonManager.getAddonByID("addon3@tests.mozilla.org", function(a3) {
+ do_check_neq(a3, null);
+ do_check_false(a3.isActive);
+ do_check_false(a3.isCompatible);
+ do_check_true(a3.appDisabled);
+ do_check_true(a3.isCompatibleWith("5"));
+ do_check_false(a3.isCompatibleWith("2"));
+
+ a3.findUpdates({
+ sawUpdate: false,
+ onCompatibilityUpdateAvailable: function(addon) {
+ do_check_false(a3.isCompatible);
+ do_check_true(a3.appDisabled);
+ do_check_false(a3.isActive);
+ this.sawUpdate = true;
+ },
- a11.findUpdates({
- onCompatibilityUpdateAvailable: function() {
- ok(false, "Should have not have seen compatibility information");
- },
+ onNoCompatibilityUpdateAvailable: function(addon) {
+ do_throw("Should have seen some compatibility information");
+ },
- onUpdateAvailable: function() {
- ok(false, "Should not have seen an available update");
- },
+ onUpdateAvailable: function(addon, install) {
+ do_throw("Should not have seen an available update");
+ },
- onUpdateFinished: function() {
- a11.uninstall();
- run_next_test();
- }
- }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
- });
+ onNoUpdateAvailable: function(addon) {
+ do_check_true(this.sawUpdate);
+ do_execute_soon(check_test_5);
+ }
+ }, AddonManager.UPDATE_WHEN_USER_REQUESTED, "3.0");
});
+}
- // 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();
+function check_test_5() {
+ restartManager();
+ AddonManager.getAddonByID("addon3@tests.mozilla.org", function(a3) {
+ do_check_neq(a3, null);
+ do_check_false(a3.isActive);
+ do_check_false(a3.isCompatible);
+ do_check_true(a3.appDisabled);
+
+ a3.uninstall();
+ do_execute_soon(run_test_6);
});
+}
- let check_test_20;
- continue_test_20 = (install) => {
- do_check_neq(install.existingAddon, null);
- do_check_eq(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) => {
- do_check_eq(install.existingAddon.pendingUpgrade.install, install);
-
- restartManager();
- AddonManager.getAddonByID("addon12@tests.mozilla.org", function(a12) {
- do_check_neq(a12, null);
- do_check_eq(a12.version, "2.0");
- do_check_eq(a12.type, "extension");
- a12.uninstall();
+// Test that background update checks work
+function run_test_6() {
+ restartManager();
- do_execute_soon(() => {
- restartManager();
- run_next_test()
- });
- });
- }
+ writeInstallRDFForExtension({
+ id: "addon1@tests.mozilla.org",
+ version: "1.0",
+ updateURL: "http://localhost:" + gPort + "/data/test_update.rdf",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "1",
+ maxVersion: "1"
+ }],
+ name: "Test Addon 1",
+ }, profileDir);
+ restartManager();
- add_task(function* cleanup() {
- let addons = yield new Promise(resolve => {
- AddonManager.getAddonsByTypes(["extension"], resolve);
- });
+ prepare_test({}, [
+ "onNewInstall",
+ "onDownloadStarted",
+ "onDownloadEnded"
+ ], continue_test_6);
- for (let addon of addons)
- addon.uninstall();
+ AddonManagerInternal.backgroundUpdateCheck();
+}
- yield promiseRestartManager();
+function continue_test_6(install) {
+ do_check_neq(install.existingAddon, null);
+ do_check_eq(install.existingAddon.id, "addon1@tests.mozilla.org");
+
+ prepare_test({
+ "addon1@tests.mozilla.org": [
+ "onInstalling"
+ ]
+ }, [
+ "onInstallStarted",
+ "onInstallEnded",
+ ], callback_soon(check_test_6));
+}
- shutdownManager();
+function check_test_6(install) {
+ do_check_eq(install.existingAddon.pendingUpgrade.install, install);
- yield new Promise(do_execute_soon);
+ restartManager();
+ AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
+ do_check_neq(a1, null);
+ do_check_eq(a1.version, "2.0");
+ do_check_eq(a1.releaseNotesURI.spec, "http://example.com/updateInfo.xhtml");
+ a1.uninstall();
+ do_execute_soon(run_test_7);
});
}
// Test that background update checks work for lightweight themes
-add_test(function run_test_7() {
- startupManager();
+function run_test_7() {
+ restartManager();
LightweightThemeManager.currentTheme = {
id: "1",
@@ -1262,7 +484,7 @@ add_test(function run_test_7() {
AddonManagerInternal.backgroundUpdateCheck();
});
-});
+}
function check_test_7() {
AddonManager.getAddonByID("1@personas.mozilla.org", function(p1) {
@@ -1279,13 +501,13 @@ function check_test_7() {
gInstallDate = p1.installDate.getTime();
- run_next_test();
+ run_test_7_cache();
});
}
// Test that background update checks for lightweight themes do not use the cache
// The update body from test 7 shouldn't be used since the cache should be bypassed.
-add_test(function () {
+function run_test_7_cache() {
// XXX The lightweight theme manager strips non-https updateURLs so hack it
// back in.
let themes = JSON.parse(Services.prefs.getCharPref("lightweightThemes.usedThemes"));
@@ -1328,7 +550,7 @@ add_test(function () {
AddonManagerInternal.backgroundUpdateCheck();
});
-});
+}
function check_test_7_cache() {
AddonManager.getAddonByID("1@personas.mozilla.org", function(p1) {
@@ -1349,19 +571,579 @@ function check_test_7_cache() {
do_check_eq(p1.installDate.getTime(), gInstallDate);
do_check_true(p1.installDate.getTime() < p1.updateDate.getTime());
- run_next_test();
+ do_execute_soon(run_test_8);
+ });
+}
+
+// Verify the parameter escaping in update urls.
+function run_test_8() {
+ writeInstallRDFForExtension({
+ id: "addon1@tests.mozilla.org",
+ version: "5.0",
+ updateURL: "http://localhost:" + gPort + "/data/param_test.rdf" + PARAMS,
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ 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: "xpcshell@tests.mozilla.org",
+ 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: "xpcshell@tests.mozilla.org",
+ 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: "xpcshell@tests.mozilla.org",
+ 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: "xpcshell@tests.mozilla.org",
+ 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) {
+ do_check_neq(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] =
+ [decodeURIComponent(a) for each (a in request.queryString.split("/"))];
+
+ do_check_eq(req_version, "2");
+
+ switch(item_id) {
+ case "addon1@tests.mozilla.org":
+ do_check_eq(item_version, "5.0");
+ do_check_eq(item_maxappversion, "2");
+ do_check_eq(item_status, "userEnabled");
+ do_check_eq(app_version, "1");
+ do_check_eq(update_type, "97");
+ break;
+ case "addon2@tests.mozilla.org":
+ do_check_eq(item_version, "67.0.5b1");
+ do_check_eq(item_maxappversion, "3");
+ do_check_eq(item_status, "userDisabled");
+ do_check_eq(app_version, "1");
+ do_check_eq(update_type, "49");
+ break;
+ case "addon3@tests.mozilla.org":
+ do_check_eq(item_version, "1.3+");
+ do_check_eq(item_maxappversion, "0");
+ do_check_eq(item_status, "userEnabled");
+ do_check_eq(app_version, "1");
+ do_check_eq(update_type, "112");
+ break;
+ case "addon4@tests.mozilla.org":
+ do_check_eq(item_version, "0.5ab6");
+ do_check_eq(item_maxappversion, "5");
+ do_check_eq(item_status, "userEnabled");
+ do_check_eq(app_version, "2");
+ do_check_eq(update_type, "98");
+ break;
+ case "addon5@tests.mozilla.org":
+ do_check_eq(item_version, "1.0");
+ do_check_eq(item_maxappversion, "1");
+ do_check_eq(item_status, "userEnabled");
+ do_check_eq(app_version, "1");
+ do_check_eq(update_type, "35");
+ break;
+ case "addon6@tests.mozilla.org":
+ do_check_eq(item_version, "1.0");
+ do_check_eq(item_maxappversion, "1");
+ do_check_eq(item_status, "userEnabled");
+ do_check_eq(app_version, "1");
+ do_check_eq(update_type, "99");
+ break;
+ default:
+ do_throw("Update request for unexpected add-on " + item_id);
+ }
+
+ do_check_eq(app_id, "xpcshell@tests.mozilla.org");
+ do_check_eq(current_app_version, "1");
+ do_check_eq(app_os, "XPCShell");
+ do_check_eq(app_abi, "noarch-spidermonkey");
+ do_check_eq(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, a2, a3, a4, a5, a6]) {
+ let count = 6;
+
+ function run_next_test() {
+ a1.uninstall();
+ a2.uninstall();
+ a3.uninstall();
+ a4.uninstall();
+ a5.uninstall();
+ a6.uninstall();
+
+ restartManager();
+ run_test_9();
+ }
+
+ let compatListener = {
+ onUpdateFinished: function(addon, error) {
+ if (--count == 0)
+ do_execute_soon(run_next_test);
+ }
+ };
+
+ let updateListener = {
+ onUpdateAvailable: function(addon, update) {
+ // Dummy so the update checker knows we care about new versions
+ },
+
+ onUpdateFinished: function(addon, error) {
+ if (--count == 0)
+ do_execute_soon(run_next_test);
+ }
+ };
+
+ a1.findUpdates(updateListener, AddonManager.UPDATE_WHEN_USER_REQUESTED);
+ a2.findUpdates(compatListener, AddonManager.UPDATE_WHEN_ADDON_INSTALLED);
+ a3.findUpdates(updateListener, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE);
+ a4.findUpdates(updateListener, AddonManager.UPDATE_WHEN_NEW_APP_DETECTED, "2");
+ a5.findUpdates(compatListener, AddonManager.UPDATE_WHEN_NEW_APP_INSTALLED);
+ a6.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.
+function run_test_9() {
+ writeInstallRDFForExtension({
+ id: "addon4@tests.mozilla.org",
+ version: "5.0",
+ updateURL: "http://localhost:" + gPort + "/data/test_update.rdf",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "0",
+ maxVersion: "1"
+ }],
+ name: "Test Addon 1",
+ }, profileDir);
+
+ restartManager();
+
+ AddonManager.getAddonByID("addon4@tests.mozilla.org", function(a4) {
+ do_check_true(a4.isActive);
+ do_check_true(a4.isCompatible);
+
+ run_test_10();
+ });
+}
+
+// Tests that a normal update check won't decrease a targetApplication's
+// maxVersion.
+function run_test_10() {
+ AddonManager.getAddonByID("addon4@tests.mozilla.org", function(a4) {
+ a4.findUpdates({
+ onUpdateFinished: function(addon) {
+ do_check_true(addon.isCompatible);
+
+ run_test_11();
+ }
+ }, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE);
+ });
+}
+
+// Tests that an update check for a new application will decrease a
+// targetApplication's maxVersion.
+function run_test_11() {
+ AddonManager.getAddonByID("addon4@tests.mozilla.org", function(a4) {
+ a4.findUpdates({
+ onUpdateFinished: function(addon) {
+ do_check_true(addon.isCompatible);
+
+ do_execute_soon(run_test_12);
+ }
+ }, AddonManager.UPDATE_WHEN_NEW_APP_INSTALLED);
+ });
+}
+
+// Check that the decreased maxVersion applied and disables the add-on
+function run_test_12() {
+ restartManager();
+
+ AddonManager.getAddonByID("addon4@tests.mozilla.org", function(a4) {
+ do_check_true(a4.isActive);
+ do_check_true(a4.isCompatible);
+
+ a4.uninstall();
+ do_execute_soon(run_test_13);
+ });
+}
+
+// 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.
+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/test_update.rdf",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "0",
+ maxVersion: "0"
+ }],
+ name: "Test Addon 7",
+ }, profileDir);
+ restartManager();
+
+ AddonManager.getAddonByID("addon7@tests.mozilla.org", function(a7) {
+ do_check_neq(a7, null);
+ do_check_true(a7.isActive);
+ do_check_true(a7.isCompatible);
+ do_check_false(a7.appDisabled);
+ do_check_true(a7.isCompatibleWith("0"));
+
+ a7.findUpdates({
+ sawUpdate: false,
+ onNoCompatibilityUpdateAvailable: function(addon) {
+ do_throw("Should have seen compatibility information");
+ },
+
+ onUpdateAvailable: function(addon, install) {
+ do_throw("Should not have seen an available update");
+ },
+
+ onUpdateFinished: function(addon) {
+ do_check_true(addon.isCompatible);
+ do_execute_soon(check_test_13);
+ }
+ }, AddonManager.UPDATE_WHEN_NEW_APP_DETECTED, "3.0");
});
}
-// Test that the update check returns nothing for addons in locked install
-// locations.
-add_test(function run_test_locked_install() {
- const lockedDir = gProfD.clone();
- lockedDir.append("locked_extensions");
- registerDirectory("XREAppFeat", lockedDir);
+function check_test_13() {
restartManager();
+ AddonManager.getAddonByID("addon7@tests.mozilla.org", function(a7) {
+ do_check_neq(a7, null);
+ do_check_true(a7.isActive);
+ do_check_true(a7.isCompatible);
+ do_check_false(a7.appDisabled);
+
+ a7.uninstall();
+ do_execute_soon(run_test_14);
+ });
+}
+
+// Test that background update checks doesn't update an add-on that isn't
+// allowed to update automatically.
+function run_test_14() {
+ restartManager();
+
+ // Have an add-on there that will be updated so we see some events from it
writeInstallRDFForExtension({
- id: "addon13@tests.mozilla.org",
+ id: "addon1@tests.mozilla.org",
+ version: "1.0",
+ updateURL: "http://localhost:" + gPort + "/data/test_update.rdf",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "1",
+ maxVersion: "1"
+ }],
+ name: "Test Addon 1",
+ }, profileDir);
+
+ writeInstallRDFForExtension({
+ id: "addon8@tests.mozilla.org",
+ version: "1.0",
+ updateURL: "http://localhost:" + gPort + "/data/test_update.rdf",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ 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: function(aInstall) {
+ if (aInstall.existingAddon.id != "addon1@tests.mozilla.org" &&
+ aInstall.existingAddon.id != "addon8@tests.mozilla.org")
+ do_throw("Saw unexpected onNewInstall for " + aInstall.existingAddon.id);
+ },
+
+ onDownloadStarted: function(aInstall) {
+ do_check_eq(aInstall.existingAddon.id, "addon1@tests.mozilla.org");
+ },
+
+ onDownloadEnded: function(aInstall) {
+ do_check_eq(aInstall.existingAddon.id, "addon1@tests.mozilla.org");
+ },
+
+ onDownloadFailed: function(aInstall) {
+ do_throw("Should not have seen onDownloadFailed event");
+ },
+
+ onDownloadCancelled: function(aInstall) {
+ do_throw("Should not have seen onDownloadCancelled event");
+ },
+
+ onInstallStarted: function(aInstall) {
+ do_check_eq(aInstall.existingAddon.id, "addon1@tests.mozilla.org");
+ },
+
+ onInstallEnded: function(aInstall) {
+ do_check_eq(aInstall.existingAddon.id, "addon1@tests.mozilla.org");
+ do_check_eq(aInstall.existingAddon.pendingUpgrade.install, aInstall);
+
+ do_execute_soon(check_test_14);
+ },
+
+ onInstallFailed: function(aInstall) {
+ do_throw("Should not have seen onInstallFailed event");
+ },
+
+ onInstallCancelled: function(aInstall) {
+ do_throw("Should not have seen onInstallCancelled event");
+ },
+ });
+
+ AddonManagerInternal.backgroundUpdateCheck();
+ });
+}
+
+function check_test_14() {
+ restartManager();
+ AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
+ "addon8@tests.mozilla.org"], function([a1, a8]) {
+ do_check_neq(a1, null);
+ do_check_eq(a1.version, "2.0");
+ a1.uninstall();
+
+ do_check_neq(a8, null);
+ do_check_eq(a8.version, "1.0");
+ a8.uninstall();
+
+ do_execute_soon(run_test_15);
+ });
+}
+
+// Test that background update checks doesn't update an add-on that is
+// pending uninstall
+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/test_update.rdf",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "1",
+ maxVersion: "1"
+ }],
+ name: "Test Addon 1",
+ }, profileDir);
+
+ writeInstallRDFForExtension({
+ id: "addon8@tests.mozilla.org",
+ version: "1.0",
+ updateURL: "http://localhost:" + gPort + "/data/test_update.rdf",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "1",
+ maxVersion: "1"
+ }],
+ name: "Test Addon 8",
+ }, profileDir);
+ restartManager();
+
+ AddonManager.getAddonByID("addon8@tests.mozilla.org", function(a8) {
+ a8.uninstall();
+ do_check_false(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: function(aInstall) {
+ if (aInstall.existingAddon.id != "addon1@tests.mozilla.org" &&
+ aInstall.existingAddon.id != "addon8@tests.mozilla.org")
+ do_throw("Saw unexpected onNewInstall for " + aInstall.existingAddon.id);
+ },
+
+ onDownloadStarted: function(aInstall) {
+ do_check_eq(aInstall.existingAddon.id, "addon1@tests.mozilla.org");
+ },
+
+ onDownloadEnded: function(aInstall) {
+ do_check_eq(aInstall.existingAddon.id, "addon1@tests.mozilla.org");
+ },
+
+ onDownloadFailed: function(aInstall) {
+ do_throw("Should not have seen onDownloadFailed event");
+ },
+
+ onDownloadCancelled: function(aInstall) {
+ do_throw("Should not have seen onDownloadCancelled event");
+ },
+
+ onInstallStarted: function(aInstall) {
+ do_check_eq(aInstall.existingAddon.id, "addon1@tests.mozilla.org");
+ },
+
+ onInstallEnded: function(aInstall) {
+ do_check_eq(aInstall.existingAddon.id, "addon1@tests.mozilla.org");
+ do_execute_soon(check_test_15);
+ },
+
+ onInstallFailed: function(aInstall) {
+ do_throw("Should not have seen onInstallFailed event");
+ },
+
+ onInstallCancelled: function(aInstall) {
+ do_throw("Should not have seen onInstallCancelled event");
+ },
+ });
+
+ AddonManagerInternal.backgroundUpdateCheck();
+ });
+}
+
+function check_test_15() {
+ restartManager();
+ AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
+ "addon8@tests.mozilla.org"], function([a1, a8]) {
+ do_check_neq(a1, null);
+ do_check_eq(a1.version, "2.0");
+ a1.uninstall();
+
+ do_check_eq(a8, null);
+
+ do_execute_soon(run_test_16);
+ });
+}
+
+function run_test_16() {
+ restartManager();
+
+ restartManager();
+
+ let url = "http://localhost:" + gPort + "/addons/test_install2_1.xpi";
+ AddonManager.getInstallForURL(url, function(aInstall) {
+ aInstall.addListener({
+ onInstallEnded: function() {
+ do_execute_soon(function install_2_1_ended() {
+ restartManager();
+
+ AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a1) {
+ do_check_neq(a1.syncGUID, null);
+ let oldGUID = a1.syncGUID;
+
+ let url = "http://localhost:" + gPort + "/addons/test_install2_2.xpi";
+ AddonManager.getInstallForURL(url, function(aInstall) {
+ aInstall.addListener({
+ onInstallEnded: function() {
+ do_execute_soon(function install_2_2_ended() {
+ restartManager();
+
+ AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) {
+ do_check_neq(a2.syncGUID, null);
+ do_check_eq(oldGUID, a2.syncGUID);
+
+ a2.uninstall();
+ do_execute_soon(run_test_17);
+ });
+ });
+ }
+ });
+ aInstall.install();
+ }, "application/x-xpinstall");
+ });
+ });
+ }
+ });
+ aInstall.install();
+ }, "application/x-xpinstall");
+}
+
+// Test that the update check correctly observes the
+// extensions.strictCompatibility pref and compatibility overrides.
+function run_test_17() {
+ restartManager();
+
+ writeInstallRDFForExtension({
+ id: "addon9@tests.mozilla.org",
version: "1.0",
updateURL: "http://localhost:" + gPort + "/data/test_update.rdf",
targetApplications: [{
@@ -1369,30 +1151,160 @@ add_test(function run_test_locked_install() {
minVersion: "0.1",
maxVersion: "0.2"
}],
- name: "Test Addon 13",
- }, lockedDir);
+ name: "Test Addon 9",
+ }, profileDir);
restartManager();
- AddonManager.getAddonByID("addon13@tests.mozilla.org", function(a13) {
- do_check_neq(a13, null);
+ AddonManager.addInstallListener({
+ onNewInstall: function(aInstall) {
+ if (aInstall.existingAddon.id != "addon9@tests.mozilla.org")
+ do_throw("Saw unexpected onNewInstall for " + aInstall.existingAddon.id);
+ do_check_eq(aInstall.version, "3.0");
+ },
+ onDownloadFailed: function(aInstall) {
+ AddonManager.getAddonByID("addon9@tests.mozilla.org", function(a9) {
+ a9.uninstall();
+ do_execute_soon(run_test_18);
+ });
+ }
+ });
- a13.findUpdates({
- onCompatibilityUpdateAvailable: function() {
- ok(false, "Should have not have seen compatibility information");
+ Services.prefs.setCharPref(PREF_GETADDONS_BYIDS,
+ "http://localhost:" + gPort + "/data/test_update.xml");
+ Services.prefs.setCharPref(PREF_GETADDONS_BYIDS_PERFORMANCE,
+ "http://localhost:" + gPort + "/data/test_update.xml");
+ 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.
+function run_test_18() {
+ restartManager();
+ writeInstallRDFForExtension({
+ id: "addon10@tests.mozilla.org",
+ version: "1.0",
+ updateURL: "http://localhost:" + gPort + "/data/test_update.rdf",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "0.1",
+ maxVersion: "0.2"
+ }],
+ name: "Test Addon 10",
+ }, profileDir);
+ restartManager();
+
+ AddonManager.getAddonByID("addon10@tests.mozilla.org", function(a10) {
+ do_check_neq(a10, null);
+
+ a10.findUpdates({
+ onNoCompatibilityUpdateAvailable: function() {
+ do_throw("Should have seen compatibility information");
},
onUpdateAvailable: function() {
- ok(false, "Should not have seen an available update");
+ do_throw("Should not have seen an available update");
},
onUpdateFinished: function() {
- ok(true, "Should have seen an onUpdateFinished");
+ a10.uninstall();
+ do_execute_soon(run_test_19);
}
}, AddonManager.UPDATE_WHEN_USER_REQUESTED);
});
+}
- AddonManager.getAllInstalls(aInstalls => {
- do_check_eq(aInstalls.length, 0);
+// Test that the update check correctly observes when an addon opts-in to
+// strict compatibility checking.
+function run_test_19() {
+ restartManager();
+ writeInstallRDFForExtension({
+ id: "addon11@tests.mozilla.org",
+ version: "1.0",
+ updateURL: "http://localhost:" + gPort + "/data/test_update.rdf",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "0.1",
+ maxVersion: "0.2"
+ }],
+ name: "Test Addon 11",
+ }, profileDir);
+ restartManager();
+
+ AddonManager.getAddonByID("addon11@tests.mozilla.org", function(a11) {
+ do_check_neq(a11, null);
+
+ a11.findUpdates({
+ onCompatibilityUpdateAvailable: function() {
+ do_throw("Should have not have seen compatibility information");
+ },
+
+ onUpdateAvailable: function() {
+ do_throw("Should not have seen an available update");
+ },
+
+ onUpdateFinished: function() {
+ a11.uninstall();
+ do_execute_soon(run_test_20);
+ }
+ }, 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
+function run_test_20() {
+ restartManager();
+ writeInstallRDFForExtension({
+ id: "addon12@tests.mozilla.org",
+ version: "1.0",
+ updateURL: "http://localhost:" + gPort + "/data/test_update.rdf",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "1",
+ maxVersion: "1"
+ }],
+ name: "Test Addon 12",
+ }, profileDir);
+ restartManager();
+
+ prepare_test({}, [
+ "onNewInstall",
+ "onDownloadStarted",
+ "onDownloadEnded"
+ ], continue_test_20);
+
+ AddonManagerPrivate.backgroundUpdateCheck();
+}
+
+function continue_test_20(install) {
+ do_check_neq(install.existingAddon, null);
+ do_check_eq(install.existingAddon.id, "addon12@tests.mozilla.org");
+
+ prepare_test({
+ "addon12@tests.mozilla.org": [
+ "onInstalling"
+ ]
+ }, [
+ "onInstallStarted",
+ "onInstallEnded",
+ ], callback_soon(check_test_20));
+}
+
+function check_test_20(install) {
+ do_check_eq(install.existingAddon.pendingUpgrade.install, install);
+
+ restartManager();
+ AddonManager.getAddonByID("addon12@tests.mozilla.org", function(a12) {
+ do_check_neq(a12, null);
+ do_check_eq(a12.version, "2.0");
+ do_check_eq(a12.type, "extension");
+ a12.uninstall();
+
+ do_execute_soon(() => {
+ restartManager();
+ end_test();
+ });
});
- run_next_test();
-});
+}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_updateCancel.js b/toolkit/mozapps/extensions/test/xpcshell/test_updateCancel.js
index b50fd4a55..d513f4adf 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_updateCancel.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_updateCancel.js
@@ -50,8 +50,9 @@ function makeCancelListener() {
}
// Set up the HTTP server so that we can control when it responds
-var httpReceived = Promise.defer();
+let httpReceived = Promise.defer();
function dataHandler(aRequest, aResponse) {
+ asyncResponse = aResponse;
aResponse.processAsync();
httpReceived.resolve([aRequest, aResponse]);
}
@@ -74,7 +75,7 @@ writeInstallRDFForExtension({
name: "Test Addon 1",
}, profileDir);
-add_task(function* cancel_during_check() {
+add_task(function cancel_during_check() {
startupManager();
let a1 = yield promiseAddonByID("addon1@tests.mozilla.org");
@@ -108,7 +109,7 @@ add_task(function* cancel_during_check() {
// Test that update check is cancelled if the XPI provider shuts down while
// the update check is in progress
-add_task(function* shutdown_during_check() {
+add_task(function shutdown_during_check() {
// Reset our HTTP listener
httpReceived = Promise.defer();
@@ -134,5 +135,8 @@ add_task(function* shutdown_during_check() {
response.write(data);
response.finish();
+ // trying to cancel again should return false, i.e. nothing to cancel
+ do_check_false(a1.cancelUpdate());
+
yield testserver.stop(Promise.defer().resolve);
});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_update_compatmode.js b/toolkit/mozapps/extensions/test/xpcshell/test_update_compatmode.js
index a1d872009..6043b1792 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_update_compatmode.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_update_compatmode.js
@@ -98,7 +98,7 @@ function run_test_1() {
do_throw("Should have seen an available update");
},
- onUpdateAvailable: function(unused, install) {
+ onUpdateAvailable: function(addon, install) {
do_check_eq(install.version, "2.0")
},
@@ -124,7 +124,7 @@ function run_test_2() {
do_throw("Should have seen an available update");
},
- onUpdateAvailable: function(unused, install) {
+ onUpdateAvailable: function(addon, install) {
do_check_eq(install.version, "2.0")
},
@@ -146,7 +146,7 @@ function run_test_3() {
do_throw("Should have not have seen compatibility information");
},
- onUpdateAvailable: function() {
+ onUpdateAvailable: function(addon, install) {
do_throw("Should not have seen an available update");
},
@@ -172,7 +172,7 @@ function run_test_4() {
do_throw("Should have seen an available update");
},
- onUpdateAvailable: function(unused, install) {
+ onUpdateAvailable: function(addon, install) {
do_check_eq(install.version, "2.0")
},
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_update_ignorecompat.js b/toolkit/mozapps/extensions/test/xpcshell/test_update_ignorecompat.js
index e899619d6..672594088 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_update_ignorecompat.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_update_ignorecompat.js
@@ -9,12 +9,12 @@ const PREF_GETADDONS_CACHE_ENABLED = "extensions.getAddons.cache.enabled";
// The test extension uses an insecure update url.
Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false);
-Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, false);
-var testserver = createHttpServer();
+Components.utils.import("resource://testing-common/httpd.js");
+var testserver = new HttpServer();
+testserver.start(-1);
gPort = testserver.identity.primaryPort;
mapFile("/data/test_update.rdf", testserver);
-mapFile("/data/test_update.json", testserver);
mapFile("/data/test_update.xml", testserver);
testserver.registerDirectory("/addons/", do_get_file("addons"));
@@ -22,86 +22,77 @@ const profileDir = gProfD.clone();
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" },
-];
-
-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);
-
- restartManager();
-
- AddonManager.addInstallListener({
- onNewInstall: function(aInstall) {
- if (aInstall.existingAddon.id != "addon9@tests.mozilla.org")
- do_throw("Saw unexpected onNewInstall for " + aInstall.existingAddon.id);
- do_check_eq(aInstall.version, "4.0");
- },
- onDownloadFailed: function(aInstall) {
- run_next_test();
- }
- });
+function run_test() {
+ createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
- Services.prefs.setCharPref(PREF_GETADDONS_BYIDS_PERFORMANCE,
- "http://localhost:" + gPort + "/data/" + updateFile);
- Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true);
+ run_test_1();
+}
- AddonManagerInternal.backgroundUpdateCheck();
+// Test that the update check correctly observes the
+// extensions.strictCompatibility pref and compatibility overrides.
+function run_test_1() {
+ writeInstallRDFForExtension({
+ id: "addon9@tests.mozilla.org",
+ version: "1.0",
+ updateURL: "http://localhost:" + gPort + "/data/test_update.rdf",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "0.1",
+ maxVersion: "0.2"
+ }],
+ name: "Test Addon 9",
+ }, profileDir);
+ restartManager();
+
+ AddonManager.addInstallListener({
+ onNewInstall: function(aInstall) {
+ if (aInstall.existingAddon.id != "addon9@tests.mozilla.org")
+ do_throw("Saw unexpected onNewInstall for " + aInstall.existingAddon.id);
+ do_check_eq(aInstall.version, "4.0");
+ },
+ onDownloadFailed: function(aInstall) {
+ do_execute_soon(run_test_2);
+ }
});
- // 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) {
- do_check_neq(a11, null);
-
- a11.findUpdates({
- onCompatibilityUpdateAvailable: function() {
- do_throw("Should not have seen compatibility information");
- },
-
- onUpdateAvailable: function() {
- do_throw("Should not have seen an available update");
- },
-
- onUpdateFinished: function() {
- run_next_test();
- }
- }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
- });
+ Services.prefs.setCharPref(PREF_GETADDONS_BYIDS_PERFORMANCE,
+ "http://localhost:" + gPort + "/data/test_update.xml");
+ 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.
+function run_test_2() {
+ writeInstallRDFForExtension({
+ id: "addon11@tests.mozilla.org",
+ version: "1.0",
+ updateURL: "http://localhost:" + gPort + "/data/test_update.rdf",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "0.1",
+ maxVersion: "0.2"
+ }],
+ name: "Test Addon 11",
+ }, profileDir);
+ restartManager();
+
+ AddonManager.getAddonByID("addon11@tests.mozilla.org", function(a11) {
+ do_check_neq(a11, null);
+
+ a11.findUpdates({
+ onCompatibilityUpdateAvailable: function() {
+ do_throw("Should have not have seen compatibility information");
+ },
+
+ onNoUpdateAvailable: function() {
+ do_throw("Should have seen an available update");
+ },
+
+ onUpdateFinished: function() {
+ end_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 2b1f65a9f..0474535f1 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_update_strictcompat.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_update_strictcompat.js
@@ -9,8 +9,7 @@ const PREF_SELECTED_LOCALE = "general.useragent.locale";
const PREF_GETADDONS_CACHE_ENABLED = "extensions.getAddons.cache.enabled";
// The test extension uses an insecure update url.
-Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false);
-Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, true);
+Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
// This test requires lightweight themes update to be enabled even if the app
// doesn't support lightweight themes.
Services.prefs.setBoolPref("lightweightThemes.update.enabled", true);
@@ -23,10 +22,11 @@ const PARAMS = "?%REQ_VERSION%/%ITEM_ID%/%ITEM_VERSION%/%ITEM_MAXAPPVERSION%/" +
var gInstallDate;
-var testserver = createHttpServer();
+Components.utils.import("resource://testing-common/httpd.js");
+var testserver = new HttpServer();
+testserver.start(-1);
gPort = testserver.identity.primaryPort;
mapFile("/data/test_update.rdf", testserver);
-mapFile("/data/test_update.json", testserver);
mapFile("/data/test_update.xml", testserver);
testserver.registerDirectory("/addons/", do_get_file("addons"));
@@ -34,1013 +34,383 @@ const profileDir = gProfD.clone();
profileDir.append("extensions");
function run_test() {
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
-
+ createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
Services.prefs.setBoolPref(PREF_MATCH_OS_LOCALE, false);
Services.prefs.setCharPref(PREF_SELECTED_LOCALE, "fr-FR");
+ Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, true);
+
+ writeInstallRDFForExtension({
+ id: "addon1@tests.mozilla.org",
+ version: "1.0",
+ updateURL: "http://localhost:" + gPort + "/data/test_update.rdf",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "1",
+ maxVersion: "1"
+ }],
+ name: "Test Addon 1",
+ }, profileDir);
+
+ writeInstallRDFForExtension({
+ id: "addon2@tests.mozilla.org",
+ version: "1.0",
+ updateURL: "http://localhost:" + gPort + "/data/test_update.rdf",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "0",
+ maxVersion: "0"
+ }],
+ name: "Test Addon 2",
+ }, profileDir);
+
+ writeInstallRDFForExtension({
+ id: "addon3@tests.mozilla.org",
+ version: "1.0",
+ updateURL: "http://localhost:" + gPort + "/data/test_update.rdf",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "5",
+ maxVersion: "5"
+ }],
+ name: "Test Addon 3",
+ }, profileDir);
- run_next_test();
-}
-
-let testParams = [
- { updateFile: "test_update.rdf",
- appId: "xpcshell@tests.mozilla.org" },
- { updateFile: "test_update.json",
- 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);
-
- 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);
-
- startupManager();
-
- 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) {
- do_check_neq(a1, null);
- do_check_eq(a1.version, "1.0");
- do_check_eq(a1.applyBackgroundUpdates, AddonManager.AUTOUPDATE_DEFAULT);
- do_check_eq(a1.releaseNotesURI, null);
-
- a1.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DEFAULT;
+ startupManager();
- prepare_test({
- "addon1@tests.mozilla.org": [
- ["onPropertyChanged", ["applyBackgroundUpdates"]]
- ]
- });
- a1.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE;
- check_test_completed();
+ do_test_pending();
+ run_test_1();
+}
- a1.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE;
+function end_test() {
+ Services.prefs.clearUserPref(PREF_EM_STRICT_COMPATIBILITY);
- prepare_test({}, [
- "onNewInstall",
- ]);
+ testserver.stop(do_test_finished);
+}
- a1.findUpdates({
- onNoCompatibilityUpdateAvailable: function(addon) {
- ok(false, "Should not have seen onNoCompatibilityUpdateAvailable notification");
- },
+// Verify that an update is available and can be installed.
+function run_test_1() {
+ AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
+ do_check_neq(a1, null);
+ do_check_eq(a1.version, "1.0");
+ do_check_eq(a1.applyBackgroundUpdates, AddonManager.AUTOUPDATE_DEFAULT);
+ do_check_eq(a1.releaseNotesURI, null);
- onUpdateAvailable: function(addon, install) {
- ensure_test_completed();
-
- AddonManager.getAllInstalls(function(aInstalls) {
- do_check_eq(aInstalls.length, 1);
- do_check_eq(aInstalls[0], install);
-
- do_check_eq(addon, a1);
- do_check_eq(install.name, addon.name);
- do_check_eq(install.version, "2.0");
- do_check_eq(install.state, AddonManager.STATE_AVAILABLE);
- do_check_eq(install.existingAddon, addon);
- do_check_eq(install.releaseNotesURI.spec, "http://example.com/updateInfo.xhtml");
-
- // Verify that another update check returns the same AddonInstall
- a1.findUpdates({
- onNoCompatibilityUpdateAvailable: function() {
- ok(false, "Should not have seen onNoCompatibilityUpdateAvailable notification");
- },
-
- onUpdateAvailable: function(newAddon, newInstall) {
- AddonManager.getAllInstalls(function(aInstalls2) {
- do_check_eq(aInstalls2.length, 1);
- do_check_eq(aInstalls2[0], install);
- do_check_eq(newAddon, addon);
- do_check_eq(newInstall, install);
-
- prepare_test({}, [
- "onDownloadStarted",
- "onDownloadEnded",
- ], check_test_1);
- install.install();
- });
- },
-
- onNoUpdateAvailable: function() {
- ok(false, "Should not have seen onNoUpdateAvailable notification");
- }
- }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
- });
- },
+ a1.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DEFAULT;
- onNoUpdateAvailable: function(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();
- do_check_eq(install.state, AddonManager.STATE_DOWNLOADED);
- run_test_2(install);
- return false;
- };
+ a1.applyBackgroundUpdates = AddonManager.AUTOUPDATE_DISABLE;
+
+ prepare_test({}, [
+ "onNewInstall",
+ ]);
- // Continue installing the update.
- let check_test_2;
- run_test_2 = (install) => {
- // Verify that another update check returns no new update
- install.existingAddon.findUpdates({
+ a1.findUpdates({
onNoCompatibilityUpdateAvailable: function(addon) {
- ok(false, "Should not have seen onNoCompatibilityUpdateAvailable notification");
+ do_throw("Should not have seen onNoCompatibilityUpdateAvailable notification");
},
- onUpdateAvailable: function() {
- ok(false, "Should find no available update when one is already downloading");
- },
+ onUpdateAvailable: function(addon, install) {
+ ensure_test_completed();
- onNoUpdateAvailable: function(addon) {
AddonManager.getAllInstalls(function(aInstalls) {
do_check_eq(aInstalls.length, 1);
do_check_eq(aInstalls[0], install);
- prepare_test({
- "addon1@tests.mozilla.org": [
- "onInstalling"
- ]
- }, [
- "onInstallStarted",
- "onInstallEnded",
- ], check_test_2);
- install.install();
+ do_check_eq(addon, a1);
+ do_check_eq(install.name, addon.name);
+ do_check_eq(install.version, "2.0");
+ do_check_eq(install.state, AddonManager.STATE_AVAILABLE);
+ do_check_eq(install.existingAddon, addon);
+ do_check_eq(install.releaseNotesURI.spec, "http://example.com/updateInfo.xhtml");
+
+ // Verify that another update check returns the same AddonInstall
+ a1.findUpdates({
+ onNoCompatibilityUpdateAvailable: function(addon) {
+ do_throw("Should not have seen onNoCompatibilityUpdateAvailable notification");
+ },
+
+ onUpdateAvailable: function(newAddon, newInstall) {
+ AddonManager.getAllInstalls(function(aInstalls) {
+ do_check_eq(aInstalls.length, 1);
+ do_check_eq(aInstalls[0], install);
+ do_check_eq(newAddon, addon);
+ do_check_eq(newInstall, install);
+
+ prepare_test({}, [
+ "onDownloadStarted",
+ "onDownloadEnded",
+ ], check_test_1);
+ install.install();
+ });
+ },
+
+ onNoUpdateAvailable: function(addon) {
+ do_throw("Should not have seen onNoUpdateAvailable notification");
+ }
+ }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
});
+ },
+
+ onNoUpdateAvailable: function(addon) {
+ do_throw("Should not have seen onNoUpdateAvailable notification");
}
}, AddonManager.UPDATE_WHEN_USER_REQUESTED);
- };
-
- check_test_2 = () => {
- ensure_test_completed();
-
- AddonManager.getAddonByID("addon1@tests.mozilla.org", callback_soon(function(olda1) {
- do_check_neq(olda1, null);
- do_check_eq(olda1.version, "1.0");
- do_check_true(isExtensionInAddonsList(profileDir, olda1.id));
-
- shutdownManager();
-
- startupManager();
-
- do_check_true(isExtensionInAddonsList(profileDir, "addon1@tests.mozilla.org"));
-
- AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
- do_check_neq(a1, null);
- do_check_eq(a1.version, "2.0");
- do_check_true(isExtensionInAddonsList(profileDir, a1.id));
- do_check_eq(a1.applyBackgroundUpdates, AddonManager.AUTOUPDATE_DISABLE);
- do_check_eq(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) {
- do_check_neq(a2, null);
- do_check_false(a2.isActive);
- do_check_false(a2.isCompatible);
- do_check_true(a2.appDisabled);
- do_check_true(a2.isCompatibleWith("0", "0"));
-
- a2.findUpdates({
- onCompatibilityUpdateAvailable: function(addon) {
- do_check_true(a2.isCompatible);
- do_check_false(a2.appDisabled);
- do_check_false(a2.isActive);
- },
-
- onUpdateAvailable: function(addon, install) {
- ok(false, "Should not have seen an available update");
- },
-
- onNoUpdateAvailable: function(addon) {
- do_check_eq(addon, a2);
- do_execute_soon(check_test_3);
- }
- }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
- });
- });
-
- check_test_3 = () => {
- restartManager();
- AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) {
- do_check_neq(a2, null);
- do_check_true(a2.isActive);
- do_check_true(a2.isCompatible);
- do_check_false(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) {
- do_check_neq(a3, null);
- do_check_false(a3.isActive);
- do_check_false(a3.isCompatible);
- do_check_true(a3.appDisabled);
- do_check_true(a3.isCompatibleWith("5", "5"));
- do_check_false(a3.isCompatibleWith("2", "2"));
-
- a3.findUpdates({
- sawUpdate: false,
- onCompatibilityUpdateAvailable: function(addon) {
- ok(false, "Should not have seen compatibility information");
- },
-
- onNoCompatibilityUpdateAvailable: function(addon) {
- this.sawUpdate = true;
- },
-
- onUpdateAvailable: function(addon, install) {
- ok(false, "Should not have seen an available update");
- },
-
- onNoUpdateAvailable: function(addon) {
- do_check_true(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) {
- do_check_neq(a3, null);
- do_check_false(a3.isActive);
- do_check_false(a3.isCompatible);
- do_check_true(a3.appDisabled);
- do_check_true(a3.isCompatibleWith("5", "5"));
- do_check_false(a3.isCompatibleWith("2", "2"));
-
- a3.findUpdates({
- sawUpdate: false,
- onCompatibilityUpdateAvailable: function(addon) {
- do_check_false(a3.isCompatible);
- do_check_true(a3.appDisabled);
- do_check_false(a3.isActive);
- this.sawUpdate = true;
- },
-
- onNoCompatibilityUpdateAvailable: function(addon) {
- ok(false, "Should have seen some compatibility information");
- },
-
- onUpdateAvailable: function(addon, install) {
- ok(false, "Should not have seen an available update");
- },
-
- onNoUpdateAvailable: function(addon) {
- do_check_true(this.sawUpdate);
- do_execute_soon(check_test_5);
- }
- }, AddonManager.UPDATE_WHEN_USER_REQUESTED, "3.0", "3.0");
- });
});
+}
- check_test_5 = () => {
- restartManager();
- AddonManager.getAddonByID("addon3@tests.mozilla.org", function(a3) {
- do_check_neq(a3, null);
- do_check_false(a3.isActive);
- do_check_false(a3.isCompatible);
- do_check_true(a3.appDisabled);
-
- a3.uninstall();
- run_next_test();
- });
- }
-
- // Test that background update checks work
- let continue_test_6;
- add_test(function run_test_6() {
- restartManager();
+function check_test_1(install) {
+ ensure_test_completed();
+ do_check_eq(install.state, AddonManager.STATE_DOWNLOADED);
+ run_test_2(install);
+ return false;
+}
- 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();
+// Continue installing the update.
+function run_test_2(install) {
+ // Verify that another update check returns no new update
+ install.existingAddon.findUpdates({
+ onNoCompatibilityUpdateAvailable: function(addon) {
+ do_throw("Should not have seen onNoCompatibilityUpdateAvailable notification");
+ },
+
+ onUpdateAvailable: function(addon, install) {
+ do_throw("Should find no available update when one is already downloading");
+ },
+
+ onNoUpdateAvailable: function(addon) {
+ AddonManager.getAllInstalls(function(aInstalls) {
+ do_check_eq(aInstalls.length, 1);
+ do_check_eq(aInstalls[0], install);
+
+ prepare_test({
+ "addon1@tests.mozilla.org": [
+ "onInstalling"
+ ]
+ }, [
+ "onInstallStarted",
+ "onInstallEnded",
+ ], check_test_2);
+ install.install();
+ });
+ }
+ }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
+}
- prepare_test({}, [
- "onNewInstall",
- "onDownloadStarted",
- "onDownloadEnded"
- ], continue_test_6);
+function check_test_2() {
+ ensure_test_completed();
- AddonManagerInternal.backgroundUpdateCheck();
- });
+ AddonManager.getAddonByID("addon1@tests.mozilla.org", callback_soon(function(olda1) {
+ do_check_neq(olda1, null);
+ do_check_eq(olda1.version, "1.0");
+ do_check_true(isExtensionInAddonsList(profileDir, olda1.id));
- let check_test_6;
- continue_test_6 = (install) => {
- do_check_neq(install.existingAddon, null);
- do_check_eq(install.existingAddon.id, "addon1@tests.mozilla.org");
+ shutdownManager();
- prepare_test({
- "addon1@tests.mozilla.org": [
- "onInstalling"
- ]
- }, [
- "onInstallStarted",
- "onInstallEnded",
- ], callback_soon(check_test_6));
- }
+ startupManager();
- check_test_6 = (install) => {
- do_check_eq(install.existingAddon.pendingUpgrade.install, install);
+ do_check_true(isExtensionInAddonsList(profileDir, olda1.id));
- restartManager();
AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
do_check_neq(a1, null);
do_check_eq(a1.version, "2.0");
+ do_check_true(isExtensionInAddonsList(profileDir, a1.id));
+ do_check_eq(a1.applyBackgroundUpdates, AddonManager.AUTOUPDATE_DISABLE);
do_check_eq(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) {
- do_check_neq(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));
-
- do_check_eq(req_version, "2");
-
- switch (item_id) {
- case "addon1@tests.mozilla.org":
- do_check_eq(item_version, "5.0");
- do_check_eq(item_maxappversion, "2");
- do_check_eq(item_status, "userEnabled");
- do_check_eq(app_version, "1");
- do_check_eq(update_type, "97");
- break;
- case "addon2@tests.mozilla.org":
- do_check_eq(item_version, "67.0.5b1");
- do_check_eq(item_maxappversion, "3");
- do_check_eq(item_status, "userDisabled");
- do_check_eq(app_version, "1");
- do_check_eq(update_type, "49");
- break;
- case "addon3@tests.mozilla.org":
- do_check_eq(item_version, "1.3+");
- do_check_eq(item_maxappversion, "0");
- do_check_eq(item_status, "userEnabled,incompatible");
- do_check_eq(app_version, "1");
- do_check_eq(update_type, "112");
- break;
- case "addon4@tests.mozilla.org":
- do_check_eq(item_version, "0.5ab6");
- do_check_eq(item_maxappversion, "5");
- do_check_eq(item_status, "userEnabled");
- do_check_eq(app_version, "2");
- do_check_eq(update_type, "98");
- break;
- case "addon5@tests.mozilla.org":
- do_check_eq(item_version, "1.0");
- do_check_eq(item_maxappversion, "1");
- do_check_eq(item_status, "userEnabled");
- do_check_eq(app_version, "1");
- do_check_eq(update_type, "35");
- break;
- case "addon6@tests.mozilla.org":
- do_check_eq(item_version, "1.0");
- do_check_eq(item_maxappversion, "1");
- do_check_eq(item_status, "userEnabled");
- do_check_eq(app_version, "1");
- do_check_eq(update_type, "99");
- break;
- default:
- ok(false, "Update request for unexpected add-on " + item_id);
- }
-
- do_check_eq(app_id, "xpcshell@tests.mozilla.org");
- do_check_eq(current_app_version, "1");
- do_check_eq(app_os, "XPCShell");
- do_check_eq(app_abi, "noarch-spidermonkey");
- do_check_eq(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: function(addon, error) {
- if (--count == 0)
- do_execute_soon(next_test);
- }
- };
-
- let updateListener = {
- onUpdateAvailable: function(addon, update) {
- // Dummy so the update checker knows we care about new versions
- },
-
- onUpdateFinished: function(addon, error) {
- if (--count == 0)
- do_execute_soon(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) {
- do_check_true(a4.isActive, "addon4 is active");
- do_check_true(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: function(addon) {
- do_check_true(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: function(addon) {
- do_check_false(addon.isCompatible, "addon4 is compatible");
-
- run_next_test();
- }
- }, AddonManager.UPDATE_WHEN_NEW_APP_INSTALLED);
+ a1.uninstall();
+ do_execute_soon(run_test_3);
});
- });
-
- // 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) {
- do_check_false(a4.isActive, "addon4 is active");
- do_check_false(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();
+// Check that an update check finds compatibility updates and applies them
+function run_test_3() {
+ 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("addon2@tests.mozilla.org", function(a2) {
+ do_check_neq(a2, null);
+ do_check_false(a2.isActive);
+ do_check_false(a2.isCompatible);
+ do_check_true(a2.appDisabled);
+ do_check_true(a2.isCompatibleWith("0"));
- AddonManager.getAddonByID("addon7@tests.mozilla.org", function(a7) {
- do_check_neq(a7, null);
- do_check_false(a7.isActive);
- do_check_false(a7.isCompatible);
- do_check_true(a7.appDisabled);
- do_check_true(a7.isCompatibleWith("0", "0"));
-
- a7.findUpdates({
- sawUpdate: false,
- onCompatibilityUpdateAvailable: function(addon) {
- ok(false, "Should not have seen compatibility information");
- },
+ a2.findUpdates({
+ onCompatibilityUpdateAvailable: function(addon) {
+ do_check_true(a2.isCompatible);
+ do_check_false(a2.appDisabled);
+ do_check_false(a2.isActive);
+ },
- onUpdateAvailable: function(addon, install) {
- ok(false, "Should not have seen an available update");
- },
+ onUpdateAvailable: function(addon, install) {
+ do_throw("Should not have seen an available update");
+ },
- onUpdateFinished: function(addon) {
- do_check_true(addon.isCompatible);
- do_execute_soon(check_test_13);
- }
- }, AddonManager.UPDATE_WHEN_NEW_APP_DETECTED, "3.0", "3.0");
- });
+ onNoUpdateAvailable: function(addon) {
+ do_check_eq(addon, a2);
+ do_execute_soon(check_test_3);
+ }
+ }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
});
+}
- check_test_13 = () => {
- restartManager();
- AddonManager.getAddonByID("addon7@tests.mozilla.org", function(a7) {
- do_check_neq(a7, null);
- do_check_true(a7.isActive);
- do_check_true(a7.isCompatible);
- do_check_false(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: function(aInstall) {
- let id = aInstall.existingAddon.id;
- ok((id == "addon1@tests.mozilla.org" || id == "addon8@tests.mozilla.org"),
- "Saw unexpected onNewInstall for " + id);
- },
-
- onDownloadStarted: function(aInstall) {
- do_check_eq(aInstall.existingAddon.id, "addon1@tests.mozilla.org");
- },
-
- onDownloadEnded: function(aInstall) {
- do_check_eq(aInstall.existingAddon.id, "addon1@tests.mozilla.org");
- },
-
- onDownloadFailed: function(aInstall) {
- ok(false, "Should not have seen onDownloadFailed event");
- },
-
- onDownloadCancelled: function(aInstall) {
- ok(false, "Should not have seen onDownloadCancelled event");
- },
-
- onInstallStarted: function(aInstall) {
- do_check_eq(aInstall.existingAddon.id, "addon1@tests.mozilla.org");
- },
-
- onInstallEnded: function(aInstall) {
- do_check_eq(aInstall.existingAddon.id, "addon1@tests.mozilla.org");
- do_check_eq(aInstall.existingAddon.pendingUpgrade.install, aInstall);
-
- do_execute_soon(check_test_14);
- },
-
- onInstallFailed: function(aInstall) {
- ok(false, "Should not have seen onInstallFailed event");
- },
-
- onInstallCancelled: function(aInstall) {
- ok(false, "Should not have seen onInstallCancelled event");
- },
- });
+function check_test_3() {
+ restartManager();
+ AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) {
+ do_check_neq(a2, null);
+ do_check_true(a2.isActive);
+ do_check_true(a2.isCompatible);
+ do_check_false(a2.appDisabled);
+ a2.uninstall();
- AddonManagerInternal.backgroundUpdateCheck();
- });
+ run_test_4();
});
+}
- check_test_14 = () => {
- restartManager();
- AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
- "addon8@tests.mozilla.org"], function([a1, a8]) {
- do_check_neq(a1, null);
- do_check_eq(a1.version, "2.0");
- a1.uninstall();
-
- do_check_neq(a8, null);
- do_check_eq(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();
- do_check_false(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: function(aInstall) {
- let id = aInstall.existingAddon.id;
- ok((id == "addon1@tests.mozilla.org" || id == "addon8@tests.mozilla.org"),
- "Saw unexpected onNewInstall for " + id);
- },
-
- onDownloadStarted: function(aInstall) {
- do_check_eq(aInstall.existingAddon.id, "addon1@tests.mozilla.org");
- },
-
- onDownloadEnded: function(aInstall) {
- do_check_eq(aInstall.existingAddon.id, "addon1@tests.mozilla.org");
- },
-
- onDownloadFailed: function(aInstall) {
- ok(false, "Should not have seen onDownloadFailed event");
- },
-
- onDownloadCancelled: function(aInstall) {
- ok(false, "Should not have seen onDownloadCancelled event");
- },
-
- onInstallStarted: function(aInstall) {
- do_check_eq(aInstall.existingAddon.id, "addon1@tests.mozilla.org");
- },
-
- onInstallEnded: function(aInstall) {
- do_check_eq(aInstall.existingAddon.id, "addon1@tests.mozilla.org");
- do_execute_soon(check_test_15);
- },
+// Checks that we see no compatibility information when there is none.
+function run_test_4() {
+ AddonManager.getAddonByID("addon3@tests.mozilla.org", function(a3) {
+ do_check_neq(a3, null);
+ do_check_false(a3.isActive);
+ do_check_false(a3.isCompatible);
+ do_check_true(a3.appDisabled);
+ do_check_true(a3.isCompatibleWith("5"));
+ do_check_false(a3.isCompatibleWith("2"));
+
+ a3.findUpdates({
+ sawUpdate: false,
+ onCompatibilityUpdateAvailable: function(addon) {
+ do_throw("Should not have seen compatibility information");
+ },
- onInstallFailed: function(aInstall) {
- ok(false, "Should not have seen onInstallFailed event");
- },
+ onNoCompatibilityUpdateAvailable: function(addon) {
+ this.sawUpdate = true;
+ },
- onInstallCancelled: function(aInstall) {
- ok(false, "Should not have seen onInstallCancelled event");
- },
- });
+ onUpdateAvailable: function(addon, install) {
+ do_throw("Should not have seen an available update");
+ },
- AddonManagerInternal.backgroundUpdateCheck();
- });
+ onNoUpdateAvailable: function(addon) {
+ do_check_true(this.sawUpdate);
+ run_test_5();
+ }
+ }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
});
+}
- check_test_15 = () => {
- restartManager();
- AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
- "addon8@tests.mozilla.org"], function([a1, a8]) {
- do_check_neq(a1, null);
- do_check_eq(a1.version, "2.0");
- a1.uninstall();
-
- do_check_eq(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();
+// Checks that compatibility info for future apps are detected but don't make
+// the item compatibile.
+function run_test_5() {
+ AddonManager.getAddonByID("addon3@tests.mozilla.org", function(a3) {
+ do_check_neq(a3, null);
+ do_check_false(a3.isActive);
+ do_check_false(a3.isCompatible);
+ do_check_true(a3.appDisabled);
+ do_check_true(a3.isCompatibleWith("5"));
+ do_check_false(a3.isCompatibleWith("2"));
+
+ a3.findUpdates({
+ sawUpdate: false,
+ onCompatibilityUpdateAvailable: function(addon) {
+ do_check_false(a3.isCompatible);
+ do_check_true(a3.appDisabled);
+ do_check_false(a3.isActive);
+ this.sawUpdate = true;
+ },
- AddonManager.addInstallListener({
- onNewInstall: function(aInstall) {
- equal(aInstall.existingAddon.id, "addon9@tests.mozilla.org",
- "Saw unexpected onNewInstall for " + aInstall.existingAddon.id);
- do_check_eq(aInstall.version, "2.0");
+ onNoCompatibilityUpdateAvailable: function(addon) {
+ do_throw("Should have seen some compatibility information");
},
- onDownloadFailed: function(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.xml");
- Services.prefs.setCharPref(PREF_GETADDONS_BYIDS_PERFORMANCE,
- "http://localhost:" + gPort + "/data/test_update.xml");
- Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true);
+ onUpdateAvailable: function(addon, install) {
+ do_throw("Should not have seen an available update");
+ },
- AddonManagerInternal.backgroundUpdateCheck();
+ onNoUpdateAvailable: function(addon) {
+ do_check_true(this.sawUpdate);
+ do_execute_soon(check_test_5);
+ }
+ }, AddonManager.UPDATE_WHEN_USER_REQUESTED, "3.0");
});
+}
- // 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) {
- do_check_neq(a11, null);
-
- a11.findUpdates({
- onCompatibilityUpdateAvailable: function() {
- ok(false, "Should have not have seen compatibility information");
- },
-
- onUpdateAvailable: function() {
- ok(false, "Should not have seen an available update");
- },
+function check_test_5() {
+ restartManager();
+ AddonManager.getAddonByID("addon3@tests.mozilla.org", function(a3) {
+ do_check_neq(a3, null);
+ do_check_false(a3.isActive);
+ do_check_false(a3.isCompatible);
+ do_check_true(a3.appDisabled);
- onUpdateFinished: function() {
- run_next_test();
- }
- }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
- });
+ a3.uninstall();
+ do_execute_soon(run_test_6);
});
+}
- add_task(function* cleanup() {
- let addons = yield new Promise(resolve => {
- AddonManager.getAddonsByTypes(["extension"], resolve);
- });
-
- for (let addon of addons)
- addon.uninstall();
+// Test that background update checks work
+function run_test_6() {
+ restartManager();
+
+ writeInstallRDFForExtension({
+ id: "addon1@tests.mozilla.org",
+ version: "1.0",
+ updateURL: "http://localhost:" + gPort + "/data/test_update.rdf",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "1",
+ maxVersion: "1"
+ }],
+ name: "Test Addon 1",
+ }, profileDir);
+ restartManager();
+
+ prepare_test({}, [
+ "onNewInstall",
+ "onDownloadStarted",
+ "onDownloadEnded"
+ ], continue_test_6);
+
+ AddonManagerInternal.backgroundUpdateCheck();
+}
- yield promiseRestartManager();
+function continue_test_6(install) {
+ do_check_neq(install.existingAddon, null);
+ do_check_eq(install.existingAddon.id, "addon1@tests.mozilla.org");
+
+ prepare_test({
+ "addon1@tests.mozilla.org": [
+ "onInstalling"
+ ]
+ }, [
+ "onInstallStarted",
+ "onInstallEnded",
+ ], callback_soon(check_test_6));
+}
- shutdownManager();
+function check_test_6(install) {
+ do_check_eq(install.existingAddon.pendingUpgrade.install, install);
- yield new Promise(do_execute_soon);
+ restartManager();
+ AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
+ do_check_neq(a1, null);
+ do_check_eq(a1.version, "2.0");
+ do_check_eq(a1.releaseNotesURI.spec, "http://example.com/updateInfo.xhtml");
+ a1.uninstall();
+ do_execute_soon(run_test_7);
});
}
// Test that background update checks work for lightweight themes
-add_test(function run_test_7() {
- startupManager();
+function run_test_7() {
+ restartManager();
LightweightThemeManager.currentTheme = {
id: "1",
@@ -1104,7 +474,7 @@ add_test(function run_test_7() {
AddonManagerInternal.backgroundUpdateCheck();
});
-});
+}
function check_test_7() {
AddonManager.getAddonByID("1@personas.mozilla.org", function(p1) {
@@ -1121,6 +491,595 @@ function check_test_7() {
gInstallDate = p1.installDate.getTime();
- run_next_test();
+ do_execute_soon(run_test_8);
+ });
+}
+
+// Verify the parameter escaping in update urls.
+function run_test_8() {
+ writeInstallRDFForExtension({
+ id: "addon1@tests.mozilla.org",
+ version: "5.0",
+ updateURL: "http://localhost:" + gPort + "/data/param_test.rdf" + PARAMS,
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ 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: "xpcshell@tests.mozilla.org",
+ 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: "xpcshell@tests.mozilla.org",
+ 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: "xpcshell@tests.mozilla.org",
+ 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: "xpcshell@tests.mozilla.org",
+ 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) {
+ do_check_neq(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] =
+ [decodeURIComponent(a) for each (a in request.queryString.split("/"))];
+
+ do_check_eq(req_version, "2");
+
+ switch(item_id) {
+ case "addon1@tests.mozilla.org":
+ do_check_eq(item_version, "5.0");
+ do_check_eq(item_maxappversion, "2");
+ do_check_eq(item_status, "userEnabled");
+ do_check_eq(app_version, "1");
+ do_check_eq(update_type, "97");
+ break;
+ case "addon2@tests.mozilla.org":
+ do_check_eq(item_version, "67.0.5b1");
+ do_check_eq(item_maxappversion, "3");
+ do_check_eq(item_status, "userDisabled");
+ do_check_eq(app_version, "1");
+ do_check_eq(update_type, "49");
+ break;
+ case "addon3@tests.mozilla.org":
+ do_check_eq(item_version, "1.3+");
+ do_check_eq(item_maxappversion, "0");
+ do_check_eq(item_status, "userEnabled,incompatible");
+ do_check_eq(app_version, "1");
+ do_check_eq(update_type, "112");
+ break;
+ case "addon4@tests.mozilla.org":
+ do_check_eq(item_version, "0.5ab6");
+ do_check_eq(item_maxappversion, "5");
+ do_check_eq(item_status, "userEnabled");
+ do_check_eq(app_version, "2");
+ do_check_eq(update_type, "98");
+ break;
+ case "addon5@tests.mozilla.org":
+ do_check_eq(item_version, "1.0");
+ do_check_eq(item_maxappversion, "1");
+ do_check_eq(item_status, "userEnabled");
+ do_check_eq(app_version, "1");
+ do_check_eq(update_type, "35");
+ break;
+ case "addon6@tests.mozilla.org":
+ do_check_eq(item_version, "1.0");
+ do_check_eq(item_maxappversion, "1");
+ do_check_eq(item_status, "userEnabled");
+ do_check_eq(app_version, "1");
+ do_check_eq(update_type, "99");
+ break;
+ default:
+ do_throw("Update request for unexpected add-on " + item_id);
+ }
+
+ do_check_eq(app_id, "xpcshell@tests.mozilla.org");
+ do_check_eq(current_app_version, "1");
+ do_check_eq(app_os, "XPCShell");
+ do_check_eq(app_abi, "noarch-spidermonkey");
+ do_check_eq(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, a2, a3, a4, a5, a6]) {
+ let count = 6;
+
+ function run_next_test() {
+ a1.uninstall();
+ a2.uninstall();
+ a3.uninstall();
+ a4.uninstall();
+ a5.uninstall();
+ a6.uninstall();
+
+ restartManager();
+ run_test_9();
+ }
+
+ let compatListener = {
+ onUpdateFinished: function(addon, error) {
+ if (--count == 0)
+ do_execute_soon(run_next_test);
+ }
+ };
+
+ let updateListener = {
+ onUpdateAvailable: function(addon, update) {
+ // Dummy so the update checker knows we care about new versions
+ },
+
+ onUpdateFinished: function(addon, error) {
+ if (--count == 0)
+ do_execute_soon(run_next_test);
+ }
+ };
+
+ a1.findUpdates(updateListener, AddonManager.UPDATE_WHEN_USER_REQUESTED);
+ a2.findUpdates(compatListener, AddonManager.UPDATE_WHEN_ADDON_INSTALLED);
+ a3.findUpdates(updateListener, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE);
+ a4.findUpdates(updateListener, AddonManager.UPDATE_WHEN_NEW_APP_DETECTED, "2");
+ a5.findUpdates(compatListener, AddonManager.UPDATE_WHEN_NEW_APP_INSTALLED);
+ a6.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.
+function run_test_9() {
+ writeInstallRDFForExtension({
+ id: "addon4@tests.mozilla.org",
+ version: "5.0",
+ updateURL: "http://localhost:" + gPort + "/data/test_update.rdf",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "0",
+ maxVersion: "1"
+ }],
+ name: "Test Addon 1",
+ }, profileDir);
+
+ restartManager();
+
+ AddonManager.getAddonByID("addon4@tests.mozilla.org", function(a4) {
+ do_check_true(a4.isActive);
+ do_check_true(a4.isCompatible);
+
+ run_test_10();
+ });
+}
+
+// Tests that a normal update check won't decrease a targetApplication's
+// maxVersion.
+function run_test_10() {
+ AddonManager.getAddonByID("addon4@tests.mozilla.org", function(a4) {
+ a4.findUpdates({
+ onUpdateFinished: function(addon) {
+ do_check_true(addon.isCompatible);
+
+ run_test_11();
+ }
+ }, AddonManager.UPDATE_WHEN_PERIODIC_UPDATE);
+ });
+}
+
+// Tests that an update check for a new application will decrease a
+// targetApplication's maxVersion.
+function run_test_11() {
+ AddonManager.getAddonByID("addon4@tests.mozilla.org", function(a4) {
+ a4.findUpdates({
+ onUpdateFinished: function(addon) {
+ do_check_false(addon.isCompatible);
+
+ do_execute_soon(run_test_12);
+ }
+ }, AddonManager.UPDATE_WHEN_NEW_APP_INSTALLED);
+ });
+}
+
+// Check that the decreased maxVersion applied and disables the add-on
+function run_test_12() {
+ restartManager();
+
+ AddonManager.getAddonByID("addon4@tests.mozilla.org", function(a4) {
+ do_check_false(a4.isActive);
+ do_check_false(a4.isCompatible);
+
+ a4.uninstall();
+ do_execute_soon(run_test_13);
+ });
+}
+
+// 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.
+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/test_update.rdf",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "0",
+ maxVersion: "0"
+ }],
+ name: "Test Addon 7",
+ }, profileDir);
+ restartManager();
+
+ AddonManager.getAddonByID("addon7@tests.mozilla.org", function(a7) {
+ do_check_neq(a7, null);
+ do_check_false(a7.isActive);
+ do_check_false(a7.isCompatible);
+ do_check_true(a7.appDisabled);
+ do_check_true(a7.isCompatibleWith("0"));
+
+ a7.findUpdates({
+ sawUpdate: false,
+ onCompatibilityUpdateAvailable: function(addon) {
+ do_throw("Should have not have seen compatibility information");
+ },
+
+ onUpdateAvailable: function(addon, install) {
+ do_throw("Should not have seen an available update");
+ },
+
+ onUpdateFinished: function(addon) {
+ do_check_true(addon.isCompatible);
+ do_execute_soon(check_test_13);
+ }
+ }, AddonManager.UPDATE_WHEN_NEW_APP_DETECTED, "3.0");
+ });
+}
+
+function check_test_13() {
+ restartManager();
+ AddonManager.getAddonByID("addon7@tests.mozilla.org", function(a7) {
+ do_check_neq(a7, null);
+ do_check_true(a7.isActive);
+ do_check_true(a7.isCompatible);
+ do_check_false(a7.appDisabled);
+
+ a7.uninstall();
+ do_execute_soon(run_test_14);
+ });
+}
+
+// Test that background update checks doesn't update an add-on that isn't
+// allowed to update automatically.
+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/test_update.rdf",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "1",
+ maxVersion: "1"
+ }],
+ name: "Test Addon 1",
+ }, profileDir);
+
+ writeInstallRDFForExtension({
+ id: "addon8@tests.mozilla.org",
+ version: "1.0",
+ updateURL: "http://localhost:" + gPort + "/data/test_update.rdf",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ 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: function(aInstall) {
+ if (aInstall.existingAddon.id != "addon1@tests.mozilla.org" &&
+ aInstall.existingAddon.id != "addon8@tests.mozilla.org")
+ do_throw("Saw unexpected onNewInstall for " + aInstall.existingAddon.id);
+ },
+
+ onDownloadStarted: function(aInstall) {
+ do_check_eq(aInstall.existingAddon.id, "addon1@tests.mozilla.org");
+ },
+
+ onDownloadEnded: function(aInstall) {
+ do_check_eq(aInstall.existingAddon.id, "addon1@tests.mozilla.org");
+ },
+
+ onDownloadFailed: function(aInstall) {
+ do_throw("Should not have seen onDownloadFailed event");
+ },
+
+ onDownloadCancelled: function(aInstall) {
+ do_throw("Should not have seen onDownloadCancelled event");
+ },
+
+ onInstallStarted: function(aInstall) {
+ do_check_eq(aInstall.existingAddon.id, "addon1@tests.mozilla.org");
+ },
+
+ onInstallEnded: function(aInstall) {
+ do_check_eq(aInstall.existingAddon.id, "addon1@tests.mozilla.org");
+ do_check_eq(aInstall.existingAddon.pendingUpgrade.install, aInstall);
+ do_execute_soon(check_test_14);
+ },
+
+ onInstallFailed: function(aInstall) {
+ do_throw("Should not have seen onInstallFailed event");
+ },
+
+ onInstallCancelled: function(aInstall) {
+ do_throw("Should not have seen onInstallCancelled event");
+ },
+ });
+
+ AddonManagerInternal.backgroundUpdateCheck();
+ });
+}
+
+function check_test_14() {
+ restartManager();
+ AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
+ "addon8@tests.mozilla.org"], function([a1, a8]) {
+ do_check_neq(a1, null);
+ do_check_eq(a1.version, "2.0");
+ a1.uninstall();
+
+ do_check_neq(a8, null);
+ do_check_eq(a8.version, "1.0");
+ a8.uninstall();
+
+ do_execute_soon(run_test_15);
+ });
+}
+
+// Test that background update checks doesn't update an add-on that is
+// pending uninstall
+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/test_update.rdf",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "1",
+ maxVersion: "1"
+ }],
+ name: "Test Addon 1",
+ }, profileDir);
+
+ writeInstallRDFForExtension({
+ id: "addon8@tests.mozilla.org",
+ version: "1.0",
+ updateURL: "http://localhost:" + gPort + "/data/test_update.rdf",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "1",
+ maxVersion: "1"
+ }],
+ name: "Test Addon 8",
+ }, profileDir);
+ restartManager();
+
+ AddonManager.getAddonByID("addon8@tests.mozilla.org", function(a8) {
+ a8.uninstall();
+ do_check_false(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: function(aInstall) {
+ if (aInstall.existingAddon.id != "addon1@tests.mozilla.org" &&
+ aInstall.existingAddon.id != "addon8@tests.mozilla.org")
+ do_throw("Saw unexpected onNewInstall for " + aInstall.existingAddon.id);
+ },
+
+ onDownloadStarted: function(aInstall) {
+ do_check_eq(aInstall.existingAddon.id, "addon1@tests.mozilla.org");
+ },
+
+ onDownloadEnded: function(aInstall) {
+ do_check_eq(aInstall.existingAddon.id, "addon1@tests.mozilla.org");
+ },
+
+ onDownloadFailed: function(aInstall) {
+ do_throw("Should not have seen onDownloadFailed event");
+ },
+
+ onDownloadCancelled: function(aInstall) {
+ do_throw("Should not have seen onDownloadCancelled event");
+ },
+
+ onInstallStarted: function(aInstall) {
+ do_check_eq(aInstall.existingAddon.id, "addon1@tests.mozilla.org");
+ },
+
+ onInstallEnded: function(aInstall) {
+ do_check_eq(aInstall.existingAddon.id, "addon1@tests.mozilla.org");
+ do_execute_soon(check_test_15);
+ },
+
+ onInstallFailed: function(aInstall) {
+ do_throw("Should not have seen onInstallFailed event");
+ },
+
+ onInstallCancelled: function(aInstall) {
+ do_throw("Should not have seen onInstallCancelled event");
+ },
+ });
+
+ AddonManagerInternal.backgroundUpdateCheck();
+ });
+}
+
+function check_test_15() {
+ restartManager();
+ AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
+ "addon8@tests.mozilla.org"], function([a1, a8]) {
+ do_check_neq(a1, null);
+ do_check_eq(a1.version, "2.0");
+ a1.uninstall();
+
+ do_check_eq(a8, null);
+
+ do_execute_soon(run_test_16);
+ });
+}
+
+// Test that the update check correctly observes the
+// extensions.strictCompatibility pref and compatibility overrides.
+function run_test_16() {
+ restartManager();
+
+ writeInstallRDFForExtension({
+ id: "addon9@tests.mozilla.org",
+ version: "1.0",
+ updateURL: "http://localhost:" + gPort + "/data/test_update.rdf",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "0.1",
+ maxVersion: "0.2"
+ }],
+ name: "Test Addon 9",
+ }, profileDir);
+ restartManager();
+
+ AddonManager.addInstallListener({
+ onNewInstall: function(aInstall) {
+ if (aInstall.existingAddon.id != "addon9@tests.mozilla.org")
+ do_throw("Saw unexpected onNewInstall for " + aInstall.existingAddon.id);
+ do_check_eq(aInstall.version, "2.0");
+ },
+ onDownloadFailed: function(aInstall) {
+ do_execute_soon(run_test_17);
+ }
+ });
+
+ Services.prefs.setCharPref(PREF_GETADDONS_BYIDS_PERFORMANCE,
+ "http://localhost:" + gPort + "/data/test_update.xml");
+ 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.
+function run_test_17() {
+
+ writeInstallRDFForExtension({
+ id: "addon11@tests.mozilla.org",
+ version: "1.0",
+ updateURL: "http://localhost:" + gPort + "/data/test_update.rdf",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "0.1",
+ maxVersion: "0.2"
+ }],
+ name: "Test Addon 11",
+ }, profileDir);
+ restartManager();
+
+ AddonManager.getAddonByID("addon11@tests.mozilla.org", function(a11) {
+ do_check_neq(a11, null);
+
+ a11.findUpdates({
+ onCompatibilityUpdateAvailable: function() {
+ do_throw("Should have not have seen compatibility information");
+ },
+
+ onUpdateAvailable: function() {
+ do_throw("Should not have seen an available update");
+ },
+
+ onUpdateFinished: function() {
+ do_execute_soon(end_test);
+ }
+ }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
});
}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_update_webextensions.js b/toolkit/mozapps/extensions/test/xpcshell/test_update_webextensions.js
deleted file mode 100644
index ff5d5d321..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_update_webextensions.js
+++ /dev/null
@@ -1,248 +0,0 @@
-"use strict";
-
-const TOOLKIT_ID = "toolkit@mozilla.org";
-
-// We don't have an easy way to serve update manifests from a secure URL.
-Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false);
-
-var testserver = createHttpServer();
-gPort = testserver.identity.primaryPort;
-
-const uuidGenerator = AM_Cc["@mozilla.org/uuid-generator;1"].getService(AM_Ci.nsIUUIDGenerator);
-
-const extensionsDir = gProfD.clone();
-extensionsDir.append("extensions");
-
-const addonsDir = gTmpD.clone();
-addonsDir.append("addons");
-addonsDir.create(AM_Ci.nsIFile.DIRECTORY_TYPE, 0o755);
-
-do_register_cleanup(() => addonsDir.remove(true));
-
-testserver.registerDirectory("/addons/", addonsDir);
-
-
-let gUpdateManifests = {};
-
-function mapManifest(aPath, aManifestData) {
- gUpdateManifests[aPath] = aManifestData;
- testserver.registerPathHandler(aPath, serveManifest);
-}
-
-function serveManifest(request, response) {
- let manifest = gUpdateManifests[request.path];
-
- response.setHeader("Content-Type", manifest.contentType, false);
- response.write(manifest.data);
-}
-
-
-function promiseInstallWebExtension(aData) {
- let addonFile = createTempWebExtensionFile(aData);
-
- return promiseInstallAllFiles([addonFile]).then(() => {
- Services.obs.notifyObservers(addonFile, "flush-cache-entry", null);
- return promiseAddonByID(aData.id);
- });
-}
-
-var checkUpdates = Task.async(function* (aData, aReason = AddonManager.UPDATE_WHEN_PERIODIC_UPDATE) {
- function provide(obj, path, value) {
- path = path.split(".");
- let prop = path.pop();
-
- for (let key of path) {
- if (!(key in obj))
- obj[key] = {};
- obj = obj[key];
- }
-
- if (!(prop in obj))
- obj[prop] = value;
- }
-
- let id = uuidGenerator.generateUUID().number;
- provide(aData, "addon.id", id);
- provide(aData, "addon.manifest.applications.gecko.id", id);
-
- let updatePath = `/updates/${id}.json`.replace(/[{}]/g, "");
- let updateUrl = `http://localhost:${gPort}${updatePath}`
-
- let addonData = { updates: [] };
- let manifestJSON = {
- addons: { [id]: addonData }
- };
-
-
- provide(aData, "addon.manifest.applications.gecko.update_url", updateUrl);
- let awaitInstall = promiseInstallWebExtension(aData.addon);
-
-
- for (let version of Object.keys(aData.updates)) {
- let update = aData.updates[version];
- update.version = version;
-
- provide(update, "addon.id", id);
- provide(update, "addon.manifest.applications.gecko.id", id);
- let addon = update.addon;
-
- delete update.addon;
-
- let file;
- if (addon.rdf) {
- provide(addon, "version", version);
- provide(addon, "targetApplications", [{id: TOOLKIT_ID,
- minVersion: "42",
- maxVersion: "*"}]);
-
- file = createTempXPIFile(addon);
- } else {
- provide(addon, "manifest.version", version);
- file = createTempWebExtensionFile(addon);
- }
- file.moveTo(addonsDir, `${id}-${version}.xpi`.replace(/[{}]/g, ""));
-
- let path = `/addons/${file.leafName}`;
- provide(update, "update_link", `http://localhost:${gPort}${path}`);
-
- addonData.updates.push(update);
- }
-
- mapManifest(updatePath, { data: JSON.stringify(manifestJSON),
- contentType: "application/json" });
-
-
- let addon = yield awaitInstall;
-
- let updates = yield promiseFindAddonUpdates(addon, aReason);
- updates.addon = addon;
-
- return updates;
-});
-
-
-function run_test() {
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "42.0", "42.0");
-
- startupManager();
- do_register_cleanup(promiseShutdownManager);
-
- run_next_test();
-}
-
-
-// Check that compatibility updates are applied.
-add_task(function* checkUpdateMetadata() {
- let update = yield checkUpdates({
- addon: {
- manifest: {
- version: "1.0",
- applications: { gecko: { strict_max_version: "45" } },
- }
- },
- updates: {
- "1.0": {
- applications: { gecko: { strict_min_version: "40",
- strict_max_version: "48" } },
- }
- }
- });
-
- ok(update.compatibilityUpdate, "have compat update");
- ok(!update.updateAvailable, "have no add-on update");
-
- ok(update.addon.isCompatibleWith("40", "40"), "compatible min");
- ok(update.addon.isCompatibleWith("48", "48"), "compatible max");
- ok(!update.addon.isCompatibleWith("49", "49"), "not compatible max");
-
- update.addon.uninstall();
-});
-
-
-// Check that updates from web extensions to web extensions succeed.
-add_task(function* checkUpdateToWebExt() {
- let update = yield checkUpdates({
- addon: { manifest: { version: "1.0" } },
- updates: {
- "1.1": { },
- "1.2": { },
- "1.3": { "applications": { "gecko": { "strict_min_version": "48" } } },
- }
- });
-
- ok(!update.compatibilityUpdate, "have no compat update");
- ok(update.updateAvailable, "have add-on update");
-
- equal(update.addon.version, "1.0", "add-on version");
-
- yield promiseCompleteAllInstalls([update.updateAvailable]);
-
- let addon = yield promiseAddonByID(update.addon.id);
- equal(addon.version, "1.2", "new add-on version");
-
- addon.uninstall();
-});
-
-
-// Check that updates from web extensions to XUL extensions fail.
-add_task(function* checkUpdateToRDF() {
- let update = yield checkUpdates({
- addon: { manifest: { version: "1.0" } },
- updates: {
- "1.1": { addon: { rdf: true } },
- }
- });
-
- ok(!update.compatibilityUpdate, "have no compat update");
- ok(update.updateAvailable, "have add-on update");
-
- equal(update.addon.version, "1.0", "add-on version");
-
- let result = yield new Promise((resolve, reject) => {
- update.updateAvailable.addListener({
- onDownloadFailed: resolve,
- onDownloadEnded: reject,
- onInstalling: reject,
- onInstallStarted: reject,
- onInstallEnded: reject,
- });
- update.updateAvailable.install();
- });
-
- equal(result.error, AddonManager.ERROR_UNEXPECTED_ADDON_TYPE, "error: unexpected add-on type");
-
- let addon = yield promiseAddonByID(update.addon.id);
- equal(addon.version, "1.0", "new add-on version");
-
- addon.uninstall();
-});
-
-
-// Check that illegal update URLs are rejected.
-add_task(function* checkIllegalUpdateURL() {
- const URLS = ["chrome://browser/content/",
- "data:text/json,...",
- "javascript:;",
- "/"];
-
- for (let url of URLS) {
- let { messages } = yield promiseConsoleOutput(() => {
- return new Promise((resolve, reject) => {
- let addonFile = createTempWebExtensionFile({
- manifest: { applications: { gecko: { update_url: url } } },
- });
-
- AddonManager.getInstallForFile(addonFile, install => {
- Services.obs.notifyObservers(addonFile, "flush-cache-entry", null);
-
- if (install && install.state == AddonManager.STATE_DOWNLOAD_FAILED)
- resolve();
- reject(new Error("Unexpected state: " + (install && install.state)))
- });
- });
- });
-
- ok(messages.some(msg => /Access denied for URL|may not load or link to|is not a valid URL/.test(msg)),
- "Got checkLoadURI error");
- }
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_updatecheck.js b/toolkit/mozapps/extensions/test/xpcshell/test_updatecheck.js
index e8529bb2c..d2e15103b 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_updatecheck.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_updatecheck.js
@@ -7,46 +7,51 @@
Components.utils.import("resource://gre/modules/addons/AddonUpdateChecker.jsm");
Components.utils.import("resource://testing-common/httpd.js");
+var testserver;
-var testserver = createHttpServer(4444);
-testserver.registerDirectory("/data/", do_get_file("data"));
+function run_test() {
+ createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
-function checkUpdates(aId, aUpdateKey, aUpdateFile) {
- return new Promise((resolve, reject) => {
- AddonUpdateChecker.checkForUpdates(aId, aUpdateKey, `http://localhost:4444/data/${aUpdateFile}`, {
- onUpdateCheckComplete: resolve,
+ // Create and configure the HTTP server.
+ testserver = new HttpServer();
+ testserver.registerDirectory("/data/", do_get_file("data"));
+ testserver.start(4444);
- onUpdateCheckError: function(status) {
- let error = new Error("Update check failed with status " + status);
- error.status = status;
- reject(error);
- }
- });
- });
+ do_test_pending();
+ run_test_1();
}
-function run_test() {
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
-
- run_next_test();
+function end_test() {
+ testserver.stop(do_test_finished);
}
// Test that a basic update check returns the expected available updates
-add_task(function* () {
- for (let file of ["test_updatecheck.rdf", "test_updatecheck.json"]) {
- let updates = yield checkUpdates("updatecheck1@tests.mozilla.org", null, 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");
- }
-});
+function run_test_1() {
+ AddonUpdateChecker.checkForUpdates("updatecheck1@tests.mozilla.org", null,
+ "http://localhost:4444/data/test_updatecheck.rdf", {
+ onUpdateCheckComplete: function(updates) {
+ check_test_1(updates);
+ },
+
+ onUpdateCheckError: function(status) {
+ do_throw("Update check failed with status " + status);
+ }
+ });
+}
+
+function check_test_1(updates) {
+ do_check_eq(updates.length, 5);
+ let update = AddonUpdateChecker.getNewestCompatibleUpdate(updates);
+ do_check_neq(update, null);
+ do_check_eq(update.version, 3);
+ update = AddonUpdateChecker.getCompatibilityUpdate(updates, "2");
+ do_check_neq(update, null);
+ do_check_eq(update.version, 2);
+ do_check_eq(update.targetApplications[0].minVersion, 1);
+ do_check_eq(update.targetApplications[0].maxVersion, 2);
+
+ run_test_2();
+}
/*
* Tests that the security checks are applied correctly
@@ -63,174 +68,245 @@ add_task(function* () {
* 9 corrent md2 https update
*/
-var updateKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDK426erD/H3XtsjvaB5+PJqbhj" +
+let updateKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDK426erD/H3XtsjvaB5+PJqbhj" +
"Zc9EDI5OCJS8R3FIObJ9ZHJK1TXeaE7JWqt9WUmBWTEFvwS+FI9vWu8058N9CHhD" +
"NyeP6i4LuUYjTURnn7Yw/IgzyIJ2oKsYa32RuxAyteqAWqPT/J63wBixIeCxmysf" +
"awB/zH4KaPiY3vnrzQIDAQAB";
-add_task(function* () {
- for (let file of ["test_updatecheck.rdf", "test_updatecheck.json"]) {
- try {
- yield checkUpdates("test_bug378216_5@tests.mozilla.org",
- updateKey, file);
- throw "Expected the update check to fail";
- } catch (e) {}
- }
-});
-
-add_task(function* () {
- for (let file of ["test_updatecheck.rdf", "test_updatecheck.json"]) {
- try {
- yield checkUpdates("test_bug378216_7@tests.mozilla.org",
- updateKey, file);
-
- throw "Expected the update check to fail";
- } catch (e) {}
- }
-});
-
-add_task(function* () {
- // Make sure that the JSON manifest is rejected when an update key is
- // required, but perform the remaining tests which aren't expected to fail
- // because of the update key, without requiring one for the JSON variant.
-
- try {
- let updates = yield checkUpdates("test_bug378216_8@tests.mozilla.org",
- updateKey, "test_updatecheck.json");
-
- throw "Expected the update check to fail";
- } catch (e) {}
-
- for (let [file, key] of [["test_updatecheck.rdf", updateKey],
- ["test_updatecheck.json", null]]) {
- let updates = yield checkUpdates("test_bug378216_8@tests.mozilla.org",
- key, file);
- equal(updates.length, 1);
- ok(!("updateURL" in updates[0]));
- }
-});
-
-add_task(function* () {
- for (let [file, key] of [["test_updatecheck.rdf", updateKey],
- ["test_updatecheck.json", null]]) {
- let updates = yield checkUpdates("test_bug378216_9@tests.mozilla.org",
- key, file);
- equal(updates.length, 1);
- equal(updates[0].version, "2.0");
- ok("updateURL" in updates[0]);
- }
-});
-
-add_task(function* () {
- for (let [file, key] of [["test_updatecheck.rdf", updateKey],
- ["test_updatecheck.json", null]]) {
- let updates = yield checkUpdates("test_bug378216_10@tests.mozilla.org",
- key, file);
- equal(updates.length, 1);
- equal(updates[0].version, "2.0");
- ok("updateURL" in updates[0]);
- }
-});
-
-add_task(function* () {
- for (let [file, key] of [["test_updatecheck.rdf", updateKey],
- ["test_updatecheck.json", null]]) {
- let updates = yield checkUpdates("test_bug378216_11@tests.mozilla.org",
- key, file);
- equal(updates.length, 1);
- equal(updates[0].version, "2.0");
- ok("updateURL" in updates[0]);
- }
-});
-
-add_task(function* () {
- for (let [file, key] of [["test_updatecheck.rdf", updateKey],
- ["test_updatecheck.json", null]]) {
- let updates = yield checkUpdates("test_bug378216_12@tests.mozilla.org",
- key, file);
- equal(updates.length, 1);
- do_check_false("updateURL" in updates[0]);
- }
-});
-
-add_task(function* () {
- for (let [file, key] of [["test_updatecheck.rdf", updateKey],
- ["test_updatecheck.json", null]]) {
- let updates = yield checkUpdates("test_bug378216_13@tests.mozilla.org",
- key, file);
- equal(updates.length, 1);
- equal(updates[0].version, "2.0");
- ok("updateURL" in updates[0]);
- }
-});
-
-add_task(function* () {
- for (let file of ["test_updatecheck.rdf", "test_updatecheck.json"]) {
- let updates = yield checkUpdates("test_bug378216_14@tests.mozilla.org",
- null, file);
- equal(updates.length, 0);
- }
-});
-
-add_task(function* () {
- for (let file of ["test_updatecheck.rdf", "test_updatecheck.json"]) {
- try {
- yield checkUpdates("test_bug378216_15@tests.mozilla.org",
- null, file);
-
- throw "Update check should have failed";
- } catch (e) {
- equal(e.status, AddonUpdateChecker.ERROR_PARSE_ERROR);
+function run_test_2() {
+ AddonUpdateChecker.checkForUpdates("test_bug378216_5@tests.mozilla.org",
+ updateKey,
+ "http://localhost:4444/data/test_updatecheck.rdf", {
+ onUpdateCheckComplete: function(updates) {
+ do_throw("Expected the update check to fail");
+ },
+
+ onUpdateCheckError: function(status) {
+ run_test_3();
+ }
+ });
+}
+
+function run_test_3() {
+ AddonUpdateChecker.checkForUpdates("test_bug378216_7@tests.mozilla.org",
+ updateKey,
+ "http://localhost:4444/data/test_updatecheck.rdf", {
+ onUpdateCheckComplete: function(updates) {
+ do_throw("Expected the update check to fail");
+ },
+
+ onUpdateCheckError: function(status) {
+ run_test_4();
+ }
+ });
+}
+
+function run_test_4() {
+ AddonUpdateChecker.checkForUpdates("test_bug378216_8@tests.mozilla.org",
+ updateKey,
+ "http://localhost:4444/data/test_updatecheck.rdf", {
+ onUpdateCheckComplete: function(updates) {
+ do_check_eq(updates.length, 1);
+ do_check_false("updateURL" in updates[0]);
+ run_test_5();
+ },
+
+ onUpdateCheckError: function(status) {
+ do_throw("Update check failed with status " + status);
+ }
+ });
+}
+
+function run_test_5() {
+ AddonUpdateChecker.checkForUpdates("test_bug378216_9@tests.mozilla.org",
+ updateKey,
+ "http://localhost:4444/data/test_updatecheck.rdf", {
+ onUpdateCheckComplete: function(updates) {
+ do_check_eq(updates.length, 1);
+ do_check_eq(updates[0].version, "2.0");
+ do_check_true("updateURL" in updates[0]);
+ run_test_6();
+ },
+
+ onUpdateCheckError: function(status) {
+ do_throw("Update check failed with status " + status);
+ }
+ });
+}
+
+function run_test_6() {
+ AddonUpdateChecker.checkForUpdates("test_bug378216_10@tests.mozilla.org",
+ updateKey,
+ "http://localhost:4444/data/test_updatecheck.rdf", {
+ onUpdateCheckComplete: function(updates) {
+ do_check_eq(updates.length, 1);
+ do_check_eq(updates[0].version, "2.0");
+ do_check_true("updateURL" in updates[0]);
+ run_test_7();
+ },
+
+ onUpdateCheckError: function(status) {
+ do_throw("Update check failed with status " + status);
+ }
+ });
+}
+
+function run_test_7() {
+ AddonUpdateChecker.checkForUpdates("test_bug378216_11@tests.mozilla.org",
+ updateKey,
+ "http://localhost:4444/data/test_updatecheck.rdf", {
+ onUpdateCheckComplete: function(updates) {
+ do_check_eq(updates.length, 1);
+ do_check_eq(updates[0].version, "2.0");
+ do_check_true("updateURL" in updates[0]);
+ run_test_8();
+ },
+
+ onUpdateCheckError: function(status) {
+ do_throw("Update check failed with status " + status);
}
- }
-});
-
-add_task(function* () {
- for (let file of ["test_updatecheck.rdf", "test_updatecheck.json"]) {
- let updates = yield checkUpdates("ignore-compat@tests.mozilla.org",
- null, file);
- equal(updates.length, 3);
- let update = AddonUpdateChecker.getNewestCompatibleUpdate(
- updates, null, null, true);
- notEqual(update, null);
- equal(update.version, 2);
- }
-});
-
-add_task(function* () {
- for (let file of ["test_updatecheck.rdf", "test_updatecheck.json"]) {
- let updates = yield checkUpdates("compat-override@tests.mozilla.org",
- null, 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(function* () {
- for (let file of ["test_updatecheck.rdf", "test_updatecheck.json"]) {
- let updates = yield checkUpdates("compat-strict-optin@tests.mozilla.org",
- null, file);
- equal(updates.length, 1);
- let update = AddonUpdateChecker.getNewestCompatibleUpdate(
- updates, null, null, true, false);
- equal(update, null);
- }
-});
+ });
+}
+
+function run_test_8() {
+ AddonUpdateChecker.checkForUpdates("test_bug378216_12@tests.mozilla.org",
+ updateKey,
+ "http://localhost:4444/data/test_updatecheck.rdf", {
+ onUpdateCheckComplete: function(updates) {
+ do_check_eq(updates.length, 1);
+ do_check_false("updateURL" in updates[0]);
+ run_test_9();
+ },
+
+ onUpdateCheckError: function(status) {
+ do_throw("Update check failed with status " + status);
+ }
+ });
+}
+
+function run_test_9() {
+ AddonUpdateChecker.checkForUpdates("test_bug378216_13@tests.mozilla.org",
+ updateKey,
+ "http://localhost:4444/data/test_updatecheck.rdf", {
+ onUpdateCheckComplete: function(updates) {
+ do_check_eq(updates.length, 1);
+ do_check_eq(updates[0].version, "2.0");
+ do_check_true("updateURL" in updates[0]);
+ run_test_10();
+ },
+
+ onUpdateCheckError: function(status) {
+ do_throw("Update check failed with status " + status);
+ }
+ });
+}
+
+function run_test_10() {
+ AddonUpdateChecker.checkForUpdates("test_bug378216_14@tests.mozilla.org",
+ null,
+ "http://localhost:4444/data/test_updatecheck.rdf", {
+ onUpdateCheckComplete: function(updates) {
+ do_check_eq(updates.length, 0);
+ run_test_11();
+ },
+
+ onUpdateCheckError: function(status) {
+ do_throw("Update check failed with status " + status);
+ }
+ });
+}
+
+function run_test_11() {
+ AddonUpdateChecker.checkForUpdates("test_bug378216_15@tests.mozilla.org",
+ null,
+ "http://localhost:4444/data/test_updatecheck.rdf", {
+ onUpdateCheckComplete: function(updates) {
+ do_throw("Update check should have failed");
+ },
+
+ onUpdateCheckError: function(status) {
+ do_check_eq(status, AddonUpdateChecker.ERROR_PARSE_ERROR);
+ run_test_12();
+ }
+ });
+}
+
+function run_test_12() {
+ AddonUpdateChecker.checkForUpdates("ignore-compat@tests.mozilla.org",
+ null,
+ "http://localhost:4444/data/test_updatecheck.rdf", {
+ onUpdateCheckComplete: function(updates) {
+ do_check_eq(updates.length, 3);
+ let update = AddonUpdateChecker.getNewestCompatibleUpdate(updates,
+ null,
+ null,
+ true);
+ do_check_neq(update, null);
+ do_check_eq(update.version, 2);
+ run_test_13();
+ },
+
+ onUpdateCheckError: function(status) {
+ do_throw("Update check failed with status " + status);
+ }
+ });
+}
+
+function run_test_13() {
+ AddonUpdateChecker.checkForUpdates("compat-override@tests.mozilla.org",
+ null,
+ "http://localhost:4444/data/test_updatecheck.rdf", {
+ onUpdateCheckComplete: function(updates) {
+ do_check_eq(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);
+ do_check_neq(update, null);
+ do_check_eq(update.version, 1);
+ run_test_14();
+ },
+
+ onUpdateCheckError: function(status) {
+ do_throw("Update check failed with status " + status);
+ }
+ });
+}
+
+function run_test_14() {
+ AddonUpdateChecker.checkForUpdates("compat-strict-optin@tests.mozilla.org",
+ null,
+ "http://localhost:4444/data/test_updatecheck.rdf", {
+ onUpdateCheckComplete: function(updates) {
+ do_check_eq(updates.length, 1);
+ let update = AddonUpdateChecker.getNewestCompatibleUpdate(updates,
+ null,
+ null,
+ true,
+ false);
+ do_check_eq(update, null);
+ end_test();
+ },
+
+ onUpdateCheckError: function(status) {
+ do_throw("Update check failed with status " + status);
+ }
+ });
+}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_updateid.js b/toolkit/mozapps/extensions/test/xpcshell/test_updateid.js
index f7e3e21e5..e8aea0301 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_updateid.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_updateid.js
@@ -7,80 +7,416 @@
// The test extension uses an insecure update url.
Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
+Components.utils.import("resource://testing-common/httpd.js");
+var testserver;
const profileDir = gProfD.clone();
profileDir.append("extensions");
-function promiseInstallUpdate(install) {
- return new Promise((resolve, reject) => {
- install.addListener({
- onDownloadFailed: () => {
- let err = new Error("download error");
- err.code = install.error;
- reject(err);
- },
- onInstallFailed: () => {
- let err = new Error("install error");
- err.code = install.error;
- reject(err);
- },
- onInstallEnded: resolve,
- });
+function resetPrefs() {
+ Services.prefs.setIntPref("bootstraptest.active_version", -1);
+ Services.prefs.setIntPref("bootstraptest.installed_version", -1);
+ Services.prefs.setIntPref("bootstraptest.startup_reason", -1);
+ Services.prefs.setIntPref("bootstraptest.shutdown_reason", -1);
+ Services.prefs.setIntPref("bootstraptest.install_reason", -1);
+ Services.prefs.setIntPref("bootstraptest.uninstall_reason", -1);
+}
- install.install();
- });
+function getActiveVersion() {
+ return Services.prefs.getIntPref("bootstraptest.active_version");
}
-// Create and configure the HTTP server.
-let testserver = createHttpServer(4444);
-testserver.registerDirectory("/data/", do_get_file("data"));
-testserver.registerDirectory("/addons/", do_get_file("addons"));
+function getInstalledVersion() {
+ return Services.prefs.getIntPref("bootstraptest.installed_version");
+}
function run_test() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
+
+ // Create and configure the HTTP server.
+ testserver = new HttpServer();
+ testserver.registerDirectory("/data/", do_get_file("data"));
+ testserver.registerDirectory("/addons/", do_get_file("addons"));
+ testserver.start(4444);
+
+ do_test_pending();
+ run_test_1();
+}
+
+function end_test() {
+ testserver.stop(do_test_finished);
+}
+
+function installUpdate(aInstall, aCallback) {
+ aInstall.addListener({
+ onInstallEnded: function(aInstall) {
+ // give the startup time to run
+ do_execute_soon(function() {
+ aCallback(aInstall);
+ });
+ }
+ });
+
+ aInstall.install();
+}
+
+// Verify that an update to an add-on with a new ID uninstalls the old add-on
+function run_test_1() {
+ writeInstallRDFForExtension({
+ id: "addon1@tests.mozilla.org",
+ version: "1.0",
+ updateURL: "http://localhost:4444/data/test_updateid.rdf",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "1",
+ maxVersion: "1"
+ }],
+ name: "Test Addon 1",
+ }, profileDir);
+
+ startupManager();
+
+ AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
+ do_check_neq(a1, null);
+ do_check_eq(a1.version, "1.0");
+
+ a1.findUpdates({
+ onUpdateAvailable: function(addon, install) {
+ do_check_eq(install.name, addon.name);
+ do_check_eq(install.version, "2.0");
+ do_check_eq(install.state, AddonManager.STATE_AVAILABLE);
+ do_check_eq(install.existingAddon, a1);
+
+ installUpdate(install, check_test_1);
+ }
+ }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
+ });
+}
+
+function check_test_1(install) {
+ AddonManager.getAddonByID("addon1@tests.mozilla.org", callback_soon(function(a1) {
+ // Existing add-on should have a pending upgrade
+ do_check_neq(a1.pendingUpgrade, null);
+ do_check_eq(a1.pendingUpgrade.id, "addon2@tests.mozilla.org");
+ do_check_eq(a1.pendingUpgrade.install.existingAddon, a1);
+ do_check_neq(a1.syncGUID);
+
+ let a1SyncGUID = a1.syncGUID;
+
+ restartManager();
+
+ AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
+ "addon2@tests.mozilla.org"], function([a1, a2]) {
+ // Should have uninstalled the old and installed the new
+ do_check_eq(a1, null);
+ do_check_neq(a2, null);
+ do_check_neq(a2.syncGUID, null);
+
+ // The Sync GUID should change when the ID changes
+ do_check_neq(a1SyncGUID, a2.syncGUID);
+
+ a2.uninstall();
+
+ do_execute_soon(run_test_2);
+ });
+ }));
+}
+
+// Test that when the new add-on already exists we just upgrade that
+function run_test_2() {
+ restartManager();
+ shutdownManager();
+
+ writeInstallRDFForExtension({
+ id: "addon1@tests.mozilla.org",
+ version: "1.0",
+ updateURL: "http://localhost:4444/data/test_updateid.rdf",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "1",
+ maxVersion: "1"
+ }],
+ name: "Test Addon 1",
+ }, profileDir);
+ writeInstallRDFForExtension({
+ id: "addon2@tests.mozilla.org",
+ version: "1.0",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "1",
+ maxVersion: "1"
+ }],
+ name: "Test Addon 2",
+ }, profileDir);
+
+ startupManager();
+
+ AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
+ do_check_neq(a1, null);
+ do_check_eq(a1.version, "1.0");
+
+ a1.findUpdates({
+ onUpdateAvailable: function(addon, install) {
+ installUpdate(install, check_test_2);
+ }
+ }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
+ });
+}
+
+function check_test_2(install) {
+ AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
+ "addon2@tests.mozilla.org"],
+ callback_soon(function([a1, a2]) {
+ do_check_eq(a1.pendingUpgrade, null);
+ // Existing add-on should have a pending upgrade
+ do_check_neq(a2.pendingUpgrade, null);
+ do_check_eq(a2.pendingUpgrade.id, "addon2@tests.mozilla.org");
+ do_check_eq(a2.pendingUpgrade.install.existingAddon, a2);
+
+ restartManager();
+
+ AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
+ "addon2@tests.mozilla.org"], function([a1, a2]) {
+ // Should have uninstalled the old and installed the new
+ do_check_neq(a1, null);
+ do_check_neq(a2, null);
+
+ a1.uninstall();
+ a2.uninstall();
+
+ do_execute_soon(run_test_3);
+ });
+ }));
+}
+
+// Test that we rollback correctly when removing the old add-on fails
+function run_test_3() {
+ restartManager();
+ shutdownManager();
+
+ // This test only works on Windows
+ if (!("nsIWindowsRegKey" in AM_Ci)) {
+ run_test_4();
+ return;
+ }
+
+ writeInstallRDFForExtension({
+ id: "addon1@tests.mozilla.org",
+ version: "1.0",
+ updateURL: "http://localhost:4444/data/test_updateid.rdf",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "1",
+ maxVersion: "1"
+ }],
+ name: "Test Addon 1",
+ }, profileDir);
+
+ startupManager();
+
+ AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
+ do_check_neq(a1, null);
+ do_check_eq(a1.version, "1.0");
+
+ a1.findUpdates({
+ onUpdateAvailable: function(addon, install) {
+ installUpdate(install, check_test_3);
+ }
+ }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
+ });
+}
+
+function check_test_3(install) {
+ AddonManager.getAddonByID("addon1@tests.mozilla.org", callback_soon(function(a1) {
+ // Existing add-on should have a pending upgrade
+ do_check_neq(a1.pendingUpgrade, null);
+ do_check_eq(a1.pendingUpgrade.id, "addon2@tests.mozilla.org");
+ do_check_eq(a1.pendingUpgrade.install.existingAddon, a1);
+
+ // Lock the old add-on open so it can't be uninstalled
+ var file = profileDir.clone();
+ file.append("addon1@tests.mozilla.org");
+ if (!file.exists())
+ file.leafName += ".xpi";
+ else
+ file.append("install.rdf");
+
+ var fstream = AM_Cc["@mozilla.org/network/file-output-stream;1"].
+ createInstance(AM_Ci.nsIFileOutputStream);
+ fstream.init(file, FileUtils.MODE_APPEND | FileUtils.MODE_WRONLY, FileUtils.PERMS_FILE, 0);
+
+ restartManager();
+
+ fstream.close();
+
+ AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
+ "addon2@tests.mozilla.org"],
+ callback_soon(function([a1, a2]) {
+ // Should not have installed the new add-on but it should still be
+ // pending install
+ do_check_neq(a1, null);
+ do_check_eq(a2, null);
+
+ restartManager();
+
+ AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
+ "addon2@tests.mozilla.org"], function([a1, a2]) {
+ // Should have installed the new add-on
+ do_check_eq(a1, null);
+ do_check_neq(a2, null);
+
+ a2.uninstall();
+
+ do_execute_soon(run_test_4);
+ });
+ }));
+ }));
+}
+
+// Tests that upgrading to a bootstrapped add-on works but requires a restart
+function run_test_4() {
+ restartManager();
+ shutdownManager();
+
+ writeInstallRDFForExtension({
+ id: "addon2@tests.mozilla.org",
+ version: "2.0",
+ updateURL: "http://localhost:4444/data/test_updateid.rdf",
+ targetApplications: [{
+ id: "xpcshell@tests.mozilla.org",
+ minVersion: "1",
+ maxVersion: "1"
+ }],
+ name: "Test Addon 2",
+ }, profileDir);
+
startupManager();
- run_next_test();
+
+ resetPrefs();
+
+ AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) {
+ do_check_neq(a2, null);
+ do_check_neq(a2.syncGUID, null);
+ do_check_eq(a2.version, "2.0");
+
+ a2.findUpdates({
+ onUpdateAvailable: function(addon, install) {
+ installUpdate(install, check_test_4);
+ }
+ }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
+ });
}
-// Verify that an update to an add-on with a new ID fails
-add_task(function* test_update_new_id() {
- yield promiseInstallFile(do_get_addon("test_updateid1"));
+function check_test_4() {
+ AddonManager.getAddonsByIDs(["addon2@tests.mozilla.org",
+ "addon3@tests.mozilla.org"],
+ callback_soon(function([a2, a3]) {
+ // Should still be pending install even though the new add-on is restartless
+ do_check_neq(a2, null);
+ do_check_eq(a3, null);
- let addon = yield promiseAddonByID("addon1@tests.mozilla.org");
- do_check_neq(addon, null);
- do_check_eq(addon.version, "1.0");
+ do_check_neq(a2.pendingUpgrade, null);
+ do_check_eq(a2.pendingUpgrade.id, "addon3@tests.mozilla.org");
- let update = yield promiseFindAddonUpdates(addon, AddonManager.UPDATE_WHEN_USER_REQUESTED);
- let install = update.updateAvailable;
- do_check_eq(install.name, addon.name);
- do_check_eq(install.version, "2.0");
- do_check_eq(install.state, AddonManager.STATE_AVAILABLE);
- do_check_eq(install.existingAddon, addon);
+ do_check_eq(getInstalledVersion(), -1);
+ do_check_eq(getActiveVersion(), -1);
- yield Assert.rejects(promiseInstallUpdate(install),
- function(err) { return err.code == AddonManager.ERROR_INCORRECT_ID },
- "Upgrade to a different ID fails");
+ restartManager();
- addon.uninstall();
-});
+ AddonManager.getAddonsByIDs(["addon2@tests.mozilla.org",
+ "addon3@tests.mozilla.org"], function([a2, a3]) {
+ // Should have updated
+ do_check_eq(a2, null);
+ do_check_neq(a3, null);
-// Verify that an update to a multi-package xpi fails
-add_task(function* test_update_new_id() {
- yield promiseInstallFile(do_get_addon("test_update_multi1"));
+ do_check_eq(getInstalledVersion(), 3);
+ do_check_eq(getActiveVersion(), 3);
- let addon = yield promiseAddonByID("updatemulti@tests.mozilla.org");
- do_check_neq(addon, null);
- do_check_eq(addon.version, "1.0");
+ do_execute_soon(run_test_5);
+ });
+ }));
+}
+
+// Tests that upgrading to another bootstrapped add-on works without a restart
+function run_test_5() {
+ AddonManager.getAddonByID("addon3@tests.mozilla.org", function(a3) {
+ do_check_neq(a3, null);
+ do_check_eq(a3.version, "3.0");
+
+ a3.findUpdates({
+ onUpdateAvailable: function(addon, install) {
+ installUpdate(install, check_test_5);
+ }
+ }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
+ });
+}
+
+function check_test_5() {
+ AddonManager.getAddonsByIDs(["addon3@tests.mozilla.org",
+ "addon4@tests.mozilla.org"],
+ callback_soon(function([a3, a4]) {
+ // Should have updated
+ do_check_eq(a3, null);
+ do_check_neq(a4, null);
+
+ do_check_eq(getInstalledVersion(), 4);
+ do_check_eq(getActiveVersion(), 4);
+
+ restartManager();
+
+ AddonManager.getAddonsByIDs(["addon3@tests.mozilla.org",
+ "addon4@tests.mozilla.org"], function([a3, a4]) {
+ // Should still be gone
+ do_check_eq(a3, null);
+ do_check_neq(a4, null);
+
+ do_check_eq(getInstalledVersion(), 4);
+ do_check_eq(getActiveVersion(), 4);
+
+ run_test_6();
+ });
+ }));
+}
+
+// Tests that upgrading to a non-bootstrapped add-on works but requires a restart
+function run_test_6() {
+ AddonManager.getAddonByID("addon4@tests.mozilla.org", function(a4) {
+ do_check_neq(a4, null);
+ do_check_eq(a4.version, "4.0");
+
+ a4.findUpdates({
+ onUpdateAvailable: function(addon, install) {
+ installUpdate(install, check_test_6);
+ }
+ }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
+ });
+}
- let update = yield promiseFindAddonUpdates(addon, AddonManager.UPDATE_WHEN_USER_REQUESTED);
- let install = update.updateAvailable;
- do_check_eq(install.name, addon.name);
- do_check_eq(install.version, "2.0");
- do_check_eq(install.state, AddonManager.STATE_AVAILABLE);
- do_check_eq(install.existingAddon, addon);
+function check_test_6() {
+ AddonManager.getAddonsByIDs(["addon4@tests.mozilla.org",
+ "addon2@tests.mozilla.org"],
+ callback_soon(function([a4, a2]) {
+ // Should still be pending install even though the old add-on is restartless
+ do_check_neq(a4, null);
+ do_check_eq(a2, null);
- yield Assert.rejects(promiseInstallUpdate(install),
- function(err) { return err.code == AddonManager.ERROR_UNEXPECTED_ADDON_TYPE },
- "Upgrade to a multipackage xpi fails");
+ do_check_neq(a4.pendingUpgrade, null);
+ do_check_eq(a4.pendingUpgrade.id, "addon2@tests.mozilla.org");
- addon.uninstall();
-});
+ do_check_eq(getInstalledVersion(), 4);
+ do_check_eq(getActiveVersion(), 4);
+
+ restartManager();
+
+ AddonManager.getAddonsByIDs(["addon4@tests.mozilla.org",
+ "addon2@tests.mozilla.org"], function([a4, a2]) {
+ // Should have updated
+ do_check_eq(a4, null);
+ do_check_neq(a2, null);
+
+ do_check_eq(getInstalledVersion(), 0);
+ do_check_eq(getActiveVersion(), 0);
+
+ end_test();
+ });
+ }));
+}
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_upgrade.js b/toolkit/mozapps/extensions/test/xpcshell/test_upgrade.js
index dc3d9438a..f79789b68 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_upgrade.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_upgrade.js
@@ -15,7 +15,7 @@ Services.prefs.setIntPref("extensions.enabledScopes",
const profileDir = gProfD.clone();
profileDir.append("extensions");
-const globalDir = Services.dirsvc.get("XREAddonAppDir", AM_Ci.nsIFile);
+const globalDir = Services.dirsvc.get("XCurProcD", AM_Ci.nsIFile);
globalDir.append("extensions");
var gGlobalExisted = globalDir.exists();
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_upgrade_strictcompat.js b/toolkit/mozapps/extensions/test/xpcshell/test_upgrade_strictcompat.js
index c2203d097..69383166e 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/test_upgrade_strictcompat.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_upgrade_strictcompat.js
@@ -13,7 +13,7 @@ Services.prefs.setIntPref("extensions.enabledScopes",
const profileDir = gProfD.clone();
profileDir.append("extensions");
-const globalDir = Services.dirsvc.get("XREAddonAppDir", AM_Ci.nsIFile);
+const globalDir = Services.dirsvc.get("XCurProcD", AM_Ci.nsIFile);
globalDir.append("extensions");
var gGlobalExisted = globalDir.exists();
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_webextension.js b/toolkit/mozapps/extensions/test/xpcshell/test_webextension.js
deleted file mode 100644
index b51f47977..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_webextension.js
+++ /dev/null
@@ -1,421 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-Components.utils.import("resource://gre/modules/AppConstants.jsm");
-
-const ID = "webextension1@tests.mozilla.org";
-
-const PREF_SELECTED_LOCALE = "general.useragent.locale";
-
-const profileDir = gProfD.clone();
-profileDir.append("extensions");
-
-createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "42");
-startupManager();
-
-const { GlobalManager, Management } = Components.utils.import("resource://gre/modules/Extension.jsm", {});
-
-function promiseAddonStartup() {
- return new Promise(resolve => {
- let listener = (evt, extension) => {
- Management.off("ready", listener);
- resolve(extension);
- };
-
- Management.on("ready", listener);
- });
-}
-
-function promiseInstallWebExtension(aData) {
- let addonFile = createTempWebExtensionFile(aData);
-
- return promiseInstallAllFiles([addonFile]).then(() => {
- Services.obs.notifyObservers(addonFile, "flush-cache-entry", null);
- return promiseAddonStartup();
- });
-}
-
-add_task(function*() {
- equal(GlobalManager.extensionMap.size, 0);
-
- yield Promise.all([
- promiseInstallAllFiles([do_get_addon("webextension_1")], true),
- promiseAddonStartup()
- ]);
-
- equal(GlobalManager.extensionMap.size, 1);
- ok(GlobalManager.extensionMap.has(ID));
-
- let chromeReg = AM_Cc["@mozilla.org/chrome/chrome-registry;1"].
- getService(AM_Ci.nsIChromeRegistry);
- try {
- chromeReg.convertChromeURL(NetUtil.newURI("chrome://webex/content/webex.xul"));
- do_throw("Chrome manifest should not have been registered");
- }
- catch (e) {
- // Expected the chrome url to not be registered
- }
-
- let addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
- do_check_eq(addon.version, "1.0");
- do_check_eq(addon.name, "Web Extension Name");
- do_check_true(addon.isCompatible);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_false(addon.isSystem);
- do_check_eq(addon.type, "extension");
- do_check_true(addon.isWebExtension);
- do_check_eq(addon.signedState, mozinfo.addon_signing ? AddonManager.SIGNEDSTATE_SIGNED : AddonManager.SIGNEDSTATE_NOT_REQUIRED);
-
- let uri = do_get_addon_root_uri(profileDir, ID);
-
- do_check_eq(addon.iconURL, uri + "icon48.png");
- do_check_eq(addon.icon64URL, uri + "icon64.png");
-
- // Should persist through a restart
- yield promiseShutdownManager();
-
- equal(GlobalManager.extensionMap.size, 0);
-
- startupManager();
- yield promiseAddonStartup();
-
- equal(GlobalManager.extensionMap.size, 1);
- ok(GlobalManager.extensionMap.has(ID));
-
- addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
- do_check_eq(addon.version, "1.0");
- do_check_eq(addon.name, "Web Extension Name");
- do_check_true(addon.isCompatible);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_false(addon.isSystem);
- do_check_eq(addon.type, "extension");
- do_check_eq(addon.signedState, mozinfo.addon_signing ? AddonManager.SIGNEDSTATE_SIGNED : AddonManager.SIGNEDSTATE_NOT_REQUIRED);
-
- let file = getFileForAddon(profileDir, ID);
- do_check_true(file.exists());
-
- uri = do_get_addon_root_uri(profileDir, ID);
-
- do_check_eq(addon.iconURL, uri + "icon48.png");
- do_check_eq(addon.icon64URL, uri + "icon64.png");
-
- addon.userDisabled = true;
-
- equal(GlobalManager.extensionMap.size, 0);
-
- addon.userDisabled = false;
- yield promiseAddonStartup();
-
- equal(GlobalManager.extensionMap.size, 1);
- ok(GlobalManager.extensionMap.has(ID));
-
- addon.uninstall();
-
- equal(GlobalManager.extensionMap.size, 0);
- do_check_false(GlobalManager.extensionMap.has(ID));
-
- yield promiseShutdownManager();
-});
-
-// Writing the manifest direct to the profile should work
-add_task(function*() {
- yield promiseWriteWebManifestForExtension({
- name: "Web Extension Name",
- version: "1.0",
- manifest_version: 2,
- applications: {
- gecko: {
- id: ID
- }
- }
- }, profileDir);
-
- startupManager();
- yield promiseAddonStartup();
-
- let addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
- do_check_eq(addon.version, "1.0");
- do_check_eq(addon.name, "Web Extension Name");
- do_check_true(addon.isCompatible);
- do_check_false(addon.appDisabled);
- do_check_true(addon.isActive);
- do_check_false(addon.isSystem);
- do_check_eq(addon.type, "extension");
- do_check_eq(addon.signedState, mozinfo.addon_signing ? AddonManager.SIGNEDSTATE_SIGNED : AddonManager.SIGNEDSTATE_NOT_REQUIRED);
-
- let file = getFileForAddon(profileDir, ID);
- do_check_true(file.exists());
-
- addon.uninstall();
-
- yield promiseRestartManager();
-});
-
-add_task(function* test_manifest_localization() {
- const extensionId = "webextension3@tests.mozilla.org";
-
- yield promiseInstallAllFiles([do_get_addon("webextension_3")], true);
- yield promiseAddonStartup();
-
- let addon = yield promiseAddonByID(extensionId);
- addon.userDisabled = true;
-
- equal(addon.name, "Web Extensiøn foo ☹");
- equal(addon.description, "Descriptïon bar ☹ of add-on");
-
- Services.prefs.setCharPref(PREF_SELECTED_LOCALE, "fr-FR");
- yield promiseRestartManager();
-
- addon = yield promiseAddonByID(extensionId);
-
- equal(addon.name, "Web Extensiøn le foo ☺");
- equal(addon.description, "Descriptïon le bar ☺ of add-on");
-
- Services.prefs.setCharPref(PREF_SELECTED_LOCALE, "de");
- yield promiseRestartManager();
-
- addon = yield promiseAddonByID(extensionId);
-
- equal(addon.name, "Web Extensiøn foo ☹");
- equal(addon.description, "Descriptïon bar ☹ of add-on");
-
- addon.uninstall();
-});
-
-// Missing version should cause a failure
-add_task(function*() {
- yield promiseWriteWebManifestForExtension({
- name: "Web Extension Name",
- manifest_version: 2,
- applications: {
- gecko: {
- id: ID
- }
- }
- }, profileDir);
-
- yield promiseRestartManager();
-
- let addon = yield promiseAddonByID(ID);
- do_check_eq(addon, null);
-
- let file = getFileForAddon(profileDir, ID);
- do_check_false(file.exists());
-
- yield promiseRestartManager();
-});
-
-// Incorrect manifest version should cause a failure
-add_task(function*() {
- yield promiseWriteWebManifestForExtension({
- name: "Web Extension Name",
- version: "1.0",
- manifest_version: 1,
- applications: {
- gecko: {
- id: ID
- }
- }
- }, profileDir);
-
- yield promiseRestartManager();
-
- let addon = yield promiseAddonByID(ID);
- do_check_eq(addon, null);
-
- let file = getFileForAddon(profileDir, ID);
- do_check_false(file.exists());
-
- yield promiseRestartManager();
-});
-
-// install.rdf should be read before manifest.json
-add_task(function*() {
-
- yield Promise.all([
- promiseInstallAllFiles([do_get_addon("webextension_2")], true)
- ]);
-
- yield promiseRestartManager();
-
- let installrdf_id = "first-webextension2@tests.mozilla.org";
- let first_addon = yield promiseAddonByID(installrdf_id);
- do_check_neq(first_addon, null);
- do_check_false(first_addon.appDisabled);
- do_check_true(first_addon.isActive);
- do_check_false(first_addon.isSystem);
-
- let manifestjson_id= "last-webextension2@tests.mozilla.org";
- let last_addon = yield promiseAddonByID(manifestjson_id);
- do_check_eq(last_addon, null);
-
- yield promiseRestartManager();
-});
-
-// Test that the "options_ui" manifest section is processed correctly.
-add_task(function* test_options_ui() {
- let OPTIONS_RE = /^moz-extension:\/\/[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}\/options\.html$/;
-
- const extensionId = "webextension@tests.mozilla.org";
- yield promiseInstallWebExtension({
- manifest: {
- applications: {gecko: {id: extensionId}},
- "options_ui": {
- "page": "options.html",
- },
- },
- });
-
- let addon = yield promiseAddonByID(extensionId);
- equal(addon.optionsType, AddonManager.OPTIONS_TYPE_INLINE_BROWSER,
- "Addon should have an INLINE_BROWSER options type");
-
- ok(OPTIONS_RE.test(addon.optionsURL),
- "Addon should have a moz-extension: options URL for /options.html");
-
- addon.uninstall();
-
- const ID2 = "webextension2@tests.mozilla.org";
- yield promiseInstallWebExtension({
- manifest: {
- applications: {gecko: {id: ID2}},
- "options_ui": {
- "page": "options.html",
- "open_in_tab": true,
- },
- },
- });
-
- addon = yield promiseAddonByID(ID2);
- equal(addon.optionsType, AddonManager.OPTIONS_TYPE_TAB,
- "Addon should have a TAB options type");
-
- ok(OPTIONS_RE.test(addon.optionsURL),
- "Addon should have a moz-extension: options URL for /options.html");
-
- addon.uninstall();
-});
-
-// Test that experiments permissions add the appropriate dependencies.
-add_task(function* test_experiments_dependencies() {
- if (AppConstants.RELEASE_OR_BETA)
- // Experiments are not enabled on release builds.
- return;
-
- let addonFile = createTempWebExtensionFile({
- manifest: {
- applications: {gecko: {id: "meh@experiment"}},
- "permissions": ["experiments.meh"],
- },
- });
-
- yield promiseInstallAllFiles([addonFile]);
-
- let addon = yield new Promise(resolve => AddonManager.getAddonByID("meh@experiment", resolve));
-
- deepEqual(addon.dependencies, ["meh@experiments.addons.mozilla.org"],
- "Addon should have the expected dependencies");
-
- equal(addon.appDisabled, true, "Add-on should be app disabled due to missing dependencies");
-
- addon.uninstall();
-});
-
-// Test that experiments API extensions install correctly.
-add_task(function* test_experiments_api() {
- if (AppConstants.RELEASE_OR_BETA)
- // Experiments are not enabled on release builds.
- return;
-
- const extensionId = "meh@experiments.addons.mozilla.org";
-
- let addonFile = createTempXPIFile({
- id: extensionId,
- type: 256,
- version: "0.1",
- name: "Meh API",
- });
-
- yield promiseInstallAllFiles([addonFile]);
-
- let addons = yield new Promise(resolve => AddonManager.getAddonsByTypes(["apiextension"], resolve));
- let addon = addons.pop();
- equal(addon.id, extensionId, "Add-on should be installed as an API extension");
-
- addons = yield new Promise(resolve => AddonManager.getAddonsByTypes(["extension"], resolve));
- equal(addons.pop().id, extensionId, "Add-on type should be aliased to extension");
-
- addon.uninstall();
-});
-
-add_task(function* developerShouldOverride() {
- let addon = yield promiseInstallWebExtension({
- manifest: {
- default_locale: "en",
- developer: {
- name: "__MSG_name__",
- url: "__MSG_url__"
- },
- author: "Will be overridden by developer",
- homepage_url: "https://will.be.overridden",
- },
- files: {
- "_locales/en/messages.json": `{
- "name": {
- "message": "en name"
- },
- "url": {
- "message": "https://example.net/en"
- }
- }`
- }
- });
-
- addon = yield promiseAddonByID(addon.id);
- equal(addon.creator, "en name");
- equal(addon.homepageURL, "https://example.net/en");
- addon.uninstall();
-});
-
-add_task(function* developerEmpty() {
- for (let developer of [{}, null, {name: null, url: null}]) {
- let addon = yield promiseInstallWebExtension({
- manifest: {
- author: "Some author",
- developer: developer,
- homepage_url: "https://example.net",
- manifest_version: 2,
- name: "Web Extension Name",
- version: "1.0",
- }
- });
-
- addon = yield promiseAddonByID(addon.id);
- equal(addon.creator, "Some author");
- equal(addon.homepageURL, "https://example.net");
- addon.uninstall();
- }
-});
-
-add_task(function* authorNotString() {
- for (let author of [{}, [], 42]) {
- let addon = yield promiseInstallWebExtension({
- manifest: {
- author: author,
- manifest_version: 2,
- name: "Web Extension Name",
- version: "1.0",
- }
- });
-
- addon = yield promiseAddonByID(addon.id);
- equal(addon.creator, null);
- addon.uninstall();
- }
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_embedded.js b/toolkit/mozapps/extensions/test/xpcshell/test_webextension_embedded.js
deleted file mode 100644
index 3bd8a2bd8..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_embedded.js
+++ /dev/null
@@ -1,306 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-BootstrapMonitor.init();
-
-const profileDir = gProfD.clone();
-profileDir.append("extensions");
-
-createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "49");
-startupManager();
-
-// NOTE: the following import needs to be called after the `createAppInfo`
-// or it will fail Extension.jsm internally imports AddonManager.jsm and
-// AddonManager will raise a ReferenceError exception because it tried to
-// access an undefined `Services.appinfo` object.
-const { Management } = Components.utils.import("resource://gre/modules/Extension.jsm", {});
-
-const {
- EmbeddedExtensionManager,
- LegacyExtensionsUtils,
-} = Components.utils.import("resource://gre/modules/LegacyExtensionsUtils.jsm");
-
-// Wait the startup of the embedded webextension.
-function promiseWebExtensionStartup() {
- return new Promise(resolve => {
- let listener = (event, extension) => {
- Management.off("startup", listener);
- resolve(extension);
- };
-
- Management.on("startup", listener);
- });
-}
-
-function promiseWebExtensionShutdown() {
- return new Promise(resolve => {
- let listener = (event, extension) => {
- Management.off("shutdown", listener);
- resolve(extension);
- };
-
- Management.on("shutdown", listener);
- });
-}
-
-const BOOTSTRAP = String.raw`
- Components.utils.import("resource://xpcshell-data/BootstrapMonitor.jsm").monitor(this);
-`;
-
-const EMBEDDED_WEBEXT_MANIFEST = JSON.stringify({
- name: "embedded webextension addon",
- manifest_version: 2,
- version: "1.0",
-});
-
-/**
- * This test case checks that an hasEmbeddedWebExtension addon property
- * is persisted and restored correctly across restarts.
- */
-add_task(function* has_embedded_webextension_persisted() {
- const ID = "embedded-webextension-addon-persist@tests.mozilla.org";
-
- const xpiFile = createTempXPIFile({
- id: ID,
- name: "Test Add-on",
- version: "1.0",
- bootstrap: true,
- hasEmbeddedWebExtension: true,
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "1.9.2"
- }]
- }, {
- "bootstrap.js": BOOTSTRAP,
- "webextension/manifest.json": EMBEDDED_WEBEXT_MANIFEST,
- });
-
- yield promiseInstallFile(xpiFile);
-
- let addon = yield promiseAddonByID(ID);
-
- notEqual(addon, null, "Got an addon object as expected");
- equal(addon.version, "1.0", "Got the expected version");
- equal(addon.hasEmbeddedWebExtension, true,
- "Got the expected hasEmbeddedWebExtension value");
-
- // Check that the addon has been installed and started.
- BootstrapMonitor.checkAddonInstalled(ID, "1.0");
- BootstrapMonitor.checkAddonStarted(ID, "1.0");
-
- let startupInfo = BootstrapMonitor.started.get(ID);
- ok(("webExtension" in startupInfo.data),
- "Got an webExtension property in the startup bootstrap method params");
- ok(("startup" in startupInfo.data.webExtension),
- "Got the expected 'startup' property in the webExtension object");
-
- // After restarting the manager, the add-on should still have the
- // hasEmbeddedWebExtension property as expected.
- yield promiseRestartManager();
-
- let persisted = JSON.parse(Services.prefs.getCharPref("extensions.bootstrappedAddons"));
- ok(ID in persisted, "Hybrid add-on persisted to bootstrappedAddons.");
- equal(persisted[ID].hasEmbeddedWebExtension, true,
- "hasEmbeddedWebExtension flag persisted to bootstrappedAddons.");
-
- // Check that the addon has been installed and started.
- BootstrapMonitor.checkAddonInstalled(ID, "1.0");
- BootstrapMonitor.checkAddonStarted(ID, "1.0");
-
- addon = yield promiseAddonByID(ID);
- notEqual(addon, null, "Got an addon object as expected");
- equal(addon.hasEmbeddedWebExtension, true, "Got the expected hasEmbeddedWebExtension value");
-
- // Check that the addon has been installed and started.
- let newStartupInfo = BootstrapMonitor.started.get(ID);
- ok(("webExtension" in newStartupInfo.data),
- "Got an webExtension property in the startup bootstrap method params");
- ok(("startup" in newStartupInfo.data.webExtension),
- "Got the expected 'startup' property in the webExtension object");
-
- let waitUninstall = promiseAddonEvent("onUninstalled");
- addon.uninstall();
- yield waitUninstall;
-});
-
-/**
- * This test case checks that an addon with hasEmbeddedWebExtension set to true
- * in its install.rdf gets the expected `embeddedWebExtension` object in the
- * parameters of its bootstrap methods.
- */
-add_task(function* run_embedded_webext_bootstrap() {
- const ID = "embedded-webextension-addon2@tests.mozilla.org";
-
- const xpiFile = createTempXPIFile({
- id: ID,
- name: "Test Add-on",
- version: "1.0",
- bootstrap: true,
- hasEmbeddedWebExtension: true,
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "1.9.2"
- }]
- }, {
- "bootstrap.js": BOOTSTRAP,
- "webextension/manifest.json": EMBEDDED_WEBEXT_MANIFEST,
- });
-
- yield AddonManager.installTemporaryAddon(xpiFile);
-
- let addon = yield promiseAddonByID(ID);
-
- notEqual(addon, null, "Got an addon object as expected");
- equal(addon.version, "1.0", "Got the expected version");
- equal(addon.hasEmbeddedWebExtension, true,
- "Got the expected hasEmbeddedWebExtension value");
-
- // Check that the addon has been installed and started.
- BootstrapMonitor.checkAddonInstalled(ID, "1.0");
-
- let installInfo = BootstrapMonitor.installed.get(ID);
- ok(!("webExtension" in installInfo.data),
- "No webExtension property is expected in the install bootstrap method params");
-
- BootstrapMonitor.checkAddonStarted(ID, "1.0");
-
- let startupInfo = BootstrapMonitor.started.get(ID);
-
- ok(("webExtension" in startupInfo.data),
- "Got an webExtension property in the startup bootstrap method params");
-
- ok(("startup" in startupInfo.data.webExtension),
- "Got the expected 'startup' property in the webExtension object");
-
- const waitForWebExtensionStartup = promiseWebExtensionStartup();
-
- const embeddedAPI = yield startupInfo.data.webExtension.startup();
-
- // WebExtension startup should have been fully resolved.
- yield waitForWebExtensionStartup;
-
- Assert.deepEqual(
- Object.keys(embeddedAPI.browser.runtime).sort(),
- ["onConnect", "onMessage"],
- `Got the expected 'runtime' in the 'browser' API object`
- );
-
- // Uninstall the addon and wait that the embedded webextension has been stopped and
- // test the params of the shutdown and uninstall bootstrap method.
- let waitForWebExtensionShutdown = promiseWebExtensionShutdown();
- let waitUninstall = promiseAddonEvent("onUninstalled");
- addon.uninstall();
- yield waitForWebExtensionShutdown;
- yield waitUninstall;
-
- BootstrapMonitor.checkAddonNotStarted(ID, "1.0");
-
- let shutdownInfo = BootstrapMonitor.stopped.get(ID);
- ok(!("webExtension" in shutdownInfo.data),
- "No webExtension property is expected in the shutdown bootstrap method params");
-
- let uninstallInfo = BootstrapMonitor.uninstalled.get(ID);
- ok(!("webExtension" in uninstallInfo.data),
- "No webExtension property is expected in the uninstall bootstrap method params");
-});
-
-/**
- * This test case checks that an addon with hasEmbeddedWebExtension can be reloaded
- * without raising unexpected exceptions due to race conditions.
- */
-add_task(function* reload_embedded_webext_bootstrap() {
- const ID = "embedded-webextension-addon2@tests.mozilla.org";
-
- // No embedded webextension should be currently around.
- equal(EmbeddedExtensionManager.embeddedExtensionsByAddonId.size, 0,
- "No embedded extension instance should be tracked here");
-
- const xpiFile = createTempXPIFile({
- id: ID,
- name: "Test Add-on",
- version: "1.0",
- bootstrap: true,
- hasEmbeddedWebExtension: true,
- targetApplications: [{
- id: "xpcshell@tests.mozilla.org",
- minVersion: "1",
- maxVersion: "1.9.2"
- }]
- }, {
- "bootstrap.js": BOOTSTRAP,
- "webextension/manifest.json": EMBEDDED_WEBEXT_MANIFEST,
- });
-
- yield AddonManager.installTemporaryAddon(xpiFile);
-
- let addon = yield promiseAddonByID(ID);
-
- notEqual(addon, null, "Got an addon object as expected");
- equal(addon.version, "1.0", "Got the expected version");
- equal(addon.isActive, true, "The Addon is active");
- equal(addon.appDisabled, false, "The addon is not app disabled");
- equal(addon.userDisabled, false, "The addon is not user disabled");
-
- // Check that the addon has been installed and started.
- BootstrapMonitor.checkAddonInstalled(ID, "1.0");
- BootstrapMonitor.checkAddonStarted(ID, "1.0");
-
- // Only one embedded extension.
- equal(EmbeddedExtensionManager.embeddedExtensionsByAddonId.size, 1,
- "Got the expected number of tracked extension instances");
-
- const embeddedWebExtension = EmbeddedExtensionManager.embeddedExtensionsByAddonId.get(ID);
-
- let startupInfo = BootstrapMonitor.started.get(ID);
- yield startupInfo.data.webExtension.startup();
-
- const waitForAddonDisabled = promiseAddonEvent("onDisabled");
- addon.userDisabled = true;
- yield waitForAddonDisabled;
-
- // No embedded webextension should be currently around.
- equal(EmbeddedExtensionManager.embeddedExtensionsByAddonId.size, 0,
- "No embedded extension instance should be tracked here");
-
- const waitForAddonEnabled = promiseAddonEvent("onEnabled");
- addon.userDisabled = false;
- yield waitForAddonEnabled;
-
- // Only one embedded extension.
- equal(EmbeddedExtensionManager.embeddedExtensionsByAddonId.size, 1,
- "Got the expected number of tracked extension instances");
-
- const embeddedWebExtensionAfterEnabled = EmbeddedExtensionManager.embeddedExtensionsByAddonId.get(ID);
- notEqual(embeddedWebExtensionAfterEnabled, embeddedWebExtension,
- "Got a new EmbeddedExtension instance after the addon has been disabled and then enabled");
-
- startupInfo = BootstrapMonitor.started.get(ID);
- yield startupInfo.data.webExtension.startup();
-
- const waitForReinstalled = promiseAddonEvent("onInstalled");
- addon.reload();
- yield waitForReinstalled;
-
- // No leaked embedded extension after the previous reloads.
- equal(EmbeddedExtensionManager.embeddedExtensionsByAddonId.size, 1,
- "Got the expected number of tracked extension instances");
-
- const embeddedWebExtensionAfterReload = EmbeddedExtensionManager.embeddedExtensionsByAddonId.get(ID);
- notEqual(embeddedWebExtensionAfterReload, embeddedWebExtensionAfterEnabled,
- "Got a new EmbeddedExtension instance after the addon has been reloaded");
-
- startupInfo = BootstrapMonitor.started.get(ID);
- yield startupInfo.data.webExtension.startup();
-
- // Uninstall the test addon
- let waitUninstalled = promiseAddonEvent("onUninstalled");
- addon.uninstall();
- yield waitUninstalled;
-
- // No leaked embedded extension after uninstalling.
- equal(EmbeddedExtensionManager.embeddedExtensionsByAddonId.size, 0,
- "No embedded extension instance should be tracked after the addon uninstall");
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_icons.js b/toolkit/mozapps/extensions/test/xpcshell/test_webextension_icons.js
deleted file mode 100644
index 25fb4115f..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_icons.js
+++ /dev/null
@@ -1,169 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/
- */
-
-const ID = "webextension1@tests.mozilla.org";
-
-const profileDir = gProfD.clone();
-profileDir.append("extensions");
-profileDir.create(AM_Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
-
-createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "42");
-startupManager();
-
-const { Management } = Components.utils.import("resource://gre/modules/Extension.jsm", {});
-
-function promiseAddonStartup() {
- return new Promise(resolve => {
- let listener = (evt, extension) => {
- Management.off("startup", listener);
- resolve(extension);
- };
-
- Management.on("startup", listener);
- });
-}
-
-// Test simple icon set parsing
-add_task(function*() {
- yield promiseWriteWebManifestForExtension({
- name: "Web Extension Name",
- version: "1.0",
- manifest_version: 2,
- applications: {
- gecko: {
- id: ID
- }
- },
- icons: {
- 16: "icon16.png",
- 32: "icon32.png",
- 48: "icon48.png",
- 64: "icon64.png"
- }
- }, profileDir);
-
- yield promiseRestartManager();
- yield promiseAddonStartup();
-
- let uri = do_get_addon_root_uri(profileDir, ID);
-
- let addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
-
- function check_icons(addon_copy) {
- deepEqual(addon_copy.icons, {
- 16: uri + "icon16.png",
- 32: uri + "icon32.png",
- 48: uri + "icon48.png",
- 64: uri + "icon64.png"
- });
-
- // iconURL should map to icons[48] and icons[64]
- equal(addon.iconURL, uri + "icon48.png");
- equal(addon.icon64URL, uri + "icon64.png");
-
- // AddonManager gets the correct icon sizes from addon.icons
- equal(AddonManager.getPreferredIconURL(addon, 1), uri + "icon16.png");
- equal(AddonManager.getPreferredIconURL(addon, 16), uri + "icon16.png");
- equal(AddonManager.getPreferredIconURL(addon, 30), uri + "icon32.png");
- equal(AddonManager.getPreferredIconURL(addon, 48), uri + "icon48.png");
- equal(AddonManager.getPreferredIconURL(addon, 64), uri + "icon64.png");
- equal(AddonManager.getPreferredIconURL(addon, 128), uri + "icon64.png");
- }
-
- check_icons(addon);
-
- // check if icons are persisted through a restart
- yield promiseRestartManager();
- yield promiseAddonStartup();
-
- addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
-
- check_icons(addon);
-
- addon.uninstall();
-
- yield promiseRestartManager();
-});
-
-// Test AddonManager.getPreferredIconURL for retina screen sizes
-add_task(function*() {
- yield promiseWriteWebManifestForExtension({
- name: "Web Extension Name",
- version: "1.0",
- manifest_version: 2,
- applications: {
- gecko: {
- id: ID
- }
- },
- icons: {
- 32: "icon32.png",
- 48: "icon48.png",
- 64: "icon64.png",
- 128: "icon128.png",
- 256: "icon256.png"
- }
- }, profileDir);
-
- yield promiseRestartManager();
- yield promiseAddonStartup();
-
- let addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
-
- let uri = do_get_addon_root_uri(profileDir, ID);
-
- // AddonManager displays larger icons for higher pixel density
- equal(AddonManager.getPreferredIconURL(addon, 32, {
- devicePixelRatio: 2
- }), uri + "icon64.png");
-
- equal(AddonManager.getPreferredIconURL(addon, 48, {
- devicePixelRatio: 2
- }), uri + "icon128.png");
-
- equal(AddonManager.getPreferredIconURL(addon, 64, {
- devicePixelRatio: 2
- }), uri + "icon128.png");
-
- addon.uninstall();
-
- yield promiseRestartManager();
-});
-
-// Handles no icons gracefully
-add_task(function*() {
- yield promiseWriteWebManifestForExtension({
- name: "Web Extension Name",
- version: "1.0",
- manifest_version: 2,
- applications: {
- gecko: {
- id: ID
- }
- }
- }, profileDir);
-
- yield promiseRestartManager();
- yield promiseAddonStartup();
-
- let addon = yield promiseAddonByID(ID);
- do_check_neq(addon, null);
-
- let uri = do_get_addon_root_uri(profileDir, ID);
-
- deepEqual(addon.icons, {});
-
- equal(addon.iconURL, null);
- equal(addon.icon64URL, null);
-
- equal(AddonManager.getPreferredIconURL(addon, 128), null);
-
- addon.uninstall();
-
- yield promiseRestartManager();
-});
-
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js b/toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js
deleted file mode 100644
index 1e7c9d9b7..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js
+++ /dev/null
@@ -1,478 +0,0 @@
-
-const {ADDON_SIGNING} = AM_Cu.import("resource://gre/modules/addons/AddonConstants.jsm", {});
-
-function run_test() {
- run_next_test();
-}
-
-let profileDir;
-add_task(function* setup() {
- profileDir = gProfD.clone();
- profileDir.append("extensions");
-
- if (!profileDir.exists())
- profileDir.create(AM_Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
-
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
- startupManager();
-});
-
-const IMPLICIT_ID_XPI = "data/webext-implicit-id.xpi";
-const IMPLICIT_ID_ID = "webext_implicit_id@tests.mozilla.org";
-
-// webext-implicit-id.xpi has a minimal manifest with no
-// applications or browser_specific_settings, so its id comes
-// from its signature, which should be the ID constant defined below.
-add_task(function* test_implicit_id() {
- // This test needs to read the xpi certificate which only works
- // if signing is enabled.
- ok(ADDON_SIGNING, "Add-on signing is enabled");
-
- let addon = yield promiseAddonByID(IMPLICIT_ID_ID);
- equal(addon, null, "Add-on is not installed");
-
- let xpifile = do_get_file(IMPLICIT_ID_XPI);
- yield promiseInstallAllFiles([xpifile]);
-
- addon = yield promiseAddonByID(IMPLICIT_ID_ID);
- notEqual(addon, null, "Add-on is installed");
-
- addon.uninstall();
-});
-
-// We should also be able to install webext-implicit-id.xpi temporarily
-// and it should look just like the regular install (ie, the ID should
-// come from the signature)
-add_task(function* test_implicit_id_temp() {
- // This test needs to read the xpi certificate which only works
- // if signing is enabled.
- ok(ADDON_SIGNING, "Add-on signing is enabled");
-
- let addon = yield promiseAddonByID(IMPLICIT_ID_ID);
- equal(addon, null, "Add-on is not installed");
-
- let xpifile = do_get_file(IMPLICIT_ID_XPI);
- yield AddonManager.installTemporaryAddon(xpifile);
-
- addon = yield promiseAddonByID(IMPLICIT_ID_ID);
- notEqual(addon, null, "Add-on is installed");
-
- // The sourceURI of a temporary installed addon should be equal to the
- // file url of the installed xpi file.
- equal(addon.sourceURI && addon.sourceURI.spec,
- Services.io.newFileURI(xpifile).spec,
- "SourceURI of the add-on has the expected value");
-
- addon.uninstall();
-});
-
-// We should be able to temporarily install an unsigned web extension
-// that does not have an ID in its manifest.
-add_task(function* test_unsigned_no_id_temp_install() {
- AddonTestUtils.useRealCertChecks = true;
- const manifest = {
- name: "no ID",
- description: "extension without an ID",
- manifest_version: 2,
- version: "1.0"
- };
-
- const addonDir = yield promiseWriteWebManifestForExtension(manifest, gTmpD,
- "the-addon-sub-dir");
- const addon = yield AddonManager.installTemporaryAddon(addonDir);
- ok(addon.id, "ID should have been auto-generated");
-
- // The sourceURI of a temporary installed addon should be equal to the
- // file url of the installed source dir.
- equal(addon.sourceURI && addon.sourceURI.spec,
- Services.io.newFileURI(addonDir).spec,
- "SourceURI of the add-on has the expected value");
-
- // Install the same directory again, as if re-installing or reloading.
- const secondAddon = yield AddonManager.installTemporaryAddon(addonDir);
- // The IDs should be the same.
- equal(secondAddon.id, addon.id, "Reinstalled add-on has the expected ID");
-
- secondAddon.uninstall();
- Services.obs.notifyObservers(addonDir, "flush-cache-entry", null);
- addonDir.remove(true);
- AddonTestUtils.useRealCertChecks = false;
-});
-
-// We should be able to install two extensions from manifests without IDs
-// at different locations and get two unique extensions.
-add_task(function* test_multiple_no_id_extensions() {
- AddonTestUtils.useRealCertChecks = true;
- const manifest = {
- name: "no ID",
- description: "extension without an ID",
- manifest_version: 2,
- version: "1.0"
- };
-
- let extension1 = ExtensionTestUtils.loadExtension({
- manifest: manifest,
- useAddonManager: "temporary",
- });
-
- let extension2 = ExtensionTestUtils.loadExtension({
- manifest: manifest,
- useAddonManager: "temporary",
- });
-
- yield Promise.all([extension1.startup(), extension2.startup()]);
-
- const allAddons = yield new Promise(resolve => {
- AddonManager.getAllAddons(addons => resolve(addons));
- });
- do_print(`Found these add-ons: ${allAddons.map(a => a.name).join(", ")}`);
- const filtered = allAddons.filter(addon => addon.name === manifest.name);
- // Make sure we have two add-ons by the same name.
- equal(filtered.length, 2, "Two add-ons are installed with the same name");
-
- yield extension1.unload();
- yield extension2.unload();
- AddonTestUtils.useRealCertChecks = false;
-});
-
-// Test that we can get the ID from browser_specific_settings
-add_task(function* test_bss_id() {
- const ID = "webext_bss_id@tests.mozilla.org";
-
- let manifest = {
- name: "bss test",
- description: "test that ID may be in browser_specific_settings",
- manifest_version: 2,
- version: "1.0",
-
- browser_specific_settings: {
- gecko: {
- id: ID
- }
- }
- };
-
- let addon = yield promiseAddonByID(ID);
- equal(addon, null, "Add-on is not installed");
-
- let extension = ExtensionTestUtils.loadExtension({
- manifest: manifest,
- useAddonManager: "temporary",
- });
- yield extension.startup();
-
- addon = yield promiseAddonByID(ID);
- notEqual(addon, null, "Add-on is installed");
-
- yield extension.unload();
-});
-
-// Test that if we have IDs in both browser_specific_settings and applications,
-// that we prefer the ID in browser_specific_settings.
-add_task(function* test_two_ids() {
- const GOOD_ID = "two_ids@tests.mozilla.org";
- const BAD_ID = "i_am_obsolete@tests.mozilla.org";
-
- let manifest = {
- name: "two id test",
- description: "test a web extension with ids in both applications and browser_specific_settings",
- manifest_version: 2,
- version: "1.0",
-
- applications: {
- gecko: {
- id: BAD_ID
- }
- },
-
- browser_specific_settings: {
- gecko: {
- id: GOOD_ID
- }
- }
- }
-
- let extension = ExtensionTestUtils.loadExtension({
- manifest: manifest,
- useAddonManager: "temporary",
- });
- yield extension.startup();
-
- let addon = yield promiseAddonByID(BAD_ID);
- equal(addon, null, "Add-on is not found using bad ID");
- addon = yield promiseAddonByID(GOOD_ID);
- notEqual(addon, null, "Add-on is found using good ID");
-
- yield extension.unload();
-});
-
-// Test that strict_min_version and strict_max_version are enforced for
-// loading temporary extension.
-add_task(function* test_strict_min_max() {
- // the app version being compared to is 1.9.2
- const addonId = "strict_min_max@tests.mozilla.org";
- const MANIFEST = {
- name: "strict min max test",
- description: "test strict min and max with temporary loading",
- manifest_version: 2,
- version: "1.0",
- };
-
- // bad max good min
- let apps = {
- applications: {
- gecko: {
- id: addonId,
- strict_min_version: "1",
- strict_max_version: "1"
- },
- },
- }
- let testManifest = Object.assign(apps, MANIFEST);
-
- let extension = ExtensionTestUtils.loadExtension({
- manifest: testManifest,
- useAddonManager: "temporary",
- });
-
- let expectedMsg = new RegExp("Add-on strict_min_max@tests.mozilla.org is not compatible with application version. " +
- "add-on minVersion: 1. add-on maxVersion: 1.");
- yield Assert.rejects(extension.startup(),
- expectedMsg,
- "Install rejects when specified maxVersion is not valid");
-
- let addon = yield promiseAddonByID(addonId);
- equal(addon, null, "Add-on is not installed");
-
- // bad min good max
- apps = {
- applications: {
- gecko: {
- id: addonId,
- strict_min_version: "2",
- strict_max_version: "2"
- },
- },
- }
- testManifest = Object.assign(apps, MANIFEST);
-
- extension = ExtensionTestUtils.loadExtension({
- manifest: testManifest,
- useAddonManager: "temporary",
- });
-
- expectedMsg = new RegExp("Add-on strict_min_max@tests.mozilla.org is not compatible with application version. " +
- "add-on minVersion: 2. add-on maxVersion: 2.");
- yield Assert.rejects(extension.startup(),
- expectedMsg,
- "Install rejects when specified minVersion is not valid");
-
- addon = yield promiseAddonByID(addonId);
- equal(addon, null, "Add-on is not installed");
-
- // bad both
- apps = {
- applications: {
- gecko: {
- id: addonId,
- strict_min_version: "2",
- strict_max_version: "1"
- },
- },
- }
- testManifest = Object.assign(apps, MANIFEST);
-
- extension = ExtensionTestUtils.loadExtension({
- manifest: testManifest,
- useAddonManager: "temporary",
- });
-
- expectedMsg = new RegExp("Add-on strict_min_max@tests.mozilla.org is not compatible with application version. " +
- "add-on minVersion: 2. add-on maxVersion: 1.");
- yield Assert.rejects(extension.startup(),
- expectedMsg,
- "Install rejects when specified minVersion and maxVersion are not valid");
-
- addon = yield promiseAddonByID(addonId);
- equal(addon, null, "Add-on is not installed");
-
- // bad only min
- apps = {
- applications: {
- gecko: {
- id: addonId,
- strict_min_version: "2"
- },
- },
- }
- testManifest = Object.assign(apps, MANIFEST);
-
- extension = ExtensionTestUtils.loadExtension({
- manifest: testManifest,
- useAddonManager: "temporary",
- });
-
- expectedMsg = new RegExp("Add-on strict_min_max@tests.mozilla.org is not compatible with application version\. " +
- "add-on minVersion: 2\.");
- yield Assert.rejects(extension.startup(),
- expectedMsg,
- "Install rejects when specified minVersion and maxVersion are not valid");
-
- addon = yield promiseAddonByID(addonId);
- equal(addon, null, "Add-on is not installed");
-
- // bad only max
- apps = {
- applications: {
- gecko: {
- id: addonId,
- strict_max_version: "1"
- },
- },
- }
- testManifest = Object.assign(apps, MANIFEST);
-
- extension = ExtensionTestUtils.loadExtension({
- manifest: testManifest,
- useAddonManager: "temporary",
- });
-
- expectedMsg = new RegExp("Add-on strict_min_max@tests.mozilla.org is not compatible with application version\. " +
- "add-on maxVersion: 1\.");
- yield Assert.rejects(extension.startup(),
- expectedMsg,
- "Install rejects when specified minVersion and maxVersion are not valid");
-
- addon = yield promiseAddonByID(addonId);
- equal(addon, null, "Add-on is not installed");
-
- // good both
- apps = {
- applications: {
- gecko: {
- id: addonId,
- strict_min_version: "1",
- strict_max_version: "2"
- },
- },
- }
- testManifest = Object.assign(apps, MANIFEST);
-
- extension = ExtensionTestUtils.loadExtension({
- manifest: testManifest,
- useAddonManager: "temporary",
- });
-
- yield extension.startup();
- addon = yield promiseAddonByID(addonId);
-
- notEqual(addon, null, "Add-on is installed");
- equal(addon.id, addonId, "Installed add-on has the expected ID");
- yield extension.unload();
-
- // good only min
- let newId = "strict_min_only@tests.mozilla.org";
- apps = {
- applications: {
- gecko: {
- id: newId,
- strict_min_version: "1",
- },
- },
- }
- testManifest = Object.assign(apps, MANIFEST);
-
- extension = ExtensionTestUtils.loadExtension({
- manifest: testManifest,
- useAddonManager: "temporary",
- });
-
- yield extension.startup();
- addon = yield promiseAddonByID(newId);
-
- notEqual(addon, null, "Add-on is installed");
- equal(addon.id, newId, "Installed add-on has the expected ID");
-
- yield extension.unload();
-
- // good only max
- newId = "strict_max_only@tests.mozilla.org";
- apps = {
- applications: {
- gecko: {
- id: newId,
- strict_max_version: "2",
- },
- },
- }
- testManifest = Object.assign(apps, MANIFEST);
-
- extension = ExtensionTestUtils.loadExtension({
- manifest: testManifest,
- useAddonManager: "temporary",
- });
-
- yield extension.startup();
- addon = yield promiseAddonByID(newId);
-
- notEqual(addon, null, "Add-on is installed");
- equal(addon.id, newId, "Installed add-on has the expected ID");
-
- yield extension.unload();
-
- // * in min will throw an error
- for (let version of ["0.*", "0.*.0"]) {
- newId = "strict_min_star@tests.mozilla.org";
- let minStarApps = {
- applications: {
- gecko: {
- id: newId,
- strict_min_version: version,
- },
- },
- }
-
- let minStarTestManifest = Object.assign(minStarApps, MANIFEST);
-
- let minStarExtension = ExtensionTestUtils.loadExtension({
- manifest: minStarTestManifest,
- useAddonManager: "temporary",
- });
-
- yield Assert.rejects(
- minStarExtension.startup(),
- /The use of '\*' in strict_min_version is invalid/,
- "loading an extension with a * in strict_min_version throws an exception");
-
- let minStarAddon = yield promiseAddonByID(newId);
- equal(minStarAddon, null, "Add-on is not installed");
- }
-
- // incompatible extension but with compatibility checking off
- newId = "checkCompatibility@tests.mozilla.org";
- apps = {
- applications: {
- gecko: {
- id: newId,
- strict_max_version: "1",
- },
- },
- }
- testManifest = Object.assign(apps, MANIFEST);
-
- extension = ExtensionTestUtils.loadExtension({
- manifest: testManifest,
- useAddonManager: "temporary",
- });
-
- let savedCheckCompatibilityValue = AddonManager.checkCompatibility;
- AddonManager.checkCompatibility = false;
- yield extension.startup();
- addon = yield promiseAddonByID(newId);
-
- notEqual(addon, null, "Add-on is installed");
- equal(addon.id, newId, "Installed add-on has the expected ID");
-
- yield extension.unload();
- AddonManager.checkCompatibility = savedCheckCompatibilityValue;
-});
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_paths.js b/toolkit/mozapps/extensions/test/xpcshell/test_webextension_paths.js
deleted file mode 100644
index 29a3dacf7..000000000
--- a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_paths.js
+++ /dev/null
@@ -1,55 +0,0 @@
-function run_test() {
- run_next_test();
-}
-
-let profileDir;
-add_task(function* setup() {
- profileDir = gProfD.clone();
- profileDir.append("extensions");
-
- createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
- startupManager();
-});
-
-// When installing an unpacked addon we derive the ID from the
-// directory name. Make sure that if the directoy name is not a valid
-// addon ID that we reject it.
-add_task(function* test_bad_unpacked_path() {
- let MANIFEST_ID = "webext_bad_path@tests.mozilla.org";
-
- let manifest = {
- name: "path test",
- description: "test of a bad directory name",
- manifest_version: 2,
- version: "1.0",
-
- browser_specific_settings: {
- gecko: {
- id: MANIFEST_ID
- }
- }
- };
-
- const directories = [
- "not a valid ID",
- '"quotes"@tests.mozilla.org',
- ];
-
- for (let dir of directories) {
- try {
- yield promiseWriteWebManifestForExtension(manifest, profileDir, dir);
- } catch (ex) {
- // This can fail if the underlying filesystem (looking at you windows)
- // doesn't handle some of the characters in the ID. In that case,
- // just ignore this test on this platform.
- continue;
- }
- yield promiseRestartManager();
-
- let addon = yield promiseAddonByID(dir);
- do_check_eq(addon, null);
- addon = yield promiseAddonByID(MANIFEST_ID);
- do_check_eq(addon, null);
- }
-});
-
diff --git a/toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini b/toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini
index 1e86e5861..bab072e83 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini
+++ b/toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini
@@ -1,14 +1,10 @@
# The file is shared between the two main xpcshell manifest files.
[DEFAULT]
-skip-if = toolkit == 'android'
-tags = addons
+skip-if = toolkit == 'android' || toolkit == 'gonk'
[test_AddonRepository.js]
-[test_reload.js]
# Bug 676992: test consistently hangs on Android
-# There's a problem removing a temp file without manually clearing the cache on Windows
-skip-if = os == "android" || os == "win"
-tags = webextensions
+skip-if = os == "android"
[test_AddonRepository_cache.js]
# Bug 676992: test consistently hangs on Android
# Bug 1026805: frequent hangs on OSX 10.8
@@ -33,7 +29,6 @@ skip-if = os == "android"
[test_bootstrap.js]
# Bug 676992: test consistently hangs on Android
skip-if = os == "android"
-[test_bootstrap_const.js]
[test_bootstrap_resource.js]
[test_bug299716.js]
# Bug 676992: test consistently hangs on Android
@@ -116,7 +111,7 @@ skip-if = os == "android"
skip-if = os == "android"
[test_bug514327_2.js]
# Bug 676992: test consistently hangs on Android
-skip-if = os == "android"
+skip-if = buildapp == "mulet" || os == "android"
[test_bug514327_3.js]
# Bug 676992: test consistently hangs on Android
skip-if = os == "android"
@@ -140,6 +135,7 @@ fail-if = os == "android"
[test_bug594058.js]
[test_bug595081.js]
[test_bug595573.js]
+[test_bug596343.js]
[test_bug596607.js]
[test_bug616841.js]
# Bug 676992: test consistently fails on Android
@@ -195,12 +191,8 @@ skip-if = os == "android"
[test_gfxBlacklist_OSVersion_mismatch_OSVersion.js]
[test_gfxBlacklist_OSVersion_mismatch_DriverVersion.js]
[test_gfxBlacklist_Vendor.js]
-[test_gfxBlacklist_Version.js]
[test_gfxBlacklist_prefs.js]
-# Bug 1248787 - consistently fails
-skip-if = true
[test_hasbinarycomponents.js]
-[test_hotfix.js]
[test_install.js]
[test_install_icons.js]
# Bug 676992: test consistently hangs on Android
@@ -233,31 +225,16 @@ requesttimeoutfactor = 2
[test_permissions.js]
[test_permissions_prefs.js]
[test_plugins.js]
+skip-if = buildapp == "mulet"
[test_pluginchange.js]
# PluginProvider.jsm is not shipped on Android
skip-if = os == "android"
[test_pluginBlocklistCtp.js]
# Bug 676992: test consistently fails on Android
-fail-if = os == "android"
+fail-if = buildapp == "mulet" || os == "android"
[test_pref_properties.js]
[test_registry.js]
[test_safemode.js]
-[test_signed_updatepref.js]
-run-if = addon_signing
-skip-if = require_signing
-[test_signed_verify.js]
-run-if = addon_signing
-[test_signed_inject.js]
-run-if = addon_signing
-[test_signed_install.js]
-run-if = addon_signing
-run-sequentially = Uses hardcoded ports in xpi files.
-[test_signed_long.js]
-run-if = addon_signing
-[test_signed_migrate.js]
-run-if = addon_signing
-[test_signed_multi.js]
-run-if = addon_signing
[test_startup.js]
# Bug 676992: test consistently fails on Android
fail-if = os == "android"
@@ -274,8 +251,6 @@ fail-if = os == "android"
[test_update.js]
# Bug 676992: test consistently hangs on Android
skip-if = os == "android"
-[test_update_webextensions.js]
-tags = webextensions
[test_updateCancel.js]
[test_update_strictcompat.js]
# Bug 676992: test consistently hangs on Android
@@ -287,9 +262,6 @@ skip-if = os == "android"
# Bug 676992: test consistently hangs on Android
skip-if = os == "android"
run-sequentially = Uses hardcoded ports in xpi files.
-[test_json_updatecheck.js]
-[test_seen.js]
-[test_seen_newprofile.js]
[test_updateid.js]
# Bug 676992: test consistently hangs on Android
skip-if = os == "android"
@@ -306,29 +278,4 @@ run-sequentially = Uses global XCurProcD dir.
[test_overrideblocklist.js]
run-sequentially = Uses global XCurProcD dir.
[test_sourceURI.js]
-[test_webextension_icons.js]
-skip-if = appname == "thunderbird"
-tags = webextensions
-[test_webextension.js]
-skip-if = appname == "thunderbird"
-tags = webextensions
-[test_webextension_install.js]
-skip-if = appname == "thunderbird"
-tags = webextensions
-[test_webextension_embedded.js]
-skip-if = appname == "thunderbird"
-tags = webextensions
[test_bootstrap_globals.js]
-[test_bug1180901_2.js]
-skip-if = os != "win"
-[test_bug1180901.js]
-skip-if = os != "win"
-[test_e10s_restartless.js]
-[test_switch_os.js]
-# Bug 1246231
-skip-if = os == "mac" && debug
-[test_softblocked.js]
-[test_ext_management.js]
-skip-if = appname == "thunderbird"
-tags = webextensions
-
diff --git a/toolkit/mozapps/extensions/test/xpcshell/xpcshell-unpack.ini b/toolkit/mozapps/extensions/test/xpcshell/xpcshell-unpack.ini
index 42a0ca1ca..51520f888 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/xpcshell-unpack.ini
+++ b/toolkit/mozapps/extensions/test/xpcshell/xpcshell-unpack.ini
@@ -2,11 +2,7 @@
head = head_addons.js head_unpack.js
tail =
firefox-appdir = browser
-skip-if = toolkit == 'android'
+skip-if = toolkit == 'android' || toolkit == 'gonk'
dupe-manifest =
-tags = addons
-
-[test_webextension_paths.js]
-tags = webextensions
[include:xpcshell-shared.ini]
diff --git a/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini b/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini
index 2b95eb158..83ab77c74 100644
--- a/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini
+++ b/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini
@@ -1,6 +1,5 @@
[DEFAULT]
-skip-if = toolkit == 'android'
-tags = addons
+skip-if = buildapp == 'mulet' || toolkit == 'android' || toolkit == 'gonk'
head = head_addons.js
tail =
firefox-appdir = browser
@@ -11,14 +10,10 @@ support-files =
[test_addon_path_service.js]
[test_asyncBlocklistLoad.js]
-[test_blocklist_gfx.js]
-[test_cache_certdb.js]
-run-if = addon_signing
[test_cacheflush.js]
[test_DeferredSave.js]
[test_gmpProvider.js]
-skip-if = appname != "firefox"
-[test_hotfix_cert.js]
+run-if = appname == "firefox"
[test_isReady.js]
[test_metadata_update.js]
[test_pluginInfoURL.js]
@@ -26,25 +21,8 @@ skip-if = appname != "firefox"
[test_provider_shutdown.js]
[test_provider_unsafe_access_shutdown.js]
[test_provider_unsafe_access_startup.js]
-[test_ProductAddonChecker.js]
[test_shutdown.js]
-[test_system_update.js]
-[test_system_reset.js]
[test_XPIcancel.js]
[test_XPIStates.js]
-[test_temporary.js]
-tags = webextensions
-[test_install_from_sources.js]
-[test_proxies.js]
-[test_proxy.js]
-[test_pass_symbol.js]
-[test_delay_update.js]
-[test_nodisable_hidden.js]
-[test_delay_update_webextension.js]
-skip-if = appname == "thunderbird"
-tags = webextensions
-[test_dependencies.js]
-[test_schema_change.js]
-[test_system_delay_update.js]
[include:xpcshell-shared.ini]