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 that element.requestFullscreen() consumes user activation #36969

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<title>Element#requestFullscreen() consumes user activation</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<div id="log"></div>
<script>
promise_test(async (t) => {
t.add_cleanup(() => {
if (document.fullscreenElement) return document.exitFullscreen();
});
const div = document.querySelector("div");

await test_driver.bless("fullscreen");
assert_true(navigator.userActivation.isActive, "Activation must be active");
// Request fullscreen twice in a row. The first request should consume the
// user activation and succeed, and the second request should fail because
// of the user activation requirement.
const p1 = div.requestFullscreen();
assert_false(navigator.userActivation.isActive, "Transient activation is consumed");
const p2 = promise_rejects_js(t, TypeError, div.requestFullscreen());
await Promise.all([p1, p2]);
});
</script>
27 changes: 27 additions & 0 deletions fullscreen/api/element-request-fullscreen-same-element.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<title>Element#requestFullscreen() on the current fullscreen element</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<div id="log"></div>
<script>
promise_test(async (t) => {
t.add_cleanup(() => {
if (document.fullscreenElement) return document.exitFullscreen();
});

// Use the body element as the fullscreen element, because the second
// test_driver.bless() call needs to insert a button inside of it, which
// can't be clicked if another element is already fullscreen.
const target = document.body;

// First enter fullscreen.
await test_driver.bless("fullscreen", () => target.requestFullscreen());
assert_equals(document.fullscreenElement, target, "fullscreen element after first request");

// Now request fullscreen again, which should be a no-op.
await test_driver.bless("fullscreen", () => target.requestFullscreen());
assert_equals(document.fullscreenElement, target, "fullscreen element after second request");
});
</script>
30 changes: 0 additions & 30 deletions fullscreen/api/element-request-fullscreen-same-manual.html

This file was deleted.

27 changes: 0 additions & 27 deletions fullscreen/api/element-request-fullscreen-twice-manual.html

This file was deleted.

This file was deleted.

37 changes: 0 additions & 37 deletions fullscreen/api/element-request-fullscreen-two-elements-manual.html

This file was deleted.

This file was deleted.

48 changes: 0 additions & 48 deletions fullscreen/api/element-request-fullscreen-two-iframes-manual.html

This file was deleted.

This file was deleted.