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

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

Issue 245893002: Improve unprefixed MediaSource test coverage. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 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 function ErrorTest(testFunction, description)
13 {
14 mediasource_test(function(test, mediaElement, mediaSource)
15 {
16 var segmentInfo = MediaSourceUtil.SEGMENT_INFO;
17
18 if (!segmentInfo) {
19 assert_unreached("No segment info compatible with this M ediaSource implementation.");
20 return;
21 }
22
23 var sourceBuffer = mediaSource.addSourceBuffer(segmentInfo.t ype);
24 MediaSourceUtil.loadBinaryData(test, segmentInfo.url, functi on(mediaData)
25 {
26 testFunction(test, mediaElement, mediaSource, segmentInf o, sourceBuffer, mediaData);
27 });
28 }, description);
29 }
30
31 ErrorTest(function(test, mediaElement, mediaSource, segmentInfo, sou rceBuffer, mediaData)
32 {
33 var mediaSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.media[0]);
34
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);
39
40 test.waitForExpectedEvents(function()
41 {
42 assert_true(mediaElement.error != null);
43 assert_equals(mediaElement.error.code, MediaError.MEDIA_ERR_ SRC_NOT_SUPPORTED);
44
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. ");
50
51 ErrorTest(function(test, mediaElement, mediaSource, segmentInfo, sou rceBuffer, mediaData)
52 {
53 assert_equals(mediaElement.readyState, HTMLMediaElement.HAVE_NOT HING);
54
55 test.expectEvent(mediaElement, "error", "mediaElement error.");
56 test.expectEvent(mediaSource, "sourceended", "mediaSource ended. ");
57 test.expectEvent(mediaSource, "sourceclose", "mediaSource closed .");
58
59 mediaSource.endOfStream("decode");
60
61 test.waitForExpectedEvents(function()
62 {
63 assert_true(mediaElement.error != null);
64 assert_equals(mediaElement.error.code, MediaError.MEDIA_ERR_ SRC_NOT_SUPPORTED);
65
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.");
71
72 ErrorTest(function(test, mediaElement, mediaSource, segmentInfo, sou rceBuffer, mediaData)
73 {
74 assert_equals(mediaElement.readyState, HTMLMediaElement.HAVE_NOT HING);
75
76 test.expectEvent(mediaElement, "error", "mediaElement error.");
77 test.expectEvent(mediaSource, "sourceended", "mediaSource ended. ");
78 test.expectEvent(mediaSource, "sourceclose", "mediaSource closed .");
79
80 mediaSource.endOfStream("network");
81
82 test.waitForExpectedEvents(function()
83 {
84 assert_true(mediaElement.error != null);
85 assert_equals(mediaElement.error.code, MediaError.MEDIA_ERR_ SRC_NOT_SUPPORTED);
86
87 assert_equals(mediaSource.sourceBuffers.length, 0);
88 assert_equals(mediaSource.readyState, "closed");
89 test.done();
90 });
91 }, "Signaling 'network' error via endOfStream() before initializatio n segment has been appended.");
92
93 ErrorTest(function(test, mediaElement, mediaSource, segmentInfo, sou rceBuffer, mediaData)
94 {
95 var initSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.init);
96 assert_equals(mediaElement.readyState, HTMLMediaElement.HAVE_NOT HING);
97
98 test.expectEvent(sourceBuffer, "updateend", "mediaSegment append ended.");
99 test.expectEvent(mediaElement, "loadedmetadata", "mediaElement m etadata.");
100 sourceBuffer.appendBuffer(initSegment);
101
102 test.waitForExpectedEvents(function()
103 {
104 assert_equals(mediaElement.readyState, HTMLMediaElement.HAVE _METADATA);
105
106 test.expectEvent(mediaElement, "error", "mediaElement error. ");
107 test.expectEvent(mediaSource, "sourceended", "mediaSource en ded.");
108 test.expectEvent(mediaSource, "sourceclose", "mediaSource cl osed.");
109
110 mediaSource.endOfStream("decode");
111 });
112
113 test.waitForExpectedEvents(function()
114 {
115 assert_true(mediaElement.error != null);
116 assert_equals(mediaElement.error.code, MediaError.MEDIA_ERR_ DECODE);
117
118 assert_equals(mediaSource.sourceBuffers.length, 0);
119 assert_equals(mediaSource.readyState, "closed");
120 test.done();
121 });
122 }, "Signaling 'decode' error via endOfStream() after initialization segment has been appended and the HTMLMediaElement has reached HAVE_METADATA.");
123
124 ErrorTest(function(test, mediaElement, mediaSource, segmentInfo, sou rceBuffer, mediaData)
125 {
126 var initSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.init);
127 assert_equals(mediaElement.readyState, HTMLMediaElement.HAVE_NOT HING);
128
129 test.expectEvent(sourceBuffer, "updateend", "mediaSegment append ended.");
130 test.expectEvent(mediaElement, "loadedmetadata", "mediaElement m etadata.");
131 sourceBuffer.appendBuffer(initSegment);
132
133 test.waitForExpectedEvents(function()
134 {
135 assert_equals(mediaElement.readyState, HTMLMediaElement.HAVE _METADATA);
136
137 test.expectEvent(mediaElement, "error", "mediaElement error. ");
138 test.expectEvent(mediaSource, "sourceended", "mediaSource en ded.");
139 test.expectEvent(mediaSource, "sourceclose", "mediaSource cl osed.");
140
141 mediaSource.endOfStream("network");
142 });
143
144 test.waitForExpectedEvents(function()
145 {
146 assert_true(mediaElement.error != null);
147 assert_equals(mediaElement.error.code, MediaError.MEDIA_ERR_ NETWORK);
148
149 assert_equals(mediaSource.sourceBuffers.length, 0);
150 assert_equals(mediaSource.readyState, "closed");
151 test.done();
152 });
153 }, "Signaling 'network' error via endOfStream() after initialization segment has been appended and the HTMLMediaElement has reached HAVE_METADATA.") ;
154 </script>
155 </body>
156 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698