test(wheel): add test for scrolling while emulating mobile (#10224)

This commit is contained in:
Joel Einbinder 2021-11-23 02:59:32 -05:00 committed by GitHub
parent 6d3bb458f9
commit 0878548238
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -15,6 +15,8 @@
*/
import type { Page } from 'playwright-core';
import { test as it, expect } from './pageTest';
import { contextTest } from '../config/browserTest';
it.skip(({ isElectron, browserMajorVersion }) => {
// Old Electron has flaky wheel events.
return isElectron && browserMajorVersion <= 11;
@ -108,6 +110,20 @@ it('should work when the event is canceled', async ({ page }) => {
expect(await page.evaluate('window.scrollY')).toBe(0);
});
contextTest('should scroll when emulating a mobile viewport', async ({ contextFactory, server, browserName }) => {
contextTest.skip(browserName === 'firefox');
contextTest.fixme(browserName === 'webkit');
const context = await contextFactory({
viewport: { 'width': 1000, 'height': 600 },
isMobile: true,
});
const page = await context.newPage();
await page.goto(server.PREFIX + '/input/scrollable.html');
await page.mouse.move(50, 60);
await page.mouse.wheel(0, 100);
await page.waitForFunction('window.scrollY === 100');
});
async function listenForWheelEvents(page: Page, selector: string) {
await page.evaluate(selector => {
document.querySelector(selector).addEventListener('wheel', (e: WheelEvent) => {