mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
36 lines
1.6 KiB
HTML
36 lines
1.6 KiB
HTML
<!DOCTYPE HTML>
|
|
<meta charset=utf-8>
|
|
<title>Largest Contentful Paint: observe cross-origin images but without renderTime.</title>
|
|
<body>
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<script>
|
|
async_test(function (t) {
|
|
if (!window.LargestContentfulPaint) {
|
|
assert_unreached("LargestContentfulPaint is not implemented");
|
|
}
|
|
const beforeLoad = performance.now();
|
|
const observer = new PerformanceObserver(
|
|
t.step_func_done(function(entryList) {
|
|
assert_equals(entryList.getEntries().length, 1);
|
|
const entry = entryList.getEntries()[0];
|
|
assert_equals(entry.entryType, 'largest-contentful-paint');
|
|
assert_equals(entry.renderTime, 0, 'The renderTime value should be 0 for a cross origin image.');
|
|
assert_equals(entry.startTime, entry.loadTime, 'startTime should equal loadTime');
|
|
assert_equals(entry.duration, 0);
|
|
// blue.png is 133 x 106.
|
|
assert_equals(entry.size, 14098);
|
|
assert_equals(entry.id, 'image_id');
|
|
const pathname = 'http://{{domains[www]}}:{{ports[http][1]}}/images/blue.png';
|
|
assert_equals(entry.url, pathname);
|
|
assert_greater_than_equal(entry.loadTime, beforeLoad);
|
|
assert_less_than(entry.loadTime, performance.now());
|
|
assert_equals(entry.element, document.getElementById('image_id'));
|
|
})
|
|
);
|
|
observer.observe({type: 'largest-contentful-paint', buffered: true});
|
|
}, 'Cross-origin image is observable, with renderTime equal to 0.');
|
|
</script>
|
|
|
|
<img src='http://{{domains[www]}}:{{ports[http][1]}}/images/blue.png' id='image_id'/>
|
|
</body>
|