Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / http / tests / media / media-source / mediasource-remove.html
index 6cf84a9..4306546 100644 (file)
               test.done();
           }, "Test remove with an negative start.");
 
+          mediasource_test(function(test, mediaElement, mediaSource)
+          {
+              var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_VIDEO_TYPE);
+
+              [ undefined, NaN, Infinity, -Infinity ].forEach(function(item)
+              {
+                  assert_throws(new TypeError(), function()
+                  {
+                      sourceBuffer.remove(item, 2);
+                  }, "remove");
+              });
+
+              test.done();
+          }, "Test remove with non-finite start.");
 
           mediasource_test(function(test, mediaElement, mediaSource)
           {
 
                   test.waitForExpectedEvents(function()
                   {
-                      var duration = segmentInfo.duration.toFixed(3);
+                      var bufferedRangeEnd = segmentInfo.bufferedRangeEndBeforeEndOfStream.toFixed(3);
                       var subType = MediaSourceUtil.getSubType(segmentInfo.type);
 
-                      assertBufferedEquals(sourceBuffer, "{ [0.000, " + duration + ") }", "Initial buffered range.");
-                      callback(test, sourceBuffer, duration, subType);
+                      assertBufferedEquals(sourceBuffer, "{ [0.000, " + bufferedRangeEnd + ") }", "Initial buffered range.");
+                      callback(test, sourceBuffer, bufferedRangeEnd, subType);
                   });
               }, description);
           };
               });
           }
 
-          removeAppendedDataTests(function(test, sourceBuffer, duration, subType)
+          removeAppendedDataTests(function(test, sourceBuffer, bufferedRangeEnd, subType)
           {
-              removeAndCheckBufferedRanges(test, sourceBuffer, 0, Number.POSITIVE_INFINITY, "{ }");
+              // Using MAX_VALUE rather than POSITIVE_INFINITY here due to lack
+              // of 'unrestricted' on end parameter. (See comment in SourceBuffer.idl)
+              removeAndCheckBufferedRanges(test, sourceBuffer, 0, Number.MAX_VALUE, "{ }");
           }, "Test removing all appended data.");
 
-          removeAppendedDataTests(function(test, sourceBuffer, duration, subType)
+          removeAppendedDataTests(function(test, sourceBuffer, bufferedRangeEnd, subType)
           {
               var expectations = {
-                webm: ("{ [3.187, " + duration + ") }"),
-                mp4: ("{ [3.021, " + duration + ") }"),
+                webm: ("{ [3.187, " + bufferedRangeEnd + ") }"),
+                mp4: ("{ [3.021, " + bufferedRangeEnd + ") }"),
               };
 
               // Note: Range doesn't start exactly at the end of the remove range because there isn't
               removeAndCheckBufferedRanges(test, sourceBuffer, 0, 3, expectations[subType]);
           }, "Test removing beginning of appended data.");
 
-          removeAppendedDataTests(function(test, sourceBuffer, duration, subType)
+          removeAppendedDataTests(function(test, sourceBuffer, bufferedRangeEnd, subType)
           {
               var expectations = {
-                webm: ("{ [0.000, 1.012) [3.187, " + duration + ") }"),
-                mp4: ("{ [0.000, 1.022) [3.021, " + duration + ") }"),
+                webm: ("{ [0.000, 1.012) [3.187, " + bufferedRangeEnd + ") }"),
+                mp4: ("{ [0.000, 1.022) [3.021, " + bufferedRangeEnd + ") }"),
               };
 
               // Note: The first resulting range ends slightly after start because the removal algorithm only removes
               removeAndCheckBufferedRanges(test, sourceBuffer, 1, 3, expectations[subType]);
           }, "Test removing the middle of appended data.");
 
-          removeAppendedDataTests(function(test, sourceBuffer, duration, subType)
+          removeAppendedDataTests(function(test, sourceBuffer, bufferedRangeEnd, subType)
           {
               var expectations = {
                 webm: "{ [0.000, 1.012) }",
                 mp4: "{ [0.000, 1.022) }",
               };
 
-              removeAndCheckBufferedRanges(test, sourceBuffer, 1, Number.POSITIVE_INFINITY, expectations[subType]);
+              // Using MAX_VALUE rather than POSITIVE_INFINITY here due to lack
+              // of 'unrestricted' on end parameter. (See comment in SourceBuffer.idl)
+              removeAndCheckBufferedRanges(test, sourceBuffer, 1, Number.MAX_VALUE, expectations[subType]);
           }, "Test removing the end of appended data.");
         </script>
     </body>