diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/tests/mochitest/pointerlock/test_pointerlock_target_not_in_active_document.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | dom/tests/mochitest/pointerlock/test_pointerlock_target_not_in_active_document.html | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/dom/tests/mochitest/pointerlock/test_pointerlock_target_not_in_active_document.html b/dom/tests/mochitest/pointerlock/test_pointerlock_target_not_in_active_document.html new file mode 100644 index 0000000000..8629230b6b --- /dev/null +++ b/dom/tests/mochitest/pointerlock/test_pointerlock_target_not_in_active_document.html @@ -0,0 +1,77 @@ +<!DOCTYPE html> +<html> +<head> + <meta charset="UTF-8"> + <title>Bug 1646493 - test_pointerlock_target_not_in_active_document.html</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <script src="/tests/SimpleTest/EventUtils.js"></script> + <link rel="stylesheet" href="/tests/SimpleTest/test.css"> +</head> +<body style="width: 100vw; height: 100vh; margin: 0;"> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1646493">Mozilla Bug 1646493</a><br> +<iframe></iframe> +<script> +if (!opener) { + SimpleTest.waitForExplicitFinish(); +} + +var newwin = null; +function finish() { + newwin.close() + setTimeout(function() { + SimpleTest.finish(); + }, 0); +} + +function testUnfocusedDocument() { + opener.document.addEventListener("pointerlockchange", function() { + opener.ok(false, "Check we have locked the pointer"); + opener.document.exitPointerLock(); + opener.testInactiveTopLevelDocument(); + }, {once: true}); + + opener.document.addEventListener("pointerlockerror", function() { + opener.ok(true, "Fail to lock pointer"); + opener.testInactiveTopLevelDocument(); + }, {once: true}); + + SpecialPowers.wrap(opener.document).notifyUserGestureActivation(); + opener.document.body.requestPointerLock(); +} + +function testInactiveTopLevelDocument() { + let iframeWin = newwin.frames[0]; + let iframeDoc = iframeWin.document; + + iframeDoc.addEventListener("pointerlockchange", function() { + ok(false, "Check we have locked the pointer"); + iframeDoc.exitPointerLock(); + finish(); + }, {once: true}); + + iframeDoc.addEventListener("pointerlockerror", function() { + ok(true, "Fail to lock pointer"); + finish(); + }, {once: true}); + + SpecialPowers.wrap(iframeDoc).notifyUserGestureActivation(); + + newwin.addEventListener("pagehide", function() { + iframeDoc.body.requestPointerLock(); + }, {once: true}); + newwin.location = "iframe_differentDOM.html"; +} + +addLoadEvent(async function() { + await SimpleTest.promiseFocus(); + + if (!opener) { + newwin = window.open(location); + return; + } + + testUnfocusedDocument(); +}); +</script> +</body> +</html> |