summaryrefslogtreecommitdiffstats
path: root/dom/media/test/seek_support.js
blob: b193fb60a49e53ef16e9b88d9fdb7fa66b65ca9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
SimpleTest.requestLongerTimeout(3);
var manager = new MediaTestManager;

// https://bugzilla.mozilla.org/show_bug.cgi?id=634747
if (navigator.platform.startsWith("Win")) {
  SimpleTest.expectAssertions(0, 5);
} else {
  // This is "###!!! ASSERTION: Page read cursor should be inside range: 'mPageOffset <= endOffset'"
  // https://bugzilla.mozilla.org/show_bug.cgi?id=846769
  SimpleTest.expectAssertions(0, 5);
}

function createTestArray() {
  var tests = [];
  var tmpVid = document.createElement("video");

  for (var testNum=0; testNum<gSeekTests.length; testNum++) {
    var test = gSeekTests[testNum];
    if (!tmpVid.canPlayType(test.type)) {
      continue;
    }

    var t = new Object;
    t.name = test.name;
    t.type = test.type;
    t.duration = test.duration;
    t.number = SEEK_TEST_NUMBER;
    tests.push(t);
  }
  return tests;
}

function startTest(test, token) {
  var v = document.createElement('video');
  v.token = token += "-seek" + test.number + ".js";
  manager.started(v.token);
  v.src = test.name;
  v.preload = "metadata";
  document.body.appendChild(v);
  var name = test.name + " seek test " + test.number;
  var localIs = function(name) { return function(a, b, msg) {
    is(a, b, name + ": " + msg);
  }}(name);
  var localOk = function(name) { return function(a, msg) {
    ok(a, name + ": " + msg);
  }}(name);
  var localFinish = function(v, manager) { return function() {
    v.onerror = null;
    removeNodeAndSource(v);
    dump("SEEK-TEST: Finished " + name + " token: " + v.token + "\n");
    manager.finished(v.token);
  }}(v, manager);
  dump("SEEK-TEST: Started " + name + "\n");
  window['test_seek' + test.number](v, test.duration/2, localIs, localOk, localFinish);
}