fix(wheel): throw on wheel access in mobile WebKit (#10946)

This commit is contained in:
Yury Semikhatsky 2021-12-15 11:57:28 -08:00 committed by GitHub
parent 0b86fbde90
commit 230e0b7049
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -149,6 +149,8 @@ export class RawMouseImpl implements input.RawMouse {
} }
async wheel(x: number, y: number, buttons: Set<types.MouseButton>, modifiers: Set<types.KeyboardModifier>, deltaX: number, deltaY: number): Promise<void> { async wheel(x: number, y: number, buttons: Set<types.MouseButton>, modifiers: Set<types.KeyboardModifier>, deltaX: number, deltaY: number): Promise<void> {
if (this._page?._browserContext._options.isMobile)
throw new Error('Mouse wheel is not supported in mobile WebKit');
await this._session!.send('Page.updateScrollingState'); await this._session!.send('Page.updateScrollingState');
// Wheel events hit the compositor first, so wait one frame for it to be synced. // Wheel events hit the compositor first, so wait one frame for it to be synced.
await this._page!.mainFrame().evaluateExpression(`new Promise(requestAnimationFrame)`, false, false, 'utility'); await this._page!.mainFrame().evaluateExpression(`new Promise(requestAnimationFrame)`, false, false, 'utility');

View File

@ -112,7 +112,6 @@ it('should work when the event is canceled', async ({ page }) => {
contextTest('should scroll when emulating a mobile viewport', async ({ contextFactory, server, browserName }) => { contextTest('should scroll when emulating a mobile viewport', async ({ contextFactory, server, browserName }) => {
contextTest.skip(browserName === 'firefox'); contextTest.skip(browserName === 'firefox');
contextTest.fixme(browserName === 'webkit');
const context = await contextFactory({ const context = await contextFactory({
viewport: { 'width': 1000, 'height': 600 }, viewport: { 'width': 1000, 'height': 600 },
isMobile: true, isMobile: true,
@ -120,7 +119,10 @@ contextTest('should scroll when emulating a mobile viewport', async ({ contextFa
const page = await context.newPage(); const page = await context.newPage();
await page.goto(server.PREFIX + '/input/scrollable.html'); await page.goto(server.PREFIX + '/input/scrollable.html');
await page.mouse.move(50, 60); await page.mouse.move(50, 60);
await page.mouse.wheel(0, 100); const error = await page.mouse.wheel(0, 100).catch(e => e);
if (browserName === 'webkit')
expect(error.message).toContain('Mouse wheel is not supported in mobile WebKit');
else
await page.waitForFunction('window.scrollY === 100'); await page.waitForFunction('window.scrollY === 100');
}); });