michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: function run_test() { michael@0: runAsyncTests(tests); michael@0: } michael@0: michael@0: let tests = [ michael@0: michael@0: function nonexistent() { michael@0: yield setGlobal("foo", 1); michael@0: yield cps.removeAllDomains(null, makeCallback()); michael@0: yield dbOK([ michael@0: [null, "foo", 1], michael@0: ]); michael@0: yield getGlobalOK(["foo"], 1); michael@0: }, michael@0: michael@0: function domains() { michael@0: yield set("a.com", "foo", 1); michael@0: yield set("a.com", "bar", 2); michael@0: yield setGlobal("foo", 3); michael@0: yield setGlobal("bar", 4); michael@0: yield set("b.com", "foo", 5); michael@0: yield set("b.com", "bar", 6); michael@0: michael@0: yield cps.removeAllDomains(null, makeCallback()); michael@0: yield dbOK([ michael@0: [null, "foo", 3], michael@0: [null, "bar", 4], michael@0: ]); michael@0: yield getOK(["a.com", "foo"], undefined); michael@0: yield getOK(["a.com", "bar"], undefined); michael@0: yield getGlobalOK(["foo"], 3); michael@0: yield getGlobalOK(["bar"], 4); michael@0: yield getOK(["b.com", "foo"], undefined); michael@0: yield getOK(["b.com", "bar"], undefined); michael@0: }, michael@0: michael@0: function privateBrowsing() { michael@0: yield set("a.com", "foo", 1); michael@0: yield set("a.com", "bar", 2); michael@0: yield setGlobal("foo", 3); michael@0: yield setGlobal("bar", 4); michael@0: yield set("b.com", "foo", 5); michael@0: michael@0: let context = { usePrivateBrowsing: true }; michael@0: yield set("a.com", "foo", 6, context); michael@0: yield setGlobal("foo", 7, context); michael@0: yield cps.removeAllDomains(context, makeCallback()); michael@0: yield dbOK([ michael@0: [null, "foo", 3], michael@0: [null, "bar", 4], michael@0: ]); michael@0: yield getOK(["a.com", "foo", context], undefined); michael@0: yield getOK(["a.com", "bar", context], undefined); michael@0: yield getGlobalOK(["foo", context], 7); michael@0: yield getGlobalOK(["bar", context], 4); michael@0: yield getOK(["b.com", "foo", context], undefined); michael@0: michael@0: yield getOK(["a.com", "foo"], undefined); michael@0: yield getOK(["a.com", "bar"], undefined); michael@0: yield getGlobalOK(["foo"], 3); michael@0: yield getGlobalOK(["bar"], 4); michael@0: yield getOK(["b.com", "foo"], undefined); michael@0: }, michael@0: michael@0: function erroneous() { michael@0: do_check_throws(function () cps.removeAllDomains(null, "bogus")); michael@0: yield true; michael@0: }, michael@0: michael@0: function invalidateCache() { michael@0: yield set("a.com", "foo", 1); michael@0: yield set("b.com", "bar", 2); michael@0: yield setGlobal("baz", 3); michael@0: getCachedOK(["a.com", "foo"], true, 1); michael@0: getCachedOK(["b.com", "bar"], true, 2); michael@0: getCachedGlobalOK(["baz"], true, 3); michael@0: cps.removeAllDomains(null, makeCallback()); michael@0: getCachedOK(["a.com", "foo"], false); michael@0: getCachedOK(["b.com", "bar"], false); michael@0: getCachedGlobalOK(["baz"], true, 3); michael@0: yield; michael@0: }, michael@0: ];