dom/plugins/test/mochitest/test_bug539565-2.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial