summaryrefslogtreecommitdiffstats
path: root/dom/media/test/test_fragment_play.html
blob: eab422bab12476ae864583650d426d0a32e1972b (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<!DOCTYPE HTML>
<html>
<head>
  <title>Media test: seek tests</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>
  <script type="text/javascript" src="fragment_play.js"></script>
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
PARALLEL_TESTS = 1;
var manager = new MediaTestManager;

// Fragment parameters to try. These tests
// try playing the video. Tests for other fragment
// formats are in test_fragment_noplay.html.
var gFragmentParams = [
  { fragment: "", start: null, end: null },
  { fragment: "#t=,", start: null, end: null },
  { fragment: "#t=3,3", start: null, end: null },
  { fragment: "#t=7,3", start: null, end: null },
  { fragment: "#t=7,15", start: 7, end: null },
  { fragment: "#t=15,20", start: 9.287982, end: null },
  { fragment: "#t=5", start: 5, end: null },
  { fragment: "#t=5.5", start: 5.5, end: null },
  { fragment: "#t=5,", start: null, end: null },
  { fragment: "#t=,5", start: 0, end: 5, todo: "See bugs 682141 and 720248" },
  { fragment: "#t=2.5,5.5", start: 2.5, end: 5.5, todo: "See bugs 682141 and 720248" },
  { fragment: "#t=1,2.5", start: 1, end: 2.5, todo: "See bugs 682141 and 720248" },
  { fragment: "#t=,15", start: 0, end: null }
];

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

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

    for (var fragNum=0; fragNum<gFragmentParams.length; fragNum++) {
      var p = gFragmentParams[fragNum];
      var t = {};
      t.name = test.name + p.fragment;
      t.type = test.type;
      t.duration = test.duration;
      t.start = p.start;
      t.end = p.end;
      t.todo = p.todo;
      tests.push(t);
    }
  }
  return tests;
}

function startTest(test, token) {
  if (test.todo) {
    todo(false, test.todo);
    return;
  }
  var video = document.createElement('video');
  manager.started(token);
  video.preload = "metadata";
  video.src = test.name;
  video.token = token;
  video.controls = true;
  document.body.appendChild(video);
  var name = test.name + " fragment test";
  var localIs = function(n) { return function(a, b, msg) {
    is(a, b, n + ": " + msg);
  }}(name);
  var localOk = function(n) { return function(a, msg) {
    ok(a, n + ": " + msg);
  }}(name);
  var localFinish = function(v, m) { return function() {
    removeNodeAndSource(v);
    m.finished(v.token);
  }}(video, manager);
  window.test_fragment_play(video, test.start, test.end, localIs, localOk, localFinish);
}

manager.runTests(createTestArray(), startTest);

</script>
</pre>
</body>
</html>