Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- Manifest: netwerk/test/unit/xpcshell.toml
"use strict";
function run_test() {
var ios = Services.io;
var ssm = Services.scriptSecurityManager;
// NON-UNICODE
Assert.equal(uri.asciiHostPort, "foo.com");
uri = uri.mutate().setPort(90).finalize();
var prin = ssm.createContentPrincipal(uri, {});
Assert.equal(uri.asciiHostPort, "foo.com:90");
Assert.equal(uri.asciiHostPort, "foo.com:10");
uri = uri.mutate().setPort(500).finalize();
prin = ssm.createContentPrincipal(uri, {});
Assert.equal(uri.asciiHostPort, "foo.com:500");
Assert.equal(uri.asciiHostPort, "foo.com:5000");
uri = uri.mutate().setPort(20).finalize();
prin = ssm.createContentPrincipal(uri, {});
Assert.equal(uri.asciiHostPort, "foo.com:20");
Assert.equal(uri.asciiHostPort, "foo.com:5000");
uri = uri.mutate().setPort(-1).finalize();
prin = ssm.createContentPrincipal(uri, {});
Assert.equal(uri.asciiHostPort, "foo.com");
Assert.equal(uri.asciiHostPort, "foo.com:5000");
uri = uri.mutate().setPort(80).finalize();
prin = ssm.createContentPrincipal(uri, {});
Assert.equal(uri.asciiHostPort, "foo.com");
// UNICODE
Assert.equal(uri.asciiHostPort, "xn--jos-dma.example.net.ch");
uri = uri.mutate().setPort(90).finalize();
prin = ssm.createContentPrincipal(uri, {});
Assert.equal(uri.asciiHostPort, "xn--jos-dma.example.net.ch:90");
Assert.equal(uri.asciiHostPort, "xn--jos-dma.example.net.ch:10");
uri = uri.mutate().setPort(500).finalize();
prin = ssm.createContentPrincipal(uri, {});
Assert.equal(uri.asciiHostPort, "xn--jos-dma.example.net.ch:500");
Assert.equal(uri.asciiHostPort, "xn--jos-dma.example.net.ch:5000");
uri = uri.mutate().setPort(20).finalize();
prin = ssm.createContentPrincipal(uri, {});
Assert.equal(uri.asciiHostPort, "xn--jos-dma.example.net.ch:20");
Assert.equal(uri.asciiHostPort, "xn--jos-dma.example.net.ch:5000");
uri = uri.mutate().setPort(-1).finalize();
prin = ssm.createContentPrincipal(uri, {});
Assert.equal(uri.asciiHostPort, "xn--jos-dma.example.net.ch");
Assert.equal(uri.asciiHostPort, "xn--jos-dma.example.net.ch:5000");
uri = uri.mutate().setPort(80).finalize();
prin = ssm.createContentPrincipal(uri, {});
Assert.equal(uri.asciiHostPort, "xn--jos-dma.example.net.ch");
// ipv6
Assert.equal(uri.asciiHostPort, "[123:45::678]");
uri = uri.mutate().setPort(90).finalize();
prin = ssm.createContentPrincipal(uri, {});
Assert.equal(uri.asciiHostPort, "[123:45::678]:90");
Assert.equal(uri.asciiHostPort, "[123:45::678]:10");
uri = uri.mutate().setPort(500).finalize();
prin = ssm.createContentPrincipal(uri, {});
Assert.equal(uri.asciiHostPort, "[123:45::678]:500");
Assert.equal(uri.asciiHostPort, "[123:45::678]:5000");
uri = uri.mutate().setPort(20).finalize();
prin = ssm.createContentPrincipal(uri, {});
Assert.equal(uri.asciiHostPort, "[123:45::678]:20");
Assert.equal(uri.asciiHostPort, "[123:45::678]:5000");
uri = uri.mutate().setPort(-1).finalize();
prin = ssm.createContentPrincipal(uri, {});
Assert.equal(uri.asciiHostPort, "[123:45::678]");
Assert.equal(uri.asciiHostPort, "[123:45::678]:5000");
uri = uri.mutate().setPort(80).finalize();
prin = ssm.createContentPrincipal(uri, {});
Assert.equal(uri.asciiHostPort, "[123:45::678]");
}