make tests green

This commit is contained in:
Max Schmitt 2024-08-23 15:24:16 +02:00
parent df72c7bed4
commit 965c20f300
3 changed files with 3 additions and 22 deletions

View file

@ -1,12 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Detect Touch Test</title>
<script src='modernizr/modernizr.js'></script>
</head>
<body style="font-size:30vmin">
<script>
document.body.textContent = Modernizr.touchevents ? 'YES' : 'NO';
</script>
</body>
</html>

View file

@ -55,23 +55,19 @@ it.describe('mobile viewport', () => {
}
});
it('should be detectable by Modernizr', async ({ playwright, browser, server, browserName, platform }) => {
it.skip(browserName === 'webkit' && platform === 'darwin' && parseInt(os.release(), 10) === 22, 'detect-touch.html uses Modernizr which uses WebGL. WebGL is not available in macOS-13 - https://bugs.webkit.org/show_bug.cgi?id=278277');
it('should be detectable', async ({ playwright, browser, server, browserName, platform }) => {
const iPhone = playwright.devices['iPhone 6'];
const context = await browser.newContext({ ...iPhone });
const page = await context.newPage();
await page.goto(server.PREFIX + '/detect-touch.html');
expect(await page.evaluate(() => document.body.textContent!.trim())).toBe('YES');
expect(await page.evaluate(() => 'ontouchstart' in window)).toBe(true);
await context.close();
});
it('should detect touch when applying viewport with touches', async ({ browser, server, browserName, platform }) => {
it.skip(browserName === 'webkit' && platform === 'darwin' && parseInt(os.release(), 10) === 22, 'Modernizr uses WebGL. WebGL is not available in macOS-13 - https://bugs.webkit.org/show_bug.cgi?id=278277');
const context = await browser.newContext({ viewport: { width: 800, height: 600 }, hasTouch: true });
const page = await context.newPage();
await page.goto(server.EMPTY_PAGE);
await page.addScriptTag({ url: server.PREFIX + '/modernizr.js' });
expect(await page.evaluate(() => (window as any)['Modernizr'].touchevents)).toBe(true);
expect(await page.evaluate(() => 'ontouchstart' in window)).toBe(true);
await context.close();
});

View file

@ -94,11 +94,8 @@ it('should emulate availWidth and availHeight', async ({ page }) => {
});
it('should not have touch by default', async ({ page, server, browserName, platform }) => {
it.skip(browserName === 'webkit' && platform === 'darwin' && parseInt(os.release(), 10) === 22, 'detect-touch.html uses Modernizr which uses WebGL. WebGL is not available in macOS-13 - https://bugs.webkit.org/show_bug.cgi?id=278277');
await page.goto(server.PREFIX + '/mobile.html');
expect(await page.evaluate(() => 'ontouchstart' in window)).toBe(false);
await page.goto(server.PREFIX + '/detect-touch.html');
expect(await page.evaluate(() => document.body.textContent.trim())).toBe('NO');
});
it('should throw on tap if hasTouch is not enabled', async ({ page }) => {