Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / media / media-source / mediasource-errors.html
blob3effd166371540b6754353a361fb78dab55cce43
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 function ErrorTest(testFunction, description)
14 mediasource_test(function(test, mediaElement, mediaSource)
16 var segmentInfo = MediaSourceUtil.SEGMENT_INFO;
18 if (!segmentInfo) {
19 assert_unreached("No segment info compatible with this MediaSource implementation.");
20 return;
23 var sourceBuffer = mediaSource.addSourceBuffer(segmentInfo.type);
24 MediaSourceUtil.loadBinaryData(test, segmentInfo.url, function(mediaData)
26 testFunction(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData);
27 });
28 }, description);
31 ErrorTest(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
33 var mediaSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.media[0]);
35 test.expectEvent(sourceBuffer, "updateend", "mediaSegment append ended.");
36 test.expectEvent(mediaElement, "error", "mediaElement error.");
37 test.expectEvent(mediaSource, "sourceclose", "mediaSource closed.");
38 sourceBuffer.appendBuffer(mediaSegment);
40 test.waitForExpectedEvents(function()
42 assert_true(mediaElement.error != null);
43 assert_equals(mediaElement.error.code, MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED);
45 assert_equals(mediaSource.sourceBuffers.length, 0);
46 assert_equals(mediaSource.readyState, "closed");
47 test.done();
48 });
49 }, "Appending media segment before the first initialization segment.");
51 ErrorTest(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
53 assert_equals(mediaElement.readyState, HTMLMediaElement.HAVE_NOTHING);
55 test.expectEvent(mediaElement, "error", "mediaElement error.");
56 test.expectEvent(mediaSource, "sourceended", "mediaSource ended.");
57 test.expectEvent(mediaSource, "sourceclose", "mediaSource closed.");
59 mediaSource.endOfStream("decode");
61 test.waitForExpectedEvents(function()
63 assert_true(mediaElement.error != null);
64 assert_equals(mediaElement.error.code, MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED);
66 assert_equals(mediaSource.sourceBuffers.length, 0);
67 assert_equals(mediaSource.readyState, "closed");
68 test.done();
69 });
70 }, "Signaling 'decode' error via endOfStream() before initialization segment has been appended.");
72 ErrorTest(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
74 assert_equals(mediaElement.readyState, HTMLMediaElement.HAVE_NOTHING);
76 test.expectEvent(mediaElement, "error", "mediaElement error.");
77 test.expectEvent(mediaSource, "sourceended", "mediaSource ended.");
78 test.expectEvent(mediaSource, "sourceclose", "mediaSource closed.");
80 mediaSource.endOfStream("network");
82 test.waitForExpectedEvents(function()
84 assert_true(mediaElement.error != null);
85 assert_equals(mediaElement.error.code, MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED);
87 assert_equals(mediaSource.sourceBuffers.length, 0);
88 assert_equals(mediaSource.readyState, "closed");
89 test.done();
90 });
91 }, "Signaling 'network' error via endOfStream() before initialization segment has been appended.");
93 ErrorTest(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
95 var initSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.init);
96 assert_equals(mediaElement.readyState, HTMLMediaElement.HAVE_NOTHING);
98 test.expectEvent(sourceBuffer, "updateend", "mediaSegment append ended.");
99 test.expectEvent(mediaElement, "loadedmetadata", "mediaElement metadata.");
100 sourceBuffer.appendBuffer(initSegment);
102 test.waitForExpectedEvents(function()
104 assert_equals(mediaElement.readyState, HTMLMediaElement.HAVE_METADATA);
106 test.expectEvent(mediaElement, "error", "mediaElement error.");
107 test.expectEvent(mediaSource, "sourceended", "mediaSource ended.");
108 mediaSource.endOfStream("decode");
111 test.waitForExpectedEvents(function()
113 assert_true(mediaElement.error != null);
114 assert_equals(mediaElement.error.code, MediaError.MEDIA_ERR_DECODE);
115 assert_equals(mediaSource.readyState, "ended");
116 test.done();
118 }, "Signaling 'decode' error via endOfStream() after initialization segment has been appended and the HTMLMediaElement has reached HAVE_METADATA.");
120 ErrorTest(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
122 var initSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.init);
123 assert_equals(mediaElement.readyState, HTMLMediaElement.HAVE_NOTHING);
125 test.expectEvent(sourceBuffer, "updateend", "mediaSegment append ended.");
126 test.expectEvent(mediaElement, "loadedmetadata", "mediaElement metadata.");
127 sourceBuffer.appendBuffer(initSegment);
129 test.waitForExpectedEvents(function()
131 assert_equals(mediaElement.readyState, HTMLMediaElement.HAVE_METADATA);
133 test.expectEvent(mediaElement, "error", "mediaElement error.");
134 test.expectEvent(mediaSource, "sourceended", "mediaSource ended.");
135 mediaSource.endOfStream("network");
138 test.waitForExpectedEvents(function()
140 assert_true(mediaElement.error != null);
141 assert_equals(mediaElement.error.code, MediaError.MEDIA_ERR_NETWORK);
142 assert_equals(mediaSource.readyState, "ended");
143 test.done();
145 }, "Signaling 'network' error via endOfStream() after initialization segment has been appended and the HTMLMediaElement has reached HAVE_METADATA.");
147 ErrorTest(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
149 assert_equals(mediaElement.readyState, HTMLMediaElement.HAVE_NOTHING);
151 var mediaSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.media[0]);
152 var index = segmentInfo.init.size + (mediaSegment.length - 1) / 2;
153 // Corrupt the media data from index of mediaData, so it can signal 'decode' error.
154 // Here use mediaSegment to replace the original mediaData[index, index + mediaSegment.length]
155 mediaData.set(mediaSegment, index);
157 test.expectEvent(mediaElement, "error", "mediaElement error.");
158 sourceBuffer.appendBuffer(mediaData);
160 test.waitForExpectedEvents(function()
162 assert_true(mediaElement.error != null);
163 assert_equals(mediaElement.error.code, MediaError.MEDIA_ERR_DECODE);
164 test.done();
166 }, "Signaling 'decode' error via segment parser loop algorithm after initialization segment and partial media segment has been appended.");
167 </script>
168 </body>
169 </html>