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 | 7 |
8 <link rel='stylesheet' href='/w3c/resources/testharness.css'> | 8 <link rel='stylesheet' href='/w3c/resources/testharness.css'> |
9 </head> | 9 </head> |
10 <body> | 10 <body> |
11 <div id="log"></div> | 11 <div id="log"></div> |
12 <script> | 12 <script> |
13 mediasource_test(function(test, mediaElement, mediaSource) | 13 mediasource_test(function(test, mediaElement, mediaSource) |
14 { | 14 { |
15 mediaSource.endOfStream(); | 15 mediaSource.endOfStream(); |
16 assert_throws("InvalidStateError", | 16 assert_throws("InvalidStateError", |
17 function() { mediaSource.addSourceBuffer(MediaSourceUt
il.AUDIO_VIDEO_TYPE); }, | 17 function() { mediaSource.addSourceBuffer(MediaSourceUt
il.AUDIO_VIDEO_TYPE); }, |
18 "addSourceBuffer() threw an exception when in 'ended'
state."); | 18 "addSourceBuffer() threw an exception when in 'ended'
state."); |
19 test.done(); | 19 test.done(); |
20 }, "Test addSourceBuffer() in 'ended' state."); | 20 }, "Test addSourceBuffer() in 'ended' state."); |
21 | 21 |
22 mediasource_test(function(test, mediaElement, mediaSource) | 22 mediasource_test(function(test, mediaElement, mediaSource) |
23 { | 23 { |
24 assert_throws("InvalidAccessError", | 24 assert_throws("InvalidAccessError", |
25 function() { mediaSource.addSourceBuffer(""); }, | 25 function() { mediaSource.addSourceBuffer(""); }, |
26 "addSourceBuffer() threw an exception when passed an e
mpty string."); | 26 "addSourceBuffer() threw an exception when passed an e
mpty string."); |
27 test.done(); | 27 test.done(); |
28 }, "Test addSourceBuffer() with empty type"); | 28 }, "Test addSourceBuffer() with empty type"); |
29 | 29 |
30 mediasource_test(function(test, mediaElement, mediaSource) | 30 mediasource_test(function(test, mediaElement, mediaSource) |
31 { | 31 { |
32 assert_throws("NotSupportedError", | 32 assert_throws("NotSupportedError", |
| 33 function() { mediaSource.addSourceBuffer(null); }, |
| 34 "addSourceBuffer() threw an exception when passed null
."); |
| 35 test.done(); |
| 36 }, "Test addSourceBuffer() with null"); |
| 37 |
| 38 mediasource_test(function(test, mediaElement, mediaSource) |
| 39 { |
| 40 assert_throws("NotSupportedError", |
33 function() { mediaSource.addSourceBuffer("invalidType"
); }, | 41 function() { mediaSource.addSourceBuffer("invalidType"
); }, |
34 "addSourceBuffer() threw an exception for an unsupport
ed type."); | 42 "addSourceBuffer() threw an exception for an unsupport
ed type."); |
35 test.done(); | 43 test.done(); |
36 }, "Test addSourceBuffer() with unsupported type"); | 44 }, "Test addSourceBuffer() with unsupported type"); |
37 | 45 |
38 mediasource_test(function(test, mediaElement, mediaSource) | 46 mediasource_test(function(test, mediaElement, mediaSource) |
39 { | 47 { |
40 var mimetype = 'video/webm;codecs="vp8,vorbis"'; | 48 var mimetype = 'video/webm;codecs="vp8,vorbis"'; |
41 | 49 |
42 assert_true(MediaSource.isTypeSupported(mimetype), mimetype + " is
supported"); | 50 assert_true(MediaSource.isTypeSupported(mimetype), mimetype + " is
supported"); |
43 | 51 |
44 var sourceBuffer = mediaSource.addSourceBuffer(mimetype); | 52 var sourceBuffer = mediaSource.addSourceBuffer(mimetype); |
45 assert_true(sourceBuffer != null, "New SourceBuffer returned"); | 53 assert_true(sourceBuffer != null, "New SourceBuffer returned"); |
46 assert_equals(mediaSource.sourceBuffers[0], sourceBuffer, "SourceB
uffer is in mediaSource.sourceBuffers"); | 54 assert_equals(mediaSource.sourceBuffers[0], sourceBuffer, "SourceB
uffer is in mediaSource.sourceBuffers"); |
47 assert_equals(mediaSource.activeSourceBuffers[0], sourceBuffer, "S
ourceBuffer is in mediaSource.activeSourceBuffers"); | 55 assert_equals(mediaSource.activeSourceBuffers[0], sourceBuffer, "S
ourceBuffer is in mediaSource.activeSourceBuffers"); |
48 test.done(); | 56 test.done(); |
49 }, "Test addSourceBuffer() with Vorbis and VP8"); | 57 }, "Test addSourceBuffer() with Vorbis and VP8"); |
50 | 58 |
51 mediasource_test(function(test, mediaElement, mediaSource) | 59 mediasource_test(function(test, mediaElement, mediaSource) |
52 { | 60 { |
53 var videoMimetype = 'video/webm;codecs="vp8"'; | 61 var videoMimetype = 'video/webm;codecs="vp8"'; |
54 var audioMimetype = 'audio/webm;codecs="vorbis"'; | 62 var audioMimetype = 'audio/webm;codecs="vorbis"'; |
55 | 63 |
56 assert_true(MediaSource.isTypeSupported(videoMimetype), videoMimet
ype + " is supported"); | 64 assert_true(MediaSource.isTypeSupported(videoMimetype), videoMimet
ype + " is supported"); |
57 assert_true(MediaSource.isTypeSupported(audioMimetype), audioMimet
ype + " is supported"); | 65 assert_true(MediaSource.isTypeSupported(audioMimetype), audioMimet
ype + " is supported"); |
58 | 66 |
59 var sourceBufferA = mediaSource.addSourceBuffer(videoMimetype); | 67 var sourceBufferA = mediaSource.addSourceBuffer(videoMimetype); |
60 var sourceBufferB = mediaSource.addSourceBuffer(audioMimetype); | 68 var sourceBufferB = mediaSource.addSourceBuffer(audioMimetype); |
61 assert_equals(mediaSource.sourceBuffers[0], sourceBufferA, "source
BufferA is in mediaSource.sourceBuffers"); | 69 assert_equals(mediaSource.sourceBuffers[0], sourceBufferA, "source
BufferA is in mediaSource.sourceBuffers"); |
62 assert_equals(mediaSource.activeSourceBuffers[0], sourceBufferA, "
sourceBufferA is in mediaSource.activeSourceBuffers"); | 70 assert_equals(mediaSource.activeSourceBuffers[0], sourceBufferA, "
sourceBufferA is in mediaSource.activeSourceBuffers"); |
63 assert_equals(mediaSource.sourceBuffers[1], sourceBufferB, "source
BufferB is in mediaSource.sourceBuffers"); | 71 assert_equals(mediaSource.sourceBuffers[1], sourceBufferB, "source
BufferB is in mediaSource.sourceBuffers"); |
64 assert_equals(mediaSource.activeSourceBuffers[1], sourceBufferB, "
sourceBufferB is in mediaSource.activeSourceBuffers"); | 72 assert_equals(mediaSource.activeSourceBuffers[1], sourceBufferB, "
sourceBufferB is in mediaSource.activeSourceBuffers"); |
65 test.done(); | 73 test.done(); |
66 }, "Test addSourceBuffer() with Vorbis and VP8 in separate SourceBuffe
rs"); | 74 }, "Test addSourceBuffer() with Vorbis and VP8 in separate SourceBuffe
rs"); |
67 | 75 |
68 mediasource_test(function(test, mediaElement, mediaSource) | 76 mediasource_test(function(test, mediaElement, mediaSource) |
69 { | 77 { |
| 78 var mimetype = MediaSourceUtil.VIDEO_ONLY_TYPE; |
| 79 |
| 80 assert_true(MediaSource.isTypeSupported(mimetype), mimetype + " is
supported"); |
| 81 |
| 82 var sourceBuffer = mediaSource.addSourceBuffer(mimetype); |
| 83 assert_true(sourceBuffer != null, "New SourceBuffer returned"); |
| 84 assert_equals(mediaSource.sourceBuffers[0], sourceBuffer, "SourceB
uffer is in mediaSource.sourceBuffers"); |
| 85 assert_equals(mediaSource.activeSourceBuffers[0], sourceBuffer, "S
ourceBuffer is in mediaSource.activeSourceBuffers"); |
| 86 test.done(); |
| 87 }, "Test addSourceBuffer() video only"); |
| 88 |
| 89 mediasource_test(function(test, mediaElement, mediaSource) |
| 90 { |
| 91 var mimetype = MediaSourceUtil.AUDIO_ONLY_TYPE; |
| 92 |
| 93 assert_true(MediaSource.isTypeSupported(mimetype), mimetype + " is
supported"); |
| 94 |
| 95 var sourceBuffer = mediaSource.addSourceBuffer(mimetype); |
| 96 assert_true(sourceBuffer != null, "New SourceBuffer returned"); |
| 97 assert_equals(mediaSource.sourceBuffers[0], sourceBuffer, "SourceB
uffer is in mediaSource.sourceBuffers"); |
| 98 assert_equals(mediaSource.activeSourceBuffers[0], sourceBuffer, "S
ourceBuffer is in mediaSource.activeSourceBuffers"); |
| 99 test.done(); |
| 100 }, "Test addSourceBuffer() audio only"); |
| 101 |
| 102 mediasource_test(function(test, mediaElement, mediaSource) |
| 103 { |
70 var mimetype = 'video/mp4;codecs="avc1.4D4001,mp4a.40.2"'; | 104 var mimetype = 'video/mp4;codecs="avc1.4D4001,mp4a.40.2"'; |
71 | 105 |
72 assert_true(MediaSource.isTypeSupported(mimetype), mimetype + " is
supported"); | 106 assert_true(MediaSource.isTypeSupported(mimetype), mimetype + " is
supported"); |
73 | 107 |
74 var sourceBuffer = mediaSource.addSourceBuffer(mimetype); | 108 var sourceBuffer = mediaSource.addSourceBuffer(mimetype); |
75 assert_true(sourceBuffer != null, "New SourceBuffer returned"); | 109 assert_true(sourceBuffer != null, "New SourceBuffer returned"); |
76 assert_equals(mediaSource.sourceBuffers[0], sourceBuffer, "SourceB
uffer is in mediaSource.sourceBuffers"); | 110 assert_equals(mediaSource.sourceBuffers[0], sourceBuffer, "SourceB
uffer is in mediaSource.sourceBuffers"); |
77 assert_equals(mediaSource.activeSourceBuffers[0], sourceBuffer, "S
ourceBuffer is in mediaSource.activeSourceBuffers"); | 111 assert_equals(mediaSource.activeSourceBuffers[0], sourceBuffer, "S
ourceBuffer is in mediaSource.activeSourceBuffers"); |
78 test.done(); | 112 test.done(); |
79 }, "Test addSourceBuffer() with AAC and H.264"); | 113 }, "Test addSourceBuffer() with AAC and H.264"); |
(...skipping 29 matching lines...) Expand all Loading... |
109 reachedLimit = true; | 143 reachedLimit = true; |
110 break; | 144 break; |
111 } | 145 } |
112 } | 146 } |
113 assert_true(reachedLimit, "Reached SourceBuffer limit."); | 147 assert_true(reachedLimit, "Reached SourceBuffer limit."); |
114 test.done(); | 148 test.done(); |
115 }, "Test addSourceBuffer() QuotaExceededError."); | 149 }, "Test addSourceBuffer() QuotaExceededError."); |
116 </script> | 150 </script> |
117 </body> | 151 </body> |
118 </html> | 152 </html> |
OLD | NEW |