55 lines
2.2 KiB
HTML
55 lines
2.2 KiB
HTML
<!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>
|