Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

test: requestFullscreen API is supported (#22889)

Yury Semikhatskyc5793456107d
diff --git a/tests/library/capabilities.spec.ts b/tests/library/capabilities.spec.ts
index aad9fb278a..37ba409b57 100644
--- a/tests/library/capabilities.spec.ts
+++ b/tests/library/capabilities.spec.ts
@@ -250,3 +250,22 @@ it('window.GestureEvent in WebKit', async ({ page, server, browserName }) => {
const type = await page.evaluate(() => typeof (window as any).GestureEvent);
expect(type).toBe(browserName === 'webkit' ? 'function' : 'undefined');
});
+
+it('requestFullscreen', async ({ page, server, browserName, headless, isLinux }) => {
+ it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/22832' });
+ it.fixme(browserName === 'chromium' && headless, 'fullscreenchange is not fired in headless Chromium');
+ it.fixme(browserName === 'webkit');
+ await page.goto(server.EMPTY_PAGE);
+ await page.evaluate(() => {
+ const result = new Promise(resolve => document.addEventListener('fullscreenchange', resolve));
+ document.documentElement.requestFullscreen();
+ return result;
+ });
+ expect(await page.evaluate(() => document.fullscreenElement === document.documentElement)).toBeTruthy();
+ await page.evaluate(() => {
+ const result = new Promise(resolve => document.addEventListener('fullscreenchange', resolve));
+ document.exitFullscreen();
+ return result;
+ });
+ expect(await page.evaluate(() => !!document.fullscreenElement)).toBeFalsy();
+});