image/test/crashtests/delaytest.html

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 <!DOCTYPE HTML>
     2 <html class="reftest-wait">
     3 <head>
     4 <title>Delayed image reftest wrapper</title>
     5 </head>
     6 <body>
     7 <img id="image1">
     8 <script>
     9 // This loads a externally specified image, forces a draw (in case of
    10 // decode-on-draw), waits 350ms, and then triggers the reftest snapshot.
    11 // This allows the animation on the page to complete.
    12 //
    13 // Use as "delaytest.html?animation.png"
    14 //
    16 // Get the image URL from our URL
    17 var imgURL = document.location.search.substr(1);
    19 // Load the image
    20 var img = document.images[0];
    21 img.src = imgURL;
    22 img.onload = forceDecode;
    23 img.onerror = forceDecode;
    25 function forceDecode() {
    27   try {
    28     // We need to force drawing of the image in an invisible context
    29     var canvas = document.createElement("canvas");
    30     var ctx = canvas.getContext("2d");
    31     ctx.drawImage(img, 0, 0);
    32   } catch(e) {}
    34   // We've force the decode. start the timer to trigger the reftest
    35   startTimer();
    36 }
    38 function startTimer() {
    39   const delay = 350;
    40   setTimeout("document.documentElement.className = '';", delay);
    41 }
    42 </script>
    43 </body>
    44 </html>

mercurial