blob: 94fdec0b18088bf840733d9ee92e814aaf7bba9f [file] [log] [blame]
<!DOCTYPE HTML>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<div id="host"></div>
<script>
description('Test pointerLockElement is the node in the same tree as the context object.<br>'
+ 'To manually test, click on "Click here" below.');
window.jsTestIsAsync = true;
shadowHost = document.getElementById('host');
shadowRoot = shadowHost.attachShadow({mode: 'closed'});
shadowRoot.innerHTML = '<span tabindex=0>Click here</span>';
target = shadowRoot.firstChild;
target.onclick = function () {
shouldBe("document.pointerLockElement", "null");
shouldBe("shadowRoot.pointerLockElement", "null");
target.requestPointerLock();
}
function clickElement(element) {
eventSender.mouseMoveTo(element.offsetLeft + 5, element.offsetTop + 5);
eventSender.mouseDown();
eventSender.mouseUp();
}
if (window.eventSender)
clickElement(target);
let state = 0;
document.addEventListener('pointerlockchange', function () {
switch (state) {
case 0:
shouldBe("document.pointerLockElement", "shadowHost");
shouldBe("shadowRoot.pointerLockElement", "target");
document.exitPointerLock();
break;
case 1:
shouldBe("document.pointerLockElement", "null");
shouldBe("shadowRoot.pointerLockElement", "null");
finishJSTest();
break;
}
state++;
});
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>