puppeteer/test/assets/idle-detector.html
Maksim Sadym 17960e5d8d
feat(page): emulate idle state (#6410)
* https://bugs.chromium.org/p/chromium/issues/detail?id=1090802
* added `page.emulateIdleState(...)` allowing emulate or remove emulation of the idle state;
* added test `emulate idle` -> `remove emulation` -> `emulate idle` -> `remove emulation`;
* added launch argument `--enable-blink-features=IdleDetection` to turn IdleDetection on.
2020-09-14 11:31:23 +02:00

24 lines
633 B
HTML

<!DOCTYPE html>
<div id="state"></div>
<script>
const elState = document.querySelector('#state');
function setState(msg) {
elState.textContent = msg;
}
async function main() {
const controller = new AbortController();
const signal = controller.signal;
const idleDetector = new IdleDetector({
threshold: 60000,
signal,
});
idleDetector.addEventListener('change', () => {
const userState = idleDetector.userState;
const screenState = idleDetector.screenState;
setState(`Idle state: ${userState}, ${screenState}.`);
});
idleDetector.start();
}
main();
</script>