forked from mykmelez/gecko
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1478002 [wpt PR 12157] - Add UserActivation member to MessageEven…
…t, a=testonly Automatic update from web-platform-testsAdd UserActivation member to MessageEvent Add an API to query user activation state on a posted message event. Add includeUserActivation attribute on the WindowPostMessageOptions so that indication of user gesture behavior can be opted in. https://github.com/dtapuska/useractivation whatwg/html#1983 BUG=846858 [email protected] Change-Id: I2459b21004afbe00c41ddf992533c60728768bb4 Reviewed-on: https://chromium-review.googlesource.com/1131558 Commit-Queue: Dave Tapuska <[email protected]> Reviewed-by: Ken Buchanan <[email protected]> Reviewed-by: Marijn Kruisselbrink <[email protected]> Cr-Commit-Position: refs/heads/master@{#579398} -- wpt-commits: 8a1d5c110779c525257fe2305ba7a21ae6e969e6 wpt-pr: 12157
- Loading branch information
1 parent
f7555b0
commit 7c8587d
Showing
4 changed files
with
120 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
55 changes: 55 additions & 0 deletions
55
.../html/user-activation/message-event-activation-api-iframe-cross-origin.sub.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,55 @@ | ||
<!DOCTYPE html> | ||
<!-- | ||
Tentative due to: | ||
https://github.com/whatwg/html/issues/3739 | ||
--> | ||
<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 in iframe has activation state in child via MessageEvent</h1> | ||
<ol id="instructions"> | ||
<li>Click inside the red area. | ||
</ol> | ||
<iframe id="child" width="200" height="200"></iframe> | ||
<script> | ||
async_test(function(t) { | ||
var child = document.getElementById("child"); | ||
assert_false(navigator.userActivation.isActive); | ||
assert_false(navigator.userActivation.hasBeenActive); | ||
window.addEventListener("message", t.step_func(event => { | ||
if (event.data == 'child-three-loaded') { | ||
// values have false after load | ||
assert_true(event.userActivation != null); | ||
assert_false(event.userActivation.isActive); | ||
assert_false(event.userActivation.hasBeenActive); | ||
test_driver.click(child); | ||
} else if (event.data == 'child-three-clicked') { | ||
// values have activation state on click | ||
assert_true(navigator.userActivation.hasBeenActive); | ||
assert_true(event.userActivation != null); | ||
assert_true(event.userActivation.isActive); | ||
assert_true(event.userActivation.hasBeenActive); | ||
child.contentWindow.postMessage('report', "*"); | ||
} else if (event.data == 'child-three-report') { | ||
assert_false(navigator.userActivation.isActive); | ||
assert_true(navigator.userActivation.hasBeenActive); | ||
assert_true(event.userActivation != null); | ||
assert_false(event.userActivation.isActive); | ||
assert_true(event.userActivation.hasBeenActive); | ||
child.contentWindow.postMessage('report-no-activation', "*"); | ||
} else if (event.data == 'child-three-report-no-activation') { | ||
assert_true(event.userActivation === null); | ||
t.done(); | ||
} | ||
})); | ||
child.src = "http://{{domains[www]}}:{{ports[http][0]}}/html/user-activation/resources/child-three.html"; | ||
}, "Message propagates values on post"); | ||
</script> | ||
</body> | ||
</html> |
15 changes: 15 additions & 0 deletions
15
testing/web-platform/tests/html/user-activation/message-event-init.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,15 @@ | ||
<!DOCTYPE html> | ||
<title>MessageEvent constructor</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
test(function() { | ||
var ev = new MessageEvent("test", { userActivation: navigator.userActivation }) | ||
assert_equals(ev.userActivation, navigator.userActivation, "userActivation attribute") | ||
}, "MessageEventInit user activation set") | ||
test(function() { | ||
var ev = new MessageEvent("test") | ||
assert_equals(ev.userActivation, null, "userActivation attribute") | ||
}, "MessageEventInit user activation not set") | ||
|
||
</script> |
19 changes: 19 additions & 0 deletions
19
testing/web-platform/tests/html/user-activation/resources/child-three.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,19 @@ | ||
<!DOCTYPE html> | ||
<body style="background: red;"> | ||
<script> | ||
window.parent.postMessage("child-three-loaded", {targetOrigin: "*", includeUserActivation: true}); | ||
window.addEventListener("click", event => { | ||
window.parent.postMessage("child-three-clicked", {targetOrigin: "*", includeUserActivation: true}); | ||
var win = window.open('404.html'); | ||
win.close(); | ||
}); | ||
|
||
window.addEventListener("message", event => { | ||
if (event.data == "report") | ||
window.parent.postMessage("child-three-report", {targetOrigin: "*", includeUserActivation: true}); | ||
if (event.data == "report-no-activation") | ||
window.parent.postMessage("child-three-report-no-activation", {targetOrigin: "*", includeUserActivation: false}); | ||
}); | ||
|
||
</script> | ||
</body> |