This commit is contained in:
Yury Semikhatsky 2024-11-22 12:42:01 -08:00
parent c0c1f0cfe0
commit 64639d91c4

View file

@ -435,28 +435,29 @@ it('should not auto play audio', {
description: 'https://github.com/microsoft/playwright/issues/33590'
}
}, async ({ page }) => {
await page.route('**/*', async (route) => {
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.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');