https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 37847586171cc8ecff44292e6c3f37e873f008ec authored by Henrik Boström on 06 April 2018, 09:24:00 UTC
Fix RTCPeerConnection-track-stats.https.html flake.
Tip revision: 3784758
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>
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, document.body);
});
</script>
back to top