Bug 645068 - TEST-UNEXPECTED-FAIL | browser_tapping.js | Fired a good double tap [r=mfinkle]
--- a/mobile/chrome/tests/browser_tapping.js
+++ b/mobile/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"