diff options
author | Matt A. Tobin <email@mattatobin.com> | 2020-02-25 15:07:00 -0500 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-04-14 12:55:19 +0200 |
commit | eb70e6e3d0bff11c25f14b1196025791bf2308fb (patch) | |
tree | 5ef4ce17db83c74d7b05ec12c8f59e095a6dd5bd /toolkit/modules/tests/xpcshell/test_PermissionsUtils.js | |
parent | 32ead795290b3399d56b4708fc75b77d296f6a1a (diff) | |
download | UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.gz UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.lz UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.xz UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.zip |
Issue #439 - Remove tests from toolkit/
Diffstat (limited to 'toolkit/modules/tests/xpcshell/test_PermissionsUtils.js')
-rw-r--r-- | toolkit/modules/tests/xpcshell/test_PermissionsUtils.js | 85 |
1 files changed, 0 insertions, 85 deletions
diff --git a/toolkit/modules/tests/xpcshell/test_PermissionsUtils.js b/toolkit/modules/tests/xpcshell/test_PermissionsUtils.js deleted file mode 100644 index 3982ce015..000000000 --- a/toolkit/modules/tests/xpcshell/test_PermissionsUtils.js +++ /dev/null @@ -1,85 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -// Tests that PerrmissionsUtils.jsm works as expected, including: -// * PermissionsUtils.importfromPrefs() -// <ROOT>.[whitelist|blacklist].add preferences are emptied when -// converted into permissions on startup. - - -const PREF_ROOT = "testpermissions."; -const TEST_PERM = "test-permission"; - -Components.utils.import("resource://gre/modules/Services.jsm"); -Components.utils.import("resource://gre/modules/PermissionsUtils.jsm"); - -function run_test() { - test_importfromPrefs(); -} - - -function test_importfromPrefs() { - // Create own preferences to test - Services.prefs.setCharPref(PREF_ROOT + "whitelist.add.EMPTY", ""); - Services.prefs.setCharPref(PREF_ROOT + "whitelist.add.EMPTY2", ","); - Services.prefs.setCharPref(PREF_ROOT + "whitelist.add.TEST", "http://whitelist.example.com"); - Services.prefs.setCharPref(PREF_ROOT + "whitelist.add.TEST2", "https://whitelist2-1.example.com,http://whitelist2-2.example.com:8080,about:home"); - Services.prefs.setCharPref(PREF_ROOT + "whitelist.add.TEST3", "whitelist3-1.example.com,about:config"); // legacy style - host only - Services.prefs.setCharPref(PREF_ROOT + "blacklist.add.EMPTY", ""); - Services.prefs.setCharPref(PREF_ROOT + "blacklist.add.TEST", "http://blacklist.example.com,"); - Services.prefs.setCharPref(PREF_ROOT + "blacklist.add.TEST2", ",https://blacklist2-1.example.com,http://blacklist2-2.example.com:8080,about:mozilla"); - Services.prefs.setCharPref(PREF_ROOT + "blacklist.add.TEST3", "blacklist3-1.example.com,about:preferences"); // legacy style - host only - - // Check they are unknown in the permission manager prior to importing. - let whitelisted = ["http://whitelist.example.com", - "https://whitelist2-1.example.com", - "http://whitelist2-2.example.com:8080", - "http://whitelist3-1.example.com", - "https://whitelist3-1.example.com", - "about:config", - "about:home"]; - let blacklisted = ["http://blacklist.example.com", - "https://blacklist2-1.example.com", - "http://blacklist2-2.example.com:8080", - "http://blacklist3-1.example.com", - "https://blacklist3-1.example.com", - "about:preferences", - "about:mozilla"]; - let untouched = ["https://whitelist.example.com", - "https://blacklist.example.com", - "http://whitelist2-1.example.com", - "http://blacklist2-1.example.com", - "https://whitelist2-2.example.com:8080", - "https://blacklist2-2.example.com:8080"]; - let unknown = whitelisted.concat(blacklisted).concat(untouched); - for (let url of unknown) { - let uri = Services.io.newURI(url, null, null); - do_check_eq(Services.perms.testPermission(uri, TEST_PERM), Services.perms.UNKNOWN_ACTION); - } - - // Import them - PermissionsUtils.importFromPrefs(PREF_ROOT, TEST_PERM); - - // Get list of preferences to check - let preferences = Services.prefs.getChildList(PREF_ROOT, {}); - - // Check preferences were emptied - for (let pref of preferences) { - do_check_eq(Services.prefs.getCharPref(pref), ""); - } - - // Check they were imported into the permissions manager - for (let url of whitelisted) { - let uri = Services.io.newURI(url, null, null); - do_check_eq(Services.perms.testPermission(uri, TEST_PERM), Services.perms.ALLOW_ACTION); - } - for (let url of blacklisted) { - let uri = Services.io.newURI(url, null, null); - do_check_eq(Services.perms.testPermission(uri, TEST_PERM), Services.perms.DENY_ACTION); - } - for (let url of untouched) { - let uri = Services.io.newURI(url, null, null); - do_check_eq(Services.perms.testPermission(uri, TEST_PERM), Services.perms.UNKNOWN_ACTION); - } -} |