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