https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 21723c60a58b1be1c940a2d284bdcd54b34715cd authored by Jarryd on 13 December 2018, 18:38:01 UTC
Cookie Store: Test cross-origin frames + service workers.
Tip revision: 21723c6
element-request-fullscreen-and-exit-iframe-manual.html
<!DOCTYPE html>
<title>Element#requestFullscreen() and Document#exitFullscreen() in iframe</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../trusted-click.js"></script>
<div id="log"></div>
<iframe allowfullscreen></iframe>
<script>
// wait for load event to avoid https://bugzil.la/1493878
window.onload = function() {
  async_test(t => {
    const iframe = document.querySelector('iframe');
    const iframeDoc = iframe.contentDocument;
    const iframeBody = iframeDoc.body;

    let count = 0;
    document.onfullscreenchange = iframeDoc.onfullscreenchange = t.step_func(event => {
      count++;
      assert_between_inclusive(count, 1, 4, 'number of fullscreenchange events');
      // Both when entering and exiting, the fullscreenchange event is fired first
      // on the outer document and then on the iframe's document. This is because
      // the events are fired in animation frame tasks, which run in "frame tree"
      // order.
      const expected = {
        target: count == 1 || count == 3 ? iframe : iframeBody,
        outerFullscreenElement: count <= 2 ? iframe : null,
        innerFullscreenElement: count <= 2 ? iframeBody : null,
      };
      assert_equals(event.target, expected.target, 'event target');
      assert_equals(document.fullscreenElement, expected.outerFullscreenElement, 'outer fullscreenElement');
      assert_equals(iframeDoc.fullscreenElement, expected.innerFullscreenElement, 'inner fullscreenElement');
      if (count == 2) {
        iframeDoc.exitFullscreen();
      } else if (count == 4) {
        // Done, but set timeout to fail on extra events.
        step_timeout(t.step_func_done());
      }
    });
    document.onfullscreenerror = t.unreached_func('fullscreenerror event');
    iframeDoc.onfullscreenerror = t.unreached_func('iframe fullscreenerror event');

    trusted_request(t, iframeBody, iframeBody);
  });
};
</script>
back to top