mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Update web-platform-tests to revision 8da19eeb64e1dbcc32cabc2961a44e15635d116f
This commit is contained in:
parent
b32bff3b97
commit
120d9aa5dc
298 changed files with 9286 additions and 3047 deletions
|
@ -6,9 +6,39 @@
|
|||
#myDiv { position: relative; width: 300px; height: 100px; }
|
||||
</style>
|
||||
<div id='myDiv'></div>
|
||||
<button id='button'>Generate a 'click' event</button>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
<script src=/resources/testdriver.js></script>
|
||||
<script src=/resources/testdriver-vendor.js></script><script>
|
||||
let timeAfterClick;
|
||||
function mainThreadBusy(duration) {
|
||||
const now = performance.now();
|
||||
while (performance.now() < now + duration);
|
||||
}
|
||||
|
||||
function clickOnElement(id, callback) {
|
||||
const element = document.getElementById(id);
|
||||
const rect = element.getBoundingClientRect();
|
||||
const xCenter = rect.x + rect.width / 2;
|
||||
const yCenter = rect.y + rect.height / 2;
|
||||
const leftButton = 0;
|
||||
const clickHandler = () => {
|
||||
mainThreadBusy(120);
|
||||
if (callback)
|
||||
callback();
|
||||
element.removeEventListener("mousedown", clickHandler);
|
||||
};
|
||||
element.addEventListener("mousedown", clickHandler);
|
||||
test_driver.click(element);
|
||||
}
|
||||
|
||||
function clickAndBlockMain(id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
clickOnElement(id, resolve);
|
||||
});
|
||||
}
|
||||
|
||||
async_test(function (t) {
|
||||
const startTime = performance.now();
|
||||
const observer = new PerformanceObserver(
|
||||
|
@ -32,6 +62,37 @@
|
|||
document.getElementById('myDiv').style = "top: 60px";
|
||||
};
|
||||
}, 'Layout shift is observable via PerformanceObserver.');
|
||||
|
||||
async_test(function (t) {
|
||||
const startTime = performance.now();
|
||||
const observer = new PerformanceObserver(
|
||||
t.step_func_done(function(entryList) {
|
||||
const endTime = performance.now();
|
||||
assert_equals(entryList.getEntries().length, 1);
|
||||
const entry = entryList.getEntries()[0];
|
||||
assert_equals(entry.entryType, "layoutShift");
|
||||
assert_equals(entry.name, "");
|
||||
assert_greater_than_equal(entry.startTime, startTime)
|
||||
assert_less_than_equal(entry.startTime, endTime)
|
||||
assert_equals(entry.duration, 0.0);
|
||||
// The layout shift value should be: 300 * (100 + 60) / viewport size.
|
||||
assert_equals(entry.value, 300 * (100 + 60) /
|
||||
(document.documentElement.clientWidth * document.documentElement.clientHeight));
|
||||
// We should see that there was a click input entry
|
||||
assert_equals(entry.hadRecentInput, true);
|
||||
assert_greater_than_equal(timeAfterClick, entry.lastInputTime);
|
||||
})
|
||||
);
|
||||
observer.observe({entryTypes: ['layoutShift']});
|
||||
window.onload = () => {
|
||||
// User input event
|
||||
clickAndBlockMain('button').then( () => {
|
||||
timeAfterClick = performance.now();
|
||||
// Modify the position of the div.
|
||||
document.getElementById('myDiv').style = "top: 60px";
|
||||
});
|
||||
};
|
||||
}, 'Layout shift within user input is observable via PerformanceObserver.');
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue