blob: 2a16f4549678ca41de41a3eaef8026700e68ce9d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
<!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 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");
child.src = "http://{{hosts[alt][]}}:{{ports[http][0]}}/html/user-activation/resources/child-message-event-api.html";
assert_false(navigator.userActivation.isActive);
assert_false(navigator.userActivation.hasBeenActive);
window.addEventListener("message", t.step_func(event => {
if (event.data == 'child-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-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-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-report-no-activation') {
assert_equals(event.userActivation, null);
t.done();
}
}));
}, "Message propagates values on post");
</script>
</body>
</html>
|