summaryrefslogtreecommitdiffstats
path: root/dom/media/test/test_reactivate.html
blob: 43675f7771697a4da81ee90452583693a5ea52b4 (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
<!DOCTYPE HTML>
<html>
<head>
  <title>Test reactivation of a media element from a dead document</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>
</head>
<body>

<iframe id="frame" src="reactivate_helper.html"></iframe>

<pre id="test">
<script class="testbody" type="text/javascript">

var elements;

function playElement(e) {
  // All elements played out, finish the test case.
  if (!e) {
    SimpleTest.finish();
    return;
  }

  e.play();
  info("Element play: " + e._name);
  var reviveElement = function() {
    document.body.appendChild(e);
    e.onended = function() {
      info("Element ended: " + e._name);
      removeNodeAndSource(e);
      // Play next element.
      playElement(elements.pop());
    }
  }
  setTimeout(reviveElement, 2000);
}

function loadedAll(elementList) {
  elements = elementList;

  // Log events for debugging.
  var events = ["suspend", "play", "canplay", "canplaythrough", "loadstart", "loadedmetadata",
                "loadeddata", "playing", "ended", "error", "stalled", "emptied", "abort",
                "waiting", "pause"];
  function logEvent(e) {
    info(e.target._name + ": got " + e.type);
  }
  elementList.forEach(function(element) {
    events.forEach(function(evt) {
      element.addEventListener(evt, logEvent);
    });
  });

  // Blow away the subframe
  document.body.removeChild(document.getElementById("frame"));

  // Play elements one by one to avoid hitting bug 847903 on MacOSX.
  playElement(elements.pop());
}
</script>
</pre>
</body>
</html>