summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/syntax/speculative-charset
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/html/syntax/speculative-charset
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/html/syntax/speculative-charset')
-rw-r--r--testing/web-platform/tests/html/syntax/speculative-charset/speculative-script.tentative.html27
-rw-r--r--testing/web-platform/tests/html/syntax/speculative-charset/support/script.py18
-rw-r--r--testing/web-platform/tests/html/syntax/speculative-charset/support/speculative-script.py11
3 files changed, 56 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/syntax/speculative-charset/speculative-script.tentative.html b/testing/web-platform/tests/html/syntax/speculative-charset/speculative-script.tentative.html
new file mode 100644
index 0000000000..e665510946
--- /dev/null
+++ b/testing/web-platform/tests/html/syntax/speculative-charset/speculative-script.tentative.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="windows-1253">
+<title>Speculative script</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src=/common/utils.js></script>
+<body>
+<script>
+const uuid = token();
+
+window.onmessage = function(e) {
+ // The script is first speculatively loaded in the windows-1253 context (inherited from this doc), so
+ // the Greek hex NCR turns into a byte. This byte is stored. Then the script is fetched
+ // non-speculatively, because the Greek hexNCR in the URL makes the URL not match in the
+ // windows-1251 context. Now the Greek hex NCR turns in to a decimal NCR and the original Greek
+ // character comes back as a byte that gets a Cyrillic interpretation.
+ assert_equals(e.data, `token: ${uuid}, character: &#950;, previous character: \u0436, byte: \u0436`, "Check result");
+ done();
+}
+
+setup({single_test: true});
+const iframe = document.createElement('iframe');
+iframe.src = `support/speculative-script.py?uuid=${uuid}`;
+document.body.appendChild(iframe);
+</script>
diff --git a/testing/web-platform/tests/html/syntax/speculative-charset/support/script.py b/testing/web-platform/tests/html/syntax/speculative-charset/support/script.py
new file mode 100644
index 0000000000..0dbf5be0ac
--- /dev/null
+++ b/testing/web-platform/tests/html/syntax/speculative-charset/support/script.py
@@ -0,0 +1,18 @@
+import time
+
+def main(request, response):
+ response.add_required_headers = False # Don't implicitly add HTTP headers
+ response.writer.write_status(200)
+ response.writer.write_header("Content-Type", "text/javascript")
+ response.writer.end_headers()
+
+ token = request.GET[b"uuid"]
+ character = request.GET[b"character"]
+ old_character = b"NOT LOADED PREVIOUSLY";
+ from_stash = request.server.stash.take(token);
+ if from_stash:
+ old_character = from_stash
+ else:
+ request.server.stash.put(token, character)
+
+ response.writer.write(b'parent.postMessage("token: %s, character: %s, previous character: %s, byte: \xE6", "*");' % (token, character, old_character));
diff --git a/testing/web-platform/tests/html/syntax/speculative-charset/support/speculative-script.py b/testing/web-platform/tests/html/syntax/speculative-charset/support/speculative-script.py
new file mode 100644
index 0000000000..c72c469ce3
--- /dev/null
+++ b/testing/web-platform/tests/html/syntax/speculative-charset/support/speculative-script.py
@@ -0,0 +1,11 @@
+import time
+
+def main(request, response):
+ response.add_required_headers = False # Don't implicitly add HTTP headers
+ response.writer.write_status(200)
+ response.writer.write_header("Content-Type", "text/html")
+ response.writer.end_headers()
+
+ response.writer.write(b'<!DOCTYPE html><script src="script.py?uuid=%s&character=&#x03B6;"></script>' % request.GET[b"uuid"]);
+ time.sleep(0.2)
+ response.writer.write(b'<meta charset="windows-1251"><p>Test: \xE6</p>');