Chromium Code Reviews| OLD | NEW | 
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <script src="/w3c/resources/testharness.js"></script> | |
| 5 <script src="/w3c/resources/testharnessreport.js"></script> | |
| 6 <script src="mediasource-util.js"></script> | |
| 7 <link rel='stylesheet' href='/w3c/resources/testharness.css'> | |
| 8 </head> | |
| 9 <body> | |
| 10 <div id="log"></div> | |
| 11 <script> | |
| 12 var mediaType = 'video/webm;codecs="vp8,vorbis"'; | |
| 13 | |
| 14 mediasource_loaddata_test = function(callback, description) | |
| 15 { | |
| 16 mediasource_test(function(test, mediaElement, mediaSource) | |
| 17 { | |
| 18 var mediaURL = '/media/resources/media-source/webm/test.webm'; | |
| 19 var sourceBuffer = mediaSource.addSourceBuffer(mediaType); | |
| 20 MediaSourceUtil.loadBinaryData(test, mediaURL, function(mediaD ata) | |
| 21 { | |
| 22 callback(test, mediaElement, mediaSource, sourceBuffer, me diaData); | |
| 23 | |
| 24 }); | |
| 25 }, description); | |
| 26 }; | |
| 27 | |
| 28 mediasource_test(function(test, mediaElement, mediaSource) | |
| 29 { | |
| 30 var sourceBuffer = mediaSource.addSourceBuffer(mediaType); | |
| 31 assert_true(sourceBuffer != null, "New SourceBuffer returned"); | |
| 32 | |
| 33 sourceBuffer.appendWindowStart = 100.0; | |
| 34 sourceBuffer.appendWindowEnd = 500.0; | |
| 35 assert_equals(sourceBuffer.appendWindowStart, 100.0, "appendWindow Start is correctly set'"); | |
| 36 assert_equals(sourceBuffer.appendWindowEnd, 500.0, "appendWindowEn d is correctly set'"); | |
| 37 | |
| 38 sourceBuffer.appendWindowStart = 200.0; | |
| 39 sourceBuffer.appendWindowEnd = 400.0; | |
| 40 assert_equals(sourceBuffer.appendWindowStart, 200.0, "appendWindow Start is correctly reset'"); | |
| 41 assert_equals(sourceBuffer.appendWindowEnd, 400.0, "appendWindowEn d is correctly reset'"); | |
| 42 test.done(); | |
| 43 }, "Test correctly reset appendWindowStart and appendWindowEnd values" ); | |
| 44 | |
| 45 mediasource_test(function(test, mediaElement, mediaSource) | |
| 46 { | |
| 47 var sourceBuffer = mediaSource.addSourceBuffer(mediaType); | |
| 48 assert_true(sourceBuffer != null, "New SourceBuffer returned"); | |
| 49 sourceBuffer.appendWindowEnd = 500.0; | |
| 50 | |
| 51 assert_throws("TypeMismatchError", | |
| 52 function() { sourceBuffer.appendWindowStart = Number.NEGATIVE_ INFINITY; }, | |
| 53 "set appendWindowStart throws an exception for Number.NEGATIVE _INFINITY."); | |
| 54 | |
| 55 assert_throws("TypeMismatchError", | |
| 56 function() { sourceBuffer.appendWindowStart = Number.POSITIVE_ INFINITY; }, | |
| 57 "set appendWindowStart throws an exception for Number.POSITIVE _INFINITY."); | |
| 58 | |
| 59 assert_throws("TypeMismatchError", | |
| 60 function() { sourceBuffer.appendWindowStart = Number.NaN; }, | |
| 61 "set appendWindowStart throws an exception for Number.NaN."); | |
| 62 | |
| 63 assert_throws("InvalidAccessError", | |
| 64 function() { sourceBuffer.appendWindowStart = 600.0; }, | |
| 65 "set appendWindowStart throws an exception when greater than a ppendWindowEnd."); | |
| 66 | |
| 67 assert_throws("InvalidAccessError", | |
| 68 function() { sourceBuffer.appendWindowStart = -100.0; }, | |
| 69 "set appendWindowStart throws an exception when less than 0.") ; | |
| 70 | |
| 71 assert_throws("InvalidAccessError", | |
| 72 function() { sourceBuffer.appendWindowEnd = Number.NaN; }, | |
| 73 "set appendWindowEnd throws an exception if NaN."); | |
| 74 test.done(); | |
| 75 }, "Test set wrong values to appendWindowStart and appendWindowEnd."); | |
| 76 | |
| 77 mediasource_loaddata_test(function(test, mediaElement, mediaSource, so urceBuffer, mediaData) | |
| 78 { | |
| 79 sourceBuffer.appendBuffer(mediaData); | |
| 
 
acolwell GONE FROM CHROMIUM
2013/08/07 16:15:56
nit: Do you actually need the appendBuffer() here?
 
 | |
| 80 | |
| 81 mediaSource.removeSourceBuffer(sourceBuffer); | |
| 82 assert_throws("InvalidStateError", | |
| 83 function() { sourceBuffer.appendWindowStart = 100.0; }, | |
| 84 "set appendWindowStart throws an exception when mediasource ob ject is not associated with a buffer."); | |
| 85 | |
| 86 assert_throws("InvalidStateError", | |
| 87 function() { sourceBuffer.appendWindowEnd = 500.0; }, | |
| 88 "set appendWindowEnd throws an exception when mediasource obje ct is not associated with a buffer."); | |
| 89 test.done(); | |
| 90 | |
| 91 }, "Test appendwindow throw error when mediasource object is not assoc iated with a sourebuffer."); | |
| 92 | |
| 93 mediasource_loaddata_test(function(test, mediaElement, mediaSource, so urceBuffer, mediaData) | |
| 94 { | |
| 95 sourceBuffer.appendBuffer(mediaData); | |
| 
 
acolwell GONE FROM CHROMIUM
2013/08/07 16:15:56
nit: You need a 'test.expectEvent(sourceBuffer, "u
 
 | |
| 96 assert_true(sourceBuffer.updating, "updating attribute is true"); | |
| 97 | |
| 98 assert_throws("InvalidStateError", | |
| 99 function() { sourceBuffer.appendWindowStart = 100.0; }, | |
| 100 "set appendWindowStart throws an exception when there is a pen ding append."); | |
| 101 | |
| 102 assert_throws("InvalidStateError", | |
| 103 function() { sourceBuffer.appendWindowEnd = 500.0; }, | |
| 104 "set appendWindowEnd throws an exception when there is a pendi ng append."); | |
| 105 | |
| 106 test.waitForExpectedEvents(function() | |
| 107 { | |
| 108 assert_false(sourceBuffer.updating, "updating attribute is fal se"); | |
| 109 test.done(); | |
| 110 }); | |
| 111 }, "Test set appendWindowStart and appendWindowEnd when source buffer updating."); | |
| 112 | |
| 113 mediasource_loaddata_test(function(test, mediaElement, mediaSource, so urceBuffer, mediaData) | |
| 114 { | |
| 115 sourceBuffer.appendBuffer(mediaData); | |
| 
 
acolwell GONE FROM CHROMIUM
2013/08/07 16:15:56
nit: You need a 'test.expectEvent(sourceBuffer, "u
 
 | |
| 116 assert_true(sourceBuffer.updating, "updating attribute is true"); | |
| 117 | |
| 118 sourceBuffer.abort(); | |
| 119 assert_equals(sourceBuffer.appendWindowStart, 0, "appendWindowStar t is 0 after an abort'"); | |
| 120 assert_equals(sourceBuffer.appendWindowEnd, Number.POSITIVE_INFINI TY, | |
| 121 "appendWindowStart is POSITIVE_INFINITY after an abo rt"); | |
| 122 test.waitForExpectedEvents(function() | |
| 123 { | |
| 124 assert_false(sourceBuffer.updating, "updating attribute is fal se"); | |
| 125 test.done(); | |
| 126 }); | |
| 127 }, "Test appendWindowStart and appendWindowEnd value after a sourceBuf fer.abort()."); | |
| 128 | |
| 129 </script> | |
| 130 </body> | |
| 131 </html> | |
| OLD | NEW |