Bug 718545. (Av1) browser_keyevents_during_autoscrolling.js: Use EventUtils sendChar() and sendKey(), instead of synthesizeKey(). r=enndeakin.
authorSerge Gautherie <sgautherie.bz@free.fr>
Tue, 24 Jan 2012 07:05:14 +0100
changeset 86339 965f4bc3fc210abfdd33f736b7565a10235c4185
parent 86338 c1fd381a7faa4bb3bfe606bebcdd1c0a0fc8ef74
child 86340 3be494e4cc8fc5a9a510b2721f777bd9aac37221
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersenndeakin
bugs718545
milestone12.0a1
Bug 718545. (Av1) browser_keyevents_during_autoscrolling.js: Use EventUtils sendChar() and sendKey(), instead of synthesizeKey(). r=enndeakin.
toolkit/content/tests/browser/browser_keyevents_during_autoscrolling.js
--- a/toolkit/content/tests/browser/browser_keyevents_during_autoscrolling.js
+++ b/toolkit/content/tests/browser/browser_keyevents_during_autoscrolling.js
@@ -9,21 +9,36 @@ function test()
   const kKeyUpEvent    = 4;
   const kAllKeyEvents  = 7;
 
   var expectedKeyEvents;
   var dispatchedKeyEvents;
   var key;
   var root;
 
+  /**
+   * Encapsulates EventUtils.sendChar().
+   */
+  function sendChar(aChar)
+  {
+    key = aChar;
+    dispatchedKeyEvents = kNoKeyEvents;
+    EventUtils.sendChar(key, gBrowser.contentWindow);
+    is(dispatchedKeyEvents, expectedKeyEvents,
+       "unexpected key events were dispatched or not dispatched: " + key);
+  }
+
+  /**
+   * Encapsulates EventUtils.sendKey().
+   */
   function sendKey(aKey)
   {
     key = aKey;
     dispatchedKeyEvents = kNoKeyEvents;
-    EventUtils.synthesizeKey(key, {}, gBrowser.contentWindow);
+    EventUtils.sendKey(key, gBrowser.contentWindow);
     is(dispatchedKeyEvents, expectedKeyEvents,
        "unexpected key events were dispatched or not dispatched: " + key);
   }
 
   function onKey(aEvent)
   {
     if (aEvent.target != root && aEvent.target != root.ownerDocument.body) {
       ok(false, "unknown target: " + aEvent.target.tagName);
@@ -64,42 +79,42 @@ function test()
 
     root = doc.documentElement;
     root.addEventListener("keydown", onKey, true);
     root.addEventListener("keypress", onKey, true);
     root.addEventListener("keyup", onKey, true);
 
     // Test whether the key events are handled correctly under normal condition
     expectedKeyEvents = kAllKeyEvents;
-    sendKey("A");
+    sendChar("A");
 
     // Start autoscrolling by middle button lick on the page
     EventUtils.synthesizeMouse(root, 10, 10, { button: 1 },
                                gBrowser.contentWindow);
 
     // Most key events should be eaten by the browser.
     expectedKeyEvents = kNoKeyEvents;
-    sendKey("A");
-    sendKey("VK_DOWN");
-    sendKey("VK_RETURN");
-    sendKey("VK_ENTER");
-    sendKey("VK_HOME");
-    sendKey("VK_END");
-    sendKey("VK_TAB");
-    sendKey("VK_ENTER");
+    sendChar("A");
+    sendKey("DOWN");
+    sendKey("RETURN");
+    sendKey("ENTER");
+    sendKey("HOME");
+    sendKey("END");
+    sendKey("TAB");
+    sendKey("ENTER");
 
     // Finish autoscrolling by ESC key.  Note that only keydown and keypress
     // events are eaten because keyup event is fired *after* the autoscrolling
     // is finished.
     expectedKeyEvents = kKeyUpEvent;
-    sendKey("VK_ESCAPE");
+    sendKey("ESCAPE");
 
     // Test whether the key events are handled correctly under normal condition
     expectedKeyEvents = kAllKeyEvents;
-    sendKey("A");
+    sendChar("A");
 
     root.removeEventListener("keydown", onKey, true);
     root.removeEventListener("keypress", onKey, true);
     root.removeEventListener("keyup", onKey, true);
 
     // restore the changed prefs
     if (Services.prefs.prefHasUserValue(kPrefName_AutoScroll))
       Services.prefs.clearUserPref(kPrefName_AutoScroll);