mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
The flaky test `input-value-does-not-force-layout.html` had an absolute threshold of 5000ms before it would fail, which did not work that great on CI. Since we are dealing with wildly different performance characteristics on our CI runners (and ASAN enabled), make this test perform relative timing comparisons instead. Confirmed to still fail locally with the original fix removed.
47 lines
1.5 KiB
HTML
47 lines
1.5 KiB
HTML
<!DOCTYPE html>
|
|
<style>
|
|
.row {
|
|
display: flex;
|
|
align-items: center;
|
|
padding: 4px;
|
|
}
|
|
</style>
|
|
<input id="inp" />
|
|
<div id="app"></div>
|
|
<script src="include.js"></script>
|
|
<script>
|
|
test(() => {
|
|
const input = document.querySelector("#inp");
|
|
const app = document.querySelector("#app");
|
|
|
|
for (let i = 0; i < 2000; i++) {
|
|
const row = document.createElement("div");
|
|
row.className = "row";
|
|
row.innerHTML = `<input type="checkbox"><span>${i}</span><button>x</button>`;
|
|
app.appendChild(row);
|
|
}
|
|
input.focus();
|
|
input.offsetWidth;
|
|
|
|
// Setting input.value with dirty layout must not be significantly slower than without it.
|
|
const values = ["a", "ab"];
|
|
|
|
const baselineStart = performance.now();
|
|
for (let i = 0; i < 2000; i++)
|
|
app.children[i % 2000].style.padding = (4 + (i % 2)) + "px";
|
|
const baseline = performance.now() - baselineStart;
|
|
|
|
input.offsetWidth;
|
|
|
|
const testStart = performance.now();
|
|
for (let i = 0; i < 2000; i++) {
|
|
app.children[i % 2000].style.padding = (4 + (i % 2)) + "px";
|
|
input.value = values[i % 2];
|
|
}
|
|
const test = performance.now() - testStart;
|
|
|
|
const ratio = test / Math.max(baseline, 1);
|
|
println(ratio < 5 ? "PASS" : `FAIL: ratio ${ratio.toFixed(1)}x (baseline=${baseline.toFixed(0)}ms, test=${test.toFixed(0)}ms)`);
|
|
});
|
|
</script>
|