|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
|
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 function run_test() { |
|
6 runAsyncTests(tests); |
|
7 } |
|
8 |
|
9 let tests = [ |
|
10 |
|
11 function get_nonexistent() { |
|
12 yield getSubdomainsOK(["a.com", "foo"], []); |
|
13 }, |
|
14 |
|
15 function isomorphicDomains() { |
|
16 yield set("a.com", "foo", 1); |
|
17 yield getSubdomainsOK(["a.com", "foo"], [["a.com", 1]]); |
|
18 yield getSubdomainsOK(["http://a.com/huh", "foo"], [["a.com", 1]]); |
|
19 }, |
|
20 |
|
21 function names() { |
|
22 yield set("a.com", "foo", 1); |
|
23 yield getSubdomainsOK(["a.com", "foo"], [["a.com", 1]]); |
|
24 |
|
25 yield set("a.com", "bar", 2); |
|
26 yield getSubdomainsOK(["a.com", "foo"], [["a.com", 1]]); |
|
27 yield getSubdomainsOK(["a.com", "bar"], [["a.com", 2]]); |
|
28 |
|
29 yield setGlobal("foo", 3); |
|
30 yield getSubdomainsOK(["a.com", "foo"], [["a.com", 1]]); |
|
31 yield getSubdomainsOK(["a.com", "bar"], [["a.com", 2]]); |
|
32 }, |
|
33 |
|
34 function subdomains() { |
|
35 yield set("a.com", "foo", 1); |
|
36 yield set("b.a.com", "foo", 2); |
|
37 yield getSubdomainsOK(["a.com", "foo"], [["a.com", 1], ["b.a.com", 2]]); |
|
38 yield getSubdomainsOK(["b.a.com", "foo"], [["b.a.com", 2]]); |
|
39 }, |
|
40 |
|
41 function privateBrowsing() { |
|
42 yield set("a.com", "foo", 1); |
|
43 yield set("a.com", "bar", 2); |
|
44 yield setGlobal("foo", 3); |
|
45 yield setGlobal("bar", 4); |
|
46 yield set("b.com", "foo", 5); |
|
47 |
|
48 let context = { usePrivateBrowsing: true }; |
|
49 yield set("a.com", "foo", 6, context); |
|
50 yield setGlobal("foo", 7, context); |
|
51 yield getSubdomainsOK(["a.com", "foo", context], [["a.com", 6]]); |
|
52 yield getSubdomainsOK(["a.com", "bar", context], [["a.com", 2]]); |
|
53 yield getSubdomainsOK(["b.com", "foo", context], [["b.com", 5]]); |
|
54 |
|
55 yield getSubdomainsOK(["a.com", "foo"], [["a.com", 1]]); |
|
56 yield getSubdomainsOK(["a.com", "bar"], [["a.com", 2]]); |
|
57 yield getSubdomainsOK(["b.com", "foo"], [["b.com", 5]]); |
|
58 }, |
|
59 |
|
60 function erroneous() { |
|
61 do_check_throws(function () |
|
62 cps.getBySubdomainAndName(null, "foo", null, {})); |
|
63 do_check_throws(function () |
|
64 cps.getBySubdomainAndName("", "foo", null, {})); |
|
65 do_check_throws(function () |
|
66 cps.getBySubdomainAndName("a.com", "", null, {})); |
|
67 do_check_throws(function () |
|
68 cps.getBySubdomainAndName("a.com", null, null, {})); |
|
69 do_check_throws(function () |
|
70 cps.getBySubdomainAndName("a.com", "foo", null, null)); |
|
71 yield true; |
|
72 }, |
|
73 ]; |