1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
<!doctype html>
<meta charset="windows-1253">
<title>meta charset in XHR</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
setup({explicit_done:true});
window.onload = function() {
runNextTest();
};
let files = [
"after-1kb.html",
"after-bogus-after-1kb.html",
"after-bogus.html",
"after-head-after-1kb-crlf.html",
"after-head-after-1kb.html",
"after-head-in-1kb-crlf.html",
"after-head-in-1kb.html",
"baseline.html",
"document-write.html",
"in-comment.html",
"in-noscript-after-template-after-1kb.html",
"in-object.html",
"in-script.html",
"in-style.html",
"in-svg.html",
"in-svg-in-cdata.html",
"in-template-after-1kb.html",
"in-template.html",
"in-title.html",
"ncr.html",
"non-ascii-in-comment-before.html",
"non-ascii-in-title-before.html",
];
function handler() {
const prefix = "Test: ";
let doc = this.response;
test(function() {
let link = doc.getElementsByTagName("link")[0];
let match = (link.rel == "match");
let content = doc.documentElement.textContent;
let index = content.indexOf(prefix);
let c = content.substring(index + prefix.length, index + prefix.length + 1);
if (match) {
assert_equals(doc.characterSet, "windows-1251", 'Check characterSet');
assert_equals(c, "\u0436", 'Check character');
} else {
assert_equals(doc.characterSet, "UTF-8", 'Check characterSet');
assert_equals(c, "\uFFFD", 'Check character');
}
}, "Check " + this.thesrc);
runNextTest();
}
function runNextTest() {
let file = files.shift();
if (!file) {
done();
return;
}
let xhr = new XMLHttpRequest();
xhr.responseType = "document";
xhr.onload = handler;
xhr.thesrc = file; // expando
xhr.open("GET", file);
xhr.send();
}
</script>
|