blob: 5bd2eef739bc0a6983ada2feb4d604d3d5b1ef9c [file] [log] [blame]
<!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>
<!-- 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;
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.");
}, "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.");
}, "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.");
}, "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();
});
}
</script>
<div id="complete-notice">
</div>
</body>
</html>