scrolling.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. var topElements;
  2. var failed = false;
  3. function doScroll(d)
  4. {
  5. if (failed)
  6. return;
  7. for (var i = 0; i < topElements.length; ++i) {
  8. var e = topElements[i];
  9. e.scrollTop = d;
  10. if (e.scrollTop != d) {
  11. document.documentElement.textContent =
  12. "Scrolling failed on " + e.tagName + " element, " +
  13. "tried to scroll to " + d + ", got " + e.scrollTop +
  14. " (Random number: " + Math.random() + ")";
  15. failed = true;
  16. }
  17. }
  18. }
  19. // bug 1134459, images are decoded off main thread
  20. // Wait for the load event so we know all images have loaded
  21. document.onload = function() {
  22. topElements = document.getElementsByClassName("scrollTop");
  23. if (!topElements.length) {
  24. topElements = [document.documentElement];
  25. }
  26. if (document.location.search == '?ref') {
  27. doScroll(20);
  28. } else if (document.location.search == '?up') {
  29. doScroll(40);
  30. document.documentElement.setAttribute("class", "reftest-wait");
  31. window.addEventListener("MozReftestInvalidate", function() {
  32. document.documentElement.removeAttribute("class");
  33. doScroll(20);
  34. }, false);
  35. } else {
  36. doScroll(1);
  37. document.documentElement.setAttribute("class", "reftest-wait");
  38. window.addEventListener("MozReftestInvalidate", function() {
  39. document.documentElement.removeAttribute("class");
  40. doScroll(20);
  41. }, false);
  42. }
  43. }