summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/user-activation/chained-setTimeout.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/html/user-activation/chained-setTimeout.html
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/html/user-activation/chained-setTimeout.html')
-rw-r--r--testing/web-platform/tests/html/user-activation/chained-setTimeout.html63
1 files changed, 63 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/user-activation/chained-setTimeout.html b/testing/web-platform/tests/html/user-activation/chained-setTimeout.html
new file mode 100644
index 0000000000..a530837392
--- /dev/null
+++ b/testing/web-platform/tests/html/user-activation/chained-setTimeout.html
@@ -0,0 +1,63 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="/resources/testdriver.js"></script>
+ <script src="/resources/testdriver-vendor.js"></script>
+ <script>
+ let chained_timeout_test = async_test("Chained setTimeout test");
+
+ const max_call_depth = 3;
+ const delay_ms = 10;
+
+ function testInitialStates(depth) {
+ assert_true(1 <= depth && depth <= max_call_depth);
+
+ chained_timeout_test.step_timeout(() => {
+ let test_name = "Call-depth=" + depth + ": initial activation states are false";
+ test(() => {
+ assert_false(navigator.userActivation.isActive);
+ assert_false(navigator.userActivation.hasBeenActive);
+ }, test_name);
+
+ if (depth < max_call_depth)
+ testInitialStates(depth+1);
+ else
+ test_driver.click(document.body);
+ }, delay_ms);
+ }
+
+ function testFinalStates(depth) {
+ assert_true(1 <= depth && depth <= max_call_depth);
+
+ chained_timeout_test.step_timeout(() => {
+ let test_name = "Call-depth=" + depth + ": after-click activation states are true";
+ test(() => {
+ assert_true(navigator.userActivation.isActive);
+ assert_true(navigator.userActivation.hasBeenActive);
+ }, test_name);
+
+ if (depth < max_call_depth)
+ testFinalStates(depth+1);
+ else
+ chained_timeout_test.done();
+ }, delay_ms)
+ }
+
+ function run() {
+ window.addEventListener("click", event => {
+ testFinalStates(1);
+ });
+
+ testInitialStates(1);
+ }
+ </script>
+</head>
+<body onload="run()">
+ <h1>User activation state in chained setTimeout calls</h1>
+ <p>Tests that user activation state is visible in arbitrary call depth of setTimeout.</p>
+ <ol id="instructions">
+ <li>Click anywhere in the document.
+ </ol></body>
+</html>