dom/plugins/test/mochitest/test_windowed_invalidate.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 <html>
michael@0 2 <head>
michael@0 3 <title>Test NPN_Invalidate working for a windowed plugin</title>
michael@0 4 <script type="text/javascript"
michael@0 5 src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 6 <script type="text/javascript" src="utils.js"></script>
michael@0 7 <link rel="stylesheet" type="text/css"
michael@0 8 href="/tests/SimpleTest/test.css" />
michael@0 9 </head>
michael@0 10 <body onload="runTests()">
michael@0 11 <script class="testbody" type="application/javascript">
michael@0 12 SimpleTest.waitForExplicitFinish();
michael@0 13 setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
michael@0 14
michael@0 15 var lastPaintCount;
michael@0 16 var p = null;
michael@0 17
michael@0 18 function checkPainted() {
michael@0 19 if (p.getPaintCount() > lastPaintCount) {
michael@0 20 ok(true, "Plugin did repaint");
michael@0 21 SimpleTest.finish();
michael@0 22 } else {
michael@0 23 setTimeout(checkPainted, 100);
michael@0 24 }
michael@0 25 }
michael@0 26
michael@0 27 function doTest() {
michael@0 28 // Cause the plugin to invalidate itself using NPN_Invalidate,
michael@0 29 // and then wait for the plugin's paintCount to increase. This is the
michael@0 30 // simplest way to check that a windowed plugin has repainted.
michael@0 31 p.setColor("FF00FF00");
michael@0 32 checkPainted();
michael@0 33 }
michael@0 34
michael@0 35 function checkPaintCountStabilized() {
michael@0 36 // Wait for the paint count to stabilize (i.e. doesn't change for a full
michael@0 37 // second), so that all buffered-up painting is hopefully finished,
michael@0 38 // before running the test
michael@0 39 lastPaintCount = p.getPaintCount();
michael@0 40 setTimeout(function() {
michael@0 41 var newCount = p.getPaintCount();
michael@0 42 if (newCount == lastPaintCount) {
michael@0 43 doTest();
michael@0 44 } else {
michael@0 45 checkPaintCountStabilized();
michael@0 46 }
michael@0 47 }, 1000);
michael@0 48 }
michael@0 49
michael@0 50 function runTests() {
michael@0 51 p = document.getElementById("p");
michael@0 52 checkPaintCountStabilized();
michael@0 53 }
michael@0 54 </script>
michael@0 55
michael@0 56 <p id="display"></p>
michael@0 57
michael@0 58 <embed id="p" type="application/x-test" wmode="window" drawmode="solid"
michael@0 59 color="FFFF0000">
michael@0 60 </embed>
michael@0 61
michael@0 62 <div id="verbose">
michael@0 63 </div>
michael@0 64 </body>
michael@0 65 </html>

mercurial