|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <head> |
|
4 <title>Test for plugin child widgets not being invalidated by scrolling</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 </head> |
|
8 <body onload="initialize()"> |
|
9 <script type="application/javascript"> |
|
10 var pluginHost = SpecialPowers.Cc["@mozilla.org/plugin/host;1"] |
|
11 .getService(SpecialPowers.Ci.nsIPluginHost); |
|
12 var pluginTags = pluginHost.getPluginTags(); |
|
13 for (var tag of pluginTags) { |
|
14 if (tag.name == "Test Plug-in") { |
|
15 tag.enabledState = SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED;; |
|
16 } |
|
17 } |
|
18 </script> |
|
19 |
|
20 <p id="display"> |
|
21 <iframe id="i" src="plugin_scroll_invalidation.html" |
|
22 width="50" height="50" scrolling="no"></iframe> |
|
23 </p> |
|
24 <div id="content" style="display: none"> |
|
25 |
|
26 </div> |
|
27 <pre id="test"> |
|
28 </pre> |
|
29 |
|
30 <script type="application/javascript"> |
|
31 SimpleTest.waitForExplicitFinish(); |
|
32 |
|
33 var scrolling; |
|
34 var scrolling_plugins = []; |
|
35 var paint_waiter; |
|
36 var last_paint_counts; |
|
37 |
|
38 function initialize() { |
|
39 scrolling = document.getElementById("i").contentWindow; |
|
40 scrolling_plugins = scrolling.document.querySelectorAll("embed.scrolling"); |
|
41 paint_waiter = scrolling.document.getElementById("paint-waiter"); |
|
42 |
|
43 scrolling.scrollTo(50, 45); |
|
44 |
|
45 is(paint_waiter.getPaintCount(), 0, "zero-sized plugin not painted"); |
|
46 |
|
47 waitForPaint(scrollAround); |
|
48 } |
|
49 |
|
50 function scrollAround() { |
|
51 var paints = getPaintCounts(); |
|
52 |
|
53 for (var i = 0; i < paints.length; ++i) { |
|
54 isnot(paints[i], 0, "embed " + scrolling_plugins[i].id + " is painted"); |
|
55 } |
|
56 |
|
57 last_paint_counts = paints; |
|
58 |
|
59 scrolling.scrollBy(-5, 5); |
|
60 scrolling.scrollBy(5, 5); |
|
61 scrolling.scrollBy(5, -5); |
|
62 scrolling.scrollBy(-5, -5); |
|
63 |
|
64 scrolling.scrollTo(45, 45); |
|
65 scrolling.scrollBy(10, 0); |
|
66 scrolling.scrollBy(0, 10); |
|
67 scrolling.scrollBy(-10, 0); |
|
68 scrolling.scrollBy(0, -10); |
|
69 |
|
70 waitForPaint(done); |
|
71 } |
|
72 |
|
73 function done() { |
|
74 var paints = getPaintCounts(); |
|
75 for (var i = 0; i < paints.length; ++i) { |
|
76 is(paints[i], last_paint_counts[i], "embed " + scrolling_plugins[i].id + " is not painted on scroll"); |
|
77 } |
|
78 SimpleTest.finish(); |
|
79 } |
|
80 |
|
81 // Waits for the paint_waiter plugin to be repainted and then |
|
82 // calls 'func' to continue. |
|
83 function waitForPaint(func) { |
|
84 paint_waiter.last_paint_count = paint_waiter.getPaintCount(); |
|
85 |
|
86 paint_waiter.style.left = scrolling.scrollX + "px"; |
|
87 paint_waiter.style.top = scrolling.scrollY + "px"; |
|
88 |
|
89 // Fiddle with the style in a way that should force some repainting |
|
90 paint_waiter.style.width = |
|
91 (paint_waiter.getBoundingClientRect().width + 1) + "px"; |
|
92 paint_waiter.style.height = "1px"; |
|
93 |
|
94 function waitForPaintHelper() { |
|
95 if (paint_waiter.getPaintCount() != paint_waiter.last_paint_count) { |
|
96 setTimeout(func, 0); |
|
97 return; |
|
98 } |
|
99 setTimeout(waitForPaintHelper, 0); |
|
100 } |
|
101 waitForPaintHelper(); |
|
102 } |
|
103 |
|
104 function getPaintCounts() { |
|
105 var result = []; |
|
106 for (var i = 0; i < scrolling_plugins.length; ++i) { |
|
107 result[i] = scrolling_plugins[i].getPaintCount(); |
|
108 } |
|
109 return result; |
|
110 } |
|
111 |
|
112 </script> |
|
113 </body> |
|
114 </html> |