layout/reftests/scrolling/scrolling.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/reftests/scrolling/scrolling.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,41 @@
     1.4 +var topElements = document.getElementsByClassName("scrollTop");
     1.5 +if (!topElements.length) {
     1.6 +  topElements = [document.documentElement];
     1.7 +}
     1.8 +
     1.9 +var failed = false;
    1.10 +
    1.11 +function doScroll(d)
    1.12 +{
    1.13 +  if (failed)
    1.14 +    return;
    1.15 +  for (var i = 0; i < topElements.length; ++i) {
    1.16 +    var e = topElements[i];
    1.17 +    e.scrollTop = d;
    1.18 +    if (e.scrollTop != d) {
    1.19 +      document.documentElement.textContent =
    1.20 +          "Scrolling failed on " + e.tagName + " element, " +
    1.21 +          "tried to scroll to " + d + ", got " + e.scrollTop +
    1.22 +          " (Random number: " + Math.random() + ")";
    1.23 +      failed = true;
    1.24 +    }
    1.25 +  }
    1.26 +}
    1.27 +
    1.28 +if (document.location.search == '?ref') {
    1.29 +  doScroll(20);
    1.30 +} else if (document.location.search == '?up') {
    1.31 +  doScroll(40);
    1.32 +  document.documentElement.setAttribute("class", "reftest-wait");
    1.33 +  window.addEventListener("MozReftestInvalidate", function() {
    1.34 +    document.documentElement.removeAttribute("class");
    1.35 +    doScroll(20);
    1.36 +  }, false);
    1.37 +} else {
    1.38 +  doScroll(1);
    1.39 +  document.documentElement.setAttribute("class", "reftest-wait");
    1.40 +  window.addEventListener("MozReftestInvalidate", function() {
    1.41 +    document.documentElement.removeAttribute("class");
    1.42 +    doScroll(20);
    1.43 +  }, false);
    1.44 +}

mercurial