toolkit/mozapps/extensions/test/xpcshell/test_bug675371.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 * http://creativecommons.org/publicdomain/zero/1.0/
michael@0 3 */
michael@0 4
michael@0 5 function run_test() {
michael@0 6 do_test_pending();
michael@0 7 createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
michael@0 8 startupManager();
michael@0 9
michael@0 10 prepare_test({ }, [
michael@0 11 "onNewInstall"
michael@0 12 ]);
michael@0 13
michael@0 14 AddonManager.getInstallForFile(do_get_addon("test_bug675371"), function(install) {
michael@0 15 ensure_test_completed();
michael@0 16
michael@0 17 do_check_neq(install, null);
michael@0 18
michael@0 19 prepare_test({
michael@0 20 "bug675371@tests.mozilla.org": [
michael@0 21 ["onInstalling", false],
michael@0 22 "onInstalled"
michael@0 23 ]
michael@0 24 }, [
michael@0 25 "onInstallStarted",
michael@0 26 "onInstallEnded",
michael@0 27 ], callback_soon(check_test));
michael@0 28 install.install();
michael@0 29 });
michael@0 30 }
michael@0 31
michael@0 32 function check_test() {
michael@0 33 AddonManager.getAddonByID("bug675371@tests.mozilla.org", do_exception_wrap(function(addon) {
michael@0 34 do_check_neq(addon, null);
michael@0 35 do_check_true(addon.isActive);
michael@0 36
michael@0 37 // Tests that chrome.manifest is registered when the addon is installed.
michael@0 38 var target = { active: false };
michael@0 39 Services.scriptloader.loadSubScript("chrome://bug675371/content/test.js", target);
michael@0 40 do_check_true(target.active);
michael@0 41
michael@0 42 prepare_test({
michael@0 43 "bug675371@tests.mozilla.org": [
michael@0 44 ["onDisabling", false],
michael@0 45 "onDisabled"
michael@0 46 ]
michael@0 47 });
michael@0 48
michael@0 49 // Tests that chrome.manifest is unregistered when the addon is disabled.
michael@0 50 addon.userDisabled = true;
michael@0 51 target.active = false;
michael@0 52 try {
michael@0 53 Services.scriptloader.loadSubScript("chrome://bug675371/content/test.js", target);
michael@0 54 do_throw("Chrome file should not have been found");
michael@0 55 } catch (e) {
michael@0 56 do_check_false(target.active);
michael@0 57 }
michael@0 58
michael@0 59 prepare_test({
michael@0 60 "bug675371@tests.mozilla.org": [
michael@0 61 ["onEnabling", false],
michael@0 62 "onEnabled"
michael@0 63 ]
michael@0 64 });
michael@0 65
michael@0 66 // Tests that chrome.manifest is registered when the addon is enabled.
michael@0 67 addon.userDisabled = false;
michael@0 68 target.active = false;
michael@0 69 Services.scriptloader.loadSubScript("chrome://bug675371/content/test.js", target);
michael@0 70 do_check_true(target.active);
michael@0 71
michael@0 72 prepare_test({
michael@0 73 "bug675371@tests.mozilla.org": [
michael@0 74 ["onUninstalling", false],
michael@0 75 "onUninstalled"
michael@0 76 ]
michael@0 77 });
michael@0 78
michael@0 79 // Tests that chrome.manifest is unregistered when the addon is uninstalled.
michael@0 80 addon.uninstall();
michael@0 81 target.active = false;
michael@0 82 try {
michael@0 83 Services.scriptloader.loadSubScript("chrome://bug675371/content/test.js", target);
michael@0 84 do_throw("Chrome file should not have been found");
michael@0 85 } catch (e) {
michael@0 86 do_check_false(target.active);
michael@0 87 }
michael@0 88
michael@0 89 do_execute_soon(do_test_finished);
michael@0 90 }));
michael@0 91 }

mercurial