ownerdiscard.html 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <!DOCTYPE html>
  2. <html class="reftest-wait">
  3. <body>
  4. <div id=tCF0>
  5. <img id=victim src=ie.png>
  6. <iframe src=discardframe.htm></iframe>
  7. </div>
  8. <script>
  9. const Ci = SpecialPowers.Ci;
  10. const Cc = SpecialPowers.Cc;
  11. function ImageDecoderObserverStub()
  12. {
  13. this.sizeAvailable = function sizeAvailable(aRequest) {}
  14. this.frameComplete = function frameComplete(aRequest) {}
  15. this.decodeComplete = function decodeComplete(aRequest) {}
  16. this.loadComplete = function loadComplete(aRequest) {}
  17. this.frameUpdate = function frameUpdate(aRequest) {}
  18. this.discard = function discard(aRequest) {}
  19. this.isAnimated = function isAnimated(aRequest) {}
  20. }
  21. var img = document.getElementById('victim');
  22. var observer = new ImageDecoderObserverStub();
  23. observer.discard = function() {
  24. cleanupAndFinish();
  25. }
  26. observer = SpecialPowers.wrapCallbackObject(observer);
  27. var gObserver = Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools)
  28. .createScriptedObserver(observer);
  29. var imgLoadingContent =
  30. SpecialPowers.wrap(img).QueryInterface(Ci.nsIImageLoadingContent);
  31. imgLoadingContent.addObserver(gObserver);
  32. function initCF() {
  33. setTimeout(function() { document.adoptNode(tCF0); }, 0);
  34. }
  35. document.addEventListener("DOMContentLoaded", initCF, false);
  36. function cleanupAndFinish() {
  37. imgLoadingContent.removeObserver(gObserver);
  38. setTimeout("document.documentElement.className = '';", 0);
  39. }
  40. function loadhandler() {
  41. setTimeout("cleanupAndFinish();", 30000);
  42. }
  43. window.addEventListener("load", function() {
  44. SpecialPowers.pushPrefEnv({"set":[["min_discard_timeout_ms", 1]]}, loadhandler)}, false);
  45. </script>
  46. </body>
  47. </html>