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