Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test the "fully active" check for requestFullscreen() #5901

Merged
merged 2 commits into from
May 15, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions fullscreen/api/element-request-fullscreen-active-document.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!DOCTYPE html>
<title>Element#requestFullscreen() when the document is not the active document</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<iframe allowfullscreen></iframe>
<script>
var t = async_test();

onload = t.step_func(() => {
var iframe = document.querySelector("iframe");
var documentBeforeNav = iframe.contentDocument;
documentBeforeNav.onfullscreenchange = t.unreached_func('fullscreenchange event');
documentBeforeNav.onfullscreenerror = t.unreached_func('fullscreenerror event');

iframe.onload = t.step_func(() => {
var p = documentBeforeNav.documentElement.requestFullscreen();
// If a promise was returned, it should already be rejected, so its reject
// callback should be invoked before a second promise's callback.
// This test does not fail if promises aren't implemented.
if (p) {
var rejected = false;
p.catch(t.step_func(() => rejected = true));
Promise.resolve().then(t.step_func(() => assert_true(rejected)));
}
// Wait two animation frames to ensure that no events are fired. (One should
// be enough per spec, but this makes the test flaky in Firefox.)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are concerned about the fullscreen transition... probably you can wait for a second instead I guess.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't concerned with any transition because this is an error case, rather I want to wait just long enough to know that the fullscreenerror event is not fired. Per current spec that should be at the next animation frame, so one rAF should be enough.

I looked into Gecko's code and see that you use AsyncEventDispatcher, which looks like the equivalent of "queue a task to fire an event". I've confirmed that a single setTimeout would make the test fail reliably in Firefox, and that setting the timeout just before the requestFullscreen call makes it pass reliably, so that checks out.

I'll tweak the test to use a mix of rAF and setTimeout to handle either implementation.

requestAnimationFrame(t.step_func(() => {
requestAnimationFrame(t.step_func_done());
}));
});

// Navigate the iframe
window[0].location.href = '/common/blank.html';
});
</script>