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): do not auto play audio without user gesture (#33734)

Yury Semikhatsky66f709663e66
diff --git a/packages/playwright-core/browsers.json b/packages/playwright-core/browsers.json
index b1d8b9487e..e4b95c9a59 100644
--- a/packages/playwright-core/browsers.json
+++ b/packages/playwright-core/browsers.json
@@ -33,7 +33,7 @@
},
{
"name": "webkit",
- "revision": "2108",
+ "revision": "2110",
"installByDefault": true,
"revisionOverrides": {
"debian11-x64": "2105",
diff --git a/tests/library/capabilities.spec.ts b/tests/library/capabilities.spec.ts
index 116784854f..7526359c20 100644
--- a/tests/library/capabilities.spec.ts
+++ b/tests/library/capabilities.spec.ts
@@ -428,3 +428,38 @@ it('should not crash when clicking a label with a <input type="file"/>', {
const fileChooser = await fileChooserPromise;
expect(fileChooser.page()).toBe(page);
});
+
+it('should not auto play audio', {
+ annotation: {
+ type: 'issue',
+ description: 'https://github.com/microsoft/playwright/issues/33590'
+ }
+}, async ({ page, browserName, isWindows }) => {
+ it.fixme(browserName === 'webkit' && isWindows);
+ await page.route('**/*', async route => {
+ await route.fulfill({
+ status: 200,
+ contentType: 'text/html',
+ body: `
+ <script>
+ async function onLoad() {
+ const log = document.getElementById('log');
+ const audioContext = new AudioContext();
+ const gainNode = new GainNode(audioContext);
+ gainNode.connect(audioContext.destination);
+ gainNode.gain.value = 0.025;
+ const sineNode = new OscillatorNode(audioContext);
+ sineNode.connect(gainNode);
+ sineNode.start();
+ await new Promise((resolve) => setTimeout(resolve, 1000));
+ log.innerHTML = 'State: ' + audioContext.state;
+ }
+ </script>
+ <body onload="onLoad()">
+ <div id="log"></div>
+ </body>`,
+ });
+ });
+ await page.goto('http://127.0.0.1/audio.html');
+ await expect(page.locator('#log')).toHaveText('State: suspended');
+});