Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

/* Any copyright is dedicated to the Public Domain.
_("Make sure uri strings are converted to nsIURIs");
function run_test() {
_test_makeURI();
}
function _test_makeURI() {
_("Check http uris");
let uri1 = "http://mozillalabs.com/";
Assert.equal(CommonUtils.makeURI(uri1).spec, uri1);
Assert.equal(CommonUtils.makeURI(uri2).spec, uri2);
Assert.equal(CommonUtils.makeURI(uri3).spec, uri3);
Assert.equal(CommonUtils.makeURI(uri4).spec, uri4);
Assert.equal(CommonUtils.makeURI(uri5).spec, uri5);
Assert.equal(CommonUtils.makeURI(uri6).spec, uri6);
_("Check https uris");
let uris1 = "https://mozillalabs.com/";
Assert.equal(CommonUtils.makeURI(uris1).spec, uris1);
Assert.equal(CommonUtils.makeURI(uris2).spec, uris2);
Assert.equal(CommonUtils.makeURI(uris3).spec, uris3);
Assert.equal(CommonUtils.makeURI(uris4).spec, uris4);
Assert.equal(CommonUtils.makeURI(uris5).spec, uris5);
Assert.equal(CommonUtils.makeURI(uris6).spec, uris6);
_("Check chrome uris");
let uric1 = "chrome://browser/content/browser.xhtml";
Assert.equal(CommonUtils.makeURI(uric1).spec, uric1);
let uric2 = "chrome://browser/skin/browser.css";
Assert.equal(CommonUtils.makeURI(uric2).spec, uric2);
_("Check about uris");
let uria1 = "about:weave";
Assert.equal(CommonUtils.makeURI(uria1).spec, uria1);
let uria2 = "about:weave/";
Assert.equal(CommonUtils.makeURI(uria2).spec, uria2);
let uria3 = "about:weave/path";
Assert.equal(CommonUtils.makeURI(uria3).spec, uria3);
let uria4 = "about:weave/multi/path";
Assert.equal(CommonUtils.makeURI(uria4).spec, uria4);
let uria5 = "about:weave/?query";
Assert.equal(CommonUtils.makeURI(uria5).spec, uria5);
let uria6 = "about:weave/#hash";
Assert.equal(CommonUtils.makeURI(uria6).spec, uria6);
_("Invalid uris are undefined");
Assert.equal(CommonUtils.makeURI("mozillalabs.com"), undefined);
Assert.equal(CommonUtils.makeURI("this is a test"), undefined);
}