Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!doctype html>
<html>
<head>
<title>pointerrawupdate</title>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" type="text/css" href="../pointerevent_styles.css">
<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>
<!-- Additional helper script for common checks across event types -->
<script type="text/javascript" src="../pointerevent_support.js"></script>
</head>
<body onload="run()">
<h2>pointerrawupdate</h2>
<h4>Test Description: This test checks if pointerrawupdate is dispatched correctly while in pointerlock mode.
<ol>
<li>Click in the black box (and accept the pointerlock permission if asked).</li>
<li>Move your mouse.</li>
<li>Click in the purple box inside the iframe</li>
<li>Move your mouse.</li>
</ol>
</h4>
<div id="target0"></div>
<iframe id="innerframe" src="../resources/pointerevent_pointerrawupdate_in_pointerlock-iframe.html"></iframe>
<script>
window.name="outerframe";
var test_pointerrawupdate = async_test("pointerrawupdate event received");
var outerframe_pointerrawupdateReceived = false;
var innerframe_pointerrawupdateReceived = false;
async function run() {
var target0 = document.getElementById("target0");
var innerframe = document.getElementById('innerframe');
var target1 = innerframe.contentDocument.getElementById('target1');
innerframe.contentWindow.name = "innerframe";
on_event(document, "pointerlockchange", function(event) {
if (document.pointerLockElement == target0) {
on_event(target0, "pointerrawupdate", function (event) {
outerframe_pointerrawupdateReceived = true;
test_pointerrawupdate.step(function() {
assert_equals(event.view.name, "outerframe", "View attribute of pointerrawupdate should be the target frame. target0 pointerrawupdate");
}, "View attribute of pointerrawupdate should be the target frame.");
});
on_event(target0, "pointermove", function (event) {
test_pointerrawupdate.step(function() {
assert_true(outerframe_pointerrawupdateReceived,
"Pointerrawupdate event should have been received before pointermove while in pointerlock mode.");
assert_equals(event.view.name, "outerframe", "View attribute of pointerrawupdate should be the target frame. target0 pointermove");
}, "Pointerrawupdate event should have been received before pointermove while in pointerlock mode.");
document.exitPointerLock();
on_event(target1, "click", function(event) {
target1.requestPointerLock();
});
on_event(innerframe.contentDocument, "pointerlockchange", function(event) {
if (innerframe.contentDocument.pointerLockElement == target1) {
on_event(target1, "pointerrawupdate", function (event) {
innerframe_pointerrawupdateReceived = true;
test_pointerrawupdate.step(function() {
assert_equals(event.view.name, "innerframe", "View attribute of pointerrawupdate should be the target frame. target1");
}, "View attribute of pointerrawupdate should be the target frame.");
});
on_event(target1, "pointermove", function (event) {
test_pointerrawupdate.step(function() {
assert_true(innerframe_pointerrawupdateReceived,
"Pointerrawupdate event should have been received before pointermove while in pointerlock mode.");
}, "Pointerrawupdate event should have been received before pointermove while in pointerlock mode.");
innerframe.contentDocument.exitPointerLock();
test_pointerrawupdate.done();
});
}
});
});
}
});
on_event(target0, "click", function(event) {
target0.requestPointerLock();
});
// Inject input
var iframeRect = innerframe.getClientRects()[0];
var rect = target1.getClientRects()[0];
var center_x = Math.round(iframeRect.left + (rect.left + rect.right) / 2);
var center_y = Math.round(iframeRect.top + (rect.top + rect.bottom) / 2);
await new test_driver.Actions()
.pointerMove(0, 0, {origin: target0})
.pointerDown()
.pointerUp()
.pointerMove(10, 0, {origin: target0})
.pointerMove(center_x, center_y)
.pointerDown()
.pointerUp()
.pointerMove(center_x + 10, center_y)
.send();
}
</script>
<div id="complete-notice">
</div>
</body>
</html>