mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-09 12:51:09 +02:00
Automatic update from web-platform-tests Replace assert_precondition with assert_equals in domparsing/ (#23007) assert_precondition is deprecated (see https://github.com/web-platform-tests/rfcs/blob/master/rfcs/assert_precondition_rename.md). In this particular case, the assertion is actually checking for an equality rather than an 'implements' phrase, so switch to assert_equals. -- wpt-commits: e65087045387dd4ecb9d5c675062a6643e00c7ad wpt-pr: 23007
47 lines
1.3 KiB
HTML
47 lines
1.3 KiB
HTML
<!doctype html>
|
|
<title>DOMParser encoding test</title>
|
|
<meta charset="windows-1252"> <!-- intentional to make sure the results are UTF-8 anyway -->
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
|
|
<script>
|
|
"use strict";
|
|
|
|
function assertEncoding(doc) {
|
|
assert_equals(doc.charset, "UTF-8", "document.charset");
|
|
assert_equals(doc.characterSet, "UTF-8", "document.characterSet");
|
|
assert_equals(doc.inputEncoding, "UTF-8", "document.characterSet");
|
|
}
|
|
|
|
setup(() => {
|
|
assert_equals(document.characterSet, "windows-1252", "the meta charset must be in effect, making the main document windows-1252");
|
|
});
|
|
|
|
test(() => {
|
|
const parser = new DOMParser();
|
|
const doc = parser.parseFromString("", "text/html");
|
|
|
|
assertEncoding(doc);
|
|
}, "HTML: empty");
|
|
|
|
test(() => {
|
|
const parser = new DOMParser();
|
|
const doc = parser.parseFromString("", "text/xml");
|
|
|
|
assertEncoding(doc);
|
|
}, "XML: empty");
|
|
|
|
test(() => {
|
|
const parser = new DOMParser();
|
|
const doc = parser.parseFromString(`<meta charset="latin2">`, "text/html");
|
|
|
|
assertEncoding(doc);
|
|
}, "HTML: meta charset");
|
|
|
|
test(() => {
|
|
const parser = new DOMParser();
|
|
const doc = parser.parseFromString(`<?xml version="1.0" encoding="latin2"?><x/>`, "text/xml");
|
|
|
|
assertEncoding(doc);
|
|
}, "XML: XML declaration");
|
|
</script>
|