michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: _("Make sure uri strings are converted to nsIURIs"); michael@0: Cu.import("resource://services-common/utils.js"); michael@0: michael@0: function run_test() { michael@0: _test_makeURI(); michael@0: } michael@0: michael@0: function _test_makeURI() { michael@0: _("Check http uris"); michael@0: let uri1 = "http://mozillalabs.com/"; michael@0: do_check_eq(CommonUtils.makeURI(uri1).spec, uri1); michael@0: let uri2 = "http://www.mozillalabs.com/"; michael@0: do_check_eq(CommonUtils.makeURI(uri2).spec, uri2); michael@0: let uri3 = "http://mozillalabs.com/path"; michael@0: do_check_eq(CommonUtils.makeURI(uri3).spec, uri3); michael@0: let uri4 = "http://mozillalabs.com/multi/path"; michael@0: do_check_eq(CommonUtils.makeURI(uri4).spec, uri4); michael@0: let uri5 = "http://mozillalabs.com/?query"; michael@0: do_check_eq(CommonUtils.makeURI(uri5).spec, uri5); michael@0: let uri6 = "http://mozillalabs.com/#hash"; michael@0: do_check_eq(CommonUtils.makeURI(uri6).spec, uri6); michael@0: michael@0: _("Check https uris"); michael@0: let uris1 = "https://mozillalabs.com/"; michael@0: do_check_eq(CommonUtils.makeURI(uris1).spec, uris1); michael@0: let uris2 = "https://www.mozillalabs.com/"; michael@0: do_check_eq(CommonUtils.makeURI(uris2).spec, uris2); michael@0: let uris3 = "https://mozillalabs.com/path"; michael@0: do_check_eq(CommonUtils.makeURI(uris3).spec, uris3); michael@0: let uris4 = "https://mozillalabs.com/multi/path"; michael@0: do_check_eq(CommonUtils.makeURI(uris4).spec, uris4); michael@0: let uris5 = "https://mozillalabs.com/?query"; michael@0: do_check_eq(CommonUtils.makeURI(uris5).spec, uris5); michael@0: let uris6 = "https://mozillalabs.com/#hash"; michael@0: do_check_eq(CommonUtils.makeURI(uris6).spec, uris6); michael@0: michael@0: _("Check chrome uris"); michael@0: let uric1 = "chrome://browser/content/browser.xul"; michael@0: do_check_eq(CommonUtils.makeURI(uric1).spec, uric1); michael@0: let uric2 = "chrome://browser/skin/browser.css"; michael@0: do_check_eq(CommonUtils.makeURI(uric2).spec, uric2); michael@0: let uric3 = "chrome://browser/locale/browser.dtd"; michael@0: do_check_eq(CommonUtils.makeURI(uric3).spec, uric3); michael@0: michael@0: _("Check about uris"); michael@0: let uria1 = "about:weave"; michael@0: do_check_eq(CommonUtils.makeURI(uria1).spec, uria1); michael@0: let uria2 = "about:weave/"; michael@0: do_check_eq(CommonUtils.makeURI(uria2).spec, uria2); michael@0: let uria3 = "about:weave/path"; michael@0: do_check_eq(CommonUtils.makeURI(uria3).spec, uria3); michael@0: let uria4 = "about:weave/multi/path"; michael@0: do_check_eq(CommonUtils.makeURI(uria4).spec, uria4); michael@0: let uria5 = "about:weave/?query"; michael@0: do_check_eq(CommonUtils.makeURI(uria5).spec, uria5); michael@0: let uria6 = "about:weave/#hash"; michael@0: do_check_eq(CommonUtils.makeURI(uria6).spec, uria6); michael@0: michael@0: _("Invalid uris are undefined"); michael@0: do_check_eq(CommonUtils.makeURI("mozillalabs.com"), undefined); michael@0: do_check_eq(CommonUtils.makeURI("chrome://badstuff"), undefined); michael@0: do_check_eq(CommonUtils.makeURI("this is a test"), undefined); michael@0: }