Bug 681640 - browser-chrome test
authorMartijn Wargers <martijn.martijn@gmail.com>
Sun, 04 Sep 2011 08:07:22 -0700
changeset 76528 e23d05fcd782220b8c32cdd2db2822bb52a330c2
parent 76527 44e3478debec190603edeb0c0d2fc1b4228d4a7d
child 76529 35f7fb57b504f2ff39d0a51bc488c25d3f1f2bf5
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
bugs681640
milestone9.0a1
Bug 681640 - browser-chrome test
mobile/chrome/tests/browser_tapping_edit.js
--- a/mobile/chrome/tests/browser_tapping_edit.js
+++ b/mobile/chrome/tests/browser_tapping_edit.js
@@ -239,8 +239,41 @@ gTests.push({
     let clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"].getService(Ci.nsIClipboardHelper);
     clipboard.copyString("We are testing Firefox");
     
     let event = content.document.createEvent("PopupEvents");
     event.initEvent("contextmenu", true, true);
     plainEdit.dispatchEvent(event);
   }
 });
+
+//------------------------------------------------------------------------------
+gTests.push({
+  desc: "Test that tapping on input box causes mouse events to fire",
+
+  run: function() {
+    let browser = gCurrentTab.browser;
+    let plainEdit = browser.contentDocument.getElementById("plain-edit");
+    plainEdit.blur();
+    plainEdit.value = '';
+
+    let eventArray = ['mouseover', 'mousedown', 'mouseup', 'click'];
+
+  while (eventArray.length > 0) {
+    let currentEventType = eventArray.shift();
+    browser.contentWindow.addEventListener(currentEventType, function(e) {
+      browser.contentWindow.removeEventListener(currentEventType, arguments.callee, true);
+      ok(e.target == plainEdit, e.type + " should fire over input id=" + plainEdit.id);
+      plainEdit.value += e.type + ' ';
+
+      if (e.type == 'click') {
+        ok(plainEdit.value == 'mouseover mousedown mouseup click ', 
+                              'Events should fire in this order: mouseover mousedown mouseup click ');
+        runNextTest();
+      }
+    } , true);
+  }
+
+    EventUtils.synthesizeMouse(plainEdit, browser.getBoundingClientRect().left + plainEdit.getBoundingClientRect().left + 2, 
+                                          browser.getBoundingClientRect().top + plainEdit.getBoundingClientRect().top + 2, {});
+  }
+});
+