blob: 50cabda8d20406f4a0c8b4ac412f6b391572bf42 [file] [log] [blame]
Nicolás Peña92d1f6c2019-02-13 20:05:531<!DOCTYPE HTML>
2<meta charset=utf-8>
Nicolás Peña Morenoc13852e2019-07-08 18:51:043<title>Layout Instability entries are not available via the performance timeline</title>
Nicolás Peña92d1f6c2019-02-13 20:05:534<body>
5<style>
6#myDiv { position: relative; width: 300px; height: 100px; }
7</style>
8<div id='myDiv'></div>
9<script src="/resources/testharness.js"></script>
10<script src="/resources/testharnessreport.js"></script>
Nicolás Peña Moreno11f1a592019-12-27 22:36:5711<script src="resources/util.js"></script>
Nicolás Peña92d1f6c2019-02-13 20:05:5312<script>
Nicolás Peña Moreno0432a102020-01-27 17:01:4913promise_test(async t => {
14 assert_precondition(window.LayoutShift, 'Layout Instability is not supported.');
Nicolás Peña Moreno11f1a592019-12-27 22:36:5715 // Wait for the initial render to complete.
16 await waitForAnimationFrames(2);
Nicolás Peña Morenoc13852e2019-07-08 18:51:0417
Nicolás Peña Moreno11f1a592019-12-27 22:36:5718 const startTime = performance.now();
Nicolás Peña Moreno0432a102020-01-27 17:01:4919 return new Promise(resolve => {
20 new PerformanceObserver(t.step_func(list => {
21 const endTime = performance.now();
22 assert_equals(list.getEntries().length, 1);
23 const entry = list.getEntries()[0];
24 assert_equals(entry.entryType, "layout-shift");
25 assert_equals(entry.name, "");
26 assert_greater_than_equal(entry.startTime, startTime);
27 assert_less_than_equal(entry.startTime, endTime);
28 assert_equals(entry.duration, 0.0);
29 // The layout shift value should be:
30 // 300 * (100 + 60) * (60 / maxDimension) / viewport size.
31 assert_equals(entry.value, computeExpectedScore(300 * (100 + 60), 60));
Nicolás Peña Moreno11f1a592019-12-27 22:36:5732
Nicolás Peña Moreno0432a102020-01-27 17:01:4933 // The entry should not be available via getEntries* methods.
34 assert_equals(performance.getEntriesByType('layout-shift').length, 0, 'getEntriesByType should have no layout-shift entries');
35 assert_equals(performance.getEntriesByName('', 'layout-shift').length, 0, 'getEntriesByName should have no layout-shift entries');
36 assert_equals(performance.getEntries().filter(e => e.entryType === 'layout-shift').length, 0, 'getEntries should have no layout-shift entries');
37 resolve();
38 })).observe({type: 'layout-shift'});
39 // Modify the position of the div.
40 document.getElementById('myDiv').style = "top: 60px";
41 });
Nicolás Peña Moreno11f1a592019-12-27 22:36:5742}, 'Layout shift before onload is not buffered into the performance timeline.');
Nicolás Peña92d1f6c2019-02-13 20:05:5343</script>
44
45</body>