Bug 645068 - TEST-UNEXPECTED-FAIL | browser_tapping.js | Fired a good double tap [r=mfinkle]
authorVivien Nicolas <21@vingtetun.org>
Sat, 26 Mar 2011 00:57:31 +0100
changeset 2944 3fc28e63d911caf64a00470013ec68c897847684
parent 2943 3f8519dfd4c69b4b94da34ce99304ac6e267e319
child 2945 6ba832bb0dc0266446f2d8e2ed6e6c7f1b2a968e
push id2482
push uservnicolas@mozilla.com
push dateFri, 25 Mar 2011 23:57:46 +0000
reviewersmfinkle
bugs645068
Bug 645068 - TEST-UNEXPECTED-FAIL | browser_tapping.js | Fired a good double tap [r=mfinkle]
chrome/tests/browser_tapping.js
--- a/chrome/tests/browser_tapping.js
+++ b/chrome/tests/browser_tapping.js
@@ -4,16 +4,18 @@
  */
 
 let testURL = chromeRoot + "browser_tap_content.html";
 
 let gTests = [];
 let gCurrentTest = null;
 let gCurrentTab;
 
+const kDoubleClickIntervalPlus = kDoubleClickInterval + 100;
+
 let gEvents = [];
 function dumpEvents(aEvent) {
   if (aEvent.target != gCurrentTab.browser.parentNode)
     return;
 
   gEvents.push(aEvent.type);
 }
 
@@ -88,25 +90,29 @@ function test() {
   gCurrentTab = Browser.addTab(testURL, true);
   ok(gCurrentTab, "Tab Opened");
 
   window.addEventListener("TapSingle", dumpEvents, true);
   window.addEventListener("TapDouble", dumpEvents, true);
   window.addEventListener("TapLong", dumpEvents, true);
 
   // Wait for the tab to load, then do the tests
-  messageManager.addMessageListener("pageshow", function() {
+  messageManager.addMessageListener("Browser:FirstPaint", function() {
   if (gCurrentTab.browser.currentURI.spec == testURL) {
-    messageManager.removeMessageListener("pageshow", arguments.callee);
+    messageManager.removeMessageListener("Browser:FirstPaint", arguments.callee);
     // Hack the allowZoom getter since we want to observe events
     // for testing purpose even if it is a local tab
     gCurrentTab.__defineGetter__("allowZoom", function() {
       return true;
     });
-    setTimeout(runNextTest, 0);
+
+    // Using setTimeout(..., 0) here result into a duplicate mousedown/mouseup
+    // sequence that makes the double tap test fails (add some dump in input.js
+    // to see that...)
+    runNextTest();
   }});
 }
 
 //------------------------------------------------------------------------------
 // Iterating tests by shifting test out one by one as runNextTest is called.
 function runNextTest() {
   // Run the next test until all tests completed
   if (gTests.length > 0) {
@@ -141,17 +147,17 @@ gTests.push({
     EventUtils.synthesizeMouse(inputHandler, width / 2, height / 2, {});
 
     // We wait a bit because of the delay allowed for double clicking on device
     // where it is not native
     setTimeout(function() {
       ok(checkEvents(["TapSingle"]), "Fired a good single tap");
       clearEvents();
       gCurrentTest.doubleTapTest();
-    }, kDoubleClickInterval);
+    }, kDoubleClickIntervalPlus);
   },
 
   doubleTapTest: function() {
     let inputHandler = gCurrentTab.browser.parentNode;
     let width = inputHandler.getBoundingClientRect().width;
     let height = inputHandler.getBoundingClientRect().height;
 
     // Should fire "TapDouble"
@@ -160,17 +166,17 @@ gTests.push({
     EventUtils.synthesizeMouse(inputHandler, width / 2, height / 2, {});
     EventUtils.synthesizeMouse(inputHandler, width / 2, height / 2, {});
 
     setTimeout(function() {
       ok(checkEvents(["TapDouble"]), "Fired a good double tap");
       clearEvents();
 
       gCurrentTest.doubleTapFailTest();
-    }, 500);
+    }, kDoubleClickIntervalPlus);
   },
 
   doubleTapFailTest: function() {
     let inputHandler = gCurrentTab.browser.parentNode;
     let width = inputHandler.getBoundingClientRect().width;
     let height = inputHandler.getBoundingClientRect().height;
 
     // Should fire "TapSingle", "TapSingle"