diff options
Diffstat (limited to 'caps/tests/unit/test_uri_escaping.js')
-rw-r--r-- | caps/tests/unit/test_uri_escaping.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/caps/tests/unit/test_uri_escaping.js b/caps/tests/unit/test_uri_escaping.js new file mode 100644 index 0000000000..91263b058c --- /dev/null +++ b/caps/tests/unit/test_uri_escaping.js @@ -0,0 +1,29 @@ +const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); +var ssm = Services.scriptSecurityManager; + +function makeURI(uri) { + return Services.io.newURI(uri); +} + +function createPrincipal(aURI) { + try { + var uri = makeURI(aURI); + var principal = ssm.createContentPrincipal(uri, {}); + return principal; + } catch (e) { + return null; + } +} + +function run_test() { + Assert.equal(createPrincipal("http://test^test/foo^bar#x^y"), null); + + Assert.equal(createPrincipal("http://test^test/foo\\bar"), null); + + Assert.equal(createPrincipal("http://test:2^3/foo\\bar"), null); + + Assert.equal( + createPrincipal("http://test/foo^bar").exposableSpec, + "http://test/foo%5Ebar" + ); +} |