Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/
3 */
5 Components.utils.import("resource://gre/modules/NetUtil.jsm");
7 // Checks that permissions set in preferences are correctly imported but can
8 // be removed by the user.
10 const XPI_MIMETYPE = "application/x-xpinstall";
12 function run_test() {
13 createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "2");
15 Services.prefs.setCharPref("xpinstall.whitelist.add", "test1.com,test2.com");
16 Services.prefs.setCharPref("xpinstall.whitelist.add.36", "test3.com,www.test4.com");
17 Services.prefs.setCharPref("xpinstall.whitelist.add.test5", "test5.com");
19 Services.perms.add(NetUtil.newURI("http://www.test9.com"), "install",
20 AM_Ci.nsIPermissionManager.ALLOW_ACTION);
22 startupManager();
24 do_check_true(AddonManager.isInstallAllowed(XPI_MIMETYPE,
25 NetUtil.newURI("http://test1.com")));
26 do_check_true(AddonManager.isInstallAllowed(XPI_MIMETYPE,
27 NetUtil.newURI("https://www.test2.com")));
28 do_check_true(AddonManager.isInstallAllowed(XPI_MIMETYPE,
29 NetUtil.newURI("https://test3.com")));
30 do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
31 NetUtil.newURI("https://test4.com")));
32 do_check_true(AddonManager.isInstallAllowed(XPI_MIMETYPE,
33 NetUtil.newURI("https://www.test4.com")));
34 do_check_true(AddonManager.isInstallAllowed(XPI_MIMETYPE,
35 NetUtil.newURI("http://www.test5.com")));
37 do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
38 NetUtil.newURI("http://www.test6.com")));
39 do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
40 NetUtil.newURI("http://test7.com")));
41 do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
42 NetUtil.newURI("http://www.test8.com")));
44 // This should remain unaffected
45 do_check_true(AddonManager.isInstallAllowed(XPI_MIMETYPE,
46 NetUtil.newURI("http://www.test9.com")));
47 do_check_true(AddonManager.isInstallAllowed(XPI_MIMETYPE,
48 NetUtil.newURI("https://www.test9.com")));
50 Services.perms.removeAll();
52 do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
53 NetUtil.newURI("http://test1.com")));
54 do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
55 NetUtil.newURI("https://www.test2.com")));
56 do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
57 NetUtil.newURI("https://test3.com")));
58 do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
59 NetUtil.newURI("https://www.test4.com")));
60 do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
61 NetUtil.newURI("http://www.test5.com")));
63 // Upgrade the application and verify that the permissions are still not there
64 restartManager("2");
66 do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
67 NetUtil.newURI("http://test1.com")));
68 do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
69 NetUtil.newURI("https://www.test2.com")));
70 do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
71 NetUtil.newURI("https://test3.com")));
72 do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
73 NetUtil.newURI("https://www.test4.com")));
74 do_check_false(AddonManager.isInstallAllowed(XPI_MIMETYPE,
75 NetUtil.newURI("http://www.test5.com")));
76 }