tor-browser

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

test_mozPaintCount.html (1983B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title>Tests for DOMWindowUtils.paintCount</title>
      5  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      6  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
      7 </head>
      8 <body onload="doBackgroundFlicker()">
      9 <p id="display">
     10 <div width="100" height="100" id="p" style="background-color: rgb(0,0,0)"/>
     11 </p>
     12 <div id="content" style="display: none">
     13  
     14 </div>
     15 <pre id="test">
     16 <script class="testbody" type="text/javascript">
     17 
     18 SimpleTest.waitForExplicitFinish();
     19 
     20 var startPaintCount = SpecialPowers.DOMWindowUtils.paintCount;
     21 ok(true, "Got to initial paint count: " + startPaintCount);
     22 var color = 0;
     23 
     24 function doElementFlicker() {
     25  ok(true, "Plugin color iteration " + color + ", paint count: " + SpecialPowers.DOMWindowUtils.paintCount);
     26  if (SpecialPowers.DOMWindowUtils.paintCount - startPaintCount > 20) {
     27    ok(true, "Got enough paints from plugin color changes");
     28    SimpleTest.finish();
     29    return;
     30  }
     31 
     32  color = (color + 1) % 256;
     33  document.getElementById("p").style.backgroundColor = "rgb(" + color + "," + color + "," + color + ")";
     34  setTimeout(doElementFlicker, 0);
     35 }
     36 
     37 function doBackgroundFlicker() {
     38  ok(true, "Background color iteration " + color + ", paint count: " + SpecialPowers.DOMWindowUtils.paintCount);
     39  if (SpecialPowers.DOMWindowUtils.paintCount - startPaintCount > 20) {
     40    ok(true, "Got enough paints from background color changes");
     41    startPaintCount = SpecialPowers.DOMWindowUtils.paintCount;
     42    doElementFlicker();
     43    return;
     44  }
     45 
     46  color = (color + 1) % 256;
     47  document.body.style.backgroundColor = "rgb(" + color + "," + color + "," + color + ")";
     48  setTimeout(doBackgroundFlicker, 0);
     49 }
     50 
     51 </script>
     52 </pre>
     53 
     54 <div style="height:4000px"></div>
     55 <a id="first"  href="http://www.mozilla.org/">first<br>link</a>
     56 <a id="second" href="http://www.mozilla.org/">second link</a>
     57 <a id="third"  href="http://www.mozilla.org/">third<br>link</a>
     58 <div style="height:4000px"></div>
     59 
     60 </body>
     61 </html>