<!DOCTYPE html>
<html>
<head>
<script>
let interactionCallback = () => ({});
const observer = new PerformanceObserver((list) => {
for (const entry of list.getEntries()) {
if (entry.name === 'keydown' || entry.name === 'keyup') {
interactionCallback();
}
}
});
observer.observe({type: 'event', buffered: true, durationThreshold: 16});
window.__interactionPromise = new Promise((resolve) => interactionCallback = resolve)
const blockMainThread = (event) => {
// Block the main thread to trigger a PerformanceEventTiming
// entry, which is only dispatched if the event's duration
// exceeds the threshold set at the `observe` call.
// See https://developer.mozilla.org/en-US/docs/Web/API/PerformanceEventTiming
const threshold = 100;
const init = performance.now();
while ((performance.now() - init) < threshold);
}
</script>
</head>
<body>
<input autofocus onkeydown="blockMainThread()">
</body>
</html>