Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / media / media-source / mediasource-endofstream-invaliderror.html
blob1c86c9ab5e8246487419a91a05a0eacb667788d0
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_test(function(test, mediaElement, mediaSource)
14 test.failOnEvent(mediaElement, 'error');
15 assert_equals(mediaSource.readyState, 'open');
17 assert_throws(new TypeError(),
18 function() { mediaSource.endOfStream('garbage'); },
19 'endOfStream(\'garbage\') throws TypeError');
21 assert_equals(mediaSource.readyState, 'open');
22 test.done();
23 }, 'Test MediaSource.endOfStream() with invalid non-empty error string.');
25 mediasource_test(function(test, mediaElement, mediaSource)
27 test.failOnEvent(mediaElement, 'error');
28 assert_equals(mediaSource.readyState, 'open');
30 assert_throws(new TypeError(),
31 function() { mediaSource.endOfStream(''); },
32 'endOfStream(\'\') throws TypeError');
34 assert_equals(mediaSource.readyState, 'open');
35 test.done();
36 }, 'Test MediaSource.endOfStream() with invalid empty error string.');
38 mediasource_test(function(test, mediaElement, mediaSource)
40 test.failOnEvent(mediaElement, 'error');
41 assert_equals(mediaSource.readyState, 'open');
43 test.expectEvent(mediaSource, 'sourceend');
44 mediaSource.endOfStream();
46 assert_equals(mediaSource.readyState, 'ended');
47 assert_throws("InvalidStateError",
48 function() { mediaSource.endOfStream(); },
49 "endofStream() threw an exception when in ended state");
51 test.done();
52 }, 'Test MediaSource.endOfStream() with when readyState is ended.');
54 mediasource_test(function(test, mediaElement, mediaSource)
56 test.failOnEvent(mediaElement, 'error');
57 assert_equals(mediaSource.readyState, 'open');
59 test.expectEvent(mediaSource, 'sourceend');
60 mediaSource.endOfStream();
62 assert_equals(mediaSource.readyState, 'ended');
63 assert_throws("InvalidStateError",
64 function() { mediaSource.endOfStream("decode"); },
65 "endofStream() threw an exception when in ended state");
67 test.done();
68 }, 'Test MediaSource.endOfStream(decode) with when readyState is ended.');
70 mediasource_test(function(test, mediaElement, mediaSource)
72 test.failOnEvent(mediaElement, 'error');
73 assert_equals(mediaSource.readyState, 'open');
75 test.expectEvent(mediaSource, 'sourceend');
76 mediaSource.endOfStream();
78 assert_equals(mediaSource.readyState, 'ended');
79 assert_throws("InvalidStateError",
80 function() { mediaSource.endOfStream("network"); },
81 "endofStream() threw an exception when in ended state");
83 test.done();
84 }, 'Test MediaSource.endOfStream(network) with when readyState is ended.');
86 mediasource_test(function(test, mediaElement, mediaSource)
88 test.failOnEvent(mediaElement, 'error');
89 assert_equals(mediaSource.readyState, 'open');
91 assert_throws(new TypeError(),
92 function() { mediaSource.endOfStream(null); },
93 'endOfStream(null) throws TypeError');
95 assert_equals(mediaSource.readyState, 'open');
96 test.done();
97 }, 'Test MediaSource.endOfStream() with invalid null error parameter.');
98 </script>
99 </body>
100 </html>