-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
fullscreen/api/element-request-fullscreen-active-document.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.) | ||
requestAnimationFrame(t.step_func(() => { | ||
requestAnimationFrame(t.step_func_done()); | ||
})); | ||
}); | ||
|
||
// Navigate the iframe | ||
window[0].location.href = '/common/blank.html'; | ||
}); | ||
</script> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.