mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix(webkit): define window.GestureEvent (#22768)
Polyfill GestureEvent so that Safari detection works. Fixes #22735
This commit is contained in:
parent
160888df99
commit
02a1a2e6a9
@ -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);
|
||||
|
||||
@ -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');
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user