| Index: media/test/data/player.html
|
| diff --git a/media/test/data/player.html b/media/test/data/player.html
|
| index 7577d8619f9cc173116311f28cb52000353615ba..1f891b0511cb68093053e94157566df54e42af14 100644
|
| --- a/media/test/data/player.html
|
| +++ b/media/test/data/player.html
|
| @@ -1,11 +1,18 @@
|
| <html>
|
| <body onload="RunTest();">
|
| <div id="player_container"></div>
|
| +<div id="logs"></div>
|
| </body>
|
|
|
| <script type="text/javascript">
|
| // <audio> or <video> player element.
|
| var player;
|
| +var logs = document.getElementById('logs');
|
| +
|
| +function Log(message) {
|
| + logs.innerHTML = message + '<br>' + logs.innerHTML;
|
| + console.log(message);
|
| +}
|
|
|
| // Listen for |event| from |element|, set document.title = |event| upon event.
|
| function InstallTitleEventHandler(element, event) {
|
| @@ -14,6 +21,28 @@ function InstallTitleEventHandler(element, event) {
|
| }, false);
|
| }
|
|
|
| +function InstallTitleErrorEventHandler(element, error_substr) {
|
| + element.addEventListener('error', function(e) {
|
| + // Element's error attribute must be populated.
|
| + var mediaError = element.error;
|
| + if (mediaError == null) {
|
| + Log('ERROR: Null element error attribute while handling error event.');
|
| + Failed();
|
| + return;
|
| + }
|
| +
|
| + Log('INFO: Element error message is ' + mediaError.message);
|
| +
|
| + if (error_substr != null && !mediaError.message.includes(error_substr)) {
|
| + Log('ERROR: Element error message (' + mediaError.message +
|
| + ') does not contain expected substring (' + error_substr + ')');
|
| + Failed();
|
| + return;
|
| + }
|
| + document.title = 'ERROR';
|
| + }, false);
|
| +}
|
| +
|
| function Failed() {
|
| document.title = 'FAILED';
|
| return false;
|
| @@ -39,14 +68,17 @@ function SeekTestTimeoutSetup() {
|
|
|
| // Uses URL query parameters to create an audio or video element using a given
|
| // source. URL must be of the form:
|
| -// "player.html?[tag]=[media_url][&loop=[true/false]]".
|
| +// "player.html?[tag]=[media_url][&loop=[true/false]][&error_substr=substr]".
|
| //
|
| // Plays the media and waits for X seconds of playback or the ended event, at
|
| // which point the test seeks near the end of the file and resumes playback.
|
| // Test completes when the second ended event occurs or an error event occurs at
|
| // any time.
|
| -// There is an optional loop query parameter which when set to true, will cause
|
| +// There is an optional loop query parameter, which when set to true will cause
|
| // the created media element to loop.
|
| +// There is an optional error_substr query parameter, which when set will cause
|
| +// any error event handling to fail if the MediaError.message does not contain
|
| +// the specified substring resulting from decodeURIComponent().
|
| function RunTest() {
|
| var url_parts = window.location.href.split('?');
|
| if (url_parts.length != 2)
|
| @@ -55,6 +87,7 @@ function RunTest() {
|
| var tag = '';
|
| var media_url = '';
|
| var loop = false;
|
| + var error_substr = null;
|
|
|
| var query_params = url_parts[1].split('&');
|
| for (var query_param in query_params) {
|
| @@ -73,6 +106,11 @@ function RunTest() {
|
| loop = (query_parts[1] == 'true');
|
| continue;
|
| }
|
| +
|
| + if (query_parts[0] == 'error_substr') {
|
| + error_substr = decodeURIComponent(query_parts[1]);
|
| + continue;
|
| + }
|
| }
|
|
|
| if (tag != 'audio' && tag != 'video') {
|
| @@ -98,8 +136,9 @@ function RunTest() {
|
| player.addEventListener('ended', SeekTestStep, false);
|
| player.addEventListener('timeupdate', SeekTestTimeoutSetup, false);
|
|
|
| - // Ensure we percolate up any error events.
|
| - InstallTitleEventHandler(player, 'error');
|
| + // Ensure we percolate up any error events, and optionally verify they contain
|
| + // the expected error substring in their message.
|
| + InstallTitleErrorEventHandler(player, error_substr);
|
|
|
| // Starts the player.
|
| player.loop = loop;
|
|
|