| 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 mediaSource.removeSourceBuffer(sourceBuffer); |
| 80 assert_throws("InvalidStateError", |
| 81 function() { sourceBuffer.appendWindowStart = 100.0; }, |
| 82 "set appendWindowStart throws an exception when mediasource ob
ject is not associated with a buffer."); |
| 83 |
| 84 assert_throws("InvalidStateError", |
| 85 function() { sourceBuffer.appendWindowEnd = 500.0; }, |
| 86 "set appendWindowEnd throws an exception when mediasource obje
ct is not associated with a buffer."); |
| 87 test.done(); |
| 88 |
| 89 }, "Test appendwindow throw error when mediasource object is not assoc
iated with a sourebuffer."); |
| 90 |
| 91 mediasource_loaddata_test(function(test, mediaElement, mediaSource, so
urceBuffer, mediaData) |
| 92 { |
| 93 test.expectEvent(sourceBuffer, "updateend", "sourceBuffer"); |
| 94 sourceBuffer.appendBuffer(mediaData); |
| 95 assert_true(sourceBuffer.updating, "updating attribute is true"); |
| 96 |
| 97 assert_throws("InvalidStateError", |
| 98 function() { sourceBuffer.appendWindowStart = 100.0; }, |
| 99 "set appendWindowStart throws an exception when there is a pen
ding append."); |
| 100 |
| 101 assert_throws("InvalidStateError", |
| 102 function() { sourceBuffer.appendWindowEnd = 500.0; }, |
| 103 "set appendWindowEnd throws an exception when there is a pendi
ng append."); |
| 104 |
| 105 test.waitForExpectedEvents(function() |
| 106 { |
| 107 assert_false(sourceBuffer.updating, "updating attribute is fal
se"); |
| 108 test.done(); |
| 109 }); |
| 110 }, "Test set appendWindowStart and appendWindowEnd when source buffer
updating."); |
| 111 |
| 112 mediasource_loaddata_test(function(test, mediaElement, mediaSource, so
urceBuffer, mediaData) |
| 113 { |
| 114 test.expectEvent(sourceBuffer, "updateend", "sourceBuffer"); |
| 115 sourceBuffer.appendBuffer(mediaData); |
| 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 |