summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/largest-contentful-paint/observe-css-generated-image.html
blob: f674e8c37d97321c3c57bce867bb164301926705 (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
<!doctype html>
<meta charset=utf-8>
<title>Largest Contentful Paint: observe element with css generated image</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/largest-contentful-paint-helpers.js"></script>
<style>
  #target::before {
    content: url('/images/black-rectangle.png');
  }
</style>
<body>
  <p id="target"></p>
  <script>
  setup({"hide_test_state": true});
  async_test(function (t) {
    assert_implements(window.LargestContentfulPaint, "LargestContentfulPaint is not implemented");
    let beforeLoad = performance.now();
    let observedFirstLetter = false;
    const observer = new PerformanceObserver(
      t.step_func_done(function(entryList) {
        const entry = entryList.getEntries()[entryList.getEntries().length -1];
        const url = window.location.origin + '/images/black-rectangle.png';
        checkImage(entry, url, 'target', 0, beforeLoad, ['sizeLowerBound']);
    }));
    observer.observe({entryTypes: ['largest-contentful-paint']});
  }, 'Largest Contentful Paint: CSS generated image is observable.');
  </script>
</body>