зеркало из https://github.com/mozilla/gecko-dev.git
93 строки
3.2 KiB
HTML
93 строки
3.2 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=599295
|
|
-->
|
|
<head>
|
|
<title>Test for Bug 599295</title>
|
|
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
|
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
|
|
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/ChromeUtils.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
|
|
</head>
|
|
<body>
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=599295">Mozilla Bug 599295</a>
|
|
<style type="text/css">
|
|
#link1 a { -moz-user-select:none; }
|
|
</style>
|
|
<div id="link1"><a href="http://www.mozilla.org/">link1</a></div>
|
|
<div id="link2"><a href="http://www.mozilla.org/">link2</a></div>
|
|
<p id="display"></p>
|
|
<div id="content" style="display: none">
|
|
|
|
</div>
|
|
<pre id="test">
|
|
<script type="application/javascript">
|
|
|
|
/** Test for Bug 599295 **/
|
|
|
|
/* Do not allow a response to a CONNECT method, used to establish an
|
|
SSL tunnel over an HTTP proxy, to contain a redirect */
|
|
|
|
const BinaryInputStream =
|
|
Components.Constructor("@mozilla.org/binaryinputstream;1",
|
|
"nsIBinaryInputStream",
|
|
"setInputStream");
|
|
|
|
const Ci = Components.interfaces;
|
|
const Cu = Components.utils;
|
|
Cu.import("resource://gre/modules/Services.jsm");
|
|
|
|
var listener = {
|
|
_httpstatus : 0,
|
|
|
|
onStartRequest: function(request, context) {
|
|
request.QueryInterface(Components.interfaces.nsIHttpChannel);
|
|
_httpstatus = request.responseStatus;
|
|
},
|
|
|
|
onDataAvailable: function(request, context, stream, offset, count) {
|
|
new BinaryInputStream(stream).readByteArray(count);
|
|
},
|
|
|
|
onStopRequest: function(request, context, status) {
|
|
/* testing here that the redirect was not followed. If it was followed
|
|
we would see a http status of 200 and status of NS_OK */
|
|
|
|
is(_httpstatus, 302, "http status 302");
|
|
is(status, Components.results.NS_ERROR_CONNECTION_REFUSED, "raised refused");
|
|
SimpleTest.finish();
|
|
}
|
|
};
|
|
|
|
function runTest() {
|
|
var ios = Components.classes["@mozilla.org/network/io-service;1"].
|
|
getService(Components.interfaces.nsIIOService);
|
|
var uri = ios.newURI("https://redirproxy.example.com/test", "", null);
|
|
|
|
var channel = ios.newChannelFromURI2(uri,
|
|
null, // aLoadingNode
|
|
Services.scriptSecurityManager.getSystemPrincipal(),
|
|
null, // aTriggeringPrincipal
|
|
Ci.nsILoadInfo.SEC_NORMAL,
|
|
Ci.nsIContentPolicy.TYPE_OTHER);
|
|
|
|
/* Previously, necko would allow a 302 as part of a CONNECT response
|
|
if the LOAD_DOCUMENT_URI flag was set and the original document
|
|
URI had not yet been changed. */
|
|
|
|
channel.loadFlags |= Components.interfaces.nsIChannel.LOAD_DOCUMENT_URI;
|
|
channel.QueryInterface(Components.interfaces.nsIHttpChannelInternal);
|
|
channel.documentURI = uri;
|
|
channel.asyncOpen(listener, null);
|
|
}
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
SimpleTest.waitForFocus(runTest);
|
|
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|
|
|