summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fetch/redirects
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/fetch/redirects')
-rw-r--r--testing/web-platform/tests/fetch/redirects/data.window.js25
-rw-r--r--testing/web-platform/tests/fetch/redirects/subresource-fragments.html39
2 files changed, 64 insertions, 0 deletions
diff --git a/testing/web-platform/tests/fetch/redirects/data.window.js b/testing/web-platform/tests/fetch/redirects/data.window.js
new file mode 100644
index 0000000000..eeb41966b4
--- /dev/null
+++ b/testing/web-platform/tests/fetch/redirects/data.window.js
@@ -0,0 +1,25 @@
+// See ../api/redirect/redirect-to-dataurl.any.js for fetch() tests
+
+async_test(t => {
+ const img = document.createElement("img");
+ img.onload = t.unreached_func();
+ img.onerror = t.step_func_done();
+ img.src = "../api/resources/redirect.py?location=data:image/png%3Bbase64,iVBORw0KGgoAAAANSUhEUgAAAIUAAABqCAIAAAAdqgU8AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAF6SURBVHhe7dNBDQAADIPA%2Bje92eBxSQUQSLedlQzo0TLQonFWPVoGWjT%2BoUfLQIvGP/RoGWjR%2BIceLQMtGv/Qo2WgReMferQMtGj8Q4%2BWgRaNf%2BjRMtCi8Q89WgZaNP6hR8tAi8Y/9GgZaNH4hx4tAy0a/9CjZaBF4x96tAy0aPxDj5aBFo1/6NEy0KLxDz1aBlo0/qFHy0CLxj/0aBlo0fiHHi0DLRr/0KNloEXjH3q0DLRo/EOPloEWjX/o0TLQovEPPVoGWjT%2BoUfLQIvGP/RoGWjR%2BIceLQMtGv/Qo2WgReMferQMtGj8Q4%2BWgRaNf%2BjRMtCi8Q89WgZaNP6hR8tAi8Y/9GgZaNH4hx4tAy0a/9CjZaBF4x96tAy0aPxDj5aBFo1/6NEy0KLxDz1aBlo0/qFHy0CLxj/0aBlo0fiHHi0DLRr/0KNloEXjH3q0DLRo/EOPloEWjX/o0TLQovEPPVoGWjT%2BoUfLQIvGP/RoGWjR%2BIceJQMPIOzeGc0PIDEAAAAASUVORK5CYII";
+}, "<img> fetch that redirects to data: URL");
+
+globalThis.globalTest = null;
+async_test(t => {
+ globalThis.globalTest = t;
+ const script = document.createElement("script");
+ script.src = "../api/resources/redirect.py?location=data:text/javascript,(globalThis.globalTest.unreached_func())()";
+ script.onerror = t.step_func_done();
+ document.body.append(script);
+}, "<script> fetch that redirects to data: URL");
+
+async_test(t => {
+ const client = new XMLHttpRequest();
+ client.open("GET", "../api/resources/redirect.py?location=data:,");
+ client.send();
+ client.onload = t.unreached_func();
+ client.onerror = t.step_func_done();
+}, "XMLHttpRequest fetch that redirects to data: URL");
diff --git a/testing/web-platform/tests/fetch/redirects/subresource-fragments.html b/testing/web-platform/tests/fetch/redirects/subresource-fragments.html
new file mode 100644
index 0000000000..0bd74d7bfb
--- /dev/null
+++ b/testing/web-platform/tests/fetch/redirects/subresource-fragments.html
@@ -0,0 +1,39 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>Subresources and fragment preservation</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script src=/html/canvas/resources/canvas-tests.js></script>
+<div id=log></div>
+<!--
+ The source image is 50h x 100w and its color depends on the fragment.
+
+ This image is then drawn on a 50h x 100w transparent black canvas.
+-->
+<img data-desc="Control"
+ src="/images/colors.svg#green">
+<img data-desc="Redirect with the original URL containing a fragment"
+ src="../api/resources/redirect.py?simple&location=/images/colors.svg#green">
+<img data-desc="Redirect with the response Location header containing a fragment"
+ src="../api/resources/redirect.py?simple&location=/images/colors.svg%23green">
+<img data-desc="Redirect with both the original URL and response Location header containing a fragment"
+ src="../api/resources/redirect.py?simple&location=/images/colors.svg%23green#red">
+<canvas width=100 height=50></canvas>
+<script>
+setup({ explicit_done:true });
+onload = () => {
+ const canvas = document.querySelector("canvas");
+ const ctx = canvas.getContext("2d");
+ document.querySelectorAll("img").forEach(img => {
+ test(t => {
+ t.add_cleanup(() => {
+ ctx.clearRect(0, 0, 100, 50);
+ });
+ ctx.drawImage(img, 0, 0);
+ // canvas, pixelX, pixelY, r, g, b, alpha, ?, ?, tolerance
+ _assertPixelApprox(canvas, 40, 40, 0, 255, 0, 255, 4);
+ }, img.dataset.desc);
+ });
+ done();
+};
+</script>