content/base/test/chrome/test_bug599295.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial