Bug 625672. Part 1: Fix scrolling tests to actually test stuff correctly. r=dbaron

This commit is contained in:
Robert O'Callahan 2011-02-10 21:58:11 +13:00
Родитель 76dfea6522
Коммит 0348123caf
2 изменённых файлов: 16 добавлений и 4 удалений

Просмотреть файл

@ -1,12 +1,24 @@
var topElements = document.getElementsByClassName("scrollTop"); var topElements = document.getElementsByClassName("scrollTop");
if (!topElements.length) { if (!topElements.length) {
topElements = [document.body]; topElements = [document.documentElement];
} }
var failed = false;
function doScroll(d) function doScroll(d)
{ {
if (failed)
return;
for (var i = 0; i < topElements.length; ++i) { for (var i = 0; i < topElements.length; ++i) {
topElements[i].scrollTop = d; var e = topElements[i];
e.scrollTop = d;
if (e.scrollTop != d) {
document.documentElement.textContent =
"Scrolling failed on " + e.tagName + " element, " +
"tried to scroll to " + d + ", got " + e.scrollTop +
" (Random number: " + Math.random() + ")";
failed = true;
}
} }
} }

Просмотреть файл

@ -1,10 +1,10 @@
<!DOCTYPE HTML> <!DOCTYPE HTML>
<html> <html>
<body> <body>
<script src="scrolling.js"></script> <div class="scrollTop" style="height:100px; overflow:hidden;">
<div class="scrollTop" style="height:100px; overflow:auto;">
<div style="margin-top:30px;">Hello Kitty</div> <div style="margin-top:30px;">Hello Kitty</div>
<div style="height:400px;"></div> <div style="height:400px;"></div>
</div> </div>
<script src="scrolling.js"></script>
</body> </body>
</html> </html>