https://github.com/web-platform-tests/wpt
Raw File
Tip revision: bd350d7475c9eaf667a254ee7f49f25a06146b52 authored by Mike Pennisi on 10 December 2018, 20:43:57 UTC
Explicitly fetch test manifest
Tip revision: bd350d7
message-event-activation-api-iframe-cross-origin.sub.tentative.html
<!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>
back to top