layout/base/tests/test_bug629838.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <!DOCTYPE HTML>
     2 <html>
     3 <head>
     4   <title>Tests for MozAfterPaint</title>
     5   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     6   <script type="text/javascript" src="enableTestPlugin.js"></script>
     7   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     8 </head>
     9 <body>
    10 <p id="display">
    11 <embed type="application/x-test" width="100" height="100" id="p"
    12        drawmode="solid" color="FF00FF00"></embed>
    13 </p>
    14 <div id="content" style="display: none">
    16 </div>
    17 <pre id="test">
    18 <script class="testbody" type="text/javascript">
    20 SimpleTest.waitForExplicitFinish();
    22 var initialPaintCount, afterPaintCount;
    23 var color = 0;
    25 function onAfterPaint () {
    26   afterPaintCount += 1;
    27 }
    29 function startTest() {
    30   setTimeout(function () {
    31     afterPaintCount = 0;
    32     initialPaintCount = window.mozPaintCount;
    33     window.addEventListener("MozAfterPaint", onAfterPaint, true);
    34     doBackgroundFlicker();
    35   }, 500);
    36 }
    38 document.addEventListener("DOMContentLoaded", startTest, true);
    40 // Unfortunately we cannot reliably assert that mozPaintCount and afterPaintCount increment perfectly
    41 // in sync, because they can diverge in the presence of OS-triggered paints or system load.
    42 // Instead, wait for a minimum number of afterPaint events to at least ensure that they are being fired.
    43 const minimumAfterPaintsToPass = 10;
    45 function doPluginFlicker() {
    46   ok(true, "Plugin color iteration " + color + 
    47      ", afterpaint count: " + afterPaintCount +
    48      ", mozpaint count: " + window.mozPaintCount);
    49   if (afterPaintCount >= minimumAfterPaintsToPass) { 
    50     ok(true, "afterPaintCount incremented enough from plugin color changes.");
    51     SimpleTest.finish();
    52     return;
    53   }
    55   color = (color + 1) % 256;
    56   var str = color.toString(16);
    57   if (str.length < 2) {
    58     str = "0" + str;
    59   }
    60   str = "FF" + str + str + str;
    61   document.getElementById("p").setColor(str);
    62   setTimeout(doPluginFlicker, 0);
    63 }
    65 function doBackgroundFlicker() {
    66   ok(true, "Background color iteration " + color + 
    67      ", afterpaint count: " + afterPaintCount +
    68      ", mozpaint count: " + window.mozPaintCount);
    69   if (afterPaintCount >= minimumAfterPaintsToPass) {
    70     ok(true, "afterPaintCount incremented enough from background color changes.");
    71     afterPaintCount = 0;
    72     initialPaintCount = window.mozPaintCount;
    73     doPluginFlicker();
    74     return;
    75   }
    77   color = (color + 1) % 256;
    78   document.body.style.backgroundColor = "rgb(" + color + "," + color + "," + color + ")";
    79   setTimeout(doBackgroundFlicker, 0);
    80 }
    82 </script>
    83 </pre>
    85 <div style="height:4000px"></div>
    86 <a id="first"  href="http://www.mozilla.org/">first<br>link</a>
    87 <a id="second" href="http://www.mozilla.org/">second link</a>
    88 <a id="third"  href="http://www.mozilla.org/">third<br>link</a>
    89 <div style="height:4000px"></div>
    91 </body>
    92 </html>

mercurial