tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

svg-image.sub.html (2178B)


      1 <!DOCTYPE html>
      2 <!--
      3 [%provenance%]
      4 -->
      5 <html lang="en">
      6  <meta charset="utf-8">
      7  {%- if subtests|length > 10 %}
      8  <meta name="timeout" content="long">
      9  {%- endif %}
     10  <title>HTTP headers on request for SVG "image" element source</title>
     11  <script src="/resources/testharness.js"></script>
     12  <script src="/resources/testharnessreport.js"></script>
     13  <script src="/fetch/metadata/resources/helper.sub.js"></script>
     14  <body>
     15  <script>
     16  'use strict';
     17 
     18  const params = {
     19    body: `
     20      <svg xmlns="http://www.w3.org/2000/svg" width="123" height="123">
     21        <rect fill="lime" width="123" height="123"/>
     22      </svg>
     23    `,
     24    mime: 'image/svg+xml'
     25  };
     26 
     27  function induceRequest(t, url, attributes) {
     28    const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
     29    svg.setAttributeNS(
     30      "http://www.w3.org/2000/xmlns/",
     31      "xmlns:xlink",
     32      "http://www.w3.org/1999/xlink"
     33    );
     34    const image = document.createElementNS("http://www.w3.org/2000/svg", "image");
     35    image.setAttribute("href", url);
     36    svg.appendChild(image);
     37 
     38    for (const [ name, value ] of Object.entries(attributes)) {
     39      image.setAttribute(name, value);
     40    }
     41 
     42    document.body.appendChild(svg);
     43    t.add_cleanup(() => svg.remove());
     44 
     45    return new Promise((resolve, reject) => {
     46      image.onload = resolve;
     47      image.onerror = reject;
     48    });
     49  }
     50 
     51  {%- for subtest in subtests %}
     52 
     53  promise_test((t) => {
     54    const key = '{{uuid()}}';
     55 
     56    return induceRequest(
     57        t,
     58        makeRequestURL(key, [% subtest.origins %], params),
     59        [%subtest.elementAttrs | default({}) | tojson%]
     60      )
     61      .then(() => retrieve(key))
     62      .then((headers) => {
     63        {%- if subtest.expected == none %}
     64          assert_not_own_property(headers, '[%subtest.headerName%]');
     65        {%- else %}
     66          assert_own_property(headers, '[%subtest.headerName%]');
     67          assert_array_equals(headers['[%subtest.headerName%]'], ['[%subtest.expected%]']);
     68        {%- endif %}
     69      });
     70  }, '[%subtest.headerName%][%subtest.description | pad("start", " - ")%] [%subtest.elementAttrs | collection("attributes")%]');
     71 
     72  {%- endfor %}
     73  </script>
     74  </body>
     75 </html>