summaryrefslogtreecommitdiffstats
path: root/image/test/crashtests/ownerdiscard.html
blob: 2e5be86023512db43145ba295504a206170c5334 (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
<!DOCTYPE html>
<html class="reftest-wait">
<body>
  <div id=tCF0>
    <img id=victim src=ie.png>
    <iframe src=discardframe.htm></iframe>
  </div>
  <script>
    const Ci = SpecialPowers.Ci;
    const Cc = SpecialPowers.Cc;

    function ImageDecoderObserverStub()
    {
      this.sizeAvailable = function sizeAvailable(aRequest)   {}
      this.frameComplete = function frameComplete(aRequest)   {}
      this.decodeComplete = function decodeComplete(aRequest) {}
      this.loadComplete = function loadComplete(aRequest)     {}
      this.frameUpdate = function frameUpdate(aRequest)       {}
      this.discard = function discard(aRequest)               {}
      this.isAnimated = function isAnimated(aRequest)         {}
    }
    var img = document.getElementById('victim');
    var observer = new ImageDecoderObserverStub();
    observer.discard = function() {
      cleanupAndFinish();
    }
    observer = SpecialPowers.wrapCallbackObject(observer);
    var gObserver = Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools)
                                                    .createScriptedObserver(observer);
    var imgLoadingContent = SpecialPowers.wrap(img);
    imgLoadingContent.addObserver(gObserver);
    function initCF() {
      setTimeout(function() { document.adoptNode(tCF0); }, 0);
    }
    document.addEventListener("DOMContentLoaded", initCF);

    function cleanupAndFinish() {
      imgLoadingContent.removeObserver(gObserver);
      setTimeout("document.documentElement.className = '';", 0);
    }
    function loadhandler() {
      setTimeout("cleanupAndFinish();", 30000);
    }
    window.addEventListener("load", function() {
      SpecialPowers.pushPrefEnv({"set":[["min_discard_timeout_ms", 1]]}, loadhandler)});
  </script>
</body>
</html>