Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
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/. */
5 function run_test() {
6 runAsyncTests(tests);
7 }
9 let tests = [
11 function nonexistent() {
12 yield setGlobal("foo", 1);
13 yield cps.removeAllDomains(null, makeCallback());
14 yield dbOK([
15 [null, "foo", 1],
16 ]);
17 yield getGlobalOK(["foo"], 1);
18 },
20 function domains() {
21 yield set("a.com", "foo", 1);
22 yield set("a.com", "bar", 2);
23 yield setGlobal("foo", 3);
24 yield setGlobal("bar", 4);
25 yield set("b.com", "foo", 5);
26 yield set("b.com", "bar", 6);
28 yield cps.removeAllDomains(null, makeCallback());
29 yield dbOK([
30 [null, "foo", 3],
31 [null, "bar", 4],
32 ]);
33 yield getOK(["a.com", "foo"], undefined);
34 yield getOK(["a.com", "bar"], undefined);
35 yield getGlobalOK(["foo"], 3);
36 yield getGlobalOK(["bar"], 4);
37 yield getOK(["b.com", "foo"], undefined);
38 yield getOK(["b.com", "bar"], undefined);
39 },
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);
48 let context = { usePrivateBrowsing: true };
49 yield set("a.com", "foo", 6, context);
50 yield setGlobal("foo", 7, context);
51 yield cps.removeAllDomains(context, makeCallback());
52 yield dbOK([
53 [null, "foo", 3],
54 [null, "bar", 4],
55 ]);
56 yield getOK(["a.com", "foo", context], undefined);
57 yield getOK(["a.com", "bar", context], undefined);
58 yield getGlobalOK(["foo", context], 7);
59 yield getGlobalOK(["bar", context], 4);
60 yield getOK(["b.com", "foo", context], undefined);
62 yield getOK(["a.com", "foo"], undefined);
63 yield getOK(["a.com", "bar"], undefined);
64 yield getGlobalOK(["foo"], 3);
65 yield getGlobalOK(["bar"], 4);
66 yield getOK(["b.com", "foo"], undefined);
67 },
69 function erroneous() {
70 do_check_throws(function () cps.removeAllDomains(null, "bogus"));
71 yield true;
72 },
74 function invalidateCache() {
75 yield set("a.com", "foo", 1);
76 yield set("b.com", "bar", 2);
77 yield setGlobal("baz", 3);
78 getCachedOK(["a.com", "foo"], true, 1);
79 getCachedOK(["b.com", "bar"], true, 2);
80 getCachedGlobalOK(["baz"], true, 3);
81 cps.removeAllDomains(null, makeCallback());
82 getCachedOK(["a.com", "foo"], false);
83 getCachedOK(["b.com", "bar"], false);
84 getCachedGlobalOK(["baz"], true, 3);
85 yield;
86 },
87 ];