Skip to content

Commit

Permalink
Bug 1478002 [wpt PR 12157] - Add UserActivation member to MessageEven…
Browse files Browse the repository at this point in the history
…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
TBR=mkwst@chromium.org

Change-Id: I2459b21004afbe00c41ddf992533c60728768bb4
Reviewed-on: https://chromium-review.googlesource.com/1131558
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: Ken Buchanan <kenrb@chromium.org>
Reviewed-by: Marijn Kruisselbrink <mek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579398}

--

wpt-commits: 8a1d5c110779c525257fe2305ba7a21ae6e969e6
wpt-pr: 12157
  • Loading branch information
dtapuska authored and moz-wptsync-bot committed Aug 3, 2018
1 parent f7555b0 commit 7c8587d
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 0 deletions.
31 changes: 31 additions & 0 deletions testing/web-platform/meta/MANIFEST.json
Original file line number Diff line number Diff line change
Expand Up @@ -287098,6 +287098,11 @@
{}
]
],
"html/user-activation/resources/child-three.html": [
[
{}
]
],
"html/user-activation/resources/child-two.html": [
[
{}
Expand Down Expand Up @@ -360760,6 +360765,20 @@
}
]
],
"html/user-activation/message-event-activation-api-iframe-cross-origin.sub.tentative.html": [
[
"/html/user-activation/message-event-activation-api-iframe-cross-origin.sub.tentative.html",
{
"testdriver": true
}
]
],
"html/user-activation/message-event-init.tentative.html": [
[
"/html/user-activation/message-event-init.tentative.html",
{}
]
],
"html/webappapis/animation-frames/callback-exception.html": [
[
"/html/webappapis/animation-frames/callback-exception.html",
Expand Down Expand Up @@ -599905,10 +599924,22 @@
"96d17e27c892ec988ba5acdfb60fd1f9edd16571",
"manual"
],
"html/user-activation/message-event-activation-api-iframe-cross-origin.sub.tentative.html": [
"63a1da05d0005c33bec1af8a58e7f011d5b09d4c",
"testharness"
],
"html/user-activation/message-event-init.tentative.html": [
"8e2b1d07014e8bd754d943e11672fff0719bbb74",
"testharness"
],
"html/user-activation/resources/child-one.html": [
"9c99729b6a98022f7449bae62a7bea616308c0c7",
"support"
],
"html/user-activation/resources/child-three.html": [
"5a74cf5360c6a14d2ad5eebb31d74db6980ebccf",
"support"
],
"html/user-activation/resources/child-two.html": [
"7d48789878a902e8a773548e2012665d279fb4ea",
"support"
Expand Down
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>
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>
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>

0 comments on commit 7c8587d

Please sign in to comment.