diff options
Diffstat (limited to 'content/test')
-rw-r--r-- | content/test/data/media/blackwhite.html | 231 | ||||
-rw-r--r-- | content/test/data/media/encrypted_frame_size_change.html | 50 | ||||
-rw-r--r-- | content/test/data/media/encrypted_media_player.html | 37 | ||||
-rw-r--r-- | content/test/data/media/encrypted_media_utils.js | 142 | ||||
-rw-r--r-- | content/test/data/media/media_source_player.html | 35 | ||||
-rw-r--r-- | content/test/data/media/media_source_utils.js | 67 | ||||
-rw-r--r-- | content/test/data/media/media_utils.js | 50 | ||||
-rw-r--r-- | content/test/data/media/mse_config_change.html | 132 | ||||
-rw-r--r-- | content/test/data/media/player.html | 77 |
9 files changed, 0 insertions, 821 deletions
diff --git a/content/test/data/media/blackwhite.html b/content/test/data/media/blackwhite.html deleted file mode 100644 index 6b9d049..0000000 --- a/content/test/data/media/blackwhite.html +++ /dev/null @@ -1,231 +0,0 @@ -<!DOCTYPE html> -<html> - <head> - <style> - body { - color: white; - background-color: black; - } - </style> - </head> - <body onload="main()"> - <div id="buttons"></div> - <table> - <tr> - <td>Image</td> - <td id="video_header"></td> - <td>Absolute Diff</td> - <td>Different Pixels</td> - </tr> - <tr> - <td><img src="blackwhite.png"></div> - <td><video autoplay></video></div> - <td><canvas id="diff"></canvas></td> - <td><canvas id="mask"></canvas></td> - </tr> - </div> - - <p id="result"></p> - - <script> - function log(str) { - document.getElementById('result').textContent = str; - console.log(str); - } - - function loadVideo(name) { - var videoElem = document.querySelector('video'); - videoElem.src = 'blackwhite_' + name; - - document.getElementById('video_header').textContent = name; - videoElem.addEventListener('ended', onVideoEnded); - } - - function onVideoEnded(e) { - document.title = verifyVideo() ? 'ENDED' : 'FAILED'; - } - - function onVideoError(e) { - document.title = 'ERROR'; - document.getElementById('diff').style.visibility = 'hidden'; - document.getElementById('mask').style.visibility = 'hidden'; - log('Error playing video: ' + e.target.error.code + '.'); - } - - function main() { - // Programatically create buttons for each clip for manual testing. - var buttonsElem = document.getElementById('buttons'); - - function createButton(name) { - var buttonElem = document.createElement('button'); - buttonElem.textContent = name; - buttonElem.addEventListener('click', function() { - loadVideo(name); - }); - buttonsElem.appendChild(buttonElem); - } - - var VIDEOS = [ - 'yuv420p.ogv', - 'yuv422p.ogv', - 'yuv444p.ogv', - 'yuv420p.webm', - 'yuv444p.webm', - 'yuv420p.mp4', - 'yuvj420p.mp4', - 'yuv422p.mp4', - 'yuv444p.mp4', - 'yuv420p.avi' - ]; - - for (var i = 0; i < VIDEOS.length; ++i) { - createButton(VIDEOS[i]); - } - - // Video event handlers. - var videoElem = document.querySelector('video'); - videoElem.addEventListener('error', onVideoError); - - // Check if a query parameter was provided for automated tests. - if (window.location.search.length > 1) { - loadVideo(window.location.search.substr(1)); - } else { - // If we're not an automated test, compute some pretty diffs. - document.querySelector('video').addEventListener('ended', - computeDiffs); - } - } - - function getCanvasPixels(canvas) { - try { - return canvas.getContext('2d') - .getImageData(0, 0, canvas.width, canvas.height) - .data; - } catch(e) { - var message = 'ERROR: ' + e; - if (e.name == 'SecurityError') { - message += ' Couldn\'t get image pixels, try running with ' + - '--allow-file-access-from-files.'; - } - log(message); - } - } - - function verifyVideo() { - var videoElem = document.querySelector('video'); - var offscreen = document.createElement('canvas'); - offscreen.width = videoElem.videoWidth; - offscreen.height = videoElem.videoHeight; - offscreen.getContext('2d') - .drawImage(videoElem, 0, 0, offscreen.width, offscreen.height); - - videoData = getCanvasPixels(offscreen); - if (!videoData) - return false; - - // Check the color of a givel pixel |x,y| in |imgData| against an - // expected value, |expected|, with up to |allowedError| difference. - function checkColor(imgData, x, y, stride, expected, allowedError) { - for (var i = 0; i < 3; ++i) { - if (Math.abs(imgData[(x + y * stride) * 4 + i] - expected) > - allowedError) { - return false; - } - } - return true; - } - - // Check one pixel in each quadrant (in the upper left, away from - // boundaries and the text, to avoid compression artifacts). - // Also allow a small error, for the same reason. - - // TODO(mtomasz): Once code.google.com/p/libyuv/issues/detail?id=324 is - // fixed, the allowedError should be decreased to 1. - var allowedError = 2; - - return checkColor(videoData, 30, 30, videoElem.videoWidth, 0xff, - allowedError) && - checkColor(videoData, 150, 30, videoElem.videoWidth, 0x00, - allowedError) && - checkColor(videoData, 30, 150, videoElem.videoWidth, 0x10, - allowedError) && - checkColor(videoData, 150, 150, videoElem.videoWidth, 0xef, - allowedError); - } - - // Compute a standard diff image, plus a high-contrast mask that shows - // each differing pixel more visibly. - function computeDiffs() { - var diffElem = document.getElementById('diff'); - var maskElem = document.getElementById('mask'); - var videoElem = document.querySelector('video'); - var imgElem = document.querySelector('img'); - - var width = imgElem.width; - var height = imgElem.height; - - if (videoElem.videoWidth != width || videoElem.videoHeight != height) { - log('ERROR: video dimensions don\'t match reference image ' + - 'dimensions'); - return; - } - - // Make an offscreen canvas to dump reference image pixels into. - var offscreen = document.createElement('canvas'); - offscreen.width = width; - offscreen.height = height; - - offscreen.getContext('2d').drawImage(imgElem, 0, 0, width, height); - imgData = getCanvasPixels(offscreen); - if (!imgData) - return; - - // Scale and clear diff canvases. - diffElem.width = maskElem.width = width; - diffElem.height = maskElem.height = height; - var diffCtx = diffElem.getContext('2d'); - var maskCtx = maskElem.getContext('2d'); - maskCtx.clearRect(0, 0, width, height); - diffCtx.clearRect(0, 0, width, height); - - // Copy video pixels into diff. - diffCtx.drawImage(videoElem, 0, 0, width, height); - - var diffIData = diffCtx.getImageData(0, 0, width, height); - var diffData = diffIData.data; - var maskIData = maskCtx.getImageData(0, 0, width, height); - var maskData = maskIData.data; - - // Make diffs and collect stats. - var meanSquaredError = 0; - for (var i = 0; i < imgData.length; i += 4) { - var difference = 0; - for (var j = 0; j < 3; ++j) { - diffData[i + j] = Math.abs(diffData[i + j] - imgData[i + j]); - meanSquaredError += diffData[i + j] * diffData[i + j]; - if (diffData[i + j] != 0) { - difference += diffData[i + j]; - } - } - if (difference > 0) { - if (difference <= 3) { - // If we're only off by a bit per channel or so, use darker red. - maskData[i] = 128; - } else { - // Bright red to indicate a different pixel. - maskData[i] = 255; - } - maskData[i+3] = 255; - } - } - - meanSquaredError /= width * height; - log('Mean squared error: ' + meanSquaredError); - diffCtx.putImageData(diffIData, 0, 0); - maskCtx.putImageData(maskIData, 0, 0); - document.getElementById('diff').style.visibility = 'visible'; - document.getElementById('mask').style.visibility = 'visible'; - } - </script> - </body> -</html> diff --git a/content/test/data/media/encrypted_frame_size_change.html b/content/test/data/media/encrypted_frame_size_change.html deleted file mode 100644 index 719d8be..0000000 --- a/content/test/data/media/encrypted_frame_size_change.html +++ /dev/null @@ -1,50 +0,0 @@ -<!DOCTYPE html> -<html> - <body onload="load()"> - <p>Tests decoding and rendering encrypted video element that has a changing - resolution.</p> - <video width=320 controls></video> - <video controls></video> - <script src="media_utils.js" type="text/javascript"></script> - <script src="media_source_utils.js" type="text/javascript"></script> - <script src="encrypted_media_utils.js" type="text/javascript"></script> - <script> - var firstVideoSeek = false; - var video_fixed_size = document.getElementsByTagName("video")[0]; - var video = document.getElementsByTagName("video")[1]; - - function load() { - loadVideo(video_fixed_size); - loadVideo(video); - } - - function loadVideo(video) { - var mediaSource = loadEncryptedMediaFromURL(video); - - video.addEventListener('playing', function() { - // Make sure the video plays for a bit. - video.addEventListener('timeupdate', function() { - if (video.currentTime > 1.0) { - video.pause(); - } - }); - }); - - video.addEventListener('pause', function() { - video.addEventListener('seeked', function() { - if (!firstVideoSeek) { - console.log('One video seeked.'); - firstVideoSeek = true; - return; - } - setResultInTitle('ENDED'); - }); - video.currentTime = 0.5; - }); - - video.addEventListener('canplay', oncanplay); - video.play(); - } - </script> - </body> -</html> diff --git a/content/test/data/media/encrypted_media_player.html b/content/test/data/media/encrypted_media_player.html deleted file mode 100644 index 2b16d51..0000000 --- a/content/test/data/media/encrypted_media_player.html +++ /dev/null @@ -1,37 +0,0 @@ -<!DOCTYPE html> -<html> - <head> - <title>Encrypted Media Player</title> - </head> - <body onload="runTest();"> - <video controls></video> - <script src="media_utils.js" type="text/javascript"></script> - <script src="media_source_utils.js" type="text/javascript"></script> - <script src="encrypted_media_utils.js" type="text/javascript"></script> - <script type="text/javascript"> - var video = document.querySelector('video'); - - function onTimeUpdate() { - if (video.currentTime < 1) - return; - // keyadded may be fired around the start of playback; check for it - // after a delay to avoid timing issues. - if (!video.receivedKeyAdded) - failTest('Key added event not received.'); - if (video.isHeartbeatExpected && !video.receivedHeartbeat) - failTest('Heartbeat keymessage event not received.'); - video.removeEventListener('ended', failTest); - installTitleEventHandler(video, 'ended'); - video.removeEventListener('timeupdate', onTimeUpdate); - } - - // The test completes after playing the encrypted media for 1 second and - // getting the ended event or when an error occurs at any time. - function runTest() { - loadEncryptedMediaFromURL(video); - video.addEventListener('timeupdate', onTimeUpdate); - video.play(); - } - </script> - </body> -</html> diff --git a/content/test/data/media/encrypted_media_utils.js b/content/test/data/media/encrypted_media_utils.js deleted file mode 100644 index 8fb3f97..0000000 --- a/content/test/data/media/encrypted_media_utils.js +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -var keySystem = QueryString.keysystem; -var mediaFile = QueryString.mediafile; -var mediaType = QueryString.mediatype || 'video/webm; codecs="vorbis, vp8"'; -var useMSE = QueryString.usemse == 1; - -// Default key used to encrypt many media files used in browser tests. -var KEY = new Uint8Array([0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b, - 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c]); -// KEY_ID constant used as init data while encrypting test media files. -var KEY_ID = getInitDataFromKeyId("0123456789012345"); -// Heart beat message header. -var HEART_BEAT_HEADER = 'HEARTBEAT'; -var EXTERNAL_CLEAR_KEY_KEY_SYSTEM = "org.chromium.externalclearkey"; -// Note that his URL has been normalized from the one in clear_key_cdm.cc. -var EXTERNAL_CLEAR_KEY_HEARTBEAT_URL = - 'http://test.externalclearkey.chromium.org/'; - -function isHeartbeatMessage(msg) { - if (msg.length < HEART_BEAT_HEADER.length) - return false; - for (var i = 0; i < HEART_BEAT_HEADER.length; ++i) { - if (String.fromCharCode(msg[i]) != HEART_BEAT_HEADER[i]) - return false; - } - return true; -} - -function loadEncryptedMediaFromURL(video) { - return loadEncryptedMedia(video, mediaFile, keySystem, KEY, useMSE); -} - -function loadEncryptedMedia(video, mediaFile, keySystem, key, useMSE, - appendSourceCallbackFn) { - var keyRequested = false; - var sourceOpened = false; - // Add properties to enable verification that events occurred. - video.receivedKeyAdded = false; - video.receivedHeartbeat = false; - video.isHeartbeatExpected = keySystem === EXTERNAL_CLEAR_KEY_KEY_SYSTEM; - video.receivedKeyMessage = false; - - if (!(video && mediaFile && keySystem && key)) { - failTest('Missing parameters in loadEncryptedMedia().'); - return; - } - - function onNeedKey(e) { - if (keyRequested) - return; - keyRequested = true; - console.log('onNeedKey', e); - try { - video.webkitGenerateKeyRequest(keySystem, e.initData); - } - catch(error) { - setResultInTitle(error.name); - } - } - - function onKeyAdded(e) { - e.target.receivedKeyAdded = true; - } - - function onKeyMessage(e) { - video.receivedKeyMessage = true; - if (!e.keySystem || e.keySystem != keySystem) { - failTest('keymessage with unexpected keySystem: ' + e.keySystem); - return; - } - - if (!e.sessionId) { - failTest('keymessage without a sessionId: ' + e.sessionId); - return; - } - - if (!e.message) { - failTest('keymessage without a message: ' + e.message); - return; - } - - if (isHeartbeatMessage(e.message)) { - console.log('onKeyMessage - heartbeat', e); - e.target.receivedHeartbeat = true; - verifyHeartbeatMessage(e); - return; - } - - // No tested key system returns defaultURL in for key request messages. - if (e.defaultURL) { - failTest('keymessage unexpectedly has defaultURL: ' + e.defaultURL); - return; - } - - // keymessage in response to generateKeyRequest. Reply with key. - console.log('onKeyMessage - key request', e); - var initData = e.message; - if (mediaType.indexOf('mp4') != -1) - initData = KEY_ID; // Temporary hack for Clear Key in v0.1. - video.webkitAddKey(keySystem, key, initData); - } - - function verifyHeartbeatMessage(e) { - // Only External Clear Key sends a HEARTBEAT message. - if (e.keySystem != EXTERNAL_CLEAR_KEY_KEY_SYSTEM) { - failTest('Unexpected heartbeat from ' + e.keySystem); - return; - } - - if (e.defaultURL != EXTERNAL_CLEAR_KEY_HEARTBEAT_URL) { - failTest('Heartbeat message with unexpected defaultURL: ' + e.defaultURL); - return; - } - } - - video.addEventListener('webkitneedkey', onNeedKey); - video.addEventListener('webkitkeymessage', onKeyMessage); - video.addEventListener('webkitkeyerror', function() { - setResultInTitle("KeyError"); - }); - video.addEventListener('webkitkeyadded', onKeyAdded); - installTitleEventHandler(video, 'error'); - - if (useMSE) { - var mediaSource = loadMediaSource(mediaFile, mediaType, - appendSourceCallbackFn); - video.src = window.URL.createObjectURL(mediaSource); - } else { - video.src = mediaFile; - } -} - -function getInitDataFromKeyId(keyID) { - var init_key_id = new Uint8Array(keyID.length); - for(var i = 0; i < keyID.length; i++) { - init_key_id[i] = keyID.charCodeAt(i); - } - return init_key_id; -} diff --git a/content/test/data/media/media_source_player.html b/content/test/data/media/media_source_player.html deleted file mode 100644 index 97f3b64..0000000 --- a/content/test/data/media/media_source_player.html +++ /dev/null @@ -1,35 +0,0 @@ -<!DOCTYPE html> -<html> - <head> - <title>Media Source Player</title> - </head> - <body onload="runTest();"> - <video controls></video> - <script src="media_utils.js" type="text/javascript"></script> - <script src="media_source_utils.js" type="text/javascript"></script> - <script type="text/javascript"> - var video = document.querySelector('video'); - - function onTimeUpdate() { - video.removeEventListener('timeupdate', onTimeUpdate); - video.currentTime = 0.9 * video.duration; - } - - function onSeeked() { - video.removeEventListener('ended', failTest); - installTitleEventHandler(video, 'ended'); - } - - // The test completes after media starts playing, seeks to 0.9 of - // duration and fires the ended event. - // The test stops when an error or ended event fire unexpectedly. - function runTest() { - loadMediaFromURL(video); - video.addEventListener('ended', failTest); - video.addEventListener('seeked', onSeeked); - video.addEventListener('timeupdate', onTimeUpdate); - video.play(); - } - </script> - </body> -</html> diff --git a/content/test/data/media/media_source_utils.js b/content/test/data/media/media_source_utils.js deleted file mode 100644 index 7f179b5..0000000 --- a/content/test/data/media/media_source_utils.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -function loadMediaFromURL(video) { - installTitleEventHandler(video, 'error'); - video.addEventListener('playing', function(event) { - console.log('Video Playing.'); - }); - var source = loadMediaSource(QueryString.mediafile, QueryString.mediatype); - video.src = window.URL.createObjectURL(source); -} - -function loadMediaSource(mediaFiles, mediaTypes, appendSourceCallbackFn) { - mediaFiles = convertToArray(mediaFiles); - mediaTypes = convertToArray(mediaTypes); - - if (!mediaFiles || !mediaTypes) - failTest('Missing parameters in loadMediaSource().'); - - var totalAppended = 0; - function onSourceOpen(e) { - console.log('onSourceOpen', e); - // We can load multiple media files using the same media type. However, if - // more than one media type is used, we expect to have a media type entry - // for each corresponding media file. - var srcBuffer = null; - for (var i = 0; i < mediaFiles.length; i++) { - if (i == 0 || mediaFiles.length == mediaTypes.length) { - console.log('Creating a source buffer for type ' + mediaTypes[i]); - try { - srcBuffer = mediaSource.addSourceBuffer(mediaTypes[i]); - } catch (e) { - failTest('Exception adding source buffer: ' + e.message); - return; - } - } - doAppend(mediaFiles[i], srcBuffer); - } - } - - function doAppend(mediaFile, srcBuffer) { - var xhr = new XMLHttpRequest(); - xhr.open('GET', mediaFile); - xhr.responseType = 'arraybuffer'; - xhr.addEventListener('load', function(e) { - var onUpdateEnd = function(e) { - console.log('End of appending buffer from ' + mediaFile); - srcBuffer.removeEventListener('updateend', onUpdateEnd); - totalAppended++; - if (totalAppended == mediaFiles.length) { - if (appendSourceCallbackFn) - appendSourceCallbackFn(mediaSource); - else - mediaSource.endOfStream(); - } - }; - srcBuffer.addEventListener('updateend', onUpdateEnd); - srcBuffer.appendBuffer(new Uint8Array(e.target.response)); - }); - xhr.send(); - } - - var mediaSource = new MediaSource(); - mediaSource.addEventListener('sourceopen', onSourceOpen); - return mediaSource; -} diff --git a/content/test/data/media/media_utils.js b/content/test/data/media/media_utils.js deleted file mode 100644 index 8c5c1d6..0000000 --- a/content/test/data/media/media_utils.js +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) 2013 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -var QueryString = function() { - // Allows access to query parameters on the URL; e.g., given a URL like: - // http://<server>/my.html?test=123&bob=123 - // Parameters can then be accessed via QueryString.test or QueryString.bob. - var params = {}; - // RegEx to split out values by &. - var r = /([^&=]+)=?([^&]*)/g; - // Lambda function for decoding extracted match values. Replaces '+' with - // space so decodeURIComponent functions properly. - function d(s) { return decodeURIComponent(s.replace(/\+/g, ' ')); } - var match; - while (match = r.exec(window.location.search.substring(1))) - params[d(match[1])] = d(match[2]); - return params; -}(); - -function failTest(msg) { - var failMessage = msg; - if (msg instanceof Event) - failMessage = msg.target + '.' + msg.type; - console.log("FAILED TEST: " + msg); - setResultInTitle('FAILED'); -} - -var titleChanged = false; -function setResultInTitle(title) { - // If document title is 'ENDED', then update it with new title to possibly - // mark a test as failure. Otherwise, keep the first title change in place. - if (!titleChanged || document.title.toUpperCase() == 'ENDED') - document.title = title.toUpperCase(); - console.log('Set document title to: ' + title + ', updated title: ' + - document.title); - titleChanged = true; -} - -function installTitleEventHandler(element, event) { - element.addEventListener(event, function(e) { - setResultInTitle(event.toString()); - }, false); -} - -function convertToArray(input) { - if (Array.isArray(input)) - return input; - return [input]; -} diff --git a/content/test/data/media/mse_config_change.html b/content/test/data/media/mse_config_change.html deleted file mode 100644 index 13f4174..0000000 --- a/content/test/data/media/mse_config_change.html +++ /dev/null @@ -1,132 +0,0 @@ -<html> - <head> - <title>Test media source config changes.</title> - </head> - <body onload="runTest();"> - <video controls></video> - <script src="media_utils.js" type="text/javascript"></script> - <script src="media_source_utils.js" type="text/javascript"></script> - <script src="encrypted_media_utils.js" type="text/javascript"></script> - <script type="text/javascript"> - var runEncrypted = QueryString.runencrypted == 1; - var video = document.querySelector('video'); - var mediaType = 'video/webm; codecs="vorbis, vp8"'; - - var MEDIA_1 = 'bear-320x240.webm'; - var MEDIA_2 = 'bear-640x360.webm'; - if (runEncrypted) { - MEDIA_1 = 'bear-320x240-av-enc_av.webm'; - MEDIA_2 = 'bear-640x360-av-enc_av.webm'; - } - - var MEDIA_1_WIDTH = 320; - var MEDIA_1_HEIGHT = 240; - - var MEDIA_2_WIDTH = 640; - var MEDIA_2_HEIGHT = 360; - var MEDIA_2_LENGTH = 2.75; - - // The time in secs to append the second media source. - var APPEND_TIME = 1; - // DELTA is the time after APPEND_TIME where the second video dimensions - // are guaranteed to take effect. - var DELTA = 0.1; - // Append MEDIA_2 source at APPEND_TIME, so expected total duration is: - var TOTAL_DURATION = APPEND_TIME + MEDIA_2_LENGTH; - - function appendNextSource(mediaSource) { - console.log('Appending next media source at ' + APPEND_TIME + 'sec.'); - var xhr = new XMLHttpRequest(); - xhr.open("GET", MEDIA_2); - xhr.responseType = 'arraybuffer'; - xhr.addEventListener('load', function(e) { - var onUpdateEnd = function(e) { - console.log('Second buffer append ended.'); - srcBuffer.removeEventListener('updateend', onUpdateEnd); - mediaSource.endOfStream(); - if (!mediaSource.duration || - Math.abs(mediaSource.duration - TOTAL_DURATION) > DELTA) { - failTest('Unexpected mediaSource.duration = ' + - mediaSource.duration + ', expected duration = ' + - TOTAL_DURATION); - return; - } - video.play(); - }; - console.log('Appending next media source at ' + APPEND_TIME + 'sec.'); - var srcBuffer = mediaSource.sourceBuffers[0]; - srcBuffer.addEventListener('updateend', onUpdateEnd); - srcBuffer.timestampOffset = APPEND_TIME; - srcBuffer.appendBuffer(new Uint8Array(e.target.response)); - }); - xhr.send(); - } - - function onTimeUpdate() { - // crbug.com/246308 - //checkVideoProperties(); - - // Seek to APPEND_TIME because after a seek a timeUpdate event is fired - // before video width and height properties get updated. - if (video.currentTime < APPEND_TIME - DELTA) { - // Seek to save test execution time (about 1 secs) and to test seek - // on the first buffer. - video.currentTime = APPEND_TIME - DELTA; - } else if (video.currentTime > APPEND_TIME + DELTA) { - // Check video duration here to guarantee that second segment has been - // appended and video total duration is updated. - // Video duration is a float value so we check it within a range. - if (!video.duration || - Math.abs(video.duration - TOTAL_DURATION) > DELTA) { - failTest('Unexpected video.duration = ' + video.duration + - ', expected duration = ' + TOTAL_DURATION); - return; - } - - video.removeEventListener('timeupdate', onTimeUpdate); - video.removeEventListener('ended', failTest); - installTitleEventHandler(video, 'ended'); - // Seek to save test execution time and to test seek on second buffer. - video.currentTime = APPEND_TIME + MEDIA_2_LENGTH * 0.9; - } - } - - function checkVideoProperties() { - if (video.currentTime <= APPEND_TIME) { - if (video.videoWidth != MEDIA_1_WIDTH || - video.videoHeight != MEDIA_1_HEIGHT) { - logVideoDimensions(); - failTest('Unexpected dimensions for first video segment.'); - return; - } - } else if (video.currentTime >= APPEND_TIME + DELTA) { - if (video.videoWidth != MEDIA_2_WIDTH || - video.videoHeight != MEDIA_2_HEIGHT) { - logVideoDimensions(); - failTest('Unexpected dimensions for second video segment.'); - return; - } - } - } - - function logVideoDimensions() { - console.log('video.currentTime = ' + video.currentTime + - ', video dimensions = ' + video.videoWidth + 'x' + - video.videoHeight + '.'); - } - - function runTest() { - video.addEventListener('timeupdate', onTimeUpdate); - video.addEventListener('ended', failTest); - if (runEncrypted) { - loadEncryptedMedia(video, MEDIA_1, keySystem, KEY, true, - appendNextSource); - } else { - var mediaSource = loadMediaSource(MEDIA_1, mediaType, - appendNextSource); - video.src = window.URL.createObjectURL(mediaSource); - } - } - </script> - </body> -</html> diff --git a/content/test/data/media/player.html b/content/test/data/media/player.html deleted file mode 100644 index e954cf8..0000000 --- a/content/test/data/media/player.html +++ /dev/null @@ -1,77 +0,0 @@ -<html> -<body onload="RunTest();"> -<div id="player_container"></div> -</body> - -<script type="text/javascript"> -// <audio> or <video> player element. -var player; - -// Listen for |event| from |element|, set document.title = |event| upon event. -function InstallTitleEventHandler(element, event) { - element.addEventListener(event, function(e) { - document.title = event.toUpperCase(); - }, false); -} - -function Failed() { - document.title = 'FAILED'; - return false; -} - -function SeekTestStep(e) { - player.removeEventListener('ended', SeekTestStep, false); - - // Test completes on the next ended event. - InstallTitleEventHandler(player, 'ended'); - - player.currentTime = 0.9 * player.duration; - player.play(); -} - -function SeekTestTimeoutSetup() { - if (player.currentTime < 2) - return; - - player.removeEventListener('timeupdate', SeekTestTimeoutSetup, false); - SeekTestStep(); -} - -// 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]". 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. -function RunTest() { - var url_parts = window.location.href.split('?'); - if (url_parts.length != 2) - return Failed(); - - var query_parts = url_parts[1].split('='); - if (query_parts.length != 2) - return Failed(); - - var tag = query_parts[0]; - var media_url = query_parts[1]; - if (tag != 'audio' && tag != 'video') - return Failed(); - - // Create player and insert into DOM. - player = document.createElement(tag); - player.controls = true; - document.getElementById('player_container').appendChild(player); - - // Transition to the seek test after X seconds of playback or when the ended - // event occurs, whichever happens first. - player.addEventListener('ended', SeekTestStep, false); - player.addEventListener('timeupdate', SeekTestTimeoutSetup, false); - - // Ensure we percolate up any error events. - InstallTitleEventHandler(player, 'error'); - - // Starts the player. - player.src = media_url; - player.play(); -} -</script> -</html> |