summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fetch/redirects/subresource-fragments.html
blob: 0bd74d7bfbcdbe78507000ef1a560ddfa0f5f672 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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>