|
1 <!DOCTYPE html> |
|
2 <html> |
|
3 <head> |
|
4 <title>Test whether windowless plugins receive correct visible/invisible notifications.</title> |
|
5 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
|
7 |
|
8 <style> |
|
9 .hidden { visibility: hidden; } |
|
10 </style> |
|
11 |
|
12 <body onload="startTest()"> |
|
13 <p id="display"></p> |
|
14 |
|
15 <script type="application/javascript" src="utils.js"></script> |
|
16 <script type="application/javascript"> |
|
17 SimpleTest.waitForExplicitFinish(); |
|
18 setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED); |
|
19 |
|
20 var didPaint = function() {}; |
|
21 |
|
22 function startTest() { |
|
23 if (SimpleTest.testPluginIsOOP()) { |
|
24 if (p.getPaintCount() < 1) { |
|
25 setTimeout(startTest, 0); |
|
26 return; |
|
27 } |
|
28 } |
|
29 |
|
30 didPaint = function() { |
|
31 ok(false, "Plugin should not paint until it is visible!"); |
|
32 }; |
|
33 |
|
34 ok(!p.isVisible(), "Plugin should not be visible."); |
|
35 paintCountIs(p, 0, "Plugin should not have painted."); |
|
36 |
|
37 didPaint = part2; |
|
38 |
|
39 p.style.visibility = 'visible'; |
|
40 } |
|
41 |
|
42 function part2() { |
|
43 ok(p.isVisible(), "Plugin should now be visible."); |
|
44 paintCountIs(p, 1, "Plugin should have painted once."); |
|
45 |
|
46 didPaint = part3; |
|
47 |
|
48 p.setColor('FF0000FF'); // this causes an invalidate/repaint |
|
49 } |
|
50 |
|
51 const kTimeout = 5000; // 5 seconds |
|
52 var part4GiveUp; |
|
53 var part4Interval; |
|
54 |
|
55 function part3() { |
|
56 ok(p.isVisible(), "Plugin should still be visible."); |
|
57 paintCountIs(p, 2, "Plugin should have painted twice."); |
|
58 |
|
59 didPaint = function() { |
|
60 ok(false, "Plugin should not paint when it is invisible."); |
|
61 }; |
|
62 |
|
63 p.style.visibility = 'hidden'; |
|
64 |
|
65 part4GiveUp = Date.now() + kTimeout; |
|
66 part4Interval = setInterval(part4, 100); |
|
67 } |
|
68 |
|
69 function part4() { |
|
70 if (p.isVisible()) { |
|
71 if (Date.now() < part4GiveUp) |
|
72 return; |
|
73 |
|
74 ok(false, "Plugin never became invisible in part4."); |
|
75 SimpleTest.finish(); |
|
76 return; |
|
77 } |
|
78 |
|
79 clearInterval(part4Interval); |
|
80 |
|
81 ok(true, "Plugin became invisible again."); |
|
82 p.setColor('FF00FF00'); |
|
83 setTimeout(SimpleTest.finish, 500); |
|
84 // wait to make sure we don't actually paint |
|
85 } |
|
86 |
|
87 function inPaint() { |
|
88 // We're actually in the middle of painting the plugin so don't do anything |
|
89 // complex here, for the sake of cases where async plugin painting isn't |
|
90 // enabled yet |
|
91 setTimeout(didPaint, 0); |
|
92 // Don't run that didPaint callback again |
|
93 didPaint = function() {}; |
|
94 } |
|
95 </script> |
|
96 |
|
97 <embed id="theplugin" class="hidden" type="application/x-test" drawmode="solid" color="FFFF0000" paintscript="inPaint()"></embed> |
|
98 |
|
99 <script type="application/javascript"> |
|
100 var p = document.getElementById('theplugin'); |
|
101 </script> |