Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: LayoutTests/http/tests/media/media-source/mediasource-closed.html

Issue 16625011: Add minimal implementation of unprefixed MediaSource API that has feature parity with prefixed API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix global-constructors-listing-expected.txt Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 test(function ()
13 {
14 var mediaSource = new MediaSource();
15 assert_equals(mediaSource.sourceBuffers.length, 0, "sourceBuffers is empty");
16 assert_equals(mediaSource.activeSourceBuffers.length, 0, "activeSo urceBuffers is empty");
17 assert_equals(mediaSource.readyState, "closed", "readyState is 'cl osed'");
18 assert_true(Number.isNaN(mediaSource.duration), "duration is NaN") ;
19 }, "Test attribute values on a closed MediaSource object.");
20
21 test(function ()
22 {
23 var mediaSource = new MediaSource();
24 assert_throws("InvalidStateError",
25 function() { mediaSource.addSourceBuffer('video/webm;codecs="v p8"'); },
26 "addSourceBuffer() throws an exception when closed.");
27 }, "Test addSourceBuffer() while closed.");
28
29 mediasource_test(function(test, mediaElement, mediaSource)
30 {
31 var VORBIS_TYPE = 'video/webm;codecs="vorbis"';
32 var AAC_TYPE = 'video/mp4;codecs="mp4a.40.2"';
33 var mediaType = MediaSource.isTypeSupported(VORBIS_TYPE) ? VORBIS_ TYPE : AAC_TYPE;
34 var sourceBuffer = mediaSource.addSourceBuffer(mediaType);
35
36 // Setup a handler to run when the MediaSource closes.
37 mediaSource.addEventListener('sourceclose', test.step_func(functio n (event)
38 {
39 assert_equals(mediaSource.sourceBuffers.length, 0, "sourceBuff ers is empty");
40 assert_equals(mediaSource.activeSourceBuffers.length, 0, "acti veSourceBuffers is empty");
41 assert_equals(mediaSource.readyState, "closed", "readyState is 'closed'");
42 assert_throws("NotFoundError",
43 function() { mediaSource.removeSourceBuffer(sourceBuffer); },
44 "removeSourceBuffer() throws an exception when closed.");
45 test.done();
46 }));
47
48 // Trigger the MediaSource to close.
49 mediaElement.src = "";
50 }, "Test removeSourceBuffer() while closed.");
51
52 test(function ()
53 {
54 var mediaSource = new MediaSource();
55 assert_throws("InvalidStateError",
56 function() { mediaSource.endOfStream(); },
57 "endOfStream() throws an exception when closed.");
58 }, "Test endOfStream() while closed.");
59
60
61 test(function ()
62 {
63 var mediaSource = new MediaSource();
64 assert_throws("InvalidStateError",
65 function() { mediaSource.duration = 10; },
66 "Setting duration throws an exception when closed.");
67 }, "Test setting duration while closed.");
68
69 </script>
70 </body>
71 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698