dom/plugins/test/mochitest/test_bug539565-1.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

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

mercurial