|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 function run_test() { |
|
5 // initialize the permission manager service |
|
6 const kTestAddr = "test@example.org"; |
|
7 const kType = "test-mailto"; |
|
8 const kCapability = 1; |
|
9 |
|
10 // make a mailto: URI with parameters |
|
11 let uri = Services.io.newURI("mailto:" + kTestAddr + "?subject=test", null, |
|
12 null); |
|
13 |
|
14 // add a permission entry for that URI |
|
15 Services.perms.add(uri, kType, kCapability); |
|
16 do_check_true(permission_exists(kTestAddr, kType, kCapability)); |
|
17 |
|
18 // remove the permission, and make sure it was removed |
|
19 Services.perms.remove(kTestAddr, kType); |
|
20 do_check_false(permission_exists(kTestAddr, kType, kCapability)); |
|
21 |
|
22 uri = Services.io.newURI("mailto:" + kTestAddr, null, null); |
|
23 Services.perms.add(uri, kType, kCapability); |
|
24 do_check_true(permission_exists(kTestAddr, kType, kCapability)); |
|
25 |
|
26 Services.perms.remove(kTestAddr, kType); |
|
27 do_check_false(permission_exists(kTestAddr, kType, kCapability)); |
|
28 } |
|
29 |
|
30 function permission_exists(aHost, aType, aCapability) { |
|
31 let e = Services.perms.enumerator; |
|
32 while (e.hasMoreElements()) { |
|
33 let perm = e.getNext().QueryInterface(Ci.nsIPermission); |
|
34 if (perm.host == aHost && |
|
35 perm.type == aType && |
|
36 perm.capability == aCapability) { |
|
37 return true; |
|
38 } |
|
39 } |
|
40 return false; |
|
41 } |