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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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 #1 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 test1() { // fullZoom=1 (sanity check)
michael@0 59 zoom(1);
michael@0 60 click(55,136, function(){verify("1",55,136,test2)});
michael@0 61 }
michael@0 62 function test2() { // fullZoom=2
michael@0 63 zoom(2);
michael@0 64 click(40,108, function(){verify("2",80,216,test2b)})
michael@0 65 }
michael@0 66 function test2b() {
michael@0 67 click(108,112, function(){verify("2c",216,224,endTest)})
michael@0 68 }
michael@0 69
michael@0 70 function endTest() {
michael@0 71 zoom(1);
michael@0 72 SimpleTest.finish();
michael@0 73 }
michael@0 74
michael@0 75 setTimeout(function(){waitForPaint(test1)},1000);
michael@0 76 }
michael@0 77
michael@0 78 SimpleTest.waitForExplicitFinish();
michael@0 79 setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
michael@0 80
michael@0 81 </script>
michael@0 82 </head>
michael@0 83
michael@0 84 <body onload="runTests()">
michael@0 85 <div id="container" style="position:relative;top: 0px; left: 0px; width: 640px; height: 480px;">
michael@0 86 <div id="abs" style="position:absolute; left:90px; top:90px; width:20px; height:20px; background:blue; pointer-events:none;"></div>
michael@0 87 <embed id="plugin1" type="application/x-test" wmode="transparent" width="200" height="200"></embed>
michael@0 88 </div>
michael@0 89 </body>
michael@0 90 </html>

mercurial