diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /netwerk/test/unit/test_compareURIs.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'netwerk/test/unit/test_compareURIs.js')
-rw-r--r-- | netwerk/test/unit/test_compareURIs.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/netwerk/test/unit/test_compareURIs.js b/netwerk/test/unit/test_compareURIs.js new file mode 100644 index 000000000..8e68fc6a4 --- /dev/null +++ b/netwerk/test/unit/test_compareURIs.js @@ -0,0 +1,49 @@ +Components.utils.import("resource://gre/modules/NetUtil.jsm"); + +function do_info(text, stack) { + if (!stack) + stack = Components.stack.caller; + + dump("TEST-INFO | " + stack.filename + " | [" + stack.name + " : " + + stack.lineNumber + "] " + text + "\n"); +} +function run_test() +{ + var tests = [ + [ "http://mozilla.org/", "http://mozilla.org/somewhere/there", true ], + [ "http://mozilla.org/", "http://www.mozilla.org/", false ], + [ "http://mozilla.org/", "http://mozilla.org:80", true ], + [ "http://mozilla.org/", "http://mozilla.org:90", false ], + [ "http://mozilla.org", "https://mozilla.org", false ], + [ "http://mozilla.org", "https://mozilla.org:80", false ], + [ "http://mozilla.org:443", "https://mozilla.org", false ], + [ "https://mozilla.org:443", "https://mozilla.org", true ], + [ "https://mozilla.org:443", "https://mozilla.org/somewhere/", true ], + [ "about:", "about:", false ], + [ "data:text/plain,text", "data:text/plain,text", false ], + [ "about:blank", "about:blank", false ], + [ "about:", "http://mozilla.org/", false ], + [ "about:", "about:config", false ], + [ "about:text/plain,text", "data:text/plain,text", false ], + [ "jar:http://mozilla.org/!/", "http://mozilla.org/", true ], + [ "view-source:http://mozilla.org/", "http://mozilla.org/", true ] + ]; + + var secman = Components.classes["@mozilla.org/scriptsecuritymanager;1"].getService(Components.interfaces.nsIScriptSecurityManager); + + tests.forEach(function(aTest) { + do_info("Comparing " + aTest[0] + " to " + aTest[1]); + + var uri1 = NetUtil.newURI(aTest[0]); + var uri2 = NetUtil.newURI(aTest[1]); + + var equal; + try { + secman.checkSameOriginURI(uri1, uri2, false); + equal = true; + } catch (e) { + equal = false + } + do_check_eq(equal, aTest[2]); + }); +} |