Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 5 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /html/semantics/invokers/invoketarget-fullscreen-behavior.tentative.html - WPT Dashboard Interop Dashboard
<!doctype html>
<meta charset="utf-8" />
<meta name="author" title="Luke Warlow" href="mailto:luke@warlow.dev" />
<meta name="timeout" content="long" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="resources/invoker-utils.js"></script>
<div id="invokee">
Fullscreen content
<button id="invokerbutton" commandfor="invokee"></button>
</div>
<script>
async function resetState() {
invokerbutton.setAttribute("command", "toggle-fullscreen");
if (document.fullscreenElement) await document.exitFullscreen();
}
// toggle-fullscreen
promise_test(async function (t) {
t.add_cleanup(resetState);
assert_false(invokee.matches(":fullscreen"));
invokerbutton.setAttribute("command", "toggle-fullscreen");
await clickOn(invokerbutton);
assert_true(invokee.matches(":fullscreen"));
}, "invoking div with toggle-fullscreen action makes div fullscreen");
promise_test(async function (t) {
t.add_cleanup(resetState);
assert_false(invokee.matches(":fullscreen"));
invokerbutton.setAttribute("command", "toggle-fullscreen");
invokerbutton.click();
assert_false(invokee.matches(":fullscreen"));
}, "invoking div with toggle-fullscreen action (without user activation) is a no-op");
promise_test(async function (t) {
t.add_cleanup(resetState);
invokee.addEventListener("command", (e) => e.preventDefault(), {
once: true,
});
assert_false(invokee.matches(":fullscreen"));
invokerbutton.setAttribute("command", "toggle-fullscreen");
await clickOn(invokerbutton);
assert_false(invokee.matches(":fullscreen"));
}, "invoking div with toggle-fullscreen action and preventDefault is a no-op");
promise_test(async function (t) {
t.add_cleanup(resetState);
invokerbutton.setAttribute("command", "toggle-fullscreen");
await test_driver.bless('go fullscreen');
await invokee.requestFullscreen();
assert_true(invokee.matches(":fullscreen"));
await clickOn(invokerbutton);
assert_false(invokee.matches(":fullscreen"));
}, "invoking fullscreen div with toggle-fullscreen action exits fullscreen");
promise_test(async function (t) {
t.add_cleanup(resetState);
invokerbutton.setAttribute("command", "tOgGlE-Fullscreen");
await test_driver.bless('go fullscreen');
await invokee.requestFullscreen();
assert_true(invokee.matches(":fullscreen"));
await clickOn(invokerbutton);
assert_false(invokee.matches(":fullscreen"));
}, "invoking fullscreen div with toggle-fullscreen (case-insensitive) action exits fullscreen");
// request-fullscreen
promise_test(async function (t) {
t.add_cleanup(resetState);
assert_false(invokee.matches(":fullscreen"));
invokerbutton.setAttribute("command", "request-fullscreen");
await clickOn(invokerbutton);
assert_true(invokee.matches(":fullscreen"));
}, "invoking div with request-fullscreen action makes div fullscreen");
promise_test(async function (t) {
t.add_cleanup(resetState);
invokee.addEventListener("command", (e) => e.preventDefault(), {
once: true,
});
assert_false(invokee.matches(":fullscreen"));
invokerbutton.setAttribute("command", "request-fullscreen");
await clickOn(invokerbutton);
assert_false(invokee.matches(":fullscreen"));
}, "invoking div with request-fullscreen action and preventDefault is a no-op");
promise_test(async function (t) {
t.add_cleanup(resetState);
invokerbutton.setAttribute("command", "request-fullscreen");
await test_driver.bless('go fullscreen');
await invokee.requestFullscreen();
assert_true(invokee.matches(":fullscreen"));
await clickOn(invokerbutton);
assert_true(invokee.matches(":fullscreen"));
}, "invoking fullscreen div with request-fullscreen action is a no-op");
// exitFullscreen
promise_test(async function (t) {
t.add_cleanup(resetState);
assert_false(invokee.matches(":fullscreen"));
invokerbutton.setAttribute("command", "exit-fullscreen");
await clickOn(invokerbutton);
assert_false(invokee.matches(":fullscreen"));
}, "invoking div with exit-fullscreen action is a no-op");
promise_test(async function (t) {
t.add_cleanup(resetState);
invokerbutton.setAttribute("command", "exit-fullscreen");
await test_driver.bless('go fullscreen');
await invokee.requestFullscreen();
assert_true(invokee.matches(":fullscreen"));
await clickOn(invokerbutton);
assert_false(invokee.matches(":fullscreen"));
}, "invoking fullscreen div with exit-fullscreen action exits fullscreen");
promise_test(async function (t) {
t.add_cleanup(resetState);
invokee.addEventListener("command", (e) => e.preventDefault(), {
once: true,
});
invokerbutton.setAttribute("command", "exit-fullscreen");
await test_driver.bless('go fullscreen');
await invokee.requestFullscreen();
assert_true(invokee.matches(":fullscreen"));
await clickOn(invokerbutton);
assert_true(invokee.matches(":fullscreen"));
}, "invoking fullscreen div with exit-fullscreen action and preventDefault is a no-op");
</script>