mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-08 12:22:34 +00:00
Bug 873727 - Use a listener instead of timers to fix intermittent failures. r=roc
This commit is contained in:
parent
7a339f0b0b
commit
a64eba0ec3
@ -28,6 +28,21 @@ function runTest()
|
||||
var sel1 = frames[0].getSelection();
|
||||
sel1.collapse(frames[0].document.body, 0);
|
||||
|
||||
var sel2 = frames[1].getSelection();
|
||||
sel2.collapse(frames[1].document.body, 0);
|
||||
window.frames[0].focus();
|
||||
document.commandDispatcher.getControllerForCommand("cmd_moveBottom").doCommand("cmd_moveBottom");
|
||||
|
||||
var listener = function() {
|
||||
if (!(frames[0].scrollY > 0)) {
|
||||
window.content.removeEventListener("scroll", listener, false);
|
||||
}
|
||||
}
|
||||
window.frames[0].addEventListener("scroll", listener, false);
|
||||
|
||||
var sel1 = frames[0].getSelection();
|
||||
sel1.collapse(frames[0].document.body, 0);
|
||||
|
||||
var sel2 = frames[1].getSelection();
|
||||
sel2.collapse(frames[1].document.body, 0);
|
||||
|
||||
@ -47,22 +62,6 @@ function runTest()
|
||||
|
||||
otherWindow = window.open("window_showcaret.xul", "_blank", "chrome,width=400,height=200");
|
||||
otherWindow.addEventListener("focus", otherWindowFocused, false);
|
||||
|
||||
var sel1 = frames[0].getSelection();
|
||||
sel1.collapse(frames[0].document.body, 0);
|
||||
|
||||
var sel2 = frames[1].getSelection();
|
||||
sel2.collapse(frames[1].document.body, 0);
|
||||
window.frames[0].focus();
|
||||
document.commandDispatcher.getControllerForCommand("cmd_moveBottom").doCommand("cmd_moveBottom");
|
||||
|
||||
/* We aren't sure exactly how long the cmd_moveBottom will take.
|
||||
* Therefore, check for success every second. If we don't have success within 10 seconds, assume the scroll
|
||||
* will never pass the test and fail it.
|
||||
*/
|
||||
|
||||
var timeoutUntilFail = window.setTimeout(scrollYTimeout, 10000);
|
||||
var testScroll = self.setInterval(function(){continueTest()}, 10);
|
||||
}
|
||||
|
||||
function otherWindowFocused()
|
||||
@ -87,19 +86,6 @@ function otherWindowFocused()
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function continueTest() {
|
||||
if (frames[0].scrollY > 0) {
|
||||
return;
|
||||
}
|
||||
testScroll = window.clearInterval(testScroll);
|
||||
window.clearTimeout(timeoutUntilFail);
|
||||
return;
|
||||
}
|
||||
|
||||
function scrollYTimeout() {
|
||||
ok(frames[0].scrollY > 0, "scrollY for non-showcaret");
|
||||
}
|
||||
|
||||
]]>
|
||||
</script>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user