Commit f82422b1 authored by Sam Goto's avatar Sam Goto Committed by Commit Bot

[idle] Assert idle detection works when page is not visible.

Change-Id: I8227667c915f19a5e4d4e34b035846b78de1ac41
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1532476
Commit-Queue: Sam Goto <goto@chromium.org>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#642661}
parent 331b1cc1
<!DOCTYPE html>
<link rel="help" href="https://github.com/samuelgoto/idle-detection">
<title>Tests the Idle Detection API</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="/gen/layout_test_data/mojo/public/js/mojo_bindings.js"></script>
<script src="/gen/mojo/public/mojom/base/string16.mojom.js"></script>
<script src="/gen/mojo/public/mojom/base/time.mojom.js"></script>
<script src="/gen/third_party/blink/public/platform/modules/idle/idle_manager.mojom.js"></script>
<script src="../external/wpt/idle-detection/mock.js"></script>
<script>
'use strict';
promise_test(async t => {
let monitor;
expect(addMonitor).andReturn((threshold, monitorPtr) => {
monitor = monitorPtr;
return Promise.resolve({
state: {
user: UserIdleState.ACTIVE,
screen: ScreenIdleState.UNLOCKED
}
});
});
let detector = new IdleDetector({threshold: 10});
let watcher = new EventWatcher(t, detector, ["change"]);
await detector.start();
await watcher.wait_for("change");
assert_equals(detector.state.user, "active");
testRunner.setPageVisibility("hidden");
monitor.update({
user: UserIdleState.IDLE,
screen: ScreenIdleState.UNLOCKED
});
// Assert that the detector works while the page is not visible.
await watcher.wait_for("change");
assert_equals(detector.state.user, "idle");
testRunner.setPageVisibility("visible");
monitor.update({
user: UserIdleState.ACTIVE,
screen: ScreenIdleState.UNLOCKED
});
await watcher.wait_for("change");
assert_equals(detector.state.user, "active");
detector.stop();
}, 'Page visibility.');
</script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment