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 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=539565
5 -->
6 <head>
7 <title>Test #2 for Bug 539565</title>
8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
9 <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
10 <script type="application/javascript" src="utils.js"></script>
11 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
13 <script class="testbody" type="text/javascript">
14 function runTests() {
15 var moveBy = 17;
16 var waitedForPaint = 0;
17 function waitForPaint(func) {
18 waitedForPaint = 0;
19 var testplugin = $("plugin1");
20 testplugin.last_paint_count = testplugin.getPaintCount ? testplugin.getPaintCount() : -2;
21 function waitForPaintCountIncrement() {
22 waitedForPaint++;
23 moveBy = -moveBy;
24 $("abs").style.left = ($("abs").offsetLeft + moveBy) + 'px';
25 var x = document.documentElement.offsetHeight;
26 var pc = testplugin.getPaintCount ? testplugin.getPaintCount() : -2;
27 if (waitedForPaint == 20 || (pc != testplugin.last_paint_count && pc >= 0)) {
28 setTimeout(func,0);
29 } else
30 setTimeout(waitForPaintCountIncrement, 50);
31 }
32 waitForPaintCountIncrement();
33 }
35 function doClick(x,y,func) {
36 synthesizeMouse($("plugin1"), x, y, {}, window);
37 setTimeout(func,0);
38 }
40 function verify(test,x,y,next) {
41 var p = $("plugin1").getLastMouseX();
42 const delta = 2;
43 ok(p-delta <= x && x <= p+delta, "test"+test+" LastMouseX got " + p + " expected " + x +
44 " with fullZoom="+SpecialPowers.getFullZoom(window)+" MozTransform='"+$("container").style.MozTransform+"'");
45 p = $("plugin1").getLastMouseY();
46 ok(p-delta <= y && y <= p+delta, "test"+test+" LastMouseY got " + p + " expected " + y +
47 " with fullZoom="+SpecialPowers.getFullZoom(window)+" MozTransform='"+$("container").style.MozTransform+"'");
48 if (next) next();
49 }
51 function click(x,y,next) {
52 waitForPaint(function(){doClick(x,y,next);})
53 }
54 function zoom(factor) {
55 SpecialPowers.setFullZoom(window, factor);
56 }
58 function test3() { // fullZoom=1 + scale(2)
59 zoom(1);
60 //
61 // ======================== BUG WARNING =========================================
62 // 'container' already has -moz-transform:scale(2) in its style attribute.
63 // Removing that and setting MozTransform dynamically here (as in test4)
64 // makes the test fail ("getLastMouseX is not a function" in verify() above)
65 // Looks like the plugin instance got destroyed and we never recover from that...
66 // ==============================================================================
67 //
68 click(50,136, function(){verify("3",25,68,test3b)});
69 }
70 function test3b() {
71 click(208,212, function(){verify("3b",104,106,test4)});
72 }
73 function test4() { // fullZoom=2 + scale(0.5)
74 zoom(2);
75 var container = $("container");
76 container.style.MozTransformOrigin = "0px 0px";
77 container.style.MozTransform = "scale(0.5)";
78 var x = document.documentElement.offsetHeight;
79 click(60,52, function(){verify("4",240,208,test5)});
80 }
81 function test5() { // fullZoom=2 + scale(2)
82 zoom(2);
83 var container = $("container");
84 container.style.MozTransformOrigin = "0px 0px";
85 container.style.MozTransform = "scale(2)";
86 var x = document.documentElement.offsetHeight;
87 click(108,112, function(){verify("5",108,112,endTest)});
88 }
90 function endTest() {
91 zoom(1);
92 SimpleTest.finish();
93 }
95 setTimeout(function(){waitForPaint(test3)},1000);
96 }
98 SimpleTest.waitForExplicitFinish();
99 setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
101 </script>
102 </head>
104 <body onload="runTests()">
105 <div id="container" style="position:relative;top: 0px; left: 0px; width: 640px; height: 480px; -moz-transform:scale(2); -moz-transform-origin:0px 0px;">
106 <div id="abs" style="position:absolute; left:90px; top:90px; width:20px; height:20px; background:blue; pointer-events:none;"></div>
107 <embed id="plugin1" type="application/x-test" wmode="transparent" width="200" height="200"></embed>
108 </div>
109 </body>
110 </html>