Bug 504586 test_bug430723.html should listen to scroll event after sending key events r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 16 Dec 2011 22:38:45 +0900
changeset 84430 e218f75ccc41d957718fce88c7403f6def13bf77
parent 84429 f720be43486d77d085411307852b7702c00a0960
child 84431 1d5d582321ccf4091e46185bcd76cc98079126b4
push id519
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 00:38:35 +0000
treeherdermozilla-beta@788ea1ef610b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs504586, 430723
milestone11.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 504586 test_bug430723.html should listen to scroll event after sending key events r=smaug
docshell/test/navigation/test_bug430723.html
--- a/docshell/test/navigation/test_bug430723.html
+++ b/docshell/test/navigation/test_bug430723.html
@@ -57,68 +57,79 @@ var nextTest =function() {
 }
 
 var step1 =function() {
   window.is(testWindow.location, gTallRedBoxURI, "Ensure red page loaded.");
   
   // Navigate down and up.
   is(testWindow.document.body.scrollTop, 0,
      "Page1: Ensure we scrollpane is at the top before we start scrolling.");
-  testWindow.focus();
-  sendKey('DOWN', testWindow);
-  SimpleTest.executeSoon(function() {
+  testWindow.addEventListener("scroll", function () {
+    testWindow.removeEventListener("scroll", arguments.callee, true);
     isnot(testWindow.document.body.scrollTop, 0,
           "Page1: Ensure we can scroll down.");
-    sendKey('UP', testWindow);
-    SimpleTest.executeSoon(function() {
+    SimpleTest.executeSoon(step1_2);
+  }, true);
+  sendKey('DOWN', testWindow);
+
+  function step1_2() {
+    testWindow.addEventListener("scroll", function () {
+      testWindow.removeEventListener("scroll", arguments.callee, true);
       is(testWindow.document.body.scrollTop, 0,
          "Page1: Ensure we can scroll up, back to the top.");  
 
       // Nav to blue box page. This should fire step2.
       testWindow.location = gTallBlueBoxURI;
-    });
-  });
+    }, true);
+    sendKey('UP', testWindow);
+  }
 }
 
 
 var step2 =function() {    
   window.is(testWindow.location, gTallBlueBoxURI, "Ensure blue page loaded.");
 
   // Scroll around a bit.
   is(testWindow.document.body.scrollTop, 0,
      "Page2: Ensure we scrollpane is at the top before we start scrolling.");
-  testWindow.focus();
-  sendKey('DOWN', testWindow);
-  sendKey('DOWN', testWindow);
+
+  var count = 0;
+  testWindow.addEventListener("scroll", function () {
+    if (++count < 4) {
+      SimpleTest.executeSoon(function () { sendKey('DOWN', testWindow); });
+    } else {
+      testWindow.removeEventListener("scroll", arguments.callee, true);
+
+      isnot(testWindow.document.body.scrollTop, 0,
+            "Page2: Ensure we could scroll.");
+
+      // Navigate backwards. This should fire step3.
+      testWindow.history.back();
+    }
+  }, true);
   sendKey('DOWN', testWindow);
-  setTimeout(function() {
-    isnot(testWindow.document.body.scrollTop, 0,
-          "Page2: Ensure we could scrol.");  
-    
-    // Navigate backwards. This should fire step3.
-    testWindow.history.back();
-  }, 0);
 }
 
 var step3 =function() {
   window.is(testWindow.location, gTallRedBoxURI,
             "Ensure red page restored from history.");
 
   // Check we can still scroll with the keys.
   is(testWindow.document.body.scrollTop, 0,
      "Page1Again: Ensure scroll pane at top before we scroll.");  
-  testWindow.focus();
-  sendKey('DOWN', testWindow);
-  setTimeout(function() {
+  testWindow.addEventListener("scroll", function () {
+    testWindow.removeEventListener("scroll", arguments.callee, true);
+
     isnot(testWindow.document.body.scrollTop, 0,
           "Page2Again: Ensure we can still scroll.");  
-    
+
     testWindow.close();
     window.SimpleTest.finish();
-  }, 0);
+  }, true);
+  sendKey('DOWN', testWindow);
 }
 
 SimpleTest.waitForExplicitFinish();
 
 //]]>
 </script>
 </pre>
 </body>