Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix: expose window.safari in webkit (#21361)
Yury Semikhatskybe259dac7cc4
diff --git a/packages/playwright-core/src/server/webkit/wkPage.ts b/packages/playwright-core/src/server/webkit/wkPage.tsindex c4cf4059b8..74fea4617f 100644--- a/packages/playwright-core/src/server/webkit/wkPage.ts+++ b/packages/playwright-core/src/server/webkit/wkPage.ts@@ -785,6 +785,8 @@ export class WKPage implements PageDelegate {scripts.push('delete window.ondevicemotion');scripts.push('delete window.ondeviceorientation');}+ scripts.push('if (!window.safari) window.safari = {};');+for (const binding of this._page.allBindings())scripts.push(binding.source);scripts.push(...this._browserContext.initScripts);diff --git a/tests/library/capabilities.spec.ts b/tests/library/capabilities.spec.tsindex 4644155417..5b7fc9b394 100644--- a/tests/library/capabilities.spec.ts+++ b/tests/library/capabilities.spec.ts@@ -200,3 +200,11 @@ it('serviceWorker should intercept document request', async ({ page, server, broawait page.reload();expect(await page.textContent('body')).toBe('intercepted');});++it('webkit should define window.safari', async ({ page, server, browserName }) => {+ it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/21037' });+ it.skip(browserName !== 'webkit');+ await page.goto(server.EMPTY_PAGE);+ const defined = await page.evaluate(() => !!(window as any).safari);+ expect(defined).toBeTruthy();+});