tor-browser

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

image-full-viewport.html (1792B)


      1 <!DOCTYPE HTML>
      2 <meta charset=utf-8>
      3 <title>Largest Contentful Paint: size when image overflows</title>
      4 <!-- In this test, an image with an intrinsic size of 100 x 50 is added, but
      5  scaled up in order to overflow the viewport. It should not be reported. -->
      6 <body>
      7 <style>
      8 body {
      9  margin: 0px;
     10 }
     11 </style>
     12 <script src="/resources/testharness.js"></script>
     13 <script src="/resources/testharnessreport.js"></script>
     14 <script src="resources/largest-contentful-paint-helpers.js"></script>
     15 <script>
     16  const viewportWidth = document.documentElement.clientWidth;
     17  const viewportHeight = document.documentElement.clientHeight;
     18  setup({"hide_test_state": true});
     19  async_test(function (t) {
     20    assert_implements(window.LargestContentfulPaint, "LargestContentfulPaint is not implemented");
     21    const beforeLoad = performance.now();
     22    new PerformanceObserver(
     23      t.step_func_done(function(entryList) {
     24        assert_equals(entryList.getEntries().length, 1, 'Should have received only one entry!');
     25        const entry = entryList.getEntries()[0];
     26        if (entry.url)
     27          assert_unreached('Should not have received an image entry!');
     28      })
     29    ).observe({type: 'largest-contentful-paint', buffered: true});
     30    // Add an image, setting width and height equal to viewport.
     31    img = document.createElement('img');
     32    img.src = '/images/lcp-100x50.png';
     33    img.id = 'image_id';
     34    img.width = viewportWidth * 2;
     35    img.height = viewportHeight * 2;
     36    img.onload = () => {
     37      const p = document.createElement('p');
     38      p.innerHTML = 'a';
     39      p.style = 'position: absolute; top: 10px; left: 10px;';
     40      document.body.appendChild(p);
     41    }
     42    document.body.appendChild(img);
     43  }, 'The intersectionRect of an img element overflowing is computed correctly');
     44 </script>
     45 </body>