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
41 lines
1.4 KiB
HTML
41 lines
1.4 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<title>Pointer Lock exit on element disconnect 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) {
|
|
var target = document.getElementById("target");
|
|
|
|
await lockPointerAndWaitForEvent(
|
|
target, /*provideTransientActivation=*/ true);
|
|
|
|
// Remove the element from the DOM. This action should
|
|
// automatically release the lock and fire another
|
|
// pointerlockchange event.
|
|
var unlockChangePromise = new Promise(resolve => {
|
|
document.addEventListener('pointerlockchange', resolve, {
|
|
once: true
|
|
});
|
|
});
|
|
target.remove();
|
|
await unlockChangePromise;
|
|
|
|
assert_equals(document.pointerLockElement, null,
|
|
"pointerLockElement should be null after target disconnected.");
|
|
assert_false(document.contains(target),
|
|
"Target element should no longer be in the document.");
|
|
}, "pointer lock exits when lock target is disconnected");
|
|
</script>
|
|
</html>
|