Skip to content

Commit

Permalink
Add web platform test for fullscreen popups
Browse files Browse the repository at this point in the history
Bug: 1142516
Change-Id: I20357e87ed799555e0ed4211fc180317e57116c0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4862737
Commit-Queue: Brad Triebwasser <[email protected]>
Reviewed-by: Mike Wasserman <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1196659}
  • Loading branch information
bradtriebwasser authored and chromium-wpt-export-bot committed Sep 14, 2023
1 parent efb9ef8 commit 05aa5ff
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!DOCTYPE html>
<meta name="timeout" content="long">
<!-- user agents are not required to support open features other than `noopener`
and on some platforms position and size features don't make sense -->
<meta name="flags" content="may">
<title>Window Management test: Fullscreen popups with window.open()</title>
<link rel="help" href="https://w3c.github.io/window-management/">
Tests the ability to open a fullscreen popup window on each screen.<br>
The host device must have 2+ screens to test cross-screen fullscreen popups.
<br><br>
<button id="closeButton" onclick="closePopups">Close popups</button><br>
<input id="autoClose" type="checkbox" checked=true>Auto-close popups</input>
<ul id="list"></ul>
<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>
<script src="resources/helpers.js"></script>
<script>
'use strict';

let popups = [];
function closePopups() {
popups.forEach(p => p.close());
popups = [];
}

promise_test(async setUpTest => {
await setUpWindowManagement(setUpTest);
for (const [i, s] of window.screenDetails.screens.entries()) {
const name = `Open a fullscreen popup on '${s.label || i}'`;
await promise_test(async test => {
await buttonClick(test, name);
const popup = await openPopupOnScreen(s, /*assertPlacement=*/false,
/*fullscreen=*/true);
popups.push(popup);
await poll(() => {
return popup.document.fullscreenElement ==
popup.document.documentElement
});
const context = `popup: ${windowLog(popup)}, ${screenLog(screen)}`;
assert_equals(popup.screenLeft, s.availLeft, context)
assert_equals(popup.screenRight, s.availRight, context);
assert_equals(popup.screen.availHeight, s.availHeight, context);
assert_equals(popup.screen.availWidth, s.availWidth, context);
if (autoClose.checked)
closePopups();
}, name);
}
}, 'Use multi-screen details to open a fullscreen popup window on each screen');
</script>
7 changes: 5 additions & 2 deletions window-management/resources/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,13 @@ async function poll(condition, interval = 100, duration = 3000) {
}

// Open and return a popup on `screen`, optionally asserting placement.
async function openPopupOnScreen(screen, assertPlacement = true) {
async function openPopupOnScreen(screen, assertPlacement = true, fullscreen = false) {
const left = screen.availLeft + Math.floor(screen.availWidth / 2) - 150;
const top = screen.availTop + Math.floor(screen.availHeight / 2) - 50;
const features = `left=${left},top=${top},width=300,height=100`;
let features = `left=${left},top=${top},width=300,height=100`;
if (fullscreen) {
features += ",fullscreen";
}
log(`Opening a popup with features '${features}' on ${screenLog(screen)}`);
// Window.open() synchronously returns a Window with estimated screenLeft|Top,
// which may be clamped to the opener's screen or incompletely initialized.
Expand Down

0 comments on commit 05aa5ff

Please sign in to comment.