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 18 matching lines...) Expand all Loading... |
29 mediasource_test(function(test, mediaElement, mediaSource) | 29 mediasource_test(function(test, mediaElement, mediaSource) |
30 { | 30 { |
31 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUD
IO_ONLY_TYPE); | 31 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUD
IO_ONLY_TYPE); |
32 | 32 |
33 // Setup a handler to run when the MediaSource closes. | 33 // Setup a handler to run when the MediaSource closes. |
34 mediaSource.addEventListener('sourceclose', test.step_func(functio
n (event) | 34 mediaSource.addEventListener('sourceclose', test.step_func(functio
n (event) |
35 { | 35 { |
36 assert_equals(mediaSource.sourceBuffers.length, 0, "sourceBuff
ers is empty"); | 36 assert_equals(mediaSource.sourceBuffers.length, 0, "sourceBuff
ers is empty"); |
37 assert_equals(mediaSource.activeSourceBuffers.length, 0, "acti
veSourceBuffers is empty"); | 37 assert_equals(mediaSource.activeSourceBuffers.length, 0, "acti
veSourceBuffers is empty"); |
38 assert_equals(mediaSource.readyState, "closed", "readyState is
'closed'"); | 38 assert_equals(mediaSource.readyState, "closed", "readyState is
'closed'"); |
| 39 assert_true(Number.isNaN(mediaSource.duration), "duration is N
aN"); |
39 assert_throws("NotFoundError", | 40 assert_throws("NotFoundError", |
40 function() { mediaSource.removeSourceBuffer(sourceBuffer);
}, | 41 function() { mediaSource.removeSourceBuffer(sourceBuffer);
}, |
41 "removeSourceBuffer() throws an exception when closed."); | 42 "removeSourceBuffer() throws an exception when closed."); |
42 test.done(); | 43 test.done(); |
43 })); | 44 })); |
44 | 45 |
45 // Trigger the MediaSource to close. | 46 // Trigger the MediaSource to close. |
46 mediaElement.src = ""; | 47 mediaElement.src = ""; |
47 }, "Test removeSourceBuffer() while closed."); | 48 }, "Test removeSourceBuffer() while closed."); |
48 | 49 |
49 test(function () | 50 test(function () |
50 { | 51 { |
51 var mediaSource = new MediaSource(); | 52 var mediaSource = new MediaSource(); |
52 assert_throws("InvalidStateError", | 53 assert_throws("InvalidStateError", |
53 function() { mediaSource.endOfStream(); }, | 54 function() { mediaSource.endOfStream(); }, |
54 "endOfStream() throws an exception when closed."); | 55 "endOfStream() throws an exception when closed."); |
55 }, "Test endOfStream() while closed."); | 56 }, "Test endOfStream() while closed."); |
56 | 57 |
| 58 test(function () |
| 59 { |
| 60 var mediaSource = new MediaSource(); |
| 61 assert_throws("InvalidStateError", |
| 62 function() { mediaSource.endOfStream("decode"); }, |
| 63 "endOfStream(decode) throws an exception when closed."); |
| 64 }, "Test endOfStream(decode) while closed."); |
| 65 |
| 66 test(function () |
| 67 { |
| 68 var mediaSource = new MediaSource(); |
| 69 assert_throws("InvalidStateError", |
| 70 function() { mediaSource.endOfStream("network"); }, |
| 71 "endOfStream(network) throws an exception when closed."); |
| 72 }, "Test endOfStream(network) while closed."); |
| 73 |
57 | 74 |
58 test(function () | 75 test(function () |
59 { | 76 { |
60 var mediaSource = new MediaSource(); | 77 var mediaSource = new MediaSource(); |
61 assert_throws("InvalidStateError", | 78 assert_throws("InvalidStateError", |
62 function() { mediaSource.duration = 10; }, | 79 function() { mediaSource.duration = 10; }, |
63 "Setting duration throws an exception when closed."); | 80 "Setting duration throws an exception when closed."); |
64 }, "Test setting duration while closed."); | 81 }, "Test setting duration while closed."); |
65 | 82 |
| 83 mediasource_test(function(test, mediaElement, mediaSource) |
| 84 { |
| 85 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUD
IO_ONLY_TYPE); |
| 86 |
| 87 assert_equals(mediaSource.readyState, "open", "readyState is 'open
'"); |
| 88 // Setup a handler to run when the MediaSource closes. |
| 89 mediaSource.addEventListener('sourceclose', test.step_func(functio
n (event) |
| 90 { |
| 91 assert_equals(mediaSource.readyState, "closed", "readyState is
'closed'"); |
| 92 assert_throws("InvalidStateError", |
| 93 function() { mediaSource.duration = 10; }, |
| 94 "Setting duration when closed throws an exception"); |
| 95 test.done(); |
| 96 })); |
| 97 |
| 98 // Trigger the MediaSource to close. |
| 99 mediaElement.src = ""; |
| 100 }, "Test setting duration while open->closed."); |
| 101 |
| 102 mediasource_test(function(test, mediaElement, mediaSource) |
| 103 { |
| 104 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUD
IO_ONLY_TYPE); |
| 105 |
| 106 assert_equals(mediaSource.readyState, "open", "readyState is 'open
'"); |
| 107 // Setup a handler to run when the MediaSource closes. |
| 108 mediaSource.addEventListener('sourceclose', test.step_func(functio
n (event) |
| 109 { |
| 110 assert_equals(mediaSource.readyState, "closed", "readyState is
'closed'"); |
| 111 assert_true(Number.isNaN(mediaSource.duration), "duration is N
aN"); |
| 112 test.done(); |
| 113 })); |
| 114 |
| 115 // Trigger the MediaSource to close. |
| 116 mediaElement.src = ""; |
| 117 }, "Test getting duration while open->closed."); |
66 </script> | 118 </script> |
67 </body> | 119 </body> |
68 </html> | 120 </html> |
OLD | NEW |