Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
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;
10 // make a mailto: URI with parameters
11 let uri = Services.io.newURI("mailto:" + kTestAddr + "?subject=test", null,
12 null);
14 // add a permission entry for that URI
15 Services.perms.add(uri, kType, kCapability);
16 do_check_true(permission_exists(kTestAddr, kType, kCapability));
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));
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));
26 Services.perms.remove(kTestAddr, kType);
27 do_check_false(permission_exists(kTestAddr, kType, kCapability));
28 }
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 }