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_mute_webAudio.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.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_mute_webAudio.js | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/browser/base/content/test/tabMediaIndicator/browser_mute_webAudio.js b/browser/base/content/test/tabMediaIndicator/browser_mute_webAudio.js new file mode 100644 index 0000000000..6f3e5f222f --- /dev/null +++ b/browser/base/content/test/tabMediaIndicator/browser_mute_webAudio.js @@ -0,0 +1,75 @@ +// The tab closing code leaves an uncaught rejection. This test has been +// whitelisted until the issue is fixed. +if (!gMultiProcessBrowser) { + const { PromiseTestUtils } = ChromeUtils.importESModule( + "resource://testing-common/PromiseTestUtils.sys.mjs" + ); + PromiseTestUtils.expectUncaughtRejection(/is no longer, usable/); +} + +const PAGE = GetTestWebBasedURL("file_webAudio.html"); + +function start_webAudio() { + var startButton = content.document.getElementById("start"); + if (!startButton) { + ok(false, "Can't get the start button!"); + } + + startButton.click(); +} + +function stop_webAudio() { + var stopButton = content.document.getElementById("stop"); + if (!stopButton) { + ok(false, "Can't get the stop button!"); + } + + stopButton.click(); +} + +add_task(async function setup_test_preference() { + await SpecialPowers.pushPrefEnv({ + set: [ + ["media.useAudioChannelService.testing", true], + ["media.block-autoplay-until-in-foreground", true], + ], + }); +}); + +add_task(async function mute_web_audio() { + info("- open new tab -"); + let tab = await BrowserTestUtils.openNewForegroundTab( + window.gBrowser, + "about:blank" + ); + BrowserTestUtils.loadURIString(tab.linkedBrowser, PAGE); + await BrowserTestUtils.browserLoaded(tab.linkedBrowser); + + info("- tab should be audible -"); + await waitForTabSoundIndicatorAppears(tab); + + info("- mute browser -"); + ok(!tab.linkedBrowser.audioMuted, "Audio should not be muted by default"); + let tabContent = tab.querySelector(".tab-content"); + await hoverIcon(tabContent); + await clickIcon(tab.overlayIcon); + ok(tab.linkedBrowser.audioMuted, "Audio should be muted now"); + + info("- stop web audip -"); + await SpecialPowers.spawn(tab.linkedBrowser, [], stop_webAudio); + + info("- start web audio -"); + await SpecialPowers.spawn(tab.linkedBrowser, [], start_webAudio); + + info("- unmute browser -"); + ok(tab.linkedBrowser.audioMuted, "Audio should be muted now"); + await hoverIcon(tabContent); + await clickIcon(tab.overlayIcon); + ok(!tab.linkedBrowser.audioMuted, "Audio should be unmuted now"); + + info("- tab should be audible -"); + await waitForTabSoundIndicatorAppears(tab); + + info("- remove tab -"); + BrowserTestUtils.removeTab(tab); +}); |