| OLD | NEW | 
|---|
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> | 
| 2 <html> | 2 <html> | 
| 3     <head> | 3     <head> | 
| 4         <script src="/w3c/resources/testharness.js"></script> | 4         <script src="/w3c/resources/testharness.js"></script> | 
| 5         <script src="/w3c/resources/testharnessreport.js"></script> | 5         <script src="/w3c/resources/testharnessreport.js"></script> | 
| 6         <script src="mediasource-util.js"></script> | 6         <script src="mediasource-util.js"></script> | 
| 7         <link rel='stylesheet' href='/w3c/resources/testharness.css'> | 7         <link rel='stylesheet' href='/w3c/resources/testharness.css'> | 
| 8     </head> | 8     </head> | 
| 9     <body> | 9     <body> | 
| 10         <div id="log"></div> | 10         <div id="log"></div> | 
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 149           { | 149           { | 
| 150               mediasource_testafterdataloaded(function(test, mediaElement, media
     Source, segmentInfo, sourceBuffer, mediaData) | 150               mediasource_testafterdataloaded(function(test, mediaElement, media
     Source, segmentInfo, sourceBuffer, mediaData) | 
| 151               { | 151               { | 
| 152                   test.expectEvent(sourceBuffer, "updatestart"); | 152                   test.expectEvent(sourceBuffer, "updatestart"); | 
| 153                   test.expectEvent(sourceBuffer, "update"); | 153                   test.expectEvent(sourceBuffer, "update"); | 
| 154                   test.expectEvent(sourceBuffer, "updateend"); | 154                   test.expectEvent(sourceBuffer, "updateend"); | 
| 155                   sourceBuffer.appendBuffer(mediaData); | 155                   sourceBuffer.appendBuffer(mediaData); | 
| 156 | 156 | 
| 157                   test.waitForExpectedEvents(function() | 157                   test.waitForExpectedEvents(function() | 
| 158                   { | 158                   { | 
| 159                       var duration = segmentInfo.duration.toFixed(3); | 159                       var bufferedRangeEnd = segmentInfo.bufferedRangeEndBeforeE
     ndOfStream.toFixed(3); | 
| 160                       var subType = MediaSourceUtil.getSubType(segmentInfo.type)
     ; | 160                       var subType = MediaSourceUtil.getSubType(segmentInfo.type)
     ; | 
| 161 | 161 | 
| 162                       assertBufferedEquals(sourceBuffer, "{ [0.000, " + duration
      + ") }", "Initial buffered range."); | 162                       assertBufferedEquals(sourceBuffer, "{ [0.000, " + buffered
     RangeEnd + ") }", "Initial buffered range."); | 
| 163                       callback(test, sourceBuffer, duration, subType); | 163                       callback(test, sourceBuffer, bufferedRangeEnd, subType); | 
| 164                   }); | 164                   }); | 
| 165               }, description); | 165               }, description); | 
| 166           }; | 166           }; | 
| 167 | 167 | 
| 168           function removeAndCheckBufferedRanges(test, sourceBuffer, start, end, 
     expected) | 168           function removeAndCheckBufferedRanges(test, sourceBuffer, start, end, 
     expected) | 
| 169           { | 169           { | 
| 170               test.expectEvent(sourceBuffer, "updatestart"); | 170               test.expectEvent(sourceBuffer, "updatestart"); | 
| 171               test.expectEvent(sourceBuffer, "update"); | 171               test.expectEvent(sourceBuffer, "update"); | 
| 172               test.expectEvent(sourceBuffer, "updateend"); | 172               test.expectEvent(sourceBuffer, "updateend"); | 
| 173               sourceBuffer.remove(start, end); | 173               sourceBuffer.remove(start, end); | 
| 174 | 174 | 
| 175               test.waitForExpectedEvents(function() | 175               test.waitForExpectedEvents(function() | 
| 176               { | 176               { | 
| 177                   assertBufferedEquals(sourceBuffer, expected, "Buffered ranges 
     after remove()."); | 177                   assertBufferedEquals(sourceBuffer, expected, "Buffered ranges 
     after remove()."); | 
| 178                   test.done(); | 178                   test.done(); | 
| 179               }); | 179               }); | 
| 180           } | 180           } | 
| 181 | 181 | 
| 182           removeAppendedDataTests(function(test, sourceBuffer, duration, subType
     ) | 182           removeAppendedDataTests(function(test, sourceBuffer, bufferedRangeEnd,
      subType) | 
| 183           { | 183           { | 
| 184               removeAndCheckBufferedRanges(test, sourceBuffer, 0, Number.POSITIV
     E_INFINITY, "{ }"); | 184               removeAndCheckBufferedRanges(test, sourceBuffer, 0, Number.POSITIV
     E_INFINITY, "{ }"); | 
| 185           }, "Test removing all appended data."); | 185           }, "Test removing all appended data."); | 
| 186 | 186 | 
| 187           removeAppendedDataTests(function(test, sourceBuffer, duration, subType
     ) | 187           removeAppendedDataTests(function(test, sourceBuffer, bufferedRangeEnd,
      subType) | 
| 188           { | 188           { | 
| 189               var expectations = { | 189               var expectations = { | 
| 190                 webm: ("{ [3.187, " + duration + ") }"), | 190                 webm: ("{ [3.187, " + bufferedRangeEnd + ") }"), | 
| 191                 mp4: ("{ [3.021, " + duration + ") }"), | 191                 mp4: ("{ [3.021, " + bufferedRangeEnd + ") }"), | 
| 192               }; | 192               }; | 
| 193 | 193 | 
| 194               // Note: Range doesn't start exactly at the end of the remove rang
     e because there isn't | 194               // Note: Range doesn't start exactly at the end of the remove rang
     e because there isn't | 
| 195               // a keyframe there. The resulting range starts at the first keyfr
     ame >= the end time. | 195               // a keyframe there. The resulting range starts at the first keyfr
     ame >= the end time. | 
| 196               removeAndCheckBufferedRanges(test, sourceBuffer, 0, 3, expectation
     s[subType]); | 196               removeAndCheckBufferedRanges(test, sourceBuffer, 0, 3, expectation
     s[subType]); | 
| 197           }, "Test removing beginning of appended data."); | 197           }, "Test removing beginning of appended data."); | 
| 198 | 198 | 
| 199           removeAppendedDataTests(function(test, sourceBuffer, duration, subType
     ) | 199           removeAppendedDataTests(function(test, sourceBuffer, bufferedRangeEnd,
      subType) | 
| 200           { | 200           { | 
| 201               var expectations = { | 201               var expectations = { | 
| 202                 webm: ("{ [0.000, 1.012) [3.187, " + duration + ") }"), | 202                 webm: ("{ [0.000, 1.012) [3.187, " + bufferedRangeEnd + ") }"), | 
| 203                 mp4: ("{ [0.000, 1.022) [3.021, " + duration + ") }"), | 203                 mp4: ("{ [0.000, 1.022) [3.021, " + bufferedRangeEnd + ") }"), | 
| 204               }; | 204               }; | 
| 205 | 205 | 
| 206               // Note: The first resulting range ends slightly after start becau
     se the removal algorithm only removes | 206               // Note: The first resulting range ends slightly after start becau
     se the removal algorithm only removes | 
| 207               // frames with a timestamp >= the start time. If a frame starts be
     fore and ends after the remove() start | 207               // frames with a timestamp >= the start time. If a frame starts be
     fore and ends after the remove() start | 
| 208               // timestamp, then it stays in the buffer. | 208               // timestamp, then it stays in the buffer. | 
| 209               removeAndCheckBufferedRanges(test, sourceBuffer, 1, 3, expectation
     s[subType]); | 209               removeAndCheckBufferedRanges(test, sourceBuffer, 1, 3, expectation
     s[subType]); | 
| 210           }, "Test removing the middle of appended data."); | 210           }, "Test removing the middle of appended data."); | 
| 211 | 211 | 
| 212           removeAppendedDataTests(function(test, sourceBuffer, duration, subType
     ) | 212           removeAppendedDataTests(function(test, sourceBuffer, bufferedRangeEnd,
      subType) | 
| 213           { | 213           { | 
| 214               var expectations = { | 214               var expectations = { | 
| 215                 webm: "{ [0.000, 1.012) }", | 215                 webm: "{ [0.000, 1.012) }", | 
| 216                 mp4: "{ [0.000, 1.022) }", | 216                 mp4: "{ [0.000, 1.022) }", | 
| 217               }; | 217               }; | 
| 218 | 218 | 
| 219               removeAndCheckBufferedRanges(test, sourceBuffer, 1, Number.POSITIV
     E_INFINITY, expectations[subType]); | 219               removeAndCheckBufferedRanges(test, sourceBuffer, 1, Number.POSITIV
     E_INFINITY, expectations[subType]); | 
| 220           }, "Test removing the end of appended data."); | 220           }, "Test removing the end of appended data."); | 
| 221         </script> | 221         </script> | 
| 222     </body> | 222     </body> | 
| 223 </html> | 223 </html> | 
| OLD | NEW | 
|---|