tor-browser

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

case-insensitive-scheme.sub.html (1521B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4    <script src='/resources/testharness.js'></script>
      5    <script src='/resources/testharnessreport.js'></script>
      6 </head>
      7 <body>
      8  <script>
      9    let tests = [
     10      {
     11        "csp": "img-src http://{{host}}:{{ports[http][0]}}/",
     12        "name": "Lowercase `http` should allow the image to load.",
     13      },
     14      {
     15        "csp": "img-src HtTp://{{host}}:{{ports[http][0]}}/",
     16        "name": "Mixed-case `http` should allow the image to load.",
     17      },
     18      {
     19        "csp": "img-src HTTP://{{host}}:{{ports[http][0]}}/",
     20        "name": "Uppercase `http` should allow the image to load.",
     21      },
     22    ];
     23 
     24    tests.forEach(test => {
     25      async_test(t => {
     26        let url = "support/load_img_and_post_result_meta.sub.html?csp="
     27            + encodeURIComponent(test.csp);
     28        test_image_loads_as_expected(test, t, url);
     29      }, test.name + " - meta tag");
     30 
     31      async_test(t => {
     32        let url = "support/load_img_and_post_result_header.html?csp="
     33            + encodeURIComponent(test.csp);
     34        test_image_loads_as_expected(test, t, url);
     35      }, test.name + " - HTTP header");
     36    });
     37 
     38    function test_image_loads_as_expected(test, t, url) {
     39      let i = document.createElement('iframe');
     40      i.src = url;
     41      window.addEventListener('message', t.step_func(function(e) {
     42        if (e.source != i.contentWindow) return;
     43        assert_equals(e.data, "img loaded");
     44        t.done();
     45      }));
     46      document.body.appendChild(i);
     47    }
     48  </script>
     49 </body>
     50 </html>