summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/xhr/data-uri.htm
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/xhr/data-uri.htm
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.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/xhr/data-uri.htm')
-rw-r--r--testing/web-platform/tests/xhr/data-uri.htm41
1 files changed, 41 insertions, 0 deletions
diff --git a/testing/web-platform/tests/xhr/data-uri.htm b/testing/web-platform/tests/xhr/data-uri.htm
new file mode 100644
index 0000000000..88a7d78fc5
--- /dev/null
+++ b/testing/web-platform/tests/xhr/data-uri.htm
@@ -0,0 +1,41 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>XMLHttpRequest: data URLs</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+
+<script>
+ function do_test(method, url, mimeType, testNamePostfix) {
+ if (typeof mimeType === 'undefined' || mimeType === null) mimeType = 'text/plain';
+ var test = async_test("XHR method " + method + " with MIME type " + mimeType + (testNamePostfix||''));
+ test.step(function() {
+ var client = new XMLHttpRequest(),
+ body = method === "HEAD" ? "" : "Hello, World!";
+ client.onreadystatechange = test.step_func(function () {
+ if (client.readyState !== 4) {
+ return;
+ }
+ assert_equals(client.responseText, body);
+ assert_equals(client.status, 200);
+ assert_equals(client.getResponseHeader('Content-Type'), mimeType);
+ var allHeaders = client.getAllResponseHeaders();
+ assert_regexp_match(allHeaders, /content\-type\:/i, 'getAllResponseHeaders() includes Content-Type');
+ assert_false(/content\-length\:/i.test(allHeaders), 'getAllResponseHeaders() must not include Content-Length');
+ test.done();
+ });
+ client.open(method, url);
+ client.send(null);
+ });
+ }
+ do_test('GET', "data:text/plain,Hello, World!");
+ do_test('GET', "data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==", undefined, " (base64)");
+ do_test('GET', "data:text/html,Hello, World!", 'text/html');
+ do_test('GET', "data:text/html;charset=UTF-8,Hello, World!", 'text/html;charset=UTF-8');
+ do_test('GET', "data:image/png,Hello, World!", 'image/png');
+ do_test('POST', "data:text/plain,Hello, World!");
+ do_test('PUT', "data:text/plain,Hello, World!");
+ do_test('DELETE', "data:text/plain,Hello, World!");
+ do_test('HEAD', "data:text/plain,Hello, World!");
+ do_test('UNICORN', "data:text/plain,Hello, World!");
+</script>