17960e5d8d
* 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.
24 lines
633 B
HTML
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>
|