Backed out changeset b71c8c052463 (bug 1943846) for causing mass failures. CLOSED...
[gecko.git] / netwerk / test / unit / test_compareURIs.js
blobe460de1c2985a5777831a3881811f1147aefcc7b
1 "use strict";
3 function do_info(text, stack) {
4 if (!stack) {
5 stack = Components.stack.caller;
8 dump(
9 "TEST-INFO | " +
10 stack.filename +
11 " | [" +
12 stack.name +
13 " : " +
14 stack.lineNumber +
15 "] " +
16 text +
17 "\n"
20 function run_test() {
21 var tests = [
22 ["http://mozilla.org/", "http://mozilla.org/somewhere/there", true],
23 ["http://mozilla.org/", "http://www.mozilla.org/", false],
24 ["http://mozilla.org/", "http://mozilla.org:80", true],
25 ["http://mozilla.org/", "http://mozilla.org:90", false],
26 ["http://mozilla.org", "https://mozilla.org", false],
27 ["http://mozilla.org", "https://mozilla.org:80", false],
28 ["http://mozilla.org:443", "https://mozilla.org", false],
29 ["https://mozilla.org:443", "https://mozilla.org", true],
30 ["https://mozilla.org:443", "https://mozilla.org/somewhere/", true],
31 ["about:", "about:", false],
32 ["data:text/plain,text", "data:text/plain,text", false],
33 ["about:blank", "about:blank", false],
34 ["about:", "http://mozilla.org/", false],
35 ["about:", "about:config", false],
36 ["about:text/plain,text", "data:text/plain,text", false],
37 ["jar:http://mozilla.org/!/", "http://mozilla.org/", true],
38 ["view-source:http://mozilla.org/", "http://mozilla.org/", true],
41 tests.forEach(function (aTest) {
42 do_info("Comparing " + aTest[0] + " to " + aTest[1]);
44 var uri1 = NetUtil.newURI(aTest[0]);
45 var uri2 = NetUtil.newURI(aTest[1]);
47 var equal;
48 try {
49 Services.scriptSecurityManager.checkSameOriginURI(
50 uri1,
51 uri2,
52 false,
53 false
55 equal = true;
56 } catch (e) {
57 equal = false;
59 Assert.equal(equal, aTest[2]);
60 });