summaryrefslogtreecommitdiffstats
path: root/toolkit/content/tests/browser/browser_block_autoplay_media.js
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-02-25 15:07:00 -0500
committerMatt A. Tobin <email@mattatobin.com>2020-02-25 15:07:00 -0500
commit0ddd00f1959c78ce37c14fef3c83401408fca3bf (patch)
treed408e02767c86cf8aac3acbb86722b03c77ede6f /toolkit/content/tests/browser/browser_block_autoplay_media.js
parent20f0905b33cbb18d1caa80c55e2f552c2e18957b (diff)
downloadUXP-0ddd00f1959c78ce37c14fef3c83401408fca3bf.tar
UXP-0ddd00f1959c78ce37c14fef3c83401408fca3bf.tar.gz
UXP-0ddd00f1959c78ce37c14fef3c83401408fca3bf.tar.lz
UXP-0ddd00f1959c78ce37c14fef3c83401408fca3bf.tar.xz
UXP-0ddd00f1959c78ce37c14fef3c83401408fca3bf.zip
Issue #439 - Remove tests from toolkit/
Diffstat (limited to 'toolkit/content/tests/browser/browser_block_autoplay_media.js')
-rw-r--r--toolkit/content/tests/browser/browser_block_autoplay_media.js87
1 files changed, 0 insertions, 87 deletions
diff --git a/toolkit/content/tests/browser/browser_block_autoplay_media.js b/toolkit/content/tests/browser/browser_block_autoplay_media.js
deleted file mode 100644
index 3b2a309b9..000000000
--- a/toolkit/content/tests/browser/browser_block_autoplay_media.js
+++ /dev/null
@@ -1,87 +0,0 @@
-const PAGE = "https://example.com/browser/toolkit/content/tests/browser/file_multipleAudio.html";
-
-var SuspendedType = {
- NONE_SUSPENDED : 0,
- SUSPENDED_PAUSE : 1,
- SUSPENDED_BLOCK : 2,
- SUSPENDED_PAUSE_DISPOSABLE : 3
-};
-
-function* wait_for_tab_playing_event(tab, expectPlaying) {
- if (tab.soundPlaying == expectPlaying) {
- ok(true, "The tab should " + (expectPlaying ? "" : "not ") + "be playing");
- } else {
- yield BrowserTestUtils.waitForEvent(tab, "TabAttrModified", false, (event) => {
- if (event.detail.changed.indexOf("soundplaying") >= 0) {
- is(tab.soundPlaying, expectPlaying, "The tab should " + (expectPlaying ? "" : "not ") + "be playing");
- return true;
- }
- return false;
- });
- }
-}
-
-function check_audio_suspended(suspendedType) {
- var autoPlay = content.document.getElementById('autoplay');
- if (!autoPlay) {
- ok(false, "Can't get the audio element!");
- }
-
- is(autoPlay.computedSuspended, suspendedType,
- "The suspeded state of autoplay audio is correct.");
-}
-
-add_task(function* setup_test_preference() {
- yield new Promise(resolve => {
- SpecialPowers.pushPrefEnv({"set": [
- ["media.useAudioChannelService.testing", true],
- ["media.block-autoplay-until-in-foreground", true]
- ]}, resolve);
- });
-});
-
-add_task(function* block_autoplay_media() {
- info("- open new background tab1 -");
- let tab1 = window.gBrowser.addTab("about:blank");
- tab1.linkedBrowser.loadURI(PAGE);
- yield BrowserTestUtils.browserLoaded(tab1.linkedBrowser);
-
- info("- should block autoplay media for non-visited tab1 -");
- yield ContentTask.spawn(tab1.linkedBrowser, SuspendedType.SUSPENDED_BLOCK,
- check_audio_suspended);
-
- info("- open new background tab2 -");
- let tab2 = window.gBrowser.addTab("about:blank");
- tab2.linkedBrowser.loadURI(PAGE);
- yield BrowserTestUtils.browserLoaded(tab2.linkedBrowser);
-
- info("- should block autoplay for non-visited tab2 -");
- yield ContentTask.spawn(tab2.linkedBrowser, SuspendedType.SUSPENDED_BLOCK,
- check_audio_suspended);
-
- info("- select tab1 as foreground tab -");
- yield BrowserTestUtils.switchTab(window.gBrowser, tab1);
-
- info("- media should be unblocked because the tab was visited -");
- yield wait_for_tab_playing_event(tab1, true);
- yield ContentTask.spawn(tab1.linkedBrowser, SuspendedType.NONE_SUSPENDED,
- check_audio_suspended);
-
- info("- open another new foreground tab3 -");
- let tab3 = yield BrowserTestUtils.openNewForegroundTab(window.gBrowser,
- "about:blank");
- info("- should still play media from tab1 -");
- yield wait_for_tab_playing_event(tab1, true);
- yield ContentTask.spawn(tab1.linkedBrowser, SuspendedType.NONE_SUSPENDED,
- check_audio_suspended);
-
- info("- should still block media from tab2 -");
- yield wait_for_tab_playing_event(tab2, false);
- yield ContentTask.spawn(tab2.linkedBrowser, SuspendedType.SUSPENDED_BLOCK,
- check_audio_suspended);
-
- info("- remove tabs -");
- yield BrowserTestUtils.removeTab(tab1);
- yield BrowserTestUtils.removeTab(tab2);
- yield BrowserTestUtils.removeTab(tab3);
-});