Bug 1128357 patch 3: test for video playback with dormant r=cpearce
authorSotaro Ikeda <sikeda@mozilla.com>
Wed, 04 Mar 2015 17:34:17 -0800
changeset 231945 9b100a29161418cd7f69d0b5d14f29df1f911b60
parent 231944 18225b2d31bad66023058e2b80807ab6c756c6c6
child 231946 d78b8a0b6392917562b3e02a62cf459149b10b04
push id56402
push usersikeda@mozilla.com
push dateThu, 05 Mar 2015 01:35:16 +0000
treeherdermozilla-inbound@d78b8a0b6392 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1128357
milestone39.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 1128357 patch 3: test for video playback with dormant r=cpearce
dom/media/test/mochitest.ini
dom/media/test/test_dormant_playback.html
--- a/dom/media/test/mochitest.ini
+++ b/dom/media/test/mochitest.ini
@@ -359,16 +359,18 @@ skip-if = (toolkit == 'android' && proce
 [test_contentDuration7.html]
 [test_controls.html]
 [test_currentTime.html]
 [test_decode_error.html]
 [test_decoder_disable.html]
 [test_defaultMuted.html]
 [test_delay_load.html]
 skip-if = buildapp == 'b2g' && toolkit != 'gonk' # bug 1082984
+[test_dormant_playback.html]
+skip-if = (os == 'win' && os_version == '5.1') || (os != 'win' && toolkit != 'gonk')
 [test_eme_access_control.html]
 skip-if = buildapp == 'b2g' || toolkit == 'android' || e10s # bug 1043403, bug 1057908
 [test_eme_canvas_blocked.html]
 skip-if = buildapp == 'b2g' || toolkit == 'android' || e10s # bug 1043403, bug 1057908
 [test_eme_non_fragmented.html]
 skip-if = buildapp == 'b2g' || toolkit == 'android' || e10s # bug 1043403, bug 1057908
 [test_eme_obs_notification.html]
 skip-if = buildapp == 'b2g' || toolkit == 'android' || e10s # bug 1043403, bug 1057908
new file mode 100644
--- /dev/null
+++ b/dom/media/test/test_dormant_playback.html
@@ -0,0 +1,82 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <meta charset='utf-8'>
+  <title>Media test: Test resuming from dormant does not emit seek related events</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<p id="display"></p>
+<div id="content" style="display: none"></div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+var gNeedInit = false;
+var gLoadedEvent = false;
+var gSeekEvent = false;
+var v1 = null;
+
+function startVideoPlayback() {
+  v1.play()
+}
+
+function setVideoVisible() {
+  document.body.appendChild(v1);
+  setTimeout(startVideoPlayback, 0);
+}
+
+function checkResult() {
+  ok(!gLoadedEvent, "loadedmetadata event should not happen");
+  ok(!gSeekEvent, "seek event should not happen");
+  SimpleTest.finish();
+}
+
+function loadedMetadata(e) {
+  if (gNeedInit) {
+    v1.currentTime = 0;
+    return;
+  }
+  gLoadedEvent = true;
+}
+
+function playbackEnded(e) {
+  checkResult();
+}
+
+function seekEnded(e) {
+  if (gNeedInit) {
+    gNeedInit = false;
+    gLoadedEvent = false;
+    gSeekEvent = false;
+    document.body.removeChild(v1);
+    setTimeout(setVideoVisible, 0);
+    return;
+  }
+  gSeekEvent = true;
+}
+
+function seeking(e) {
+  gSeekEvent = true;
+}
+
+function runTest() {
+  gNeedInit = true;
+
+  v1 = document.createElement('video');
+  document.body.appendChild(v1);
+  v1.preload = "metadata";
+  v1.src = "gizmo.mp4"
+  v1.addEventListener("loadedmetadata", loadedMetadata, false);
+  v1.addEventListener("ended", playbackEnded, false);
+  v1.addEventListener("seeked", seekEnded, false);
+  v1.addEventListener("seeking", seeking, false);
+}
+
+addLoadEvent(runTest);
+SimpleTest.waitForExplicitFinish();
+
+</script>
+</pre>
+</body>
+</html>