blob: fc83ba19715aa6d57a5d92f63a1704e739c89257 [file] [log] [blame]
<!DOCTYPE html>
<title>Ensure encoding labels match the Encoding standard</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../../external/wpt/encoding/resources/encodings.js"></script>
<script>
// The list of encoding labels is not web-exposed. This test makes
// use of the "internals" API for testing and therefore can not be
// upstreamed to web-platform-tests.
let supported_labels = internals.supportedTextEncodingLabels().sort();
// Specified labels from: https://encoding.spec.whatwg.org/
let specified_labels = [];
encodings_table.forEach(section => {
section.encodings.forEach(encoding => {
encoding.labels.forEach(label => specified_labels.push(label));
});
});
supported_labels = new Set(supported_labels.map(s => s.toLowerCase()));
specified_labels = new Set(specified_labels.map(s => s.toLowerCase()));
const union = new Set([...supported_labels, ...specified_labels]);
for (const label of union) {
test(t => {
assert_true(supported_labels.has(label),
`${label} should be supported since it is specified`);
assert_true(specified_labels.has(label),
`${label} should only be supported if it is specified`);
}, `Supported label: ${label}`);
}
</script>