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 get_nonexistent() { michael@0: yield getSubdomainsOK(["a.com", "foo"], []); michael@0: }, michael@0: michael@0: function isomorphicDomains() { michael@0: yield set("a.com", "foo", 1); michael@0: yield getSubdomainsOK(["a.com", "foo"], [["a.com", 1]]); michael@0: yield getSubdomainsOK(["http://a.com/huh", "foo"], [["a.com", 1]]); michael@0: }, michael@0: michael@0: function names() { michael@0: yield set("a.com", "foo", 1); michael@0: yield getSubdomainsOK(["a.com", "foo"], [["a.com", 1]]); michael@0: michael@0: yield set("a.com", "bar", 2); michael@0: yield getSubdomainsOK(["a.com", "foo"], [["a.com", 1]]); michael@0: yield getSubdomainsOK(["a.com", "bar"], [["a.com", 2]]); michael@0: michael@0: yield setGlobal("foo", 3); michael@0: yield getSubdomainsOK(["a.com", "foo"], [["a.com", 1]]); michael@0: yield getSubdomainsOK(["a.com", "bar"], [["a.com", 2]]); michael@0: }, michael@0: michael@0: function subdomains() { michael@0: yield set("a.com", "foo", 1); michael@0: yield set("b.a.com", "foo", 2); michael@0: yield getSubdomainsOK(["a.com", "foo"], [["a.com", 1], ["b.a.com", 2]]); michael@0: yield getSubdomainsOK(["b.a.com", "foo"], [["b.a.com", 2]]); 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 getSubdomainsOK(["a.com", "foo", context], [["a.com", 6]]); michael@0: yield getSubdomainsOK(["a.com", "bar", context], [["a.com", 2]]); michael@0: yield getSubdomainsOK(["b.com", "foo", context], [["b.com", 5]]); michael@0: michael@0: yield getSubdomainsOK(["a.com", "foo"], [["a.com", 1]]); michael@0: yield getSubdomainsOK(["a.com", "bar"], [["a.com", 2]]); michael@0: yield getSubdomainsOK(["b.com", "foo"], [["b.com", 5]]); michael@0: }, michael@0: michael@0: function erroneous() { michael@0: do_check_throws(function () michael@0: cps.getBySubdomainAndName(null, "foo", null, {})); michael@0: do_check_throws(function () michael@0: cps.getBySubdomainAndName("", "foo", null, {})); michael@0: do_check_throws(function () michael@0: cps.getBySubdomainAndName("a.com", "", null, {})); michael@0: do_check_throws(function () michael@0: cps.getBySubdomainAndName("a.com", null, null, {})); michael@0: do_check_throws(function () michael@0: cps.getBySubdomainAndName("a.com", "foo", null, null)); michael@0: yield true; michael@0: }, michael@0: ];