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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/contentprefs/tests/unit_cps2/test_extractDomain.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,20 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +function run_test() {
     1.9 +  let tests = {
    1.10 +    "http://example.com": "example.com",
    1.11 +    "http://example.com/": "example.com",
    1.12 +    "http://example.com/foo/bar/baz": "example.com",
    1.13 +    "http://subdomain.example.com/foo/bar/baz": "subdomain.example.com",
    1.14 +    "http://qix.quux.example.com/foo/bar/baz": "qix.quux.example.com",
    1.15 +    "file:///home/foo/bar": "file:///home/foo/bar",
    1.16 +    "not a url": "not a url",
    1.17 +  };
    1.18 +  let cps = Cc["@mozilla.org/content-pref/service;1"].
    1.19 +            getService(Ci.nsIContentPrefService2);
    1.20 +  for (let url in tests) {
    1.21 +    do_check_eq(cps.extractDomain(url), tests[url]);
    1.22 +  }
    1.23 +}

mercurial