Automatic update from web-platform-tests Add WPT tests to increase PointerLock coverage New tests in wpt/pointerlock/: - pointerlock_all_mouse_events_to_locktarget: verifies that mouse events are routed to the lock target element and not the element under the cursor (spec §2.1). - pointerlock_suppress_mouse_boundary_events_when_locked.html: verifies that mouse boundary events (out, leave, etc) do not fire while the pointer is locked (spec §2.1). - pointerlock_target_change: verifies that calling requestPointerLock() on a different element while already locked changes the lock target, fires pointerlockchange, and that subsequent pointermove events are dispatched to the new lock target (spec §3 step 6.2, plus Pointer Events routing during lock). - pointerlock_api_behavior: verifies miscellaneous behaviours of calling pointerlock functions. Has two tests: (a) exitPointerLock() is a no-op when not locked, and (b) the pointerlockchange event fired by the UA matches spec (does not bubble, is not cancelable, targets the document) (spec §2.3, §3, §4). Replaced/strengthened test in wpt/pointerlock/: - pointerlock_remove_target: replaces the previous manual-style test with an automated version that verifies pointer lock exits when the locked element is removed from the DOM (spec §8). The pointerlock spec is defined in https://w3c.github.io/pointerlock/ Bug: 521748207 Change-Id: I0ec1359afb99bab94aa8d4bf9fb10a40075b58bd Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7682773 Commit-Queue: Gaston Rodriguez <gastonr@microsoft.com> Reviewed-by: Mustaq Ahmed <mustaq@chromium.org> Cr-Commit-Position: refs/heads/main@{#1648623} -- wpt-commits: f013fa8e4862dca55e7ed285374fe2bdee842506 wpt-pr: 60707
66 lines
2.4 KiB
HTML
66 lines
2.4 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<title>Pointer Lock API behavior test</title>
|
|
<meta name="viewport" content="width=device-width">
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<script src="/resources/testdriver.js"></script>
|
|
<script src="/resources/testdriver-actions.js"></script>
|
|
<script src="/resources/testdriver-vendor.js"></script>
|
|
<script src="test-helper.js"></script>
|
|
</head>
|
|
<body>
|
|
<div id="target" style="width:200px;height:200px;background:green"></div>
|
|
</body>
|
|
<script>
|
|
promise_test(async function(t) {
|
|
assert_equals(document.pointerLockElement, null,
|
|
"pointerLockElement should be null before test.");
|
|
|
|
var handler = e => assert_unreached(
|
|
`Unexpected firing of ${e.type}`);
|
|
document.addEventListener('pointerlockchange', handler);
|
|
document.addEventListener('pointerlockerror', handler);
|
|
|
|
// Should be a harmless no-op.
|
|
document.exitPointerLock();
|
|
|
|
// Give any async events a chance to fire.
|
|
await new Promise(resolve => t.step_timeout(resolve, 500));
|
|
|
|
document.removeEventListener('pointerlockchange', handler);
|
|
document.removeEventListener('pointerlockerror', handler);
|
|
|
|
assert_equals(document.pointerLockElement, null,
|
|
"document.pointerLockElement should be null after exitPointerLock."
|
|
);
|
|
}, "exitPointerLock() is a no-op when pointer is not locked");
|
|
|
|
promise_test(async function(t) {
|
|
var target = document.getElementById("target");
|
|
|
|
const lockEvent = await lockPointerAndWaitForEvent(
|
|
target, /*provideTransientActivation=*/ true);
|
|
|
|
assert_not_equals(lockEvent, null,
|
|
"lockEvent should've been set in 'pointerlockchange'");
|
|
assert_false(lockEvent.bubbles,
|
|
"pointerlockchange event should not bubble.");
|
|
assert_false(lockEvent.cancelable,
|
|
"pointerlockchange event should not be cancelable.");
|
|
assert_equals(lockEvent.target, document,
|
|
"pointerlockchange event target should be the document.");
|
|
|
|
const unlockEvent = await unlockPointerAndWaitForEvent();
|
|
|
|
assert_not_equals(unlockEvent, null,
|
|
"unlockEvent should've been set in 'pointerlockchange'");
|
|
assert_false(unlockEvent.bubbles,
|
|
"pointerlockchange on unlock should not bubble.");
|
|
assert_false(unlockEvent.cancelable,
|
|
"pointerlockchange on unlock should not be cancelable.");
|
|
}, "pointerlockchange event does not bubble and is not cancelable");
|
|
</script>
|
|
</html>
|