summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/dom/Document/document-charset.html
blob: fffc724ea39d86330c8e810ead12a36078f8b93a (plain)
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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=koi8-r">
</head>
<body>
<script>

if (window.testRunner)
    testRunner.dumpAsText();

document.write("<p>Initial</p>");
document.write("<p>&nbsp;document.charset: " + document.charset + "</p>"); // MSIE
document.write("<p>&nbsp;document.defaultCharset: " + (document.defaultCharset ? "defined" : "undefined") + "</p>"); // MSIE
document.write("<p>&nbsp;document.characterSet: " + document.characterSet + "</p>"); // Firefox
document.write("<p>&nbsp;document.inputEncoding: " + document.inputEncoding + "</p>"); // DOM3

document.write("<p>Setting charset to UTF-8...</p>");
try {
    document.charset = "utf-8";
    document.write("<p>&nbsp;document.charset: " + document.charset + "</p>");
    document.write("<p>&nbsp;document.defaultCharset: " + (document.defaultCharset ? "defined" : "undefined") + "</p>");
    document.write("<p>&nbsp;document.characterSet: " + document.characterSet + "</p>");
    document.write("<p>&nbsp;document.inputEncoding: " + document.inputEncoding + "</p>");
} catch (ex) {
    document.write("<p>Failure</p>");
}

// throws an exception in Firefox, but JavaScriptCore seems to silently ignore assignment to read-only properties
document.write("<p>Setting characterSet to KOI8-R (expected to fail, matching Firefox)...</p>");
try {
    document.characterSet = "KOI8-R";
    document.write("<p>&nbsp;document.charset: " + document.charset + "</p>");
    document.write("<p>&nbsp;document.defaultCharset: " + (document.defaultCharset ? "defined" : "undefined") + "</p>");
    document.write("<p>&nbsp;document.characterSet: " + document.characterSet + "</p>");
    document.write("<p>&nbsp;document.inputEncoding: " + document.inputEncoding + "</p>");
} catch (ex) {
    document.write("<p>Failure (expected)</p>");
}

</script>
</body>
<html>