|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <head> |
|
4 <title>Test for windowless plugin invalidation and expose events in clips</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 <style> |
|
8 div#container { |
|
9 position: relative; |
|
10 height: 30px; |
|
11 background: blue; |
|
12 } |
|
13 div#clip { |
|
14 overflow:hidden; |
|
15 position:absolute; |
|
16 left: 10.3px; |
|
17 top: 9.7px; |
|
18 width: 10px; |
|
19 height: 0px; |
|
20 background: red; |
|
21 } |
|
22 embed { |
|
23 position:absolute; |
|
24 } |
|
25 embed#paint-waiter { |
|
26 top: 0px; |
|
27 left: 0px; |
|
28 width: 1px; |
|
29 height: 0px; |
|
30 } |
|
31 embed#clipped { |
|
32 left: -5.3px; |
|
33 top: -4.7px; |
|
34 width: 20px; |
|
35 height: 20px; |
|
36 } |
|
37 </style> |
|
38 </head> |
|
39 <body onload="initialize()"> |
|
40 |
|
41 <script type="application/javascript" src="utils.js"></script> |
|
42 <script type="application/javascript"> |
|
43 SimpleTest.waitForExplicitFinish(); |
|
44 setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED); |
|
45 |
|
46 var paint_waiter; |
|
47 var clip; |
|
48 var clipped; |
|
49 |
|
50 function initialize() { |
|
51 paint_waiter = document.getElementById("paint-waiter"); |
|
52 clip = document.getElementById("clip"); |
|
53 clipped = document.getElementById("clipped"); |
|
54 |
|
55 waitForPaint(show); |
|
56 } |
|
57 |
|
58 function show() { |
|
59 paintCountIs(clipped, 0, "fully clipped plugin not painted"); |
|
60 |
|
61 clip.style.height = "10px"; |
|
62 |
|
63 // Capturing an image (as in a reftest) would force a repaint and use |
|
64 // different paths for the image surface, so instead check the plugin's |
|
65 // paint count. |
|
66 waitForPaint(invalidate); |
|
67 } |
|
68 |
|
69 function invalidate() { |
|
70 paintCountIs(clipped, 1, "partially clipped plugin painted once"); |
|
71 |
|
72 clipped.setColor("FF00FF00"); // plugin invalidates |
|
73 |
|
74 waitForPaint(done); |
|
75 } |
|
76 |
|
77 function done() { |
|
78 paintCountIs(clipped, 2, "painted after invalidate"); |
|
79 |
|
80 SimpleTest.finish(); |
|
81 } |
|
82 |
|
83 function waitForPaint(func) { |
|
84 paint_waiter.last_paint_count = paint_waiter.getPaintCount(); |
|
85 // Ensure the waiter has had a style change, so that this will |
|
86 // change its size and cause a paint. |
|
87 paint_waiter.style.backgroundColor = paint_waiter.style.backgroundColor == "blue" ? "yellow" : "blue"; |
|
88 var flush = paint_waiter.offsetHeight; |
|
89 paint_waiter.style.height = "1px"; |
|
90 waitForPaintHelper(func); |
|
91 } |
|
92 |
|
93 function waitForPaintHelper(func) { |
|
94 if (paint_waiter.getPaintCount() != paint_waiter.last_paint_count) { |
|
95 // hide the paint waiter |
|
96 paint_waiter.style.height = "0px"; |
|
97 setTimeout(func, 0); |
|
98 return; |
|
99 } |
|
100 setTimeout(function() { waitForPaintHelper(func); }, 1000); |
|
101 } |
|
102 |
|
103 </script> |
|
104 |
|
105 <p id="display"></p> |
|
106 <div id="container"> |
|
107 <embed id="paint-waiter" type="application/x-test"/> |
|
108 <div id="clip"> |
|
109 <embed id="clipped" type="application/x-test" |
|
110 drawmode="solid" color="FF808080"/> |
|
111 </div> |
|
112 </div> |
|
113 <div id="content" style="display: none"> |
|
114 |
|
115 </div> |
|
116 <pre id="test"> |
|
117 </pre> |
|
118 |
|
119 </body> |
|
120 </html> |