Skip to content

Commit

Permalink
Add tests for exiting from nested fullscreen
Browse files Browse the repository at this point in the history
Tests for whatwg/fullscreen#72.

Before that change, the per-spec pass condition for the nested-in-iframe
case would have been to exit fully to the outer document, which was a
spec bug and doesn't match implementations.

In order to automate these tests, it was necessary to teach
auto-click.js to traverse out of iframes to take their position into
account.

These tests have also been run manually in Firefox Nightly and confirmed
to pass there.

Actually adopting the new spec wording will be part of relanding issue
402376, together with other necessary spec changes.

BUG=402376

Review-Url: https://codereview.chromium.org/2706293013
Cr-Commit-Position: refs/heads/master@{#452841}
  • Loading branch information
foolip authored and jeffcarp committed Feb 24, 2017
1 parent 13aba11 commit d4e48e5
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<title>Document#exitFullscreen() for nested fullscreen inside an iframe</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../trusted-click.js"></script>
<iframe allowfullscreen></iframe>
<script>
window.t = async_test();
t.step(() => {
const iframe = document.querySelector("iframe");
iframe.srcdoc = "<div><div></div></div>";
iframe.onload = t.step_func(() => {
const doc = iframe.contentDocument;
const outer = doc.querySelector("div");
const inner = outer.firstChild;

// First request fullscreen for the outer element.
trusted_request(t, outer);
doc.onfullscreenchange = t.step_func(() => {
assert_equals(document.fullscreenElement, iframe);
assert_equals(doc.fullscreenElement, outer);

// Then request fullscreen for the inner element.
trusted_request(t, inner);
doc.onfullscreenchange = t.step_func(() => {
assert_equals(document.fullscreenElement, iframe);
assert_equals(doc.fullscreenElement, inner);

// Now exit fullscreen for the iframe's content document.
doc.exitFullscreen();
doc.onfullscreenchange = t.step_func_done(() => {
assert_equals(document.fullscreenElement, iframe);
assert_equals(doc.fullscreenElement, outer);
});
});
});
doc.onfullscreenerror = t.unreached_func("fullscreenerror event");
});
});
</script>
31 changes: 31 additions & 0 deletions fullscreen/api/document-exit-fullscreen-nested-manual.html
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<title>Document#exitFullscreen() for nested fullscreen</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../trusted-click.js"></script>
<div><div></div></div>
<script>
async_test(t => {
const outer = document.querySelector("div");
const inner = outer.firstChild;

// First request fullscreen for the outer element.
trusted_request(t, outer);
document.onfullscreenchange = t.step_func(() => {
assert_equals(document.fullscreenElement, outer);

// Then request fullscreen for the inner element.
trusted_request(t, inner);
document.onfullscreenchange = t.step_func(() => {
assert_equals(document.fullscreenElement, inner);

// Now exit fullscreen.
document.exitFullscreen();
document.onfullscreenchange = t.step_func_done(() => {
assert_equals(document.fullscreenElement, outer);
});
});
});
document.onfullscreenerror = t.unreached_func("fullscreenerror event");
});
</script>

0 comments on commit d4e48e5

Please sign in to comment.