Bug 657791 - Add cueless WebM seeking tests. r=jya
authorBryce Van Dyk <bvandyk@mozilla.com>
Thu, 18 Feb 2016 13:52:03 +1300
changeset 288506 51766683141be21bc5621337c9221b99dcea20a1
parent 288505 fd6e5a3c2817dcaed4775e14ffcf4cef68eab6ee
child 288507 389126282bc6993149e84ad7ac0b27c9a6eecb3f
push id73430
push userryanvm@gmail.com
push dateSun, 13 Mar 2016 17:40:31 +0000
treeherdermozilla-inbound@51766683141b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs657791
milestone48.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 657791 - Add cueless WebM seeking tests. r=jya Add tests to exercise seeking in cueless WebMs. These tests reproduce a subset of the test_seek tests, namely the first 3. These tests have been added separately from the test_seek ones to avoid additional logic required to handle cueless WebMs in such test. Once random seeking for cueless WebMs is implemented then these cases can be easily rolled into the existing test_seek cases by moving the cueless WebM into the appropriate test array in the manifest -- after which these tests can be removed. MozReview-Commit-ID: DNwiSmMmALQ
dom/media/test/manifest.js
dom/media/test/mochitest.ini
dom/media/test/test_cueless_webm_seek-1.html
dom/media/test/test_cueless_webm_seek-2.html
dom/media/test/test_cueless_webm_seek-3.html
--- a/dom/media/test/manifest.js
+++ b/dom/media/test/manifest.js
@@ -474,17 +474,16 @@ var gErrorTests = [
 // These are files that have nontrivial duration and are useful for seeking within.
 var gSeekTests = [
   { name:"r11025_s16_c1.wav", type:"audio/x-wav", duration:1.0 },
   { name:"audio.wav", type:"audio/x-wav", duration:0.031247 },
   { name:"seek.ogv", type:"video/ogg", duration:3.966 },
   { name:"320x240.ogv", type:"video/ogg", duration:0.266 },
   { name:"seek.webm", type:"video/webm", duration:3.966 },
   { name:"sine.webm", type:"audio/webm", duration:4.001 },
-  { name:"no-cues.webm", type:"video/webm", duration:3.967 },
   { name:"bug516323.indexed.ogv", type:"video/ogg", duration:4.208333 },
   { name:"split.webm", type:"video/webm", duration:1.967 },
   { name:"detodos.opus", type:"audio/ogg; codecs=opus", duration:2.9135 },
   { name:"gizmo.mp4", type:"video/mp4", duration:5.56 },
   { name:"owl.mp3", type:"audio/mpeg", duration:3.343 },
   { name:"bogus.duh", type:"bogus/duh", duration:123 },
 
   // Bug 1242338: hit a numerical problem while seeking to the duration.
@@ -502,16 +501,23 @@ var gFastSeekTests = [
 ];
 
 function IsWindows8OrLater() {
   var re = /Windows NT (\d.\d)/;
   var winver = manifestNavigator().userAgent.match(re);
   return winver && winver.length == 2 && parseFloat(winver[1]) >= 6.2;
 }
 
+// These files are WebMs without cues. They're seekable within their buffered
+// ranges. If work renders WebMs fully seekable these files should be moved
+// into gSeekTests
+var gCuelessWebMTests = [
+  { name:"no-cues.webm", type:"video/webm", duration:3.967 },
+];
+
 // These are files that are non seekable, due to problems with the media,
 // for example broken or missing indexes.
 var gUnseekableTests = [
   { name:"bogus.duh", type:"bogus/duh"}
 ];
 
 var androidVersion = -1; // non-Android platforms
 if (manifestNavigator().userAgent.indexOf("Mobile") != -1 ||
--- a/dom/media/test/mochitest.ini
+++ b/dom/media/test/mochitest.ini
@@ -618,16 +618,19 @@ skip-if = buildapp == 'b2g' || (toolkit 
 [test_can_play_type_no_ogg.html]
 [test_can_play_type_ogg.html]
 [test_chaining.html]
 [test_clone_media_element.html]
 skip-if = (toolkit == 'android' && processor == 'x86') #x86 only bug 914439
 [test_closing_connections.html]
 [test_constants.html]
 [test_controls.html]
+[test_cueless_webm_seek-1.html]
+[test_cueless_webm_seek-2.html]
+[test_cueless_webm_seek-3.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')
new file mode 100644
--- /dev/null
+++ b/dom/media/test/test_cueless_webm_seek-1.html
@@ -0,0 +1,136 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=657791
+-->
+<head>
+  <title>Test for Bug 657791</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  <script type="text/javascript" src="manifest.js"></script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=657791">Mozilla Bug 657791</a>
+
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+// Subset of seek tests for cueless WebMs. When random seeking (rather than just
+// in buffered ranges) is implemented for WebM, these tests can be removed and
+// the cueless WebM(s) references can be moved to the general test_seek test
+// array.
+// Test array is defined in manifest.js
+
+var manager = new MediaTestManager;
+
+// Exercise functionality as in test_seek-1
+function testWebM1(e) {
+  var v = e.target;
+  v.removeEventListener('loadeddata', testWebM1);
+
+  var startPassed = false;
+  var endPassed = false;
+  var seekFlagStart = false;
+  var seekFlagEnd = false;
+  var readonly = true;
+  var completed = false;
+
+  ok(v.buffered.length >= 1, "Should have a buffered range");
+  var halfBuffered = v.buffered.end(0) / 2;
+
+  function startTest() {
+    is(v.seekable.start(0), v.buffered.start(0), "Seekable start should be buffered start");
+    is(v.seekable.end(0), v.buffered.end(0), "Seekable end should be buffered end");
+    ok(!completed, "Should not be completed yet");
+    ok(!v.seeking, "seeking should default to false");
+    try {
+      v.seeking = true;
+      readonly = v.seeking === false;
+    }
+    catch(e) {
+      readonly = "threw exception: " + e;
+    }
+    is(readonly, true, "seeking should be readonly");
+
+    v.currentTime = halfBuffered;
+    seekFlagStart = v.seeking;
+  }
+
+  function seekStarted() {
+    ok(!completed, "should not be completed yet");
+    startPassed = true;
+  }
+
+  function seekEnded() {
+    ok(!completed, "should not be completed yet");
+    ok(Math.abs(v.currentTime - halfBuffered) < 0.1,
+       "Video currentTime should be around " + halfBuffered + ": " + v.currentTime + " (seeked)");
+    endPassed = true;
+    seekFlagEnd = v.seeking;
+    v.play();
+  }
+
+  function playbackEnded() {
+    ok(!completed, "should not be completed yet");
+
+    completed = true;
+    ok(startPassed, "seeking event");
+    ok(endPassed, "seeked event");
+    ok(seekFlagStart, "seeking flag on start should be true");
+    ok(!seekFlagEnd, "seeking flag on end should be false");
+    removeNodeAndSource(v);
+    manager.finished(v._token);
+  }
+
+  once(v, "ended", playbackEnded);
+  once(v, "seeking", seekStarted);
+  once(v, "seeked", seekEnded);
+
+  startTest();
+}
+
+// Fetch the media resource using XHR so we can be sure the entire
+// resource is loaded before we test buffered ranges. This ensures
+// we have deterministic behaviour.
+function fetch(url, fetched_callback) {
+  var xhr = new XMLHttpRequest();
+  xhr.open("GET", url, true);
+  xhr.responseType = "blob";
+
+  var loaded = function (event) {
+    if (xhr.status == 200 || xhr.status == 206) {
+      // Request fulfilled. Note sometimes we get 206... Presumably because either
+      // httpd.js or Necko cached the result.
+      fetched_callback(window.URL.createObjectURL(xhr.response));
+    } else {
+      ok(false, "Fetch failed headers=" + xhr.getAllResponseHeaders());
+    }
+  };
+
+  xhr.addEventListener("load", loaded, false);
+  xhr.send();
+}
+
+function startTest(test, token) {
+  var onfetched = function(uri) {
+    var v = document.createElement('video');
+    v._token = token;
+    v.src = uri;
+    v.addEventListener("loadeddata", testWebM1, false);
+    document.body.appendChild(v);
+  }
+  manager.started(token);
+  fetch(test.name, onfetched);
+}
+
+SimpleTest.waitForExplicitFinish();
+manager.runTests(gCuelessWebMTests, startTest);
+
+</script>
+</pre>
+</body>
+</html>
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/dom/media/test/test_cueless_webm_seek-2.html
@@ -0,0 +1,126 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=657791
+-->
+<head>
+  <title>Test for Bug 657791</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  <script type="text/javascript" src="manifest.js"></script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=657791">Mozilla Bug 657791</a>
+
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+// Subset of seek tests for cueless WebMs. When random seeking (rather than just
+// in buffered ranges) is implemented for WebM, these tests can be removed and
+// the cueless WebM(s) references can be moved to the general test_seek test
+// array.
+// Test array is defined in manifest.js
+
+var manager = new MediaTestManager;
+
+// Exercise functionality as in test_seek-2
+function testWebM2(e) {
+  var v = e.target;
+  v.removeEventListener('loadeddata', testWebM2);
+
+  var startPassed = false;
+  var endPassed = false;
+  var completed = false;
+
+  ok(v.buffered.length >= 1, "Should have a buffered range");
+  var halfBuffered = v.buffered.end(0) / 2;
+
+  function startTest() {
+    if (completed)
+      return;
+
+    is(v.seekable.start(0), v.buffered.start(0), "Seekable start should be buffered start");
+    is(v.seekable.end(0), v.buffered.end(0), "Seekable end should be buffered end");
+    v.currentTime=halfBuffered;
+    v.play();
+  }
+
+  function seekStarted() {
+    if (completed)
+      return;
+
+    startPassed = true;
+  }
+
+  function seekEnded() {
+    if (completed)
+      return;
+
+    endPassed = true;
+  }
+
+  function playbackEnded() {
+    if (completed)
+      return;
+
+    completed = true;
+    ok(startPassed, "send seeking event");
+    ok(endPassed, "send seeked event");
+    ok(v.ended, "Checking playback has ended");
+    ok(Math.abs(v.currentTime - v.duration) <= 0.1, "Checking currentTime at end: " + v.currentTime);
+    removeNodeAndSource(v);
+    manager.finished(v._token);
+  }
+
+  v.addEventListener("ended", playbackEnded, false);
+  v.addEventListener("seeking", seekStarted, false);
+  v.addEventListener("seeked", seekEnded, false);
+
+  startTest();
+}
+
+// Fetch the media resource using XHR so we can be sure the entire
+// resource is loaded before we test buffered ranges. This ensures
+// we have deterministic behaviour.
+function fetch(url, fetched_callback) {
+  var xhr = new XMLHttpRequest();
+  xhr.open("GET", url, true);
+  xhr.responseType = "blob";
+
+  var loaded = function (event) {
+    if (xhr.status == 200 || xhr.status == 206) {
+      // Request fulfilled. Note sometimes we get 206... Presumably because either
+      // httpd.js or Necko cached the result.
+      fetched_callback(window.URL.createObjectURL(xhr.response));
+    } else {
+      ok(false, "Fetch failed headers=" + xhr.getAllResponseHeaders());
+    }
+  };
+
+  xhr.addEventListener("load", loaded, false);
+  xhr.send();
+}
+
+function startTest(test, token) {
+  var onfetched = function(uri) {
+    var v = document.createElement('video');
+    v._token = token;
+    v.src = uri;
+    v.addEventListener("loadeddata", testWebM2, false);
+    document.body.appendChild(v);
+  }
+  manager.started(token);
+  fetch(test.name, onfetched);
+}
+
+SimpleTest.waitForExplicitFinish();
+manager.runTests(gCuelessWebMTests, startTest);
+
+</script>
+</pre>
+</body>
+</html>
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/dom/media/test/test_cueless_webm_seek-3.html
@@ -0,0 +1,122 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=657791
+-->
+<head>
+  <title>Test for Bug 657791</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  <script type="text/javascript" src="manifest.js"></script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=657791">Mozilla Bug 657791</a>
+
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+// Subset of seek tests for cueless WebMs. When random seeking (rather than just
+// in buffered ranges) is implemented for WebM, these tests can be removed and
+// the cueless WebM(s) references can be moved to the general test_seek test
+// array.
+// Test array is defined in manifest.js
+
+var manager = new MediaTestManager;
+
+// Exercise functionality as in test_seek-3
+function testWebM3(e) {
+  var v = e.target;
+  v.removeEventListener('loadeddata', testWebM3);
+
+  var startPassed = false;
+  var completed = false;
+  var gotTimeupdate = false;
+
+  ok(v.buffered.length >= 1, "Should have a buffered range");
+  var halfBuffered = v.buffered.end(0) / 2;
+
+  function startTest() {
+    if (completed)
+      return;
+
+    is(v.seekable.start(0), v.buffered.start(0), "Seekable start should be buffered start");
+    is(v.seekable.end(0), v.buffered.end(0), "Seekable end should be buffered end");
+    v.currentTime=halfBuffered;
+  }
+
+  function timeupdate() {
+    gotTimeupdate = true;
+    v.removeEventListener("timeupdate", timeupdate, false);
+  }
+
+  function seekStarted() {
+    if (completed)
+      return;
+
+    v.addEventListener("timeupdate", timeupdate, false);
+    startPassed = true;
+  }
+
+  function seekEnded() {
+    if (completed)
+      return;
+
+    var t = v.currentTime;
+    ok(Math.abs(t - halfBuffered) <= 0.1, "Video currentTime should be around " + halfBuffered + ": " + t);
+    ok(gotTimeupdate, "Should have got timeupdate between seeking and seekended");
+    completed = true;
+    removeNodeAndSource(v);
+    manager.finished(v._token);
+  }
+
+  v.addEventListener("seeking", seekStarted, false);
+  v.addEventListener("seeked", seekEnded, false);
+
+  startTest()
+}
+
+// Fetch the media resource using XHR so we can be sure the entire
+// resource is loaded before we test buffered ranges. This ensures
+// we have deterministic behaviour.
+function fetch(url, fetched_callback) {
+  var xhr = new XMLHttpRequest();
+  xhr.open("GET", url, true);
+  xhr.responseType = "blob";
+
+  var loaded = function (event) {
+    if (xhr.status == 200 || xhr.status == 206) {
+      // Request fulfilled. Note sometimes we get 206... Presumably because either
+      // httpd.js or Necko cached the result.
+      fetched_callback(window.URL.createObjectURL(xhr.response));
+    } else {
+      ok(false, "Fetch failed headers=" + xhr.getAllResponseHeaders());
+    }
+  };
+
+  xhr.addEventListener("load", loaded, false);
+  xhr.send();
+}
+
+function startTest(test, token) {
+  var onfetched = function(uri) {
+    var v = document.createElement('video');
+    v._token = token;
+    v.src = uri;
+    v.addEventListener("loadeddata", testWebM3, false);
+    document.body.appendChild(v);
+  }
+  manager.started(token);
+  fetch(test.name, onfetched);
+}
+
+SimpleTest.waitForExplicitFinish();
+manager.runTests(gCuelessWebMTests, startTest);
+
+</script>
+</pre>
+</body>
+</html>
\ No newline at end of file