4 https://bugzilla.mozilla.org/show_bug.cgi?id=431701
7 <meta charset=
"windows-1252">
8 <title>Test for Bug
431701</title>
9 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
13 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=431701">Mozilla Bug
431701</a>
15 <div id=
"content" style=
"display: none">
16 <iframe id=
"one"></iframe>
17 <iframe id=
"two"></iframe>
18 <iframe id=
"three"></iframe>
19 <iframe id=
"four"></iframe>
20 <iframe id=
"five"></iframe>
21 <iframe id=
"six"></iframe>
22 <iframe id=
"seven"></iframe>
25 <script class=
"testbody" type=
"text/javascript">
27 /** Test for Bug
431701 **/
28 SimpleTest.waitForExplicitFinish();
31 "iframe1_bug431701.html",
32 "iframe2_bug431701.html",
33 "iframe3_bug431701.html",
34 "iframe4_bug431701.xml",
35 "iframe5_bug431701.xml",
36 "iframe6_bug431701.xml",
37 "iframe7_bug431701.xml",
40 for (let i =
0; i < docSources.length; ++i) {
41 document.getElementsByTagName(
"iframe")[i].src = docSources[i];
44 function frameDoc(id) {
45 return function() { return $(id).contentDocument; };
48 function createDoc() {
49 return document.implementation.createDocument('', 'html', null);
52 function xhrDoc(idx) {
54 // Defy same-origin restrictions!
55 var xhr = new XMLHttpRequest({mozAnon: true, mozSystem: true});
56 xhr.open(
"GET", docSources[idx], false);
58 return xhr.responseXML;
62 // Each row has the document getter function, then the characterSet,
63 // inputEncoding expected for that document.
66 [ frameDoc(
"one"),
"windows-1252" ],
67 [ frameDoc(
"two"),
"UTF-8" ],
68 [ frameDoc(
"three"),
"windows-1252" ],
69 [ frameDoc(
"four"),
"UTF-8" ],
70 [ frameDoc(
"five"),
"UTF-8" ],
71 [ frameDoc(
"six"),
"UTF-8" ],
72 [ frameDoc(
"seven"),
"windows-1252" ],
73 [ createDoc,
"UTF-8" ],
74 [ xhrDoc(
4),
"UTF-8" ],
75 [ xhrDoc(
5),
"UTF-8" ],
76 [ xhrDoc(
6),
"windows-1252" ],
79 function doTest(idx) {
80 var [docGetter, expectedCharacterSet] = tests[idx];
81 var doc = docGetter();
83 // Have to be careful here to catch null vs
""
84 is(doc.characterSet, expectedCharacterSet,
"Test " + idx +
" characterSet");
85 is(doc.inputEncoding, expectedCharacterSet,
86 "Test " + idx +
" inputEncoding");
89 addLoadEvent(function() {
90 SpecialPowers.pushPermissions([{'type': 'systemXHR', 'allow': true, 'context': document}], startTest);
93 function startTest() {
95 isnot(
"", null,
"Shouldn't be equal!");
97 for (let i =
0; i < tests.length; ++i) {
101 // Now check what xhr does
102 var xhr = new XMLHttpRequest();
103 xhr.open(
"POST", document.location.href);
104 xhr.send(createDoc());
105 is(SpecialPowers.wrap(xhr).channel.QueryInterface(SpecialPowers.Ci.nsIHttpChannel)
106 .getRequestHeader(
"Content-Type"),
107 "application/xml;charset=UTF-8",
"Testing correct type on the wire");