Bug 1293613: Make liveseekable test run. r?gerald draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 10 Aug 2016 14:22:11 +1000
changeset 399476 e51fb05e733356cc2de7555793ae4319a0849822
parent 399475 ef996bbb17007f826e57f507e59d0b019e77551a
child 399477 f443d14ebdb69af1503788f481d130e842cd5244
push id25846
push userbmo:jyavenard@mozilla.com
push dateThu, 11 Aug 2016 05:48:53 +0000
reviewersgerald
bugs1293613
milestone51.0a1
Bug 1293613: Make liveseekable test run. r?gerald - No html document existed, preventing the test to run. - Remove test related to the updating attribute being cleared: see https://github.com/w3c/media-source/issues/118 MozReview-Commit-ID: GxOBnr5mqyh
testing/web-platform/tests/media-source/mediasource-liveseekable.html
--- a/testing/web-platform/tests/media-source/mediasource-liveseekable.html
+++ b/testing/web-platform/tests/media-source/mediasource-liveseekable.html
@@ -1,136 +1,118 @@
 <!DOCTYPE html>
-<meta charset="utf-8">
-<title>Checks setting/clearing the live seekable range and HTMLMediaElement.seekable</title>
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<script src="mediasource-util.js"></script>
-<script>
-test(function(test)
-{
-    var mediaSource = new MediaSource();
-    assert_equals(mediaSource.readyState, "closed", "media source is closed.");
-    assert_throws("InvalidStateError", function() { mediaSource.setLiveSeekableRange(0, 1); });
-}, "setLiveSeekableRange throws an InvalidStateError exception if the readyState attribute is not 'open'");
+<html>
+    <head>
+        <title>Checks setting/clearing the live seekable range and HTMLMediaElement.seekable</title>
+        <script src="/resources/testharness.js"></script>
+        <script src="/resources/testharnessreport.js"></script>
+        <script src="mediasource-util.js"></script>
+    </head>
+    <body>
+        <div id="log"></div>
+        <script>
+          test(function(test)
+          {
+              var mediaSource = new MediaSource();
+              assert_equals(mediaSource.readyState, "closed", "media source is closed.");
+              assert_throws("InvalidStateError", function() { mediaSource.setLiveSeekableRange(0, 1); });
+          }, "setLiveSeekableRange throws an InvalidStateError exception if the readyState attribute is not 'open'");
 
 
-test(function(test)
-{
-    var mediaSource = new MediaSource();
-    assert_equals(mediaSource.readyState, "closed", "media source is closed.");
-    assert_throws("InvalidStateError", function() { mediaSource.clearLiveSeekableRange(); });
-}, "clearLiveSeekableRange throws an InvalidStateError exception if the readyState attribute is not 'open'");
+          test(function(test)
+          {
+              var mediaSource = new MediaSource();
+              assert_equals(mediaSource.readyState, "closed", "media source is closed.");
+              assert_throws("InvalidStateError", function() { mediaSource.clearLiveSeekableRange(); });
+          }, "clearLiveSeekableRange throws an InvalidStateError exception if the readyState attribute is not 'open'");
 
 
-mediasource_test(function(test, mediaElement, mediaSource)
-{
-    mediaElement.addEventListener('error', test.unreached_func("Unexpected event 'error'"));
-    var mimetype = MediaSourceUtil.AUDIO_VIDEO_TYPE;
-    var sourceBuffer = mediaSource.addSourceBuffer(mimetype);
-    sourceBuffer.appendBuffer(new Uint8Array(0));
-    assert_true(sourceBuffer.updating, "Updating set when a buffer is appended.");
-    assert_throws("InvalidStateError", function() { mediaSource.setLiveSeekableRange(0, 1); });
-    test.done();
-}, "setLiveSeekableRange throws an InvalidStateError exception if a SourceBuffer is updating");
+          mediasource_test(function(test, mediaElement, mediaSource)
+          {
+              mediaElement.addEventListener('error', test.unreached_func("Unexpected event 'error'"));
+              assert_throws(new TypeError(), function() { mediaSource.setLiveSeekableRange(-1, 1); });
+              test.done();
+          }, "setLiveSeekableRange throws a TypeError if start is negative");
 
 
-mediasource_test(function(test, mediaElement, mediaSource)
-{
-    mediaElement.addEventListener('error', test.unreached_func("Unexpected event 'error'"));
-    var mimetype = MediaSourceUtil.AUDIO_VIDEO_TYPE;
-    var sourceBuffer = mediaSource.addSourceBuffer(mimetype);
-    sourceBuffer.appendBuffer(new Uint8Array(0));
-    assert_true(sourceBuffer.updating, "Updating set when a buffer is appended.");
-    assert_throws("InvalidStateError", function() { mediaSource.clearLiveSeekableRange(); });
-    test.done();
-}, "clearLiveSeekableRange throws an InvalidStateError exception if a SourceBuffer is updating");
+          mediasource_test(function(test, mediaElement, mediaSource)
+          {
+              mediaElement.addEventListener('error', test.unreached_func("Unexpected event 'error'"));
+              assert_throws(new TypeError(), function() { mediaSource.setLiveSeekableRange(2, 1); });
+              test.done();
+          }, "setLiveSeekableRange throws a TypeError if start is greater than end");
 
 
-mediasource_test(function(test, mediaElement, mediaSource)
-{
-    mediaElement.addEventListener('error', test.unreached_func("Unexpected event 'error'"));
-    assert_throws(new TypeError(), function() { mediaSource.setLiveSeekableRange(-1, 1); });
-    test.done();
-}, "setLiveSeekableRange throws a TypeError if start is negative");
+          mediasource_test(function(test, mediaElement, mediaSource)
+          {
+              mediaElement.addEventListener('error', test.unreached_func("Unexpected event 'error'"));
+              mediaSource.setLiveSeekableRange(0, 1);
+              test.done();
+          }, "setLiveSeekableRange returns with no error when conditions are correct");
 
 
-mediasource_test(function(test, mediaElement, mediaSource)
-{
-    mediaElement.addEventListener('error', test.unreached_func("Unexpected event 'error'"));
-    assert_throws(new TypeError(), function() { mediaSource.setLiveSeekableRange(2, 1); });
-    test.done();
-}, "setLiveSeekableRange throws a TypeError if start is greater than end");
+          mediasource_test(function(test, mediaElement, mediaSource)
+          {
+              mediaElement.addEventListener('error', test.unreached_func("Unexpected event 'error'"));
+              mediaSource.clearLiveSeekableRange();
+              test.done();
+          }, "clearLiveSeekableRange returns with no error when conditions are correct");
 
 
-mediasource_test(function(test, mediaElement, mediaSource)
-{
-    mediaElement.addEventListener('error', test.unreached_func("Unexpected event 'error'"));
-    mediaSource.setLiveSeekableRange(0, 1);
-    test.done();
-}, "setLiveSeekableRange returns with no error when conditions are correct");
-
-
-mediasource_test(function(test, mediaElement, mediaSource)
-{
-    mediaElement.addEventListener('error', test.unreached_func("Unexpected event 'error'"));
-    mediaSource.clearLiveSeekableRange();
-    test.done();
-}, "clearLiveSeekableRange returns with no error when conditions are correct");
+          mediasource_test(function(test, mediaElement, mediaSource)
+          {
+              mediaSource.duration = +Infinity;
+              mediaSource.setLiveSeekableRange(1, 2);
+              assert_equals(mediaElement.seekable.length, 1,
+                'The seekable attribute contains a single range.');
+              assertSeekableEquals(mediaElement, '{ [1.000, 2.000) }',
+                'The seekable attribute returns the correct range.');
 
-
-mediasource_test(function(test, mediaElement, mediaSource)
-{
-    mediaSource.duration = +Infinity;
-    mediaSource.setLiveSeekableRange(1, 2);
-    assert_equals(mediaElement.seekable.length, 1,
-      'The seekable attribute contains a single range.');
-    assertSeekableEquals(mediaElement, '{ [1.000, 2.000) }',
-      'The seekable attribute returns the correct range.');
-
-    mediaSource.clearLiveSeekableRange();
-    assertSeekableEquals(mediaElement, '{ }',
-      'The seekable attribute now returns an empty range.');
-    test.done();
-}, "HTMLMediaElement.seekable returns the live seekable range or an empty range if that range was cleared when nothing is buffered");
+              mediaSource.clearLiveSeekableRange();
+              assertSeekableEquals(mediaElement, '{ }',
+                'The seekable attribute now returns an empty range.');
+              test.done();
+          }, "HTMLMediaElement.seekable returns the live seekable range or an empty range if that range was cleared when nothing is buffered");
 
 
-mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
-{
-    var initSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.init);
-    test.expectEvent(sourceBuffer, 'updateend', 'Init segment appended to SourceBuffer.');
-    sourceBuffer.appendBuffer(initSegment);
-    test.waitForExpectedEvents(function()
-    {
-        mediaSource.duration = +Infinity;
-        mediaSource.setLiveSeekableRange(40, 42);
+          mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
+          {
+              var initSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.init);
+              test.expectEvent(sourceBuffer, 'updateend', 'Init segment appended to SourceBuffer.');
+              sourceBuffer.appendBuffer(initSegment);
+              test.waitForExpectedEvents(function()
+              {
+                  mediaSource.duration = +Infinity;
+                  mediaSource.setLiveSeekableRange(40, 42);
 
-        // Append a segment that starts after 1s to ensure seekable
-        // won't use 0 as starting point.
-        var midSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.media[5]);
-        test.expectEvent(sourceBuffer, 'updateend');
-        sourceBuffer.appendBuffer(midSegment);
-        test.waitForExpectedEvents(function()
-        {
-            assert_equals(mediaElement.seekable.length, 1,
-              'The seekable attribute contains a single range.');
-            assert_equals(mediaElement.buffered.length, 1,
-              'The buffered attribute contains a single range.');
-            assert_not_equals(mediaElement.seekable.start(0), 0,
-              'The range starts after 0.');
-            assert_equals(mediaElement.seekable.start(0), mediaElement.buffered.start(0),
-              'The start time is the start time of the buffered range.');
-            assert_equals(mediaElement.seekable.end(0), 42,
-              'The end time is the end time of the seekable range.');
+                  // Append a segment that starts after 1s to ensure seekable
+                  // won't use 0 as starting point.
+                  var midSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.media[5]);
+                  test.expectEvent(sourceBuffer, 'updateend');
+                  sourceBuffer.appendBuffer(midSegment);
+                  test.waitForExpectedEvents(function()
+                  {
+                      assert_equals(mediaElement.seekable.length, 1,
+                        'The seekable attribute contains a single range.');
+                      assert_equals(mediaElement.buffered.length, 1,
+                        'The buffered attribute contains a single range.');
+                      assert_not_equals(mediaElement.seekable.start(0), 0,
+                        'The range starts after 0.');
+                      assert_equals(mediaElement.seekable.start(0), mediaElement.buffered.start(0),
+                        'The start time is the start time of the buffered range.');
+                      assert_equals(mediaElement.seekable.end(0), 42,
+                        'The end time is the end time of the seekable range.');
 
-            mediaSource.clearLiveSeekableRange();
-            assert_equals(mediaElement.seekable.length, 1,
-              'The seekable attribute contains a single range.');
-            assert_equals(mediaElement.seekable.start(0), 0,
-              'The start time is now 0.');
-            assert_equals(mediaElement.seekable.end(0), mediaElement.buffered.end(0),
-              'The end time is now the end time of the buffered range.');
+                      mediaSource.clearLiveSeekableRange();
+                      assert_equals(mediaElement.seekable.length, 1,
+                        'The seekable attribute contains a single range.');
+                      assert_equals(mediaElement.seekable.start(0), 0,
+                        'The start time is now 0.');
+                      assert_equals(mediaElement.seekable.end(0), mediaElement.buffered.end(0),
+                        'The end time is now the end time of the buffered range.');
 
-            test.done();
-        });
-    });
-}, 'HTMLMediaElement.seekable returns the union of the buffered range and the live seekable range, when set');
-</script>
\ No newline at end of file
+                      test.done();
+                  });
+              });
+          }, 'HTMLMediaElement.seekable returns the union of the buffered range and the live seekable range, when set');
+        </script>
+    </body>
+</html>