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/file_pointerlock_xorigin_iframe_no_user_gesture.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/file_pointerlock_xorigin_iframe_no_user_gesture.html | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/dom/tests/mochitest/pointerlock/file_pointerlock_xorigin_iframe_no_user_gesture.html b/dom/tests/mochitest/pointerlock/file_pointerlock_xorigin_iframe_no_user_gesture.html new file mode 100644 index 0000000000..68977ffada --- /dev/null +++ b/dom/tests/mochitest/pointerlock/file_pointerlock_xorigin_iframe_no_user_gesture.html @@ -0,0 +1,95 @@ +<!DOCTYPE HTML> +<html> +<!--https://bugzilla.mozilla.org/show_bug.cgi?id=1672330--> +<head> +<title>Bug 1672330</title> +<script src="/tests/SimpleTest/EventUtils.js"></script> +<script src="/tests/SimpleTest/SimpleTest.js"></script> +<script src="/tests/SimpleTest/paint_listener.js"></script> +<script src="/tests/gfx/layers/apz/test/mochitest/apz_test_utils.js"></script> +<script src="pointerlock_utils.js"></script> +<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> +<style> +#target { + width: 100px; + height: 100px; + background-color: green; +} +iframe { + width: 400px; + height: 300px; + border: 1px solid blue; +} +</style> +</head> +<body> +<a target="_blank"href="https://bugzilla.mozilla.org/show_bug.cgi?id=1672330">Mozilla Bug 1672330</a> +<div id="target"></div> +<iframe src="https://example.com/tests/dom/tests/mochitest/pointerlock/iframe_differentDOM.html"></iframe> + +<pre id="test"> +<script type="text/javascript"> +/** + * Test for Bug 1672330 + */ +SimpleTest.waitForExplicitFinish(); + +async function requestPointerLock(aElement, aExpectError = false) { + let doc = aElement.ownerDocument; + let waitForPointerLockEvent = function() { + return new Promise((aResolve) => { + let eventHandler = function(aEvent) { + is(aEvent.type, aExpectError ? 'pointerlockerror' : 'pointerlockchange', + `got ${aEvent.type}`); + doc.removeEventListener('pointerlockchange', eventHandler); + doc.removeEventListener('pointerlockerror', eventHandler); + aResolve(); + }; + + doc.addEventListener('pointerlockchange', eventHandler); + doc.addEventListener('pointerlockerror', eventHandler); + }); + }; + + aElement.requestPointerLock(); + await waitForPointerLockEvent(); + is(doc.pointerLockElement, aExpectError ? null : aElement, "target pointer locked"); +} + +async function start() { + await waitUntilApzStable(); + + let target = document.getElementById("target"); + SpecialPowers.wrap(document).clearUserGestureActivation(); + // Pointer lock request should be rejected due to the lack of user gesture. + await requestPointerLock(target, true); + + // Test mouse event should not be dispatched to document. + document.addEventListener("mousemove", function(e) { + ok(false, "Got unexpected mousemove"); + }); + + info("test sending mouse event to iframe"); + let iframe = document.querySelector("iframe"); + synthesizeMouse(iframe, 10, 10, { type: "mousemove" }); + await new Promise(resolve => { SimpleTest.executeSoon(resolve); }); + + info("test sending mouse event to another window"); + await new Promise((aResolve) => { + let win = window.open("iframe_differentDOM.html"); + win.addEventListener("load", async function() { + info("win onload"); + await waitUntilApzStable(); + synthesizeMouse(win.document.body, 10, 10, { type: "mousemove" }, win); + win.close(); + aResolve(); + }); + }); + await new Promise(resolve => { SimpleTest.executeSoon(resolve); }); + + SimpleTest.finish(); +} +</script> +</pre> +</body> +</html> |