layout/generic/test/test_bug784410.html
author L. David Baron <dbaron@dbaron.org>
Sat, 13 Sep 2014 06:17:36 -0700
changeset 228423 c81eb3a1336b2ab5f4e83b8b5df394dfea8be37e
parent 113502 3ee856aa68d228953d0d576dc8bd4a6da138c1ca
child 258365 8d23b1e2cc0f70fa3c1778353192779efae4056e
permissions -rw-r--r--
Bug 977991 patch 1 - Expose variant of RulesMatching on nsHTMLCSSStyleSheet that is less work to call. r=birtles This allows nsStyleSet::RuleNodeWithReplacement to call it without constructing an entire (and unnecessary) ElementRuleProcessorData, which will happen in patch 3.

<!DOCTYPE HTML>
<html>
<head>
  <title>Test bug 784410</title>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>
<div id="outer" style="overflow:auto; height:200px; border:2px dotted black;" onscroll="doneScroll()">
  <div id="d" style="overflow:auto; height:102px;" onscroll="doneScroll()">
    <div id="inner" style="height:100.1px; border:1px solid black; background:yellow;">Hello</div>
  </div>
  <div style="height:500px;"></div>
</div>
<pre id="test">
<script class="testbody" type="text/javascript;version=1.7">
var sel = window.getSelection();
var outer = document.getElementById("outer");
var d = document.getElementById("d");
var inner = document.getElementById("inner");
var smoothScrollPref = "general.smoothScroll";

function innerScrollOffset() {
  return inner.getBoundingClientRect().top - d.getBoundingClientRect().top;
}
var innerStartScrollOffset = innerScrollOffset();

var step = 0;
function doneScroll() {
  ++step;
  switch (step) {
  case 1:
    is(innerScrollOffset(), innerStartScrollOffset, "Inner element should not have scrolled down");
    ok(outer.scrollTop > 0, "Outer element should have scrolled down");

    outer.scrollTop = 0;
    break;
  case 2:
    synthesizeWheel(inner, 4, 4,
      { deltaMode: WheelEvent.DOM_DELTA_LINE, deltaY: 1 });
    break;
  case 3:
    is(innerScrollOffset(), innerStartScrollOffset, "Inner element should not have scrolled down");
    ok(outer.scrollTop > 0, "Outer element should have scrolled down");
    
    SpecialPowers.clearUserPref(smoothScrollPref);
    SimpleTest.finish();
    break;
  }
}

function test() {
  SpecialPowers.setBoolPref(smoothScrollPref, false);
  sel.collapse(inner.firstChild, 2);
  synthesizeKey("VK_PAGE_DOWN", {});
}

SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(test);

</script>
</pre>
</body>
</html>