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
75 lines
2.1 KiB
HTML
75 lines
2.1 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<title>Pointer Lock target change 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="div1" style="width:800px;height:250px;background:green"></div>
|
|
<div id="div2" style="width:800px;height:250px;background:yellow"></div>
|
|
</body>
|
|
<script>
|
|
promise_test(async function(t) {
|
|
var div1 = document.getElementById("div1");
|
|
var div2 = document.getElementById("div2");
|
|
var mousemove_on_div1 = 0;
|
|
var mousemove_on_div2 = 0;
|
|
|
|
div1.addEventListener('mousemove', function(event) {
|
|
mousemove_on_div1++;
|
|
});
|
|
div2.addEventListener('mousemove', function(event) {
|
|
mousemove_on_div2++;
|
|
});
|
|
|
|
await lockPointerAndWaitForEvent(div1, /*provideTransientActivation=*/
|
|
true);
|
|
|
|
// Send some moves, then click to provide transient activation
|
|
// before re-locking to div2.
|
|
await new test_driver.Actions()
|
|
.pointerMove(10, 10, {
|
|
origin: div1
|
|
})
|
|
.pointerMove(20, 20, {
|
|
origin: div1
|
|
})
|
|
.pointerDown()
|
|
.pointerUp()
|
|
.send();
|
|
|
|
assert_greater_than(mousemove_on_div1, 0,
|
|
"div1 should have received mousemove events while it was the lock target."
|
|
);
|
|
|
|
// Re-lock to div2 and wait for the change event.
|
|
await lockPointerAndWaitForEvent(div2);
|
|
|
|
// Send mouse moves which should be routed to div2.
|
|
await new test_driver.Actions()
|
|
.pointerMove(10, 10, {
|
|
origin: div2
|
|
})
|
|
.pointerMove(20, 20, {
|
|
origin: div2
|
|
})
|
|
.pointerMove(30, 30, {
|
|
origin: div2
|
|
})
|
|
.send();
|
|
|
|
await unlockPointerAndWaitForEvent();
|
|
|
|
assert_greater_than(mousemove_on_div2, 0,
|
|
"div2 should have received mousemove events after becoming the lock target."
|
|
);
|
|
}, "pointer lock target can be changed while locked");
|
|
</script>
|
|
</html>
|