Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<title>Test for Bug 657791</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="text/javascript" src="manifest.js"></script>
<a target="_blank" href="">Mozilla Bug 657791</a>
<p id="display"></p>
<div id="content" style="display: none">
<pre id="test">
<script type="application/javascript">
// Subset of seek tests for cueless WebMs. When random seeking (rather than just
// in buffered ranges) is implemented for WebM, these tests can be removed and
// the cueless WebM(s) references can be moved to the general test_seek test
// array.
// Test array is defined in manifest.js
var manager = new MediaTestManager;
// Exercise functionality as in test_seek-3
function testWebM3(e) {
var v =;
v.removeEventListener('loadeddata', testWebM3);
var completed = false;
var gotTimeupdate = false;
ok(v.buffered.length >= 1, "Should have a buffered range");
var halfBuffered = v.buffered.end(0) / 2;
function start() {
if (completed)
is(v.seekable.start(0), v.buffered.start(0), "Seekable start should be buffered start");
is(v.seekable.end(0), v.buffered.end(0), "Seekable end should be buffered end");
function timeupdate() {
gotTimeupdate = true;
v.removeEventListener("timeupdate", timeupdate);
function seekStarted() {
if (completed)
v.addEventListener("timeupdate", timeupdate);
function seekEnded() {
if (completed)
var t = v.currentTime;
ok(Math.abs(t - halfBuffered) <= 0.1, "Video currentTime should be around " + halfBuffered + ": " + t);
ok(gotTimeupdate, "Should have got timeupdate between seeking and seekended");
completed = true;
v.addEventListener("seeking", seekStarted);
v.addEventListener("seeked", seekEnded);
// Fetch the media resource using XHR so we can be sure the entire
// resource is loaded before we test buffered ranges. This ensures
// we have deterministic behaviour.
function fetch(url, fetched_callback) {
var xhr = new XMLHttpRequest();"GET", url, true);
xhr.responseType = "blob";
var loaded = function (event) {
if (xhr.status == 200 || xhr.status == 206) {
// Request fulfilled. Note sometimes we get 206... Presumably because either
// httpd.js or Necko cached the result.
} else {
ok(false, "Fetch failed headers=" + xhr.getAllResponseHeaders());
xhr.addEventListener("load", loaded);
function startTest(test, token) {
var onfetched = function(uri) {
var v = document.createElement('video');
v._token = token;
v.src = uri;
v.addEventListener("loadeddata", testWebM3);
fetch(, onfetched);
manager.runTests(gCuelessWebMTests, startTest);