tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug435296.html (2402B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=435296
      5 -->
      6 <head>
      7  <title>Test for Bug 435296</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <script type="application/javascript" src="imgutils.js"></script>
     10  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     11 </head>
     12 <body>
     13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=435296">Mozilla Bug 435296</a>
     14 <img id="testimage" style="display: none;">
     15 <pre id="test">
     16 <script type="application/javascript">
     17 
     18 // Boilerplate
     19 SimpleTest.waitForExplicitFinish();
     20 
     21 // Assert that discarding isn't enabled, which might make this test go orange.
     22 ok(!getImagePref(DISCARD_ENABLED_PREF), "discarding should NOT be enabled here");
     23 
     24 // We want to make sure d-o-d is enabled, since that's what we're testing
     25 var oldDODPref = getImagePref(DECODEONDRAW_ENABLED_PREF);
     26 setImagePref(DECODEONDRAW_ENABLED_PREF, true);
     27 
     28 // We're relying on very particular behavior for certain images - clear the
     29 // image cache.
     30 clearImageCache();
     31 
     32 // In order to work around the effects introduced in bug 512435, we only load
     33 // the image after window onload fires
     34 function windowLoadHandler()
     35 {
     36  // Set the source and an onload handler
     37  var image = document.getElementById("testimage");
     38  image.src = "schrep.png";
     39  image.onload = imageLoadHandler;
     40 }
     41 
     42 function imageLoadHandler()
     43 {
     44  // The image is hidden, so it should not be decoded
     45  ok(!isFrameDecoded("testimage"), "image should not be decoded");
     46 
     47  // Make the image visible
     48  var image = document.getElementById("testimage");
     49  image.style.display = "inline";
     50 
     51  // Wait for the image to decode
     52  setTimeout(function() {
     53    tryToFinish();
     54  }, 500);
     55 }
     56 
     57 function tryToFinish()
     58 {
     59  // If it hasn't happened yet, wait longer. If it never happens, this test
     60  // will timeout after 300 seconds...
     61  if (!isFrameDecoded("testimage")) {
     62    setTimeout(function() {
     63      tryToFinish();
     64    }, 500);
     65    return;
     66  }
     67 
     68  // By definition, the image is decoded here. Give ourselves a pat on the back.
     69  ok(isFrameDecoded("testimage"), "image should be decoded");
     70 
     71  // Restore the decode-on-draw pref
     72  setImagePref(DECODEONDRAW_ENABLED_PREF, oldDODPref);
     73 
     74  // All done
     75  SimpleTest.finish();
     76 }
     77 
     78 // Set our onload handler, making sure we have focus
     79 window.onload = SimpleTest.waitForFocus(windowLoadHandler);
     80 
     81 </script>
     82 </pre>
     83 </body>
     84 </html>