Automatic update from web-platform-tests Make WPT tests require a gesture to acquire a pointerlock Per the spec, some sort of user interaction is required for a web page to successfully acquire a pointer lock. Currently, the regular browser window and web tests (that run on content_shell) correctly require a user gesture to acquire a pointer lock, but tests run on the headless shell don't. This CL adds a check to enforce this requirement and a new WPT test that validates that user agents enforce this requirement as well. Bug: 40154547 Change-Id: If57e7ec64ee134983d4907867e1cef36473cab29 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7528184 Reviewed-by: Peter Kvitek <kvitekp@chromium.org> Commit-Queue: Gaston Rodriguez <gastonr@microsoft.com> Cr-Commit-Position: refs/heads/main@{#1577354} -- wpt-commits: aac8513c52747fc0f850d8aba93deea1d0c8c112 wpt-pr: 57446
29 lines
1022 B
HTML
29 lines
1022 B
HTML
<!doctype html>
|
|
<html>
|
|
<link rel="help" href="https://w3c.github.io/pointerlock" />
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<body>
|
|
This page will request a pointer lock on load. The test will fail if the User
|
|
Agent provides the pointer lock despite the request not originating from user input.
|
|
</body>
|
|
<script>
|
|
async_test(function(test) {
|
|
document.addEventListener("pointerlockerror", function() {
|
|
test.done();
|
|
});
|
|
document.addEventListener("pointerlockchange", function() {
|
|
if (document.pointerLockElement) {
|
|
test.step(() => {
|
|
assert_unreached('Pointer lock should not be granted without a user gesture');
|
|
});
|
|
}
|
|
test.done();
|
|
});
|
|
// Catch and ignore the promise rejection - the pointerlockerror event should fire
|
|
// and complete the test.
|
|
document.body.requestPointerLock().catch(() => {});
|
|
}, 'Request pointer lock without user gesture should fail');
|
|
</script>
|
|
</html>
|