2008-05-02 17:00:18 -07:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=308484
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<title>Test for Bug 308484</title>
|
|
|
|
<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 **/
|
|
|
|
|
2008-07-12 16:06:36 -07:00
|
|
|
var headers = [
|
|
|
|
"aCCept-chaRset",
|
|
|
|
"acCePt-eNcoDing",
|
2010-11-15 03:55:30 -08:00
|
|
|
"aCcEsS-cOnTrOl-ReQuEsT-mEtHoD",
|
|
|
|
"aCcEsS-cOnTrOl-ReQuEsT-hEaDeRs",
|
2008-07-12 16:06:36 -07:00
|
|
|
"coNnEctIon",
|
|
|
|
"coNtEnt-LEngth",
|
2010-11-15 03:55:30 -08:00
|
|
|
"CoOKIe",
|
|
|
|
"cOOkiE2",
|
2008-07-12 16:06:36 -07:00
|
|
|
"cOntEnt-tRAnsFer-enCoDiNg",
|
|
|
|
"DATE",
|
|
|
|
"exPeCt",
|
|
|
|
"hOSt",
|
|
|
|
"keep-alive",
|
2010-11-15 03:55:30 -08:00
|
|
|
"oRiGiN",
|
2008-07-12 16:06:36 -07:00
|
|
|
"reFERer",
|
|
|
|
"te",
|
|
|
|
"trAiLer",
|
|
|
|
"trANsfEr-eNcoDiNg",
|
|
|
|
"uPGraDe",
|
2010-11-15 03:55:30 -08:00
|
|
|
"user-AGENT",
|
2008-07-12 16:06:36 -07:00
|
|
|
"viA",
|
|
|
|
"pRoxy-",
|
|
|
|
"sEc-",
|
|
|
|
"proxy-fOobar",
|
|
|
|
"sec-bAZbOx"
|
|
|
|
];
|
2008-05-02 17:00:18 -07:00
|
|
|
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
|
2012-03-30 09:38:19 -07:00
|
|
|
var channel = SpecialPowers.wrap(request).channel.QueryInterface(Components.interfaces.nsIHttpChannel);
|
2008-05-02 17:00:18 -07:00
|
|
|
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
|
2012-03-30 09:38:19 -07:00
|
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
2008-05-02 17:00:18 -07:00
|
|
|
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
|
2012-03-30 09:38:19 -07:00
|
|
|
var channel = SpecialPowers.wrap(request).channel.QueryInterface(Components.interfaces.nsIHttpChannel);
|
2008-05-02 17:00:18 -07:00
|
|
|
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>
|