tor-browser

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

image-loading-lazy-referrerpolicy-change.sub.html (2200B)


      1 <!DOCTYPE html>
      2 <head>
      3  <title>Deferred loading=lazy images are fetched with the latest
      4         `referrerpolicy` attribute</title>
      5  <link rel="author" title="Dom Farolino" href="mailto:dom@chromium.org">
      6  <link rel="author" title="Raj T" href="mailto:rajendrant@chromium.org">
      7  <link rel="help" href="https://html.spec.whatwg.org/multipage/images.html#updating-the-image-data">
      8  <script src="/resources/testharness.js"></script>
      9  <script src="/resources/testharnessreport.js"></script>
     10  <script src="../resources/common.js"></script>
     11 </head>
     12 
     13 <script>
     14  const below_viewport_img = new ElementLoadPromise("below_viewport_img");
     15 
     16  async_test(function(t) {
     17    // At this point the image's #updating-the-image-data algorithm has been
     18    // invoked, and the image request has been deferred. The deferred request
     19    // was created with the default referrer policy, which will result in a
     20    // `Referer` header being sent when the request is finally made. The request
     21    // is also for an image that the server will send a broken response for if
     22    // the request has a `Referer` header.
     23    // While the request is deferred, we'll set the `referrerpolicy` attribute
     24    // to `no-referrer`, which would cause the image request to succeed. Since
     25    // `referrerpolicy` mutations trigger another #updating-the-image-data
     26    // invocation (replacing the first one), when we scroll the image into view,
     27    // the image should be fetched with no `Referer` header, and succeed.
     28    window.addEventListener("load", t.step_func(() => {
     29      below_viewport_img.element().referrerPolicy = "no-referrer";
     30      below_viewport_img.element().scrollIntoView();
     31    }));
     32 
     33    below_viewport_img.promise
     34      .then(t.step_func_done())
     35      .catch(t.unreached_func("The image request should successfully load"))
     36  }, "Test that when a deferred image is loaded, it uses the latest referrerpolicy");
     37 </script>
     38 
     39 <body>
     40  <div style="height:1000vh;"></div>
     41  <img id="below_viewport_img"
     42       src="resources/referrer-checker-img.py?expected_referrer="
     43       loading="lazy" referrerpolicy="unsafe-url"
     44       onload="below_viewport_img.resolve();"
     45       onerror="below_viewport_img.reject();">
     46 </body>