mirror of
https://github.com/microsoft/playwright.git
synced 2024-10-27 21:58:52 +03:00
fix: expose window.safari in webkit (#21361)
The actual API of the object is not implemented because those who want to test it will likely need their own mock and for the browser detection logic (as described in the bug) just having the property on window should be sufficient. Fixes #21037
This commit is contained in:
parent
26fa0eeae8
commit
be259dac7c
@ -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);
|
||||
|
@ -200,3 +200,11 @@ it('serviceWorker should intercept document request', async ({ page, server, bro
|
||||
await 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();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user