2008-08-28 05:56:45 -07:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=431701
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<title>Test for Bug 431701</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=431701">Mozilla Bug 431701</a>
|
|
|
|
<p id="display"></p>
|
|
|
|
<div id="content" style="display: none">
|
|
|
|
<iframe id="one"></iframe>
|
|
|
|
<iframe id="two"></iframe>
|
|
|
|
<iframe id="three"></iframe>
|
|
|
|
<iframe id="four"></iframe>
|
|
|
|
<iframe id="five"></iframe>
|
|
|
|
<iframe id="six"></iframe>
|
|
|
|
<iframe id="seven"></iframe>
|
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
|
|
|
|
/** Test for Bug 431701 **/
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
|
|
var docSources = [
|
|
|
|
"data:text/html,<html></html>",
|
|
|
|
"data:text/html;charset=UTF-8,<html></html>",
|
|
|
|
"data:text/html;charset=ISO-8859-1,<html></html>",
|
|
|
|
"data:text/xml,<html></html>",
|
|
|
|
"data:text/xml,<?xml version='1.0'?><html></html>",
|
|
|
|
"data:text/xml,<?xml version='1.0' encoding='UTF-8'?><html></html>",
|
|
|
|
"data:text/xml,<?xml version='1.0' encoding='ISO-8859-1'?><html></html>",
|
|
|
|
];
|
|
|
|
|
|
|
|
for (var i = 0; i < docSources.length; ++i) {
|
|
|
|
document.getElementsByTagName("iframe")[i].src = docSources[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
function frameDoc(id) {
|
|
|
|
return function() { return $(id).contentDocument; };
|
|
|
|
}
|
|
|
|
|
|
|
|
function createDoc() {
|
|
|
|
return document.implementation.createDocument('', 'html', null);
|
|
|
|
}
|
|
|
|
|
|
|
|
function xhrDoc(idx) {
|
|
|
|
return function() {
|
|
|
|
// Defy same-origin restrictions!
|
2011-03-17 09:19:13 -07:00
|
|
|
var xhr = SpecialPowers.createSystemXHR();
|
2008-08-28 05:56:45 -07:00
|
|
|
xhr.open("GET", docSources[idx], false);
|
|
|
|
xhr.send();
|
|
|
|
return xhr.responseXML;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
// Each row has the document getter function, then the characterSet,
|
2011-10-01 09:14:40 -07:00
|
|
|
// inputEncoding expected for that document.
|
2008-08-28 05:56:45 -07:00
|
|
|
|
|
|
|
var tests = [
|
2012-10-14 01:13:19 -07:00
|
|
|
[ frameDoc("one"), "iso-8859-1", "iso-8859-1" ],
|
|
|
|
[ frameDoc("two"), "utf-8", "utf-8" ],
|
|
|
|
[ frameDoc("three"), "iso-8859-1", "iso-8859-1" ],
|
|
|
|
[ frameDoc("four"), "utf-8", "utf-8" ],
|
|
|
|
[ frameDoc("five"), "utf-8", "utf-8" ],
|
|
|
|
[ frameDoc("six"), "utf-8", "utf-8" ],
|
|
|
|
[ frameDoc("seven"), "iso-8859-1", "iso-8859-1" ],
|
|
|
|
[ createDoc, "utf-8", null ],
|
|
|
|
[ xhrDoc(4), "utf-8", "utf-8" ],
|
|
|
|
[ xhrDoc(5), "utf-8", "utf-8" ],
|
|
|
|
[ xhrDoc(6), "iso-8859-1", "iso-8859-1" ],
|
2008-08-28 05:56:45 -07:00
|
|
|
];
|
|
|
|
|
|
|
|
function doTest(idx) {
|
|
|
|
var [docGetter, expectedCharacterSet,
|
2011-10-01 09:14:40 -07:00
|
|
|
expectedInputEncoding] = tests[idx];
|
2008-08-28 05:56:45 -07:00
|
|
|
var doc = docGetter();
|
|
|
|
|
|
|
|
// Have to be careful here to catch null vs ""
|
|
|
|
is(doc.characterSet, expectedCharacterSet, "Test " + idx + " characterSet");
|
|
|
|
is(doc.inputEncoding, expectedInputEncoding,
|
|
|
|
"Test " + idx + " inputEncoding");
|
|
|
|
}
|
|
|
|
|
|
|
|
addLoadEvent(function() {
|
|
|
|
// sanity check
|
|
|
|
isnot("", null, "Shouldn't be equal!");
|
|
|
|
|
|
|
|
for (var i = 0; i < tests.length; ++i) {
|
|
|
|
doTest(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now check what xhr does
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
xhr.open("POST", document.location.href);
|
|
|
|
xhr.send(createDoc());
|
2012-09-24 05:46:29 -07:00
|
|
|
is(SpecialPowers.wrap(xhr).channel.QueryInterface(SpecialPowers.Ci.nsIHttpChannel)
|
2008-08-28 05:56:45 -07:00
|
|
|
.getRequestHeader("Content-Type"),
|
|
|
|
"application/xml; charset=UTF-8", "Testing correct type on the wire");
|
|
|
|
xhr.abort();
|
|
|
|
|
|
|
|
SimpleTest.finish();
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|