-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an API to query whether the window has seen a user gesture.
Add a variable on the navigator object to query whether the frame has seen a user activation ever. The postMessage part of the proposal will be done in a separate patch, this change is limited to just adding the object definition and exposing it on navigator. https://github.com/dtapuska/useractivation whatwg/html#1983 BUG=846858 Change-Id: I6ca4c80f4096bfae9ca13b175b46df6b4486a6dd
- Loading branch information
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!DOCTYPE HTML> | ||
<!-- | ||
Tentative due to: | ||
https://github.com/whatwg/html/issues/1983 | ||
--> | ||
<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>Clicking on document sets user activation</h1> | ||
<p>Click anywhere in the document.</p> | ||
<script> | ||
async_test(function(t) { | ||
assert_false(navigator.userActivation.hasBeenActive); | ||
assert_false(navigator.userActivation.isActive); | ||
window.addEventListener("click", t.step_func_done(event => { | ||
assert_true(navigator.userActivation.hasBeenActive); | ||
assert_true(navigator.userActivation.isActive); | ||
|
||
// Opening a window should consume the activation. | ||
window.open('404.html'); | ||
assert_true(navigator.userActivation.hasBeenActive); | ||
assert_false(navigator.userActivation.isActive); | ||
})); | ||
test_driver.click(document.body); | ||
}, "Values adjust on activity"); | ||
</script> | ||
</body> | ||
</html> |
36 changes: 36 additions & 0 deletions
36
html/user-activation/activation-api-setTimeout.tentative.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!DOCTYPE HTML> | ||
<!-- | ||
Tentative due to: | ||
https://github.com/whatwg/html/issues/1983 | ||
--> | ||
<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>Clicking on document sets user activation even after setTimeout</h1> | ||
<p>Click anywhere in the document.</p> | ||
<script> | ||
async_test(function(t) { | ||
assert_false(navigator.userActivation.hasBeenActive); | ||
assert_false(navigator.userActivation.isActive); | ||
window.addEventListener("click", event => { | ||
t.step_timeout(() => { | ||
assert_true(navigator.userActivation.hasBeenActive); | ||
assert_true(navigator.userActivation.isActive); | ||
|
||
// Opening a window should consume the activation. | ||
window.open('404.html'); | ||
assert_true(navigator.userActivation.hasBeenActive); | ||
assert_false(navigator.userActivation.isActive); | ||
t.done(); | ||
}, 0); | ||
}); | ||
test_driver.click(document.body); | ||
}, "Values adjust on activity"); | ||
</script> | ||
</body> | ||
</html> |