Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / media / media-source / mediasource-sourcebuffer-trackdefaults.html
blobf21c364766d062425640ebd937d70776bffe199f
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>
8 <link rel='stylesheet' href='/w3c/resources/testharness.css'>
9 </head>
10 <body>
11 <div id="log"></div>
12 <script>
14 function sourceBufferTrackDefaultsTest(callback, description)
16 mediasource_test(function(test, mediaElement, mediaSource)
18 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_VIDEO_TYPE);
19 assert_array_equals(sourceBuffer.trackDefaults, [], "Empty initial SourceBuffer.trackDefaults");
20 callback(test, mediaElement, mediaSource, sourceBuffer);
21 }, description);
24 sourceBufferTrackDefaultsTest(function(test, mediaElement, mediaSource, sourceBuffer)
26 var emptyList = new TrackDefaultList([]);
27 assert_not_equals(sourceBuffer.trackDefaults, emptyList, "Initial trackDefaults object differs from new empty list");
29 sourceBuffer.trackDefaults = emptyList;
31 assert_array_equals(sourceBuffer.trackDefaults, [], "Round-tripped empty trackDefaults");
32 assert_equals(sourceBuffer.trackDefaults, emptyList, "Round-tripped the empty TrackDefaultList object");
33 test.done();
34 }, "Test round-trip of empty SourceBuffer.trackDefaults");
36 sourceBufferTrackDefaultsTest(function(test, mediaElement, mediaSource, sourceBuffer)
38 var trackDefault = new TrackDefault("audio", "en-US", "audio label", ["main"], "1");
39 var trackDefaults = new TrackDefaultList([ trackDefault ]);
41 sourceBuffer.trackDefaults = trackDefaults;
43 assert_array_equals(sourceBuffer.trackDefaults, trackDefaults, "Round-tripped non-empty trackDefaults");
44 assert_equals(sourceBuffer.trackDefaults.length, 1, "Confirmed non-empty trackDefaults");
45 assert_equals(sourceBuffer.trackDefaults, trackDefaults, "Round-tripped the non-empty TrackDefaultList object");
46 test.done();
47 }, "Test round-trip of non-empty SourceBuffer.trackDefaults");
49 sourceBufferTrackDefaultsTest(function(test, mediaElement, mediaSource, sourceBuffer)
51 mediaSource.removeSourceBuffer(sourceBuffer);
52 assert_throws("InvalidStateError",
53 function() { sourceBuffer.trackDefaults = new TrackDefaultList([]); },
54 "Exception thrown when setting trackDefaults on SourceBuffer that is removed from MediaSource");
55 test.done();
56 }, "Test setting trackDefaults on an already-removed SourceBuffer");
58 mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
60 assert_array_equals(sourceBuffer.trackDefaults, [], "Empty initial SourceBuffer.trackDefaults");
61 test.expectEvent(sourceBuffer, "updateend", "Append ended");
62 sourceBuffer.appendBuffer(mediaData);
63 assert_true(sourceBuffer.updating, "SourceBuffer is updating");
65 assert_throws("InvalidStateError",
66 function() { sourceBuffer.trackDefaults = new TrackDefaultList([]); },
67 "Exception thrown when setting trackDefaults on SourceBuffer that is updating");
69 test.waitForExpectedEvents(function()
71 assert_false(sourceBuffer.updating, "SourceBuffer is not updating");
72 sourceBuffer.trackDefaults = new TrackDefaultList([]);
73 test.done();
74 });
75 }, "Test setting trackDefaults on a SourceBuffer that is updating");
77 sourceBufferTrackDefaultsTest(function(test, mediaElement, mediaSource, sourceBuffer)
79 assert_throws(new TypeError(),
80 function() { sourceBuffer.trackDefaults = null; },
81 "null should be disallowed by trackDefaults setter");
82 test.done();
83 }, "Test setting null SourceBuffer.trackDefaults");
84 </script>
85 </body>
86 </html>