dom/plugins/test/mochitest/test_plugin_scroll_painting.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 <head>
     4   <title>Test that scrolling a windowless plugin doesn't force us to repaint it</title>
     5   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     6   <script type="text/javascript" src="utils.js"></script>
     7   <script type="text/javascript">
     8     setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
     9   </script>
    10   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    11 </head>
    12 <body onload="runTest()">
    13 <p id="display"></p>
    14   <embed id="plugin" type="application/x-test" style="width:50px; height:10px; margin-top:20px;"></embed>
    15 </div>
    16 <div id="content" style="display: none">
    18 </div>
    19 <pre id="test">
    20 </pre>
    22 <script type="application/javascript">
    23 SimpleTest.waitForExplicitFinish();
    25 var container = document.documentElement;
    26 container.scrollTop = 0;
    27 var plugin = document.getElementById("plugin");
    28 var pluginTop;
    29 var beforeScrollPaintCount;
    31 function waitForScroll() {
    32   if (plugin.getEdge(1) >= pluginTop) {
    33     setTimeout(waitForScroll, 0);
    34     return;
    35   }
    37   is(plugin.getPaintCount(), beforeScrollPaintCount, "plugin should not paint due to scrolling");
    38   SimpleTest.finish();
    39 }
    41 function waitForInitialScroll() {
    42   if (plugin.getEdge(1) >= pluginTop) {
    43     setTimeout(waitForInitialScroll, 0);
    44     return;
    45   }
    47   pluginTop = plugin.getEdge(1);
    48   beforeScrollPaintCount = plugin.getPaintCount();
    49   container.scrollTop = 20;
    50   waitForScroll();
    51 }
    53 function runTest() {
    54   document.body.offsetTop;
    55   pluginTop = plugin.getEdge(1);
    56   container.scrollTop = 10;
    57   waitForInitialScroll();
    58 }
    59 </script>
    61 <div style="height:4000px;"></div>
    63 </body>
    64 </html>

mercurial