summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/user-activation/navigation-state-reset-sameorigin.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/html/user-activation/navigation-state-reset-sameorigin.html')
-rw-r--r--testing/web-platform/tests/html/user-activation/navigation-state-reset-sameorigin.html62
1 files changed, 62 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/user-activation/navigation-state-reset-sameorigin.html b/testing/web-platform/tests/html/user-activation/navigation-state-reset-sameorigin.html
new file mode 100644
index 0000000000..c240f96b2c
--- /dev/null
+++ b/testing/web-platform/tests/html/user-activation/navigation-state-reset-sameorigin.html
@@ -0,0 +1,62 @@
+<!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>
+ </head>
+ <body>
+ <h1>Post-navigation activation state in child</h1>
+ <p>
+ Tests that navigating a same-origin child frame resets its activation
+ states.
+ </p>
+ <ol id="instructions">
+ <li>Click inside the yellow area.</li>
+ </ol>
+
+ <iframe id="child" width="200" height="50"> </iframe>
+ <script>
+ function message(type) {
+ return new Promise((resolve) => {
+ window.addEventListener("message", function listener(event) {
+ const data = JSON.parse(event.data);
+ if (data.type === type) {
+ window.removeEventListener("message", listener);
+ resolve(data);
+ }
+ });
+ });
+ }
+ promise_test(async (t) => {
+ var child = document.getElementById("child");
+ child.src = "./resources/child-one.html";
+ const unclickeData = await message("child-one-loaded");
+ assert_false(navigator.userActivation.isActive);
+ assert_false(navigator.userActivation.hasBeenActive);
+ assert_false(unclickeData.isActive);
+ assert_false(unclickeData.hasBeenActive);
+
+ const [, child1Data] = await Promise.all([
+ test_driver.click(child),
+ message("child-one-clicked"),
+ ]);
+
+ assert_true(navigator.userActivation.isActive);
+ assert_true(navigator.userActivation.hasBeenActive);
+ assert_true(child1Data.isActive);
+ assert_true(child1Data.hasBeenActive);
+
+ child.src = "./resources/child-two.html";
+
+ const child2Data = await message("child-two-loaded");
+
+ assert_true(navigator.userActivation.isActive);
+ assert_true(navigator.userActivation.hasBeenActive);
+ assert_false(child2Data.isActive);
+ assert_false(child2Data.hasBeenActive);
+ }, "Post-navigation state reset.");
+ </script>
+ </body>
+</html>