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 mediasource_loaddata_test = function(callback, description) |
| 13 { |
| 14 mediasource_test(function(test, mediaElement, mediaSource) |
| 15 { |
| 16 var mediaType = 'video/webm;codecs="vp8,vorbis"'; |
| 17 var mediaURL = '/media/resources/media-source/webm/test.webm'; |
| 18 var sourceBuffer = mediaSource.addSourceBuffer(mediaType); |
| 19 MediaSourceUtil.loadBinaryData(test, mediaURL, function(mediaD
ata) |
| 20 { |
| 21 callback(test, mediaElement, mediaSource, sourceBuffer, me
diaData); |
| 22 |
| 23 }); |
| 24 }, description); |
| 25 }; |
| 26 |
| 27 mediasource_loaddata_test(function(test, mediaElement, mediaSource, so
urceBuffer, mediaData) |
| 28 { |
| 29 test.failOnEvent(mediaElement, 'error'); |
| 30 |
| 31 test.expectEvent(sourceBuffer, "updatestart", "Append started."); |
| 32 test.expectEvent(sourceBuffer, "update", "Append success."); |
| 33 test.expectEvent(sourceBuffer, "updateend", "Append ended."); |
| 34 sourceBuffer.appendBuffer(mediaData); |
| 35 |
| 36 assert_true(sourceBuffer.updating, "updating attribute is true"); |
| 37 |
| 38 test.waitForExpectedEvents(function() |
| 39 { |
| 40 assert_false(sourceBuffer.updating, "updating attribute is fals
e"); |
| 41 test.done(); |
| 42 }); |
| 43 }, "Test SourceBuffer.appendBuffer() event dispatching."); |
| 44 |
| 45 mediasource_loaddata_test(function(test, mediaElement, mediaSource, so
urceBuffer, mediaData) |
| 46 { |
| 47 test.failOnEvent(mediaElement, 'error'); |
| 48 |
| 49 test.expectEvent(sourceBuffer, "updatestart", "Append started."); |
| 50 test.expectEvent(sourceBuffer, "update", "Append success."); |
| 51 test.expectEvent(sourceBuffer, "updateend", "Append ended."); |
| 52 sourceBuffer.appendBuffer(mediaData); |
| 53 |
| 54 assert_true(sourceBuffer.updating, "updating attribute is true"); |
| 55 |
| 56 assert_throws("InvalidStateError", |
| 57 function() { sourceBuffer.appendBuffer(mediaData); }, |
| 58 "appendBuffer() throws an exception there is a pending append.
"); |
| 59 |
| 60 assert_true(sourceBuffer.updating, "updating attribute is true"); |
| 61 |
| 62 test.waitForExpectedEvents(function() |
| 63 { |
| 64 assert_false(sourceBuffer.updating, "updating attribute is fal
se"); |
| 65 test.done(); |
| 66 }); |
| 67 }, "Test SourceBuffer.appendBuffer() call during a pending appendBuffe
r()."); |
| 68 |
| 69 mediasource_loaddata_test(function(test, mediaElement, mediaSource, so
urceBuffer, mediaData) |
| 70 { |
| 71 test.failOnEvent(mediaElement, 'error'); |
| 72 |
| 73 test.expectEvent(sourceBuffer, "updatestart", "Append started."); |
| 74 test.expectEvent(sourceBuffer, "abort", "Append aborted."); |
| 75 test.expectEvent(sourceBuffer, "updateend", "Append ended."); |
| 76 sourceBuffer.appendBuffer(mediaData); |
| 77 |
| 78 assert_true(sourceBuffer.updating, "updating attribute is true"); |
| 79 |
| 80 sourceBuffer.abort(); |
| 81 |
| 82 assert_false(sourceBuffer.updating, "updating attribute is false")
; |
| 83 |
| 84 test.waitForExpectedEvents(function() |
| 85 { |
| 86 assert_false(sourceBuffer.updating, "updating attribute is fal
se"); |
| 87 test.done(); |
| 88 }); |
| 89 }, "Test SourceBuffer.abort() call during a pending appendBuffer()."); |
| 90 |
| 91 mediasource_loaddata_test(function(test, mediaElement, mediaSource, so
urceBuffer, mediaData) |
| 92 { |
| 93 test.failOnEvent(mediaElement, 'error'); |
| 94 |
| 95 test.expectEvent(sourceBuffer, "updatestart", "Append started."); |
| 96 test.expectEvent(sourceBuffer, "update", "Append success."); |
| 97 test.expectEvent(sourceBuffer, "updateend", "Append ended."); |
| 98 sourceBuffer.appendBuffer(mediaData); |
| 99 assert_true(sourceBuffer.updating, "updating attribute is true"); |
| 100 |
| 101 test.waitForExpectedEvents(function() |
| 102 { |
| 103 assert_false(sourceBuffer.updating, "updating attribute is fal
se"); |
| 104 |
| 105 test.expectEvent(mediaSource, "sourceended", "MediaSource sour
ceended event"); |
| 106 mediaSource.endOfStream(); |
| 107 assert_equals(mediaSource.readyState, "ended", "MediaSource re
adyState is 'ended'"); |
| 108 }); |
| 109 |
| 110 test.waitForExpectedEvents(function() |
| 111 { |
| 112 assert_equals(mediaSource.readyState, "ended", "MediaSource re
adyState is 'ended'"); |
| 113 |
| 114 test.expectEvent(mediaSource, "sourceopen", "MediaSource sourc
eopen event"); |
| 115 test.expectEvent(sourceBuffer, "updatestart", "Append started.
"); |
| 116 test.expectEvent(sourceBuffer, "update", "Append success."); |
| 117 test.expectEvent(sourceBuffer, "updateend", "Append ended."); |
| 118 sourceBuffer.appendBuffer(mediaData); |
| 119 |
| 120 assert_equals(mediaSource.readyState, "open", "MediaSource rea
dyState is 'open'"); |
| 121 assert_true(sourceBuffer.updating, "updating attribute is true
"); |
| 122 }); |
| 123 |
| 124 test.waitForExpectedEvents(function() |
| 125 { |
| 126 assert_equals(mediaSource.readyState, "open", "MediaSource rea
dyState is 'open'"); |
| 127 assert_false(sourceBuffer.updating, "updating attribute is fal
se"); |
| 128 test.done(); |
| 129 }); |
| 130 }, "Test SourceBuffer.appendBuffer() triggering an 'ended' to 'open' t
ransition."); |
| 131 |
| 132 mediasource_loaddata_test(function(test, mediaElement, mediaSource, so
urceBuffer, mediaData) |
| 133 { |
| 134 test.failOnEvent(mediaElement, 'error'); |
| 135 |
| 136 test.expectEvent(sourceBuffer, "updatestart", "Append started."); |
| 137 test.expectEvent(sourceBuffer, "abort", "Append aborted."); |
| 138 test.expectEvent(sourceBuffer, "updateend", "Append ended."); |
| 139 sourceBuffer.appendBuffer(mediaData); |
| 140 |
| 141 assert_true(sourceBuffer.updating, "updating attribute is true"); |
| 142 |
| 143 test.expectEvent(mediaSource.activeSourceBuffers, "removesourcebuf
fer", "activeSourceBuffers"); |
| 144 test.expectEvent(mediaSource.sourceBuffers, "removesourcebuffer",
"sourceBuffers"); |
| 145 mediaSource.removeSourceBuffer(sourceBuffer); |
| 146 |
| 147 assert_false(sourceBuffer.updating, "updating attribute is false")
; |
| 148 |
| 149 assert_throws("InvalidStateError", |
| 150 function() { sourceBuffer.appendBuffer(mediaData); }, |
| 151 "appendBuffer() throws an exception because it isn't attached
to the mediaSource anymore."); |
| 152 |
| 153 test.waitForExpectedEvents(function() |
| 154 { |
| 155 assert_false(sourceBuffer.updating, "updating attribute is fal
se"); |
| 156 test.done(); |
| 157 }); |
| 158 }, "Test MediaSource.removeSourceBuffer() call during a pending append
Buffer()."); |
| 159 </script> |
| 160 </body> |
| 161 </html> |
OLD | NEW |