image/test/crashtests/ownerdiscard.html
author Emanuel Hoogeveen <emanuel.hoogeveen@gmail.com>
Mon, 24 Jun 2013 21:32:05 -0700
changeset 148674 b3f8eee3c38943a29cca0d1c97049c352324332c
parent 145520 fff2111dd03367eee348ff7e945d5819bc7a63e9
child 224822 10ce60dfd2237fdf026555da950363839a72076e
permissions -rw-r--r--
Bug 886128 - Fix various clang warnings and some potential bugs in nonstandard configurations. r=nnethercote,terrence.

<!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() {
      SpecialPowers.clearUserPref('min_discard_timeout_ms');
      imgLoadingContent.removeObserver(gObserver);
      setTimeout("document.documentElement.className = '';", 0);
    }
    observer = SpecialPowers.wrapCallbackObject(observer);
    var gObserver = Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools)
                                                    .createScriptedObserver(observer);
    var imgLoadingContent =
      SpecialPowers.wrap(img).QueryInterface(Ci.nsIImageLoadingContent);
    imgLoadingContent.addObserver(gObserver);

    SpecialPowers.setBoolPref('min_discard_timeout_ms', 1);

    function initCF() {
      setTimeout(function() { document.adoptNode(tCF0); }, 0);
    }
    document.addEventListener("DOMContentLoaded", initCF, false);
    function finish() {
      setTimeout("document.documentElement.className = '';", 30000);
    }
    window.addEventListener("load", finish, false);
  </script>
</body>
</html>