1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/plugins/test/mochitest/test_bug539565-1.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,90 @@ 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 #1 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 test1() { // fullZoom=1 (sanity check) 1.62 + zoom(1); 1.63 + click(55,136, function(){verify("1",55,136,test2)}); 1.64 + } 1.65 + function test2() { // fullZoom=2 1.66 + zoom(2); 1.67 + click(40,108, function(){verify("2",80,216,test2b)}) 1.68 + } 1.69 + function test2b() { 1.70 + click(108,112, function(){verify("2c",216,224,endTest)}) 1.71 + } 1.72 + 1.73 + function endTest() { 1.74 + zoom(1); 1.75 + SimpleTest.finish(); 1.76 + } 1.77 + 1.78 + setTimeout(function(){waitForPaint(test1)},1000); 1.79 +} 1.80 + 1.81 +SimpleTest.waitForExplicitFinish(); 1.82 +setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED); 1.83 + 1.84 + </script> 1.85 +</head> 1.86 + 1.87 +<body onload="runTests()"> 1.88 + <div id="container" style="position:relative;top: 0px; left: 0px; width: 640px; height: 480px;"> 1.89 + <div id="abs" style="position:absolute; left:90px; top:90px; width:20px; height:20px; background:blue; pointer-events:none;"></div> 1.90 + <embed id="plugin1" type="application/x-test" wmode="transparent" width="200" height="200"></embed> 1.91 + </div> 1.92 +</body> 1.93 +</html>