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