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'
>
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');
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');
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");
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");
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");
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');
97 }, 'Test MediaSource.endOfStream() with invalid null error parameter.');