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