Bug 1532495 - part2 : add test 'test_background_video_resume_looping_video_without_audio.html' r=jya
authoralwu <alwu@mozilla.com>
Thu, 09 May 2019 23:09:44 +0000
changeset 532154 126a59b083f619859b308f023bc5c8df49686b3d
parent 532153 5567ad616234db69e9c4aff10805eca281c839ab
child 532155 e754d9ad197df615a1f71185f6201d956efc31b9
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1532495
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1532495 - part2 : add test 'test_background_video_resume_looping_video_without_audio.html' r=jya Add test to to ensure that the looping video (without audio track) which has been suspended can continute to playback correctly after we resume video decoding. Differential Revision: https://phabricator.services.mozilla.com/D30419
dom/media/test/mochitest.ini
dom/media/test/test_background_video_resume_looping_video_without_audio.html
--- a/dom/media/test/mochitest.ini
+++ b/dom/media/test/mochitest.ini
@@ -1299,16 +1299,18 @@ tags = suspend
 skip-if = toolkit == 'android' # android(bug 1304480)
 tags = suspend
 [test_background_video_no_suspend_not_in_tree.html]
 skip-if = toolkit == 'android' # bug 1346705
 tags = suspend
 [test_background_video_resume_after_end_show_last_frame.html]
 skip-if = toolkit == 'android' # bug 1346705
 tags = suspend
+[test_background_video_resume_looping_video_without_audio.html]
+tags = suspend
 [test_background_video_suspend.html]
 skip-if = toolkit == 'android' # android(bug 1304480)
 tags = suspend
 [test_background_video_suspend_ends.html]
 skip-if = toolkit == 'android' # bug 1295884, android(bug 1304480, bug 1232305)
 tags = suspend
 [test_background_video_tainted_by_capturestream.html]
 skip-if = toolkit == 'android' # bug 1346705
new file mode 100644
--- /dev/null
+++ b/dom/media/test/test_background_video_resume_looping_video_without_audio.html
@@ -0,0 +1,85 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Resume suspended looping video which doesn't contain audio track</title>
+  <script src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script src="manifest.js"></script>
+  <script src="background_video.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<script class="testbody" type="text/javascript">
+/**
+ * This test is used to ensure that the looping video (without audio track) which
+ * has been suspended can continute to playback correctly after we resume video
+ * decoding.
+ */
+async function startTest() {
+  const video = await createVisibleVideo();
+  await startVideo(video);
+  await suspendVideoDecoding(video);
+  await resumeVideoDecoding(video);
+  await waitUntilVideoLoopAgain(video);
+  endTestAndClearVideo(video);
+}
+
+SimpleTest.waitForExplicitFinish();
+SpecialPowers.pushPrefEnv({ 'set': [
+    ["media.test.video-suspend", true],
+    ["media.suspend-bkgnd-video.enabled", true],
+    ["media.suspend-bkgnd-video.delay-ms", 0],
+  ]}, () => {
+  startTest();
+});
+
+/**
+ * The following are test helper functions.
+ */
+async function createVisibleVideo() {
+  let video = document.createElement("video");
+  video.src = "gizmo-noaudio.webm";
+  video.controls = true;
+  video.loop = true;
+  // In order to reduce the test running time, because we don't need to acutally
+  // go through the whole video.
+  video.currentTime = 3;
+  document.body.appendChild(video);
+  info(`ensure video becomes visible`);
+  await waitUntilVisible(video);
+  return video;
+}
+
+async function startVideo(video) {
+  info(`start playing video`);
+  const played = video && await video.play().then(() => true, () => false);
+  ok(played, "video has started playing");
+}
+
+async function suspendVideoDecoding(video) {
+  info(`suspend video decoding`);
+  video.setVisible(false);
+  await nextVideoSuspends(video);
+}
+
+async function resumeVideoDecoding(video) {
+  info(`resume video decoding.`);
+  video.setVisible(true);
+  await nextVideoResumes(video);
+}
+
+async function waitUntilVideoLoopAgain(video) {
+  info(`ensure video is still playing after resuming video decoding.`);
+  await once(video, "seeking");
+  info(`got 'seeking' event.`);
+  await once(video, "seeked");
+  ok(!video.paused, "video is still playing and looping again.")
+}
+
+function endTestAndClearVideo(video) {
+  removeNodeAndSource(video);
+  SimpleTest.finish();
+}
+
+</script>
+</body>
+</html>