Skip to content

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

fix(webkit): define window.GestureEvent (#22768)

Yury Semikhatsky02a1a2e6a9c5
diff --git a/packages/playwright-core/src/server/webkit/wkPage.ts b/packages/playwright-core/src/server/webkit/wkPage.ts
index 99dc45e6af..d7c2c1a82b 100644
--- a/packages/playwright-core/src/server/webkit/wkPage.ts
+++ b/packages/playwright-core/src/server/webkit/wkPage.ts
@@ -788,6 +788,7 @@ export class WKPage implements PageDelegate {
scripts.push('delete window.ondeviceorientation');
}
scripts.push('if (!window.safari) window.safari = {};');
+ scripts.push('if (!window.GestureEvent) window.GestureEvent = function GestureEvent() {};');
for (const binding of this._page.allBindings())
scripts.push(binding.source);
diff --git a/tests/library/capabilities.spec.ts b/tests/library/capabilities.spec.ts
index c740a45584..5c004ea3c1 100644
--- a/tests/library/capabilities.spec.ts
+++ b/tests/library/capabilities.spec.ts
@@ -241,3 +241,12 @@ it('loading in HTMLImageElement.prototype', async ({ page, server, browserName }
const defined = await page.evaluate(() => 'loading' in HTMLImageElement.prototype);
expect(defined).toBeTruthy();
});
+
+it('window.GestureEvent in WebKit', async ({ page, server, browserName }) => {
+ it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/22735' });
+ await page.goto(server.EMPTY_PAGE);
+ const defined = await page.evaluate(() => 'GestureEvent' in window);
+ expect(defined).toBe(browserName === 'webkit');
+ const type = await page.evaluate(() => typeof (window as any).GestureEvent);
+ expect(type).toBe(browserName === 'webkit' ? 'function' : 'undefined');
+});