Skip to content

Truly independent web browser

Tests: Import WPT test for unsupported encoding labels

Andreas Kling2177f7fae7a6
diff --git a/Tests/LibWeb/TestConfig.ini b/Tests/LibWeb/TestConfig.ini
index bb7285ebd9f..4c67cfe32b4 100644
--- a/Tests/LibWeb/TestConfig.ini
+++ b/Tests/LibWeb/TestConfig.ini
@@ -521,6 +521,7 @@ Text/input/wpt-import/html/webappapis/atob/base64.any.html
; so these tests must be served via HTTP.
Text/input/wpt-import/encoding-detection/utf-8.html
Text/input/wpt-import/encoding-detection/ja-ISO-2022-JP.tentative.html
+Text/input/wpt-import/encoding/unsupported-labels.window.html
; Cache operations explicitly only work with HTTP(S) URLs.
Text/input/wpt-import/service-workers/cache-storage/cache-add.https.any.html
diff --git a/Tests/LibWeb/Text/expected/wpt-import/encoding/unsupported-labels.window.txt b/Tests/LibWeb/Text/expected/wpt-import/encoding/unsupported-labels.window.txt
new file mode 100644
index 00000000000..c01daf9d103
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/wpt-import/encoding/unsupported-labels.window.txt
@@ -0,0 +1,163 @@
+Harness status: OK
+
+Found 158 tests
+
+158 Fail
+Fail 437 is not supported by the Encoding Standard
+Fail adobe-standard-encoding is not supported by the Encoding Standard
+Fail armscii-8 is not supported by the Encoding Standard
+Fail bocu-1 is not supported by the Encoding Standard
+Fail cesu-8 is not supported by the Encoding Standard
+Fail cp1025 is not supported by the Encoding Standard
+Fail cp437 is not supported by the Encoding Standard
+Fail cp737 is not supported by the Encoding Standard
+Fail cp851 is not supported by the Encoding Standard
+Fail cp858 is not supported by the Encoding Standard
+Fail cp862 is not supported by the Encoding Standard
+Fail cp864 is not supported by the Encoding Standard
+Fail cp869 is not supported by the Encoding Standard
+Fail cp875 is not supported by the Encoding Standard
+Fail cp950 is not supported by the Encoding Standard
+Fail csiso103t618bit is not supported by the Encoding Standard
+Fail csiso111ecmacyrillic is not supported by the Encoding Standard
+Fail cspc8codepage437 is not supported by the Encoding Standard
+Fail csviscii is not supported by the Encoding Standard
+Fail dos-720 is not supported by the Encoding Standard
+Fail dos-862 is not supported by the Encoding Standard
+Fail ecma-cyrillic is not supported by the Encoding Standard
+Fail euc-tw is not supported by the Encoding Standard
+Fail german is not supported by the Encoding Standard
+Fail geostd8 is not supported by the Encoding Standard
+Fail hp-roman8 is not supported by the Encoding Standard
+Fail ibm-thai is not supported by the Encoding Standard
+Fail ibm00858 is not supported by the Encoding Standard
+Fail ibm00924 is not supported by the Encoding Standard
+Fail ibm01047 is not supported by the Encoding Standard
+Fail ibm01140 is not supported by the Encoding Standard
+Fail ibm01141 is not supported by the Encoding Standard
+Fail ibm01142 is not supported by the Encoding Standard
+Fail ibm01143 is not supported by the Encoding Standard
+Fail ibm01144 is not supported by the Encoding Standard
+Fail ibm01145 is not supported by the Encoding Standard
+Fail ibm01146 is not supported by the Encoding Standard
+Fail ibm01147 is not supported by the Encoding Standard
+Fail ibm01148 is not supported by the Encoding Standard
+Fail ibm01149 is not supported by the Encoding Standard
+Fail ibm037 is not supported by the Encoding Standard
+Fail ibm1026 is not supported by the Encoding Standard
+Fail ibm1047 is not supported by the Encoding Standard
+Fail ibm273 is not supported by the Encoding Standard
+Fail ibm277 is not supported by the Encoding Standard
+Fail ibm278 is not supported by the Encoding Standard
+Fail ibm280 is not supported by the Encoding Standard
+Fail ibm284 is not supported by the Encoding Standard
+Fail ibm285 is not supported by the Encoding Standard
+Fail ibm290 is not supported by the Encoding Standard
+Fail ibm297 is not supported by the Encoding Standard
+Fail ibm367 is not supported by the Encoding Standard
+Fail ibm420 is not supported by the Encoding Standard
+Fail ibm423 is not supported by the Encoding Standard
+Fail ibm424 is not supported by the Encoding Standard
+Fail ibm437 is not supported by the Encoding Standard
+Fail ibm500 is not supported by the Encoding Standard
+Fail ibm737 is not supported by the Encoding Standard
+Fail ibm775 is not supported by the Encoding Standard
+Fail ibm850 is not supported by the Encoding Standard
+Fail ibm852 is not supported by the Encoding Standard
+Fail ibm855 is not supported by the Encoding Standard
+Fail ibm857 is not supported by the Encoding Standard
+Fail ibm860 is not supported by the Encoding Standard
+Fail ibm861 is not supported by the Encoding Standard
+Fail ibm862 is not supported by the Encoding Standard
+Fail ibm863 is not supported by the Encoding Standard
+Fail ibm864 is not supported by the Encoding Standard
+Fail ibm864i is not supported by the Encoding Standard
+Fail ibm865 is not supported by the Encoding Standard
+Fail ibm868 is not supported by the Encoding Standard
+Fail ibm869 is not supported by the Encoding Standard
+Fail ibm870 is not supported by the Encoding Standard
+Fail ibm871 is not supported by the Encoding Standard
+Fail ibm880 is not supported by the Encoding Standard
+Fail ibm905 is not supported by the Encoding Standard
+Fail ibm918 is not supported by the Encoding Standard
+Fail iso-2022-jp-1 is not supported by the Encoding Standard
+Fail iso-2022-jp-2 is not supported by the Encoding Standard
+Fail iso-2022-jp-3 is not supported by the Encoding Standard
+Fail iso-8859-8 visual is not supported by the Encoding Standard
+Fail jis_c6226-1978 is not supported by the Encoding Standard
+Fail jis_x0208-1983 is not supported by the Encoding Standard
+Fail jis_x0208-1990 is not supported by the Encoding Standard
+Fail jis_x0212-1990 is not supported by the Encoding Standard
+Fail johab is not supported by the Encoding Standard
+Fail latin9 is not supported by the Encoding Standard
+Fail norwegian is not supported by the Encoding Standard
+Fail sami-ws2 is not supported by the Encoding Standard
+Fail scsu is not supported by the Encoding Standard
+Fail shift_jis_x0213-2000 is not supported by the Encoding Standard
+Fail swedish is not supported by the Encoding Standard
+Fail tcvn is not supported by the Encoding Standard
+Fail tis-620-2533 is not supported by the Encoding Standard
+Fail utf-7 is not supported by the Encoding Standard
+Fail utf-32 is not supported by the Encoding Standard
+Fail viscii is not supported by the Encoding Standard
+Fail windows-936-2000 is not supported by the Encoding Standard
+Fail windows-sami-2 is not supported by the Encoding Standard
+Fail ws2 is not supported by the Encoding Standard
+Fail x-chinese-cns is not supported by the Encoding Standard
+Fail x-chinese-eten is not supported by the Encoding Standard
+Fail x-cp20001 is not supported by the Encoding Standard
+Fail x-cp20003 is not supported by the Encoding Standard
+Fail x-cp20004 is not supported by the Encoding Standard
+Fail x-cp20005 is not supported by the Encoding Standard
+Fail x-cp20261 is not supported by the Encoding Standard
+Fail x-cp20269 is not supported by the Encoding Standard
+Fail x-cp20936 is not supported by the Encoding Standard
+Fail x-cp20949 is not supported by the Encoding Standard
+Fail x-cp21027 is not supported by the Encoding Standard
+Fail x-cp50227 is not supported by the Encoding Standard
+Fail x-cp50229 is not supported by the Encoding Standard
+Fail x-ebcdic-koreanextended is not supported by the Encoding Standard
+Fail x-europa is not supported by the Encoding Standard
+Fail x-ia5 is not supported by the Encoding Standard
+Fail x-ia5-german is not supported by the Encoding Standard
+Fail x-ia5-norwegian is not supported by the Encoding Standard
+Fail x-ia5-swedish is not supported by the Encoding Standard
+Fail x-iscii-as is not supported by the Encoding Standard
+Fail x-iscii-be is not supported by the Encoding Standard
+Fail x-iscii-de is not supported by the Encoding Standard
+Fail x-iscii-gu is not supported by the Encoding Standard
+Fail x-iscii-ka is not supported by the Encoding Standard
+Fail x-iscii-ma is not supported by the Encoding Standard
+Fail x-iscii-or is not supported by the Encoding Standard
+Fail x-iscii-pa is not supported by the Encoding Standard
+Fail x-iscii-t is not supported by the Encoding Standard
+Fail x-iscii-ta is not supported by the Encoding Standard
+Fail x-iscii-te is not supported by the Encoding Standard
+Fail x-mac-arabic is not supported by the Encoding Standard
+Fail x-mac-ce is not supported by the Encoding Standard
+Fail x-mac-centraleurroman is not supported by the Encoding Standard
+Fail x-mac-chinesesimp is not supported by the Encoding Standard
+Fail x-mac-chinesetrad is not supported by the Encoding Standard
+Fail x-mac-croatian is not supported by the Encoding Standard
+Fail x-mac-devanagari is not supported by the Encoding Standard
+Fail x-mac-dingbats is not supported by the Encoding Standard
+Fail x-mac-farsi is not supported by the Encoding Standard
+Fail x-mac-greek is not supported by the Encoding Standard
+Fail x-mac-gujarati is not supported by the Encoding Standard
+Fail x-mac-gurmukhi is not supported by the Encoding Standard
+Fail x-mac-hebrew is not supported by the Encoding Standard
+Fail x-mac-icelandic is not supported by the Encoding Standard
+Fail x-mac-japanese is not supported by the Encoding Standard
+Fail x-mac-korean is not supported by the Encoding Standard
+Fail x-mac-roman-latin1 is not supported by the Encoding Standard
+Fail x-mac-romanian is not supported by the Encoding Standard
+Fail x-mac-symbol is not supported by the Encoding Standard
+Fail x-mac-thai is not supported by the Encoding Standard
+Fail x-mac-tibetan is not supported by the Encoding Standard
+Fail x-mac-turkish is not supported by the Encoding Standard
+Fail x-mac-vt100 is not supported by the Encoding Standard
+Fail x-nextstep is not supported by the Encoding Standard
+Fail x-vps is not supported by the Encoding Standard
+Fail _autodetect is not supported by the Encoding Standard
+Fail _autodetect_all is not supported by the Encoding Standard
+Fail _autodetect_kr is not supported by the Encoding Standard
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/input/wpt-import/encoding/resources/text-html-meta-charset.py b/Tests/LibWeb/Text/input/wpt-import/encoding/resources/text-html-meta-charset.py
new file mode 100644
index 00000000000..f73110743ea
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/encoding/resources/text-html-meta-charset.py
@@ -0,0 +1,3 @@
+def main(request, response):
+ response.headers.set(b"Content-Type", b"text/html")
+ response.content = b"<meta charset=\"" + request.GET.first(b"label") + b"\">hello encoding"
diff --git a/Tests/LibWeb/Text/input/wpt-import/encoding/unsupported-labels.window.html b/Tests/LibWeb/Text/input/wpt-import/encoding/unsupported-labels.window.html
new file mode 100644
index 00000000000..a15b51e109a
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/encoding/unsupported-labels.window.html
@@ -0,0 +1,8 @@
+<!doctype html>
+<meta charset=utf-8>
+
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+
+<div id=log></div>
+<script src="../encoding/unsupported-labels.window.js"></script>
diff --git a/Tests/LibWeb/Text/input/wpt-import/encoding/unsupported-labels.window.js b/Tests/LibWeb/Text/input/wpt-import/encoding/unsupported-labels.window.js
new file mode 100644
index 00000000000..0262bbbc61f
--- /dev/null
+++ b/Tests/LibWeb/Text/input/wpt-import/encoding/unsupported-labels.window.js
@@ -0,0 +1,180 @@
+// This list was inspired by these sources:
+// - https://annevankesteren.nl/2010/8-bit-labels
+// - http://l0.cm/encodings/table/
+
+[
+ "437",
+ "adobe-standard-encoding",
+ "armscii-8",
+ "bocu-1",
+ "cesu-8",
+ "cp1025",
+ "cp437",
+ "cp737",
+ "cp851",
+ "cp858",
+ "cp862",
+ "cp864",
+ "cp869",
+ "cp875",
+ "cp950",
+ "csiso103t618bit",
+ "csiso111ecmacyrillic",
+ "cspc8codepage437",
+ "csviscii",
+ "dos-720",
+ "dos-862",
+ "ecma-cyrillic",
+ "euc-tw",
+ "german",
+ "geostd8",
+ "hp-roman8",
+ "ibm-thai",
+ "ibm00858",
+ "ibm00924",
+ "ibm01047",
+ "ibm01140",
+ "ibm01141",
+ "ibm01142",
+ "ibm01143",
+ "ibm01144",
+ "ibm01145",
+ "ibm01146",
+ "ibm01147",
+ "ibm01148",
+ "ibm01149",
+ "ibm037",
+ "ibm1026",
+ "ibm1047",
+ "ibm273",
+ "ibm277",
+ "ibm278",
+ "ibm280",
+ "ibm284",
+ "ibm285",
+ "ibm290",
+ "ibm297",
+ "ibm367",
+ "ibm420",
+ "ibm423",
+ "ibm424",
+ "ibm437",
+ "ibm500",
+ "ibm737",
+ "ibm775",
+ "ibm850",
+ "ibm852",
+ "ibm855",
+ "ibm857",
+ "ibm860",
+ "ibm861",
+ "ibm862",
+ "ibm863",
+ "ibm864",
+ "ibm864i",
+ "ibm865",
+ "ibm868",
+ "ibm869",
+ "ibm870",
+ "ibm871",
+ "ibm880",
+ "ibm905",
+ "ibm918",
+ "iso-2022-jp-1",
+ "iso-2022-jp-2",
+ "iso-2022-jp-3",
+ "iso-8859-8 visual",
+ "jis_c6226-1978",
+ "jis_x0208-1983",
+ "jis_x0208-1990",
+ "jis_x0212-1990",
+ "johab",
+ "latin9",
+ "norwegian",
+ "sami-ws2",
+ "scsu",
+ "shift_jis_x0213-2000",
+ "swedish",
+ "tcvn",
+ "tis-620-2533",
+ "utf-7",
+ "utf-32",
+ "viscii",
+ "windows-936-2000",
+ "windows-sami-2",
+ "ws2",
+ "x-chinese-cns",
+ "x-chinese-eten",
+ "x-cp20001",
+ "x-cp20003",
+ "x-cp20004",
+ "x-cp20005",
+ "x-cp20261",
+ "x-cp20269",
+ "x-cp20936",
+ "x-cp20949",
+ "x-cp21027",
+ "x-cp50227",
+ "x-cp50229",
+ "x-ebcdic-koreanextended",
+ "x-europa",
+ "x-ia5",
+ "x-ia5-german",
+ "x-ia5-norwegian",
+ "x-ia5-swedish",
+ "x-iscii-as",
+ "x-iscii-be",
+ "x-iscii-de",
+ "x-iscii-gu",
+ "x-iscii-ka",
+ "x-iscii-ma",
+ "x-iscii-or",
+ "x-iscii-pa",
+ "x-iscii-t",
+ "x-iscii-ta",
+ "x-iscii-te",
+ "x-mac-arabic",
+ "x-mac-ce",
+ "x-mac-centraleurroman",
+ "x-mac-chinesesimp",
+ "x-mac-chinesetrad",
+ "x-mac-croatian",
+ "x-mac-devanagari",
+ "x-mac-dingbats",
+ "x-mac-farsi",
+ "x-mac-greek",
+ "x-mac-gujarati",
+ "x-mac-gurmukhi",
+ "x-mac-hebrew",
+ "x-mac-icelandic",
+ "x-mac-japanese",
+ "x-mac-korean",
+ "x-mac-roman-latin1",
+ "x-mac-romanian",
+ "x-mac-symbol",
+ "x-mac-thai",
+ "x-mac-tibetan",
+ "x-mac-turkish",
+ "x-mac-vt100",
+ "x-nextstep",
+ "x-vps",
+ "_autodetect",
+ "_autodetect_all",
+ "_autodetect_kr"
+].forEach(label => {
+ async_test(t => {
+ const frame = document.createElement("iframe");
+ t.add_cleanup(() => {
+ frame.remove();
+ });
+ // Intentionally use <meta> as Content-Type results in browser differences
+ // See /html/syntax/charset/inheritance-bogus-meta.html
+ frame.src = "resources/text-html-meta-charset.py?label=" + label;
+ frame.onload = t.step_func_done(() => {
+ // UTF-8 as it inherits from the parent document when unrecognized
+ assert_equals(frame.contentDocument.characterSet, "UTF-8");
+ assert_equals(frame.contentDocument.inputEncoding, "UTF-8");
+ });
+ document.body.append(frame);
+ }, `${label} is not supported by the Encoding Standard`);
+});