toolkit/components/contentprefs/tests/unit_cps2/test_getSubdomains.js

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

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 get_nonexistent() {
    12     yield getSubdomainsOK(["a.com", "foo"], []);
    13   },
    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   },
    21   function names() {
    22     yield set("a.com", "foo", 1);
    23     yield getSubdomainsOK(["a.com", "foo"], [["a.com", 1]]);
    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]]);
    29     yield setGlobal("foo", 3);
    30     yield getSubdomainsOK(["a.com", "foo"], [["a.com", 1]]);
    31     yield getSubdomainsOK(["a.com", "bar"], [["a.com", 2]]);
    32   },
    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   },
    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 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]]);
    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   },
    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 ];

mercurial