summaryrefslogtreecommitdiffstats
path: root/image/test/crashtests/1634839-2.html
blob: d3629421fb2ef9fc211a6bbd458de71c874e7120 (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
<!DOCTYPE HTML>
<html class="reftest-wait">
<head>
</head>
<body>
<div id="container">
  <iframe id='if' src="1634839-2-iframe.html"></iframe>
</div>

<script>
let iterationsLeft = 1;

let img = null;

function runTest() {
  // Make sure the image is decoded and advanced to it's final frame.
  img = document.getElementById("if").contentWindow.document.getElementById("image1");
  img.decode().then(function() {
    setTimeout(forceDiscard, 1000);
  });
}

function showIframe() {
  document.getElementById("container").style.display = "";
  document.documentElement.getBoundingClientRect();
  requestAnimationFrame(forceDecode);
}

function forceDecode() {
  img.decode().then(function() {
    setTimeout(forceDiscard, 0);
  });
}

function forceDiscard() {
  iterationsLeft--;
  if (iterationsLeft < 0) {
    document.documentElement.className = "";
    return;
  }
  document.getElementById("container").style.display = "none";
  document.documentElement.getBoundingClientRect();
  img.remove();
  requestAnimationFrame(() => { requestAnimationFrame( () => { setTimeout(showIframe, 0); } ) });
}

//window.addEventListener("load", runTest);
window.addEventListener("MozReftestInvalidate", runTest);
</script>
</body>
</html>