mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-03 18:47:53 +00:00
Bug 1388660
- part2 : add test. r=Ehsan
Add a new file "almostSilentAudioTrack.webm" and the test to prevent showing the sound indicator when playing that kinds of video. MozReview-Commit-ID: CeUhAePBuqs --HG-- extra : rebase_source : c1deb2ec749fcebeccb554b64ffe77b46a18aa3d
This commit is contained in:
parent
d5273690a3
commit
fee7fb93ca
BIN
toolkit/content/tests/browser/almostSilentAudioTrack.webm
Normal file
BIN
toolkit/content/tests/browser/almostSilentAudioTrack.webm
Normal file
Binary file not shown.
@ -1,7 +1,9 @@
|
||||
[DEFAULT]
|
||||
support-files =
|
||||
almostSilentAudioTrack.webm
|
||||
audio.ogg
|
||||
empty.png
|
||||
file_almostSilentAudioTrack.html
|
||||
file_blockMedia_shouldNotPlay.html
|
||||
file_blockMedia_shouldPlay.html
|
||||
file_contentTitle.html
|
||||
@ -89,4 +91,6 @@ support-files =
|
||||
data/post_form_outer.sjs
|
||||
skip-if = e10s # Bug ?????? - test directly manipulates content (gBrowser.contentDocument.getElementById("postForm").submit();)
|
||||
[browser_saveImageURL.js]
|
||||
[browser_sound_indicator_silent_video.js]
|
||||
tags = audiochannel
|
||||
[browser_resume_bkg_video_on_tab_hover.js]
|
||||
|
@ -0,0 +1,67 @@
|
||||
const SILENT_PAGE = "https://example.com/browser/toolkit/content/tests/browser/file_silentAudioTrack.html";
|
||||
const ALMOST_SILENT_PAGE = "https://example.com/browser/toolkit/content/tests/browser/file_almostSilentAudioTrack.html";
|
||||
|
||||
function check_audio_playing_state(isPlaying) {
|
||||
let autoPlay = content.document.getElementById("autoplay");
|
||||
if (!autoPlay) {
|
||||
ok(false, "Can't get the audio element!");
|
||||
}
|
||||
|
||||
is(autoPlay.paused, !isPlaying,
|
||||
"The playing state of autoplay audio is correct.");
|
||||
|
||||
// wait for a while to make sure the video is playing and related event has
|
||||
// been dispatched (if any).
|
||||
let PLAYING_TIME_SEC = 0.5;
|
||||
ok(PLAYING_TIME_SEC < autoPlay.duration, "The playing time is valid.")
|
||||
|
||||
return new Promise(resolve => {
|
||||
autoPlay.ontimeupdate = function() {
|
||||
if (autoPlay.currentTime > PLAYING_TIME_SEC) {
|
||||
resolve();
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
add_task(async function should_not_show_sound_indicator_for_silent_video() {
|
||||
info("- open new foreground tab -");
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(window.gBrowser,
|
||||
"about:blank");
|
||||
|
||||
info("- tab should not have sound indicator before playing silent video -");
|
||||
await waitForTabPlayingEvent(tab, false);
|
||||
|
||||
info("- loading autoplay silent video -");
|
||||
tab.linkedBrowser.loadURI(SILENT_PAGE);
|
||||
await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
|
||||
await ContentTask.spawn(tab.linkedBrowser, true /* playing */,
|
||||
check_audio_playing_state);
|
||||
|
||||
info("- tab should not have sound indicator after playing silent video -");
|
||||
await waitForTabPlayingEvent(tab, false);
|
||||
|
||||
info("- remove tab -");
|
||||
await BrowserTestUtils.removeTab(tab);
|
||||
});
|
||||
|
||||
add_task(async function should_not_show_sound_indicator_for_almost_silent_video() {
|
||||
info("- open new foreground tab -");
|
||||
let tab = await BrowserTestUtils.openNewForegroundTab(window.gBrowser,
|
||||
"about:blank");
|
||||
|
||||
info("- tab should not have sound indicator before playing almost silent video -");
|
||||
await waitForTabPlayingEvent(tab, false);
|
||||
|
||||
info("- loading autoplay almost silent video -");
|
||||
tab.linkedBrowser.loadURI(ALMOST_SILENT_PAGE);
|
||||
await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
|
||||
await ContentTask.spawn(tab.linkedBrowser, true /* playing */,
|
||||
check_audio_playing_state);
|
||||
|
||||
info("- tab should not have sound indicator after playing almost silent video -");
|
||||
await waitForTabPlayingEvent(tab, false);
|
||||
|
||||
info("- remove tab -");
|
||||
await BrowserTestUtils.removeTab(tab);
|
||||
});
|
@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
|
||||
<meta content="utf-8" http-equiv="encoding">
|
||||
</head>
|
||||
<body>
|
||||
<video id="autoplay" src="almostSilentAudioTrack.webm"></video>
|
||||
<script type="text/javascript">
|
||||
|
||||
// In linux debug on try server, sometimes the download process would fail, so
|
||||
// we can't activate the "auto-play" or playing after receving "oncanplay".
|
||||
// Therefore, we just call play here.
|
||||
var video = document.getElementById("autoplay");
|
||||
video.loop = true;
|
||||
video.play();
|
||||
|
||||
</script>
|
||||
</body>
|
Loading…
Reference in New Issue
Block a user