diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /browser/base/content/test/tabMediaIndicator/browser_webAudio_hideSoundPlayingIcon.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | browser/base/content/test/tabMediaIndicator/browser_webAudio_hideSoundPlayingIcon.js | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/browser/base/content/test/tabMediaIndicator/browser_webAudio_hideSoundPlayingIcon.js b/browser/base/content/test/tabMediaIndicator/browser_webAudio_hideSoundPlayingIcon.js new file mode 100644 index 0000000000..be40f6e146 --- /dev/null +++ b/browser/base/content/test/tabMediaIndicator/browser_webAudio_hideSoundPlayingIcon.js @@ -0,0 +1,60 @@ +/** + * This test is used to ensure the 'sound-playing' icon would not disappear after + * sites call AudioContext.resume(). + */ +"use strict"; + +function setup_test_preference() { + return SpecialPowers.pushPrefEnv({ + set: [ + ["media.useAudioChannelService.testing", true], + ["browser.tabs.delayHidingAudioPlayingIconMS", 0], + ], + }); +} + +async function resumeAudioContext() { + const ac = content.ac; + await ac.resume(); + ok(true, "AudioContext is resumed."); +} + +async function testResumeRunningAudioContext() { + info(`- create new tab -`); + const tab = await BrowserTestUtils.openNewForegroundTab( + window.gBrowser, + "about:blank" + ); + const browser = tab.linkedBrowser; + + info(`- create audio context -`); + // We want the same audio context to be used across different content tasks. + await SpecialPowers.spawn(tab.linkedBrowser, [], () => { + content.ac = new content.AudioContext(); + const ac = content.ac; + const dest = ac.destination; + const osc = ac.createOscillator(); + osc.connect(dest); + osc.start(); + }); + + info(`- wait for 'sound-playing' icon showing -`); + await waitForTabSoundIndicatorAppears(tab); + + info(`- resume AudioContext -`); + await SpecialPowers.spawn(browser, [], resumeAudioContext); + + info(`- 'sound-playing' icon should still exist -`); + await waitForTabSoundIndicatorAppears(tab); + + info(`- remove tab -`); + await BrowserTestUtils.removeTab(tab); +} + +add_task(async function start_test() { + info("- setup test preference -"); + await setup_test_preference(); + + info("- start testing -"); + await testResumeRunningAudioContext(); +}); |