1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/plugins/test/mochitest/test_bug539565-2.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,110 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=539565 1.8 +--> 1.9 +<head> 1.10 + <title>Test #2 for Bug 539565</title> 1.11 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script> 1.13 + <script type="application/javascript" src="utils.js"></script> 1.14 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.15 + 1.16 + <script class="testbody" type="text/javascript"> 1.17 +function runTests() { 1.18 + var moveBy = 17; 1.19 + var waitedForPaint = 0; 1.20 + function waitForPaint(func) { 1.21 + waitedForPaint = 0; 1.22 + var testplugin = $("plugin1"); 1.23 + testplugin.last_paint_count = testplugin.getPaintCount ? testplugin.getPaintCount() : -2; 1.24 + function waitForPaintCountIncrement() { 1.25 + waitedForPaint++; 1.26 + moveBy = -moveBy; 1.27 + $("abs").style.left = ($("abs").offsetLeft + moveBy) + 'px'; 1.28 + var x = document.documentElement.offsetHeight; 1.29 + var pc = testplugin.getPaintCount ? testplugin.getPaintCount() : -2; 1.30 + if (waitedForPaint == 20 || (pc != testplugin.last_paint_count && pc >= 0)) { 1.31 + setTimeout(func,0); 1.32 + } else 1.33 + setTimeout(waitForPaintCountIncrement, 50); 1.34 + } 1.35 + waitForPaintCountIncrement(); 1.36 + } 1.37 + 1.38 + function doClick(x,y,func) { 1.39 + synthesizeMouse($("plugin1"), x, y, {}, window); 1.40 + setTimeout(func,0); 1.41 + } 1.42 + 1.43 + function verify(test,x,y,next) { 1.44 + var p = $("plugin1").getLastMouseX(); 1.45 + const delta = 2; 1.46 + ok(p-delta <= x && x <= p+delta, "test"+test+" LastMouseX got " + p + " expected " + x + 1.47 + " with fullZoom="+SpecialPowers.getFullZoom(window)+" MozTransform='"+$("container").style.MozTransform+"'"); 1.48 + p = $("plugin1").getLastMouseY(); 1.49 + ok(p-delta <= y && y <= p+delta, "test"+test+" LastMouseY got " + p + " expected " + y + 1.50 + " with fullZoom="+SpecialPowers.getFullZoom(window)+" MozTransform='"+$("container").style.MozTransform+"'"); 1.51 + if (next) next(); 1.52 + } 1.53 + 1.54 + function click(x,y,next) { 1.55 + waitForPaint(function(){doClick(x,y,next);}) 1.56 + } 1.57 + function zoom(factor) { 1.58 + SpecialPowers.setFullZoom(window, factor); 1.59 + } 1.60 + 1.61 + function test3() { // fullZoom=1 + scale(2) 1.62 + zoom(1); 1.63 + // 1.64 + // ======================== BUG WARNING ========================================= 1.65 + // 'container' already has -moz-transform:scale(2) in its style attribute. 1.66 + // Removing that and setting MozTransform dynamically here (as in test4) 1.67 + // makes the test fail ("getLastMouseX is not a function" in verify() above) 1.68 + // Looks like the plugin instance got destroyed and we never recover from that... 1.69 + // ============================================================================== 1.70 + // 1.71 + click(50,136, function(){verify("3",25,68,test3b)}); 1.72 + } 1.73 + function test3b() { 1.74 + click(208,212, function(){verify("3b",104,106,test4)}); 1.75 + } 1.76 + function test4() { // fullZoom=2 + scale(0.5) 1.77 + zoom(2); 1.78 + var container = $("container"); 1.79 + container.style.MozTransformOrigin = "0px 0px"; 1.80 + container.style.MozTransform = "scale(0.5)"; 1.81 + var x = document.documentElement.offsetHeight; 1.82 + click(60,52, function(){verify("4",240,208,test5)}); 1.83 + } 1.84 + function test5() { // fullZoom=2 + scale(2) 1.85 + zoom(2); 1.86 + var container = $("container"); 1.87 + container.style.MozTransformOrigin = "0px 0px"; 1.88 + container.style.MozTransform = "scale(2)"; 1.89 + var x = document.documentElement.offsetHeight; 1.90 + click(108,112, function(){verify("5",108,112,endTest)}); 1.91 + } 1.92 + 1.93 + function endTest() { 1.94 + zoom(1); 1.95 + SimpleTest.finish(); 1.96 + } 1.97 + 1.98 + setTimeout(function(){waitForPaint(test3)},1000); 1.99 +} 1.100 + 1.101 +SimpleTest.waitForExplicitFinish(); 1.102 +setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED); 1.103 + 1.104 + </script> 1.105 +</head> 1.106 + 1.107 +<body onload="runTests()"> 1.108 + <div id="container" style="position:relative;top: 0px; left: 0px; width: 640px; height: 480px; -moz-transform:scale(2); -moz-transform-origin:0px 0px;"> 1.109 + <div id="abs" style="position:absolute; left:90px; top:90px; width:20px; height:20px; background:blue; pointer-events:none;"></div> 1.110 + <embed id="plugin1" type="application/x-test" wmode="transparent" width="200" height="200"></embed> 1.111 + </div> 1.112 +</body> 1.113 +</html>