summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/syntax/charset/xhr.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/html/syntax/charset/xhr.html
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/html/syntax/charset/xhr.html')
-rw-r--r--testing/web-platform/tests/html/syntax/charset/xhr.html73
1 files changed, 73 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/syntax/charset/xhr.html b/testing/web-platform/tests/html/syntax/charset/xhr.html
new file mode 100644
index 0000000000..70af7e720c
--- /dev/null
+++ b/testing/web-platform/tests/html/syntax/charset/xhr.html
@@ -0,0 +1,73 @@
+<!doctype html>
+<meta charset="windows-1253">
+<title>meta charset in XHR</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+
+<script>
+setup({explicit_done:true});
+window.onload = function() {
+ runNextTest();
+};
+
+let files = [
+ "after-1kb.html",
+ "after-bogus-after-1kb.html",
+ "after-bogus.html",
+ "after-head-after-1kb-crlf.html",
+ "after-head-after-1kb.html",
+ "after-head-in-1kb-crlf.html",
+ "after-head-in-1kb.html",
+ "baseline.html",
+ "document-write.html",
+ "in-comment.html",
+ "in-noscript-after-template-after-1kb.html",
+ "in-object.html",
+ "in-script.html",
+ "in-style.html",
+ "in-svg.html",
+ "in-svg-in-cdata.html",
+ "in-template-after-1kb.html",
+ "in-template.html",
+ "in-title.html",
+ "ncr.html",
+ "non-ascii-in-comment-before.html",
+ "non-ascii-in-title-before.html",
+];
+
+function handler() {
+ const prefix = "Test: ";
+ let doc = this.response;
+ test(function() {
+ let link = doc.getElementsByTagName("link")[0];
+ let match = (link.rel == "match");
+ let content = doc.documentElement.textContent;
+ let index = content.indexOf(prefix);
+ let c = content.substring(index + prefix.length, index + prefix.length + 1);
+ if (match) {
+ assert_equals(doc.characterSet, "windows-1251", 'Check characterSet');
+ assert_equals(c, "\u0436", 'Check character');
+ } else {
+ assert_equals(doc.characterSet, "UTF-8", 'Check characterSet');
+ assert_equals(c, "\uFFFD", 'Check character');
+ }
+ }, "Check " + this.thesrc);
+ runNextTest();
+}
+
+function runNextTest() {
+ let file = files.shift();
+ if (!file) {
+ done();
+ return;
+ }
+ let xhr = new XMLHttpRequest();
+ xhr.responseType = "document";
+ xhr.onload = handler;
+ xhr.thesrc = file; // expando
+ xhr.open("GET", file);
+ xhr.send();
+}
+
+</script>
+