OLD | NEW |
1 (function(window) { | 1 (function(window) { |
2 EventExpectationsManager = function(test) { | 2 EventExpectationsManager = function(test) { |
3 this.test_ = test; | 3 this.test_ = test; |
4 this.eventTargetList_ = []; | 4 this.eventTargetList_ = []; |
5 this.waitCallbacks_ = []; | 5 this.waitCallbacks_ = []; |
6 }; | 6 }; |
7 | 7 |
8 EventExpectationsManager.prototype.expectEvent = function(object, eventName,
description) | 8 EventExpectationsManager.prototype.expectEvent = function(object, eventName,
description) |
9 { | 9 { |
10 var eventInfo = { 'target': object, 'type': eventName, 'description': de
scription}; | 10 var eventInfo = { 'target': object, 'type': eventName, 'description': de
scription}; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 request.onload = test.step_func(function(event) | 75 request.onload = test.step_func(function(event) |
76 { | 76 { |
77 if (request.status != 200) { | 77 if (request.status != 200) { |
78 assert_unreached("Unexpected status code : " + request.status); | 78 assert_unreached("Unexpected status code : " + request.status); |
79 return; | 79 return; |
80 } | 80 } |
81 var response = request.response; | 81 var response = request.response; |
82 if (isBinary) { | 82 if (isBinary) { |
83 response = new Uint8Array(response); | 83 response = new Uint8Array(response); |
84 } | 84 } |
85 callback(new Uint8Array(response)); | 85 callback(response); |
86 }); | 86 }); |
87 request.onerror = test.step_func(function(event) | 87 request.onerror = test.step_func(function(event) |
88 { | 88 { |
89 assert_unreached("Unexpected error"); | 89 assert_unreached("Unexpected error"); |
90 }); | 90 }); |
91 request.send(); | 91 request.send(); |
92 } | 92 } |
93 | 93 |
94 function openMediaSource_(test, mediaTag, callback) | 94 function openMediaSource_(test, mediaTag, callback) |
95 { | 95 { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 var oldTestDone = test.done.bind(test); | 165 var oldTestDone = test.done.bind(test); |
166 test.done = function() | 166 test.done = function() |
167 { | 167 { |
168 if (test.status == test.PASS) | 168 if (test.status == test.PASS) |
169 assert_false(test.eventExpectations_.expectingEvents(), "No pend
ing event expectations."); | 169 assert_false(test.eventExpectations_.expectingEvents(), "No pend
ing event expectations."); |
170 oldTestDone(); | 170 oldTestDone(); |
171 }; | 171 }; |
172 }; | 172 }; |
173 | 173 |
174 window['MediaSourceUtil'] = MediaSourceUtil; | 174 window['MediaSourceUtil'] = MediaSourceUtil; |
175 window['mediasource_test'] = function(testFunction, description) | 175 window['mediasource_test'] = function(testFunction, description, options) |
176 { | 176 { |
| 177 options = options || {}; |
177 return async_test(function(test) { | 178 return async_test(function(test) { |
178 var mediaTag = document.createElement("video"); | 179 var mediaTag = document.createElement("video"); |
179 document.body.appendChild(mediaTag); | 180 document.body.appendChild(mediaTag); |
180 | 181 |
181 addExtraTestMethods(test); | 182 addExtraTestMethods(test); |
182 | 183 |
183 // Overload done() so that element added to the document can be remo
ved. | 184 // Overload done() so that element added to the document can be remo
ved. |
184 test.removeMediaElement_ = true; | 185 test.removeMediaElement_ = true; |
185 var oldTestDone = test.done.bind(test); | 186 var oldTestDone = test.done.bind(test); |
186 test.done = function() | 187 test.done = function() |
187 { | 188 { |
188 if (test.removeMediaElement_) { | 189 if (test.removeMediaElement_) { |
189 document.body.removeChild(mediaTag); | 190 document.body.removeChild(mediaTag); |
190 test.removeMediaElement_ = false; | 191 test.removeMediaElement_ = false; |
191 } | 192 } |
192 oldTestDone(); | 193 oldTestDone(); |
193 }; | 194 }; |
194 | 195 |
195 openMediaSource_(test, mediaTag, function(mediaSource) | 196 openMediaSource_(test, mediaTag, function(mediaSource) |
196 { | 197 { |
197 testFunction(test, mediaTag, mediaSource); | 198 testFunction(test, mediaTag, mediaSource); |
198 }); | 199 }); |
199 }, description); | 200 }, description, options); |
200 | 201 |
201 }; | 202 }; |
202 })(window); | 203 })(window); |
OLD | NEW |