summaryrefslogtreecommitdiffstats
path: root/dom/base/test/useractivation/test_useractivation_scrollbar.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/base/test/useractivation/test_useractivation_scrollbar.html
parentInitial commit. (diff)
downloadfirefox-esr-upstream.tar.xz
firefox-esr-upstream.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/base/test/useractivation/test_useractivation_scrollbar.html')
-rw-r--r--dom/base/test/useractivation/test_useractivation_scrollbar.html135
1 files changed, 135 insertions, 0 deletions
diff --git a/dom/base/test/useractivation/test_useractivation_scrollbar.html b/dom/base/test/useractivation/test_useractivation_scrollbar.html
new file mode 100644
index 0000000000..778d6d0898
--- /dev/null
+++ b/dom/base/test/useractivation/test_useractivation_scrollbar.html
@@ -0,0 +1,135 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<title>User activation test: consume transient flag</title>
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<script src="/tests/SimpleTest/EventUtils.js"></script>
+<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<textarea style="height: 100px; resize: none">
+&nbsp
+&nbsp
+&nbsp
+&nbsp
+&nbsp
+&nbsp
+&nbsp
+&nbsp
+&nbsp
+&nbsp
+&nbsp
+&nbsp
+&nbsp
+</textarea>
+<div id="target" style="height: 100px; width: 200px; overflow: scroll">
+&nbsp<br>
+&nbsp<br>
+&nbsp<br>
+&nbsp<br>
+&nbsp<br>
+&nbsp<br>
+&nbsp<br>
+&nbsp<br>
+&nbsp<br>
+&nbsp<br>
+&nbsp<br>
+&nbsp<br>
+&nbsp<br>
+</div>
+<div style="height: 2000px; width: 500px; background-color: green;"></div>
+<script>
+
+// Open a new window to ensure scrollbar is always visible.
+if (!opener) {
+ add_task(async function init() {
+ // Turn on the prefs that force overlay scrollbars to always be visible.
+ await SpecialPowers.pushPrefEnv({
+ set: [["layout.testing.overlay-scrollbars.always-visible", true]],
+ });
+ });
+
+ async function testOnNewWindow(aPrefValue) {
+ await SpecialPowers.pushPrefEnv({
+ set: [["dom.user_activation.ignore_scrollbars", aPrefValue]],
+ });
+
+ let win = window.open(location);
+ // wait for message
+ await new Promise((aResolve) => {
+ window.addEventListener("message", function listener(event) {
+ if ("done" == event.data) {
+ window.removeEventListener("message", listener);
+ aResolve();
+ }
+ });
+ });
+ win.close();
+ }
+
+ add_task(async function test_pref_on() {
+ await testOnNewWindow(true);
+ });
+
+ add_task(async function test_pref_off() {
+ await testOnNewWindow(false);
+ });
+} else {
+ SimpleTest.waitForFocus(async function() {
+ function waitForEvent(aTarget, aEvent) {
+ return new Promise((aResolve) => {
+ aTarget.addEventListener(aEvent, function listener(event) {
+ aResolve();
+ }, { once: true });
+ });
+ }
+
+ let ignoreScrollbars = SpecialPowers.getBoolPref("dom.user_activation.ignore_scrollbars");
+
+ SpecialPowers.wrap(document).clearUserGestureActivation();
+ let textarea = document.querySelector("textarea");
+ var rect = textarea.getBoundingClientRect();
+
+ // click scrollbar of textarea
+ let promise = waitForEvent(textarea, "scroll");
+ synthesizeMouse(textarea, rect.width - 5, rect.height / 2, {});
+ await promise;
+
+ opener.is(SpecialPowers.wrap(document).hasBeenUserGestureActivated,
+ !ignoreScrollbars, "check has-been-user-activated");
+ opener.is(SpecialPowers.wrap(document).hasValidTransientUserGestureActivation,
+ !ignoreScrollbars, "check has-valid-transient-user-activation");
+
+ SpecialPowers.wrap(document).clearUserGestureActivation();
+ let div = document.querySelector("div[id=target]");
+ rect = div.getBoundingClientRect();
+
+ // click scrollbar of div
+ promise = waitForEvent(div, "scroll");
+ synthesizeMouse(div, rect.width - 5, rect.height / 2, {});
+ await promise;
+
+ opener.is(SpecialPowers.wrap(document).hasBeenUserGestureActivated,
+ !ignoreScrollbars, "check has-been-user-activated");
+ opener.is(SpecialPowers.wrap(document).hasValidTransientUserGestureActivation,
+ !ignoreScrollbars, "check has-valid-transient-user-activation");
+
+ SpecialPowers.wrap(document).clearUserGestureActivation();
+ let body = document.querySelector("body");
+
+ // click scrollbar of page
+ promise = waitForEvent(document, "scroll");
+ synthesizeMouse(body, innerWidth - 10, innerHeight / 2, {});
+ await promise;
+
+ opener.is(SpecialPowers.wrap(document).hasBeenUserGestureActivated,
+ !ignoreScrollbars, "check has-been-user-activated");
+ opener.is(SpecialPowers.wrap(document).hasValidTransientUserGestureActivation,
+ !ignoreScrollbars, "check has-valid-transient-user-activation");
+
+ opener.postMessage("done", "*");
+ }, window);
+}
+
+</script>
+</body>