summaryrefslogtreecommitdiffstats
path: root/caps/tests/unit/test_ipv6_host_literal.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /caps/tests/unit/test_ipv6_host_literal.js
parentInitial commit. (diff)
downloadfirefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz
firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'caps/tests/unit/test_ipv6_host_literal.js')
-rw-r--r--caps/tests/unit/test_ipv6_host_literal.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/caps/tests/unit/test_ipv6_host_literal.js b/caps/tests/unit/test_ipv6_host_literal.js
new file mode 100644
index 0000000000..0539e17de5
--- /dev/null
+++ b/caps/tests/unit/test_ipv6_host_literal.js
@@ -0,0 +1,39 @@
+const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
+var ssm = Services.scriptSecurityManager;
+function makeURI(uri) {
+ return Services.io.newURI(uri);
+}
+
+function testIPV6Host(aHost, aExpected) {
+ var ipv6Host = ssm.createContentPrincipal(makeURI(aHost), {});
+ Assert.equal(ipv6Host.origin, aExpected);
+}
+
+function run_test() {
+ testIPV6Host("http://[::1]/", "http://[::1]");
+
+ testIPV6Host(
+ "http://[2001:db8:85a3:8d3:1319:8a2e:370:7348]/",
+ "http://[2001:db8:85a3:8d3:1319:8a2e:370:7348]"
+ );
+
+ testIPV6Host(
+ "http://[2001:db8:85a3:8d3:1319:8a2e:370:7348]:443/",
+ "http://[2001:db8:85a3:8d3:1319:8a2e:370:7348]:443"
+ );
+
+ testIPV6Host(
+ "http://[2001:db8:85a3::1319:8a2e:370:7348]/",
+ "http://[2001:db8:85a3:0:1319:8a2e:370:7348]"
+ );
+
+ testIPV6Host(
+ "http://[20D1:0000:3238:DFE1:63:0000:0000:FEFB]/",
+ "http://[20d1:0:3238:dfe1:63::fefb]"
+ );
+
+ testIPV6Host(
+ "http://[20D1:0:3238:DFE1:63::FEFB]/",
+ "http://[20d1:0:3238:dfe1:63::fefb]"
+ );
+}