1 // Test for bug 1195415
7 var ssm = Services.scriptSecurityManager;
10 var uri = ios.newURI("http://foo.com/file.txt");
11 Assert.equal(uri.asciiHostPort, "foo.com");
12 uri = uri.mutate().setPort(90).finalize();
13 var prin = ssm.createContentPrincipal(uri, {});
14 Assert.equal(uri.asciiHostPort, "foo.com:90");
15 Assert.equal(prin.origin, "http://foo.com:90");
17 uri = ios.newURI("http://foo.com:10/file.txt");
18 Assert.equal(uri.asciiHostPort, "foo.com:10");
19 uri = uri.mutate().setPort(500).finalize();
20 prin = ssm.createContentPrincipal(uri, {});
21 Assert.equal(uri.asciiHostPort, "foo.com:500");
22 Assert.equal(prin.origin, "http://foo.com:500");
24 uri = ios.newURI("http://foo.com:5000/file.txt");
25 Assert.equal(uri.asciiHostPort, "foo.com:5000");
26 uri = uri.mutate().setPort(20).finalize();
27 prin = ssm.createContentPrincipal(uri, {});
28 Assert.equal(uri.asciiHostPort, "foo.com:20");
29 Assert.equal(prin.origin, "http://foo.com:20");
31 uri = ios.newURI("http://foo.com:5000/file.txt");
32 Assert.equal(uri.asciiHostPort, "foo.com:5000");
33 uri = uri.mutate().setPort(-1).finalize();
34 prin = ssm.createContentPrincipal(uri, {});
35 Assert.equal(uri.asciiHostPort, "foo.com");
36 Assert.equal(prin.origin, "http://foo.com");
38 uri = ios.newURI("http://foo.com:5000/file.txt");
39 Assert.equal(uri.asciiHostPort, "foo.com:5000");
40 uri = uri.mutate().setPort(80).finalize();
41 prin = ssm.createContentPrincipal(uri, {});
42 Assert.equal(uri.asciiHostPort, "foo.com");
43 Assert.equal(prin.origin, "http://foo.com");
46 uri = ios.newURI("http://jos\u00e9.example.net.ch/file.txt");
47 Assert.equal(uri.asciiHostPort, "xn--jos-dma.example.net.ch");
48 uri = uri.mutate().setPort(90).finalize();
49 prin = ssm.createContentPrincipal(uri, {});
50 Assert.equal(uri.asciiHostPort, "xn--jos-dma.example.net.ch:90");
51 Assert.equal(prin.origin, "http://xn--jos-dma.example.net.ch:90");
53 uri = ios.newURI("http://jos\u00e9.example.net.ch:10/file.txt");
54 Assert.equal(uri.asciiHostPort, "xn--jos-dma.example.net.ch:10");
55 uri = uri.mutate().setPort(500).finalize();
56 prin = ssm.createContentPrincipal(uri, {});
57 Assert.equal(uri.asciiHostPort, "xn--jos-dma.example.net.ch:500");
58 Assert.equal(prin.origin, "http://xn--jos-dma.example.net.ch:500");
60 uri = ios.newURI("http://jos\u00e9.example.net.ch:5000/file.txt");
61 Assert.equal(uri.asciiHostPort, "xn--jos-dma.example.net.ch:5000");
62 uri = uri.mutate().setPort(20).finalize();
63 prin = ssm.createContentPrincipal(uri, {});
64 Assert.equal(uri.asciiHostPort, "xn--jos-dma.example.net.ch:20");
65 Assert.equal(prin.origin, "http://xn--jos-dma.example.net.ch:20");
67 uri = ios.newURI("http://jos\u00e9.example.net.ch:5000/file.txt");
68 Assert.equal(uri.asciiHostPort, "xn--jos-dma.example.net.ch:5000");
69 uri = uri.mutate().setPort(-1).finalize();
70 prin = ssm.createContentPrincipal(uri, {});
71 Assert.equal(uri.asciiHostPort, "xn--jos-dma.example.net.ch");
72 Assert.equal(prin.origin, "http://xn--jos-dma.example.net.ch");
74 uri = ios.newURI("http://jos\u00e9.example.net.ch:5000/file.txt");
75 Assert.equal(uri.asciiHostPort, "xn--jos-dma.example.net.ch:5000");
76 uri = uri.mutate().setPort(80).finalize();
77 prin = ssm.createContentPrincipal(uri, {});
78 Assert.equal(uri.asciiHostPort, "xn--jos-dma.example.net.ch");
79 Assert.equal(prin.origin, "http://xn--jos-dma.example.net.ch");
82 uri = ios.newURI("http://[123:45::678]/file.txt");
83 Assert.equal(uri.asciiHostPort, "[123:45::678]");
84 uri = uri.mutate().setPort(90).finalize();
85 prin = ssm.createContentPrincipal(uri, {});
86 Assert.equal(uri.asciiHostPort, "[123:45::678]:90");
87 Assert.equal(prin.origin, "http://[123:45::678]:90");
89 uri = ios.newURI("http://[123:45::678]:10/file.txt");
90 Assert.equal(uri.asciiHostPort, "[123:45::678]:10");
91 uri = uri.mutate().setPort(500).finalize();
92 prin = ssm.createContentPrincipal(uri, {});
93 Assert.equal(uri.asciiHostPort, "[123:45::678]:500");
94 Assert.equal(prin.origin, "http://[123:45::678]:500");
96 uri = ios.newURI("http://[123:45::678]:5000/file.txt");
97 Assert.equal(uri.asciiHostPort, "[123:45::678]:5000");
98 uri = uri.mutate().setPort(20).finalize();
99 prin = ssm.createContentPrincipal(uri, {});
100 Assert.equal(uri.asciiHostPort, "[123:45::678]:20");
101 Assert.equal(prin.origin, "http://[123:45::678]:20");
103 uri = ios.newURI("http://[123:45::678]:5000/file.txt");
104 Assert.equal(uri.asciiHostPort, "[123:45::678]:5000");
105 uri = uri.mutate().setPort(-1).finalize();
106 prin = ssm.createContentPrincipal(uri, {});
107 Assert.equal(uri.asciiHostPort, "[123:45::678]");
108 Assert.equal(prin.origin, "http://[123:45::678]");
110 uri = ios.newURI("http://[123:45::678]:5000/file.txt");
111 Assert.equal(uri.asciiHostPort, "[123:45::678]:5000");
112 uri = uri.mutate().setPort(80).finalize();
113 prin = ssm.createContentPrincipal(uri, {});
114 Assert.equal(uri.asciiHostPort, "[123:45::678]");
115 Assert.equal(prin.origin, "http://[123:45::678]");