content/base/test/chrome/test_bug599295.html

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:d3c4cb1a4c3a
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=599295
5 -->
6 <head>
7 <title>Test for Bug 599295</title>
8 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
9 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
10 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/ChromeUtils.js"></script>
11 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
12 </head>
13 <body>
14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=599295">Mozilla Bug 599295</a>
15 <style type="text/css">
16 #link1 a { -moz-user-select:none; }
17 </style>
18 <div id="link1"><a href="http://www.mozilla.org/">link1</a></div>
19 <div id="link2"><a href="http://www.mozilla.org/">link2</a></div>
20 <p id="display"></p>
21 <div id="content" style="display: none">
22
23 </div>
24 <pre id="test">
25 <script type="application/javascript">
26
27 /** Test for Bug 599295 **/
28
29 /* Do not allow a response to a CONNECT method, used to establish an
30 SSL tunnel over an HTTP proxy, to contain a redirect */
31
32 const BinaryInputStream =
33 Components.Constructor("@mozilla.org/binaryinputstream;1",
34 "nsIBinaryInputStream",
35 "setInputStream");
36 var listener = {
37 _httpstatus : 0,
38
39 onStartRequest: function(request, context) {
40 request.QueryInterface(Components.interfaces.nsIHttpChannel);
41 _httpstatus = request.responseStatus;
42 },
43
44 onDataAvailable: function(request, context, stream, offset, count) {
45 new BinaryInputStream(stream).readByteArray(count);
46 },
47
48 onStopRequest: function(request, context, status) {
49 /* testing here that the redirect was not followed. If it was followed
50 we would see a http status of 200 and status of NS_OK */
51
52 is(_httpstatus, 302, "http status 302");
53 is(status, Components.results.NS_ERROR_CONNECTION_REFUSED, "raised refused");
54 SimpleTest.finish();
55 }
56 };
57
58 function runTest() {
59 var ios = Components.classes["@mozilla.org/network/io-service;1"].
60 getService(Components.interfaces.nsIIOService);
61 var uri = ios.newURI("https://redirproxy.example.com/test", "", null);
62 var channel = ios.newChannelFromURI(uri);
63
64 /* Previously, necko would allow a 302 as part of a CONNECT response
65 if the LOAD_DOCUMENT_URI flag was set and the original document
66 URI had not yet been changed. */
67
68 channel.loadFlags |= Components.interfaces.nsIChannel.LOAD_DOCUMENT_URI;
69 channel.QueryInterface(Components.interfaces.nsIHttpChannelInternal);
70 channel.documentURI = uri;
71 channel.asyncOpen(listener, null);
72 }
73
74 SimpleTest.waitForExplicitFinish();
75 SimpleTest.waitForFocus(runTest);
76
77 </script>
78 </pre>
79 </body>
80 </html>
81

mercurial