dom/plugins/test/mochitest/test_plugin_scroll_painting.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/plugins/test/mochitest/test_plugin_scroll_painting.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,64 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<head>
     1.7 +  <title>Test that scrolling a windowless plugin doesn't force us to repaint it</title>
     1.8 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     1.9 +  <script type="text/javascript" src="utils.js"></script>
    1.10 +  <script type="text/javascript">
    1.11 +    setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
    1.12 +  </script>
    1.13 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.14 +</head>
    1.15 +<body onload="runTest()">
    1.16 +<p id="display"></p>
    1.17 +  <embed id="plugin" type="application/x-test" style="width:50px; height:10px; margin-top:20px;"></embed>
    1.18 +</div>
    1.19 +<div id="content" style="display: none">
    1.20 +
    1.21 +</div>
    1.22 +<pre id="test">
    1.23 +</pre>
    1.24 +
    1.25 +<script type="application/javascript">
    1.26 +SimpleTest.waitForExplicitFinish();
    1.27 +
    1.28 +var container = document.documentElement;
    1.29 +container.scrollTop = 0;
    1.30 +var plugin = document.getElementById("plugin");
    1.31 +var pluginTop;
    1.32 +var beforeScrollPaintCount;
    1.33 +
    1.34 +function waitForScroll() {
    1.35 +  if (plugin.getEdge(1) >= pluginTop) {
    1.36 +    setTimeout(waitForScroll, 0);
    1.37 +    return;
    1.38 +  }
    1.39 +
    1.40 +  is(plugin.getPaintCount(), beforeScrollPaintCount, "plugin should not paint due to scrolling");
    1.41 +  SimpleTest.finish();
    1.42 +}
    1.43 +
    1.44 +function waitForInitialScroll() {
    1.45 +  if (plugin.getEdge(1) >= pluginTop) {
    1.46 +    setTimeout(waitForInitialScroll, 0);
    1.47 +    return;
    1.48 +  }
    1.49 +
    1.50 +  pluginTop = plugin.getEdge(1);
    1.51 +  beforeScrollPaintCount = plugin.getPaintCount();
    1.52 +  container.scrollTop = 20;
    1.53 +  waitForScroll();
    1.54 +}
    1.55 +
    1.56 +function runTest() {
    1.57 +  document.body.offsetTop;
    1.58 +  pluginTop = plugin.getEdge(1);
    1.59 +  container.scrollTop = 10;
    1.60 +  waitForInitialScroll();
    1.61 +}
    1.62 +</script>
    1.63 +
    1.64 +<div style="height:4000px;"></div>
    1.65 +
    1.66 +</body>
    1.67 +</html>

mercurial