Bug 1011748 - Mochitest unit test + resource files for this bug. r=bzbarsky

This commit is contained in:
Michael A. Milazzo 2014-06-13 21:59:32 -07:00
parent 141256b4cf
commit aaea81fdae
4 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,4 @@
// Function to indicate HTTP 200 OK after redirect from file_bug1011748_redirect.sjs
function handleRequest(request, response) {
response.setStatusLine(null, 200, "OK");
}

View File

@ -0,0 +1,5 @@
// SJS handler to redirect the XMLHttpRequest object to file_bug1011748_OK.sjs
function handleRequest(request, response) {
response.setStatusLine(null, 302, "Moved Temporarily");
response.setHeader("Location", "file_bug1011748_OK.sjs", false);
}

View File

@ -648,3 +648,5 @@ support-files = bug444546.sjs
[test_bug503473.html]
disabled = Disabled due to making the harness time out
support-files = file_bug503473-frame.sjs
[test_bug1011748.html]
support-files = file_bug1011748_redirect.sjs file_bug1011748_OK.sjs

View File

@ -0,0 +1,57 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1011748
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 1011748</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript">
/** Test for Bug 1011748 **/
"use strict";
var observer = {
observe: function (aSubject, aTopic, aData) {
try {
var channel = aSubject.QueryInterface(SpecialPowers.Ci.nsIHttpChannel);
channel.getResponseHeader("Location");
} catch (e) {
return;
}
statusTexts.push(xhr.statusText);
}
};
var statusTexts = [];
SpecialPowers.addObserver(observer, "http-on-examine-response", false);
SimpleTest.waitForExplicitFinish();
var xhr = new XMLHttpRequest();
xhr.addEventListener("load", function() {
statusTexts.push(this.statusText);
SpecialPowers.removeObserver(observer, "http-on-examine-response");
is(statusTexts[0], "", "Empty statusText value for HTTP 302");
is(statusTexts[1], "OK", "OK statusText value for the redirect.");
SimpleTest.finish();
});
xhr.open("GET", "file_bug1011748_redirect.sjs", true);
xhr.send();
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1011748">Mozilla Bug 1011748</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
</body>
</html>