зеркало из https://github.com/mozilla/pjs.git
Test for bug 308484 by Wladimir Palant <trev@gtchat.de>. r=bz
This commit is contained in:
Родитель
c8c17c9cc5
Коммит
53742638ca
|
@ -66,6 +66,7 @@ RunSet.runall = function() {
|
|||
'test_bug238409.html',
|
||||
'test_bug277724.html',
|
||||
'test_bug302186.html',
|
||||
'test_bug308484.html',
|
||||
'test_bug308856.html',
|
||||
'test_bug333983.html',
|
||||
'test_bug337124.html',
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=308484
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 308484</title>
|
||||
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=308484">Mozilla Bug 308484</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
/** Test for Bug 308484 **/
|
||||
|
||||
var headers = ["Host", "Content-Length", "Transfer-Encoding", "Via", "Upgrade"];
|
||||
var i, request;
|
||||
|
||||
// Try setting headers in unprivileged context
|
||||
request = new XMLHttpRequest();
|
||||
request.open("GET", window.location.href);
|
||||
for (i = 0; i < headers.length; i++)
|
||||
request.setRequestHeader(headers[i], "test" + i);
|
||||
|
||||
// Read out headers
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalBrowserWrite");
|
||||
var channel = request.channel.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
for (i = 0; i < headers.length; i++) {
|
||||
// Retrieving Content-Length will throw an exception
|
||||
var value = null;
|
||||
try {
|
||||
value = channel.getRequestHeader(headers[i]);
|
||||
}
|
||||
catch(e) {}
|
||||
|
||||
isnot(value, "test" + i, "Setting " + headers[i] + " header in unprivileged context");
|
||||
}
|
||||
|
||||
// Try setting headers in privileged context
|
||||
request = new XMLHttpRequest();
|
||||
request.open("GET", window.location.href);
|
||||
for (i = 0; i < headers.length; i++)
|
||||
request.setRequestHeader(headers[i], "test" + i);
|
||||
|
||||
// Read out headers
|
||||
var channel = request.channel.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
for (i = 0; i < headers.length; i++) {
|
||||
var value = channel.getRequestHeader(headers[i]);
|
||||
is(value, "test" + i, "Setting " + headers[i] + " header in privileged context");
|
||||
}
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче