gecko-dev/testing/web-platform/tests/pointerlock/pointerlock_remove_target.html
Ella Ge 7ba49592d7 Bug 1534874 [wpt PR 15745] - Automate some pointerlock wpt, a=testonly
Automatic update from web-platform-tests
Automate some pointerlock wpt

This CL adds test driver automation to 5 tests in wpt/pointerlock.

After this CL, there are still 6 tests left as manual test and do not
have any automation. They are either require hotkey such as "ctrl +
Tab" or "Esc", or needs the system cursor. It's impossible to automate
them at this point.

Bug: 359740
Change-Id: I0395c9a0a7c964617172417bdb70f471a2cba224
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1509794
Reviewed-by: Lan Wei <lanwei@chromium.org>
Reviewed-by: Navid Zolghadr <nzolghadr@chromium.org>
Commit-Queue: Ella Ge <eirage@chromium.org>
Cr-Commit-Position: refs/heads/master@{#640046}

--

wpt-commits: 28c2d0ced51c3060b287345647016d0971a3706b
wpt-pr: 15745
2019-04-01 14:43:26 +01:00

96 lines
2.6 KiB
HTML

<!DOCTYPE html>
<html>
<body>
<meta name="timeout" content="long">
<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>
<style type="text/css">
button {
color: blue;
}
#target-wrap {
position: relative;
background-color: lightgrey;
width: 200px;
height: 100px;
border: grey 1px solid;
}
#target {
position: relative;
background-color: lightyellow;
width: 100px;
height: 30px;
border: yellow 1px solid;
}
#status-log {
margin: 10px 0;
color: green;
}
</style>
</head>
<body>
<h2>Description</h2>
<p>This test validates that pointer lock will be lost when the target is disconnected.</p>
<hr/>
<h2>Manual Test Steps:</h2>
<p>
<ol>
<li>Click the "lockTarget" button to request a pointer lock.</li>
<li>Test is done.</li>
</ol>
</p>
<hr/>
<button id="Button" onclick="lockTarget();">lockTarget</button>
<div id="target-wrap">
<div id="status-log">Click the "lockTarget" button.</div>
<div id="target">Target</div>
</div>
<hr/>
<div id="log"></div>
<script type="text/javascript" >
var target = document.querySelector('#target'),
target_wrap = document.querySelector('#target-wrap')
status_log = document.querySelector('#status-log');
var removeTargetTest = async_test("Test that pointer lock will be lost when taking the target element out of the DOM.");
document.addEventListener("pointerlockchange", function() {
if(document.pointerLockElement) {
status_log.innerHTML = "Target is locked!";
target_wrap.removeChild(target);
} else {
status_log.innerHTML = "Pointer lock exited!";
removeTargetTest.step(function() {
assert_true(document.pointerLockElement === null, "Pointer lock exited!");
});
removeTargetTest.done();
}
});
function lockTarget() {
target.requestPointerLock();
}
// Inject mouse inputs.
new test_driver.Actions()
.pointerMove(0, 0, {origin: Button})
.pointerDown()
.pointerUp()
.send();
</script>
</body>
</html>