Bug 1610669 [wpt PR 21326] - Use assert_precondition in ElementTiming/LargestContentf...
[gecko.git] / testing / web-platform / tests / largest-contentful-paint / contracted-image.html
blobed6adfb2c7c66c65bd13f514be173d1cb48ff19e
1 <!DOCTYPE HTML>
2 <meta charset=utf-8>
3 <title>Largest Contentful Paint: contracted image bounded by display size.</title>
4 <style type="text/css">
5 #image_id {
6 width: 50px;
7 height: 50px;
9 </style>
10 <body>
11 <script src="/resources/testharness.js"></script>
12 <script src="/resources/testharnessreport.js"></script>
13 <script src="resources/largest-contentful-paint-helpers.js"></script>
14 <script>
15 async_test(function (t) {
16 assert_precondition(window.LargestContentfulPaint, "LargestContentfulPaint is not implemented");
17 const beforeLoad = performance.now();
18 const observer = new PerformanceObserver(
19 t.step_func_done(function(entryList) {
20 assert_equals(entryList.getEntries().length, 1);
21 const entry = entryList.getEntries()[0];
22 const url = window.location.origin + '/images/black-rectangle.png';
23 // black-rectangle.png is 100 x 50. It occupies 50 x 50 so size will be bounded by the displayed size.
24 const size = 50 * 50;
25 checkImage(entry, url, 'image_id', size, beforeLoad);
28 observer.observe({type: 'largest-contentful-paint', buffered: true});
29 }, 'Largest Contentful Paint: |size| attribute is bounded by display size.');
30 </script>
31 <img src='/images/black-rectangle.png' id='image_id'/>
32 </body>