tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_utils_makeURI.js (2477B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 _("Make sure uri strings are converted to nsIURIs");
      5 
      6 function run_test() {
      7  _test_makeURI();
      8 }
      9 
     10 function _test_makeURI() {
     11  _("Check http uris");
     12  let uri1 = "http://mozillalabs.com/";
     13  Assert.equal(CommonUtils.makeURI(uri1).spec, uri1);
     14  let uri2 = "http://www.mozillalabs.com/";
     15  Assert.equal(CommonUtils.makeURI(uri2).spec, uri2);
     16  let uri3 = "http://mozillalabs.com/path";
     17  Assert.equal(CommonUtils.makeURI(uri3).spec, uri3);
     18  let uri4 = "http://mozillalabs.com/multi/path";
     19  Assert.equal(CommonUtils.makeURI(uri4).spec, uri4);
     20  let uri5 = "http://mozillalabs.com/?query";
     21  Assert.equal(CommonUtils.makeURI(uri5).spec, uri5);
     22  let uri6 = "http://mozillalabs.com/#hash";
     23  Assert.equal(CommonUtils.makeURI(uri6).spec, uri6);
     24 
     25  _("Check https uris");
     26  let uris1 = "https://mozillalabs.com/";
     27  Assert.equal(CommonUtils.makeURI(uris1).spec, uris1);
     28  let uris2 = "https://www.mozillalabs.com/";
     29  Assert.equal(CommonUtils.makeURI(uris2).spec, uris2);
     30  let uris3 = "https://mozillalabs.com/path";
     31  Assert.equal(CommonUtils.makeURI(uris3).spec, uris3);
     32  let uris4 = "https://mozillalabs.com/multi/path";
     33  Assert.equal(CommonUtils.makeURI(uris4).spec, uris4);
     34  let uris5 = "https://mozillalabs.com/?query";
     35  Assert.equal(CommonUtils.makeURI(uris5).spec, uris5);
     36  let uris6 = "https://mozillalabs.com/#hash";
     37  Assert.equal(CommonUtils.makeURI(uris6).spec, uris6);
     38 
     39  _("Check chrome uris");
     40  let uric1 = "chrome://browser/content/browser.xhtml";
     41  Assert.equal(CommonUtils.makeURI(uric1).spec, uric1);
     42  let uric2 = "chrome://browser/skin/browser.css";
     43  Assert.equal(CommonUtils.makeURI(uric2).spec, uric2);
     44 
     45  _("Check about uris");
     46  let uria1 = "about:weave";
     47  Assert.equal(CommonUtils.makeURI(uria1).spec, uria1);
     48  let uria2 = "about:weave/";
     49  Assert.equal(CommonUtils.makeURI(uria2).spec, uria2);
     50  let uria3 = "about:weave/path";
     51  Assert.equal(CommonUtils.makeURI(uria3).spec, uria3);
     52  let uria4 = "about:weave/multi/path";
     53  Assert.equal(CommonUtils.makeURI(uria4).spec, uria4);
     54  let uria5 = "about:weave/?query";
     55  Assert.equal(CommonUtils.makeURI(uria5).spec, uria5);
     56  let uria6 = "about:weave/#hash";
     57  Assert.equal(CommonUtils.makeURI(uria6).spec, uria6);
     58 
     59  _("Invalid uris are undefined");
     60  Assert.equal(CommonUtils.makeURI("mozillalabs.com"), undefined);
     61  Assert.equal(CommonUtils.makeURI("this is a test"), undefined);
     62 }