Bug 1299453 - Stop using createEvent("DragEvents"/"KeyEvents") internally; r=smaug
authorAryeh Gregor <ayg@aryeh.name>
Wed, 31 Aug 2016 16:24:40 +0300
changeset 353394 bc4801b96009f6dfd51deb4ef87347ccd813776c
parent 353393 3f6b84d701ae0df834dfa6efbd56a9d915026998
child 353395 21ec43d33e0c2ac8049355c506282ce076625578
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1299453
milestone51.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 1299453 - Stop using createEvent("DragEvents"/"KeyEvents") internally; r=smaug They are non-standard aliases for "DragEvent" and "KeyboardEvent" that are not supported by any other UA, and we would like to drop support. So first let's stop using them ourselves, so we can use telemetry to see if any sites are using them. MozReview-Commit-ID: ICC33ORa2st
browser/base/content/newtab/dropTargetShim.js
browser/base/content/test/newtab/browser_newtab_bug723121.js
browser/base/content/test/newtab/browser_newtab_bug725996.js
browser/base/content/test/newtab/browser_newtab_bug765628.js
browser/base/content/test/newtab/browser_newtab_drag_drop.js
browser/base/content/test/newtab/head.js
dom/events/test/test_bug456273.html
dom/events/test/test_bug508479.html
dom/events/test/test_bug591249.xul
dom/events/test/test_dom_keyboard_event.html
dom/events/test/test_dragstart.html
dom/html/test/file_fullscreen-api-keys.html
dom/tests/mochitest/ajax/prototype/test/lib/unittest.js
dom/tests/mochitest/ajax/scriptaculous/src/unittest.js
dom/tests/mochitest/whatwg/test_bug477323.html
editor/libeditor/tests/test_contenteditable_text_input_handling.html
layout/base/tests/test_bug603550.html
layout/xul/test/test_bug381167.xhtml
services/sync/tps/extensions/mozmill/resource/driver/mozelement.js
toolkit/content/tests/chrome/bug304188_window.xul
toolkit/content/tests/chrome/bug331215_window.xul
toolkit/content/tests/chrome/bug360437_window.xul
toolkit/content/tests/chrome/bug429723_window.xul
toolkit/content/tests/chrome/findbar_entireword_window.xul
toolkit/content/tests/chrome/findbar_events_window.xul
toolkit/content/tests/chrome/findbar_window.xul
toolkit/content/tests/chrome/window_browser_drop.xul
toolkit/content/widgets/findbar.xml
toolkit/modules/tests/browser/browser_FinderHighlighter.js
--- a/browser/base/content/newtab/dropTargetShim.js
+++ b/browser/base/content/newtab/dropTargetShim.js
@@ -216,17 +216,17 @@ var gDropTargetShim = {
   /**
    * Dispatches a custom DragEvent on the given target node.
    * @param aEvent The source event.
    * @param aType The event type.
    * @param aTarget The target node that receives the event.
    */
   _dispatchEvent: function (aEvent, aType, aTarget) {
     let node = aTarget.node;
-    let event = document.createEvent("DragEvents");
+    let event = document.createEvent("DragEvent");
 
     // The event should not bubble to prevent recursion.
     event.initDragEvent(aType, false, true, window, 0, 0, 0, 0, 0, false, false,
                         false, false, 0, node, aEvent.dataTransfer);
 
     node.dispatchEvent(event);
   }
 };
--- a/browser/base/content/test/newtab/browser_newtab_bug723121.js
+++ b/browser/base/content/test/newtab/browser_newtab_bug723121.js
@@ -14,17 +14,17 @@ add_task(function* () {
     let link = site.querySelector(".newtab-link");
 
     function checkGridLocked(aLocked, aMessage) {
       Assert.equal(grid.node.hasAttribute("locked"), aLocked, aMessage);
     }
 
     function sendDragEvent(aEventType, aTarget) {
       let dataTransfer = new content.DataTransfer(aEventType, false);
-      let event = content.document.createEvent("DragEvents");
+      let event = content.document.createEvent("DragEvent");
       event.initDragEvent(aEventType, true, true, content, 0, 0, 0, 0, 0,
                           false, false, false, false, 0, null, dataTransfer);
       aTarget.dispatchEvent(event);
     }
 
     checkGridLocked(false, "grid is unlocked");
 
     sendDragEvent("dragstart", link);
--- a/browser/base/content/test/newtab/browser_newtab_bug725996.js
+++ b/browser/base/content/test/newtab/browser_newtab_bug725996.js
@@ -7,17 +7,17 @@ add_task(function* () {
 
   yield* addNewTabPageTab();
   yield* checkGrid("0,1,2,3,4,5,6,7,8");
 
   function doDrop(data) {
     return ContentTask.spawn(gBrowser.selectedBrowser, { data: data }, function*(args) {
       let dataTransfer = new content.DataTransfer("dragstart", false);
       dataTransfer.mozSetDataAt("text/x-moz-url", args.data, 0);
-      let event = content.document.createEvent("DragEvents");
+      let event = content.document.createEvent("DragEvent");
       event.initDragEvent("drop", true, true, content, 0, 0, 0, 0, 0,
                           false, false, false, false, 0, null, dataTransfer);
 
       let target = content.gGrid.cells[0].node;
       target.dispatchEvent(event);
     });
   }
 
--- a/browser/base/content/test/newtab/browser_newtab_bug765628.js
+++ b/browser/base/content/test/newtab/browser_newtab_bug765628.js
@@ -10,17 +10,17 @@ add_task(function* () {
 
   yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function*() {
     const BAD_DRAG_DATA = "javascript:alert('h4ck0rz');\nbad stuff";
     const GOOD_DRAG_DATA = "http://example99.com/\nsite 99";
 
     function sendDropEvent(aCellIndex, aDragData) {
       let dataTransfer = new content.DataTransfer("dragstart", false);
       dataTransfer.mozSetDataAt("text/x-moz-url", aDragData, 0);
-      let event = content.document.createEvent("DragEvents");
+      let event = content.document.createEvent("DragEvent");
       event.initDragEvent("drop", true, true, content, 0, 0, 0, 0, 0,
                           false, false, false, false, 0, null, dataTransfer);
 
       let target = content.gGrid.cells[aCellIndex].node;
       target.dispatchEvent(event);
     }
 
     sendDropEvent(0, BAD_DRAG_DATA);
--- a/browser/base/content/test/newtab/browser_newtab_drag_drop.js
+++ b/browser/base/content/test/newtab/browser_newtab_drag_drop.js
@@ -73,23 +73,23 @@ add_task(function* () {
   yield doDragEvent(0, 4);
   yield* checkGrid("3,1p,2p,4,0p,5p,6,7,8");
 });
 
 function doDragEvent(sourceIndex, dropIndex) {
   return ContentTask.spawn(gBrowser.selectedBrowser,
                            { sourceIndex: sourceIndex, dropIndex: dropIndex }, function*(args) {
     let dataTransfer = new content.DataTransfer("dragstart", false);
-    let event = content.document.createEvent("DragEvents");
+    let event = content.document.createEvent("DragEvent");
     event.initDragEvent("dragstart", true, true, content, 0, 0, 0, 0, 0,
                         false, false, false, false, 0, null, dataTransfer);
 
     let target = content.gGrid.cells[args.sourceIndex].site.node;
     target.dispatchEvent(event);
 
-    event = content.document.createEvent("DragEvents");
+    event = content.document.createEvent("DragEvent");
     event.initDragEvent("drop", true, true, content, 0, 0, 0, 0, 0,
                         false, false, false, false, 0, null, dataTransfer);
 
     target = content.gGrid.cells[args.dropIndex].node;
     target.dispatchEvent(event);
   });
 }
--- a/browser/base/content/test/newtab/head.js
+++ b/browser/base/content/test/newtab/head.js
@@ -413,17 +413,17 @@ function* simulateExternalDrop(aDestInde
       let iframe = doc.createElement("iframe");
 
       function iframeLoaded() {
         let link = iframe.contentDocument.getElementById("link");
 
         let dataTransfer = new iframe.contentWindow.DataTransfer("dragstart", false);
         dataTransfer.mozSetDataAt("text/x-moz-url", "http://example99.com/", 0);
 
-        let event = content.document.createEvent("DragEvents");
+        let event = content.document.createEvent("DragEvent");
         event.initDragEvent("drop", true, true, content, 0, 0, 0, 0, 0,
                             false, false, false, false, 0, null, dataTransfer);
 
         let target = content.gGrid.cells[dropIndex].node;
         target.dispatchEvent(event);
 
         iframe.remove();
 
--- a/dom/events/test/test_bug456273.html
+++ b/dom/events/test/test_bug456273.html
@@ -18,17 +18,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 <div id="edit456273" contenteditable="true">text</div>
 
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 456273 **/
 
 function doTest() {
-  var ev = document.createEvent('KeyEvents');
+  var ev = document.createEvent('KeyboardEvent');
   ev.initKeyEvent("keypress", true, true, null, true, false,
                  false, false, 0, "z".charCodeAt(0));
   SpecialPowers.dispatchEvent(window, document.getElementById('edit456273'), ev);
 
   ok(true, "PASS");
   SimpleTest.finish();
 }
 
--- a/dom/events/test/test_bug508479.html
+++ b/dom/events/test/test_bug508479.html
@@ -34,25 +34,25 @@ function fireDrop(element, shouldAllowDr
   synthesizeMouse(element, 2, 2, { type: "mousedown" });
   synthesizeMouse(element, 11, 11, { type: "mousemove" });
   synthesizeMouse(element, 20, 20, { type: "mousemove" });
   window.removeEventListener("dragstart", trapDrag, true);
   synthesizeMouse(element, 20, 20, { type: "mouseup" });
 
   ds.startDragSession();
 
-  var event = document.createEvent("DragEvents");
+  var event = document.createEvent("DragEvent");
   event.initDragEvent("dragover", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null, dataTransfer);
   fireEvent(element, event);
 
   is(ds.getCurrentSession().canDrop, shouldAllowDrop, "Unexpected .canDrop");
   is(ds.getCurrentSession().onlyChromeDrop, shouldAllowOnlyChromeDrop,
      "Unexpected .onlyChromeDrop");
 
-  event = document.createEvent("DragEvents");
+  event = document.createEvent("DragEvent");
   event.initDragEvent("drop", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null, dataTransfer);
   fireEvent(element, event);
 
   ds.endDragSession(false);
   ok(!ds.getCurrentSession(), "There shouldn't be a drag session anymore!");
 }
 
 var chromeGotEvent = false;
--- a/dom/events/test/test_bug591249.xul
+++ b/dom/events/test/test_bug591249.xul
@@ -55,17 +55,17 @@ function RunTest() {
   // need to use real mouse action to get the dataTransfer
   window.addEventListener("dragstart", trapDrag, true);
   synthesizeMouse(image, 2, 2, { type: "mousedown" });
   synthesizeMouse(image, 11, 11, { type: "mousemove" });
   synthesizeMouse(image, 20, 20, { type: "mousemove" });
   window.removeEventListener("dragstart", trapDrag, true);
   synthesizeMouse(image, 20, 20, { type: "mouseup" });
 
-  var event = document.createEvent("DragEvents");
+  var event = document.createEvent("DragEvent");
   event.initDragEvent("dragover", true, true, iBox.ownerDocument.defaultView, 0, 0, 0, 0, 0, false, false, false, false, 0, iBox, dataTransfer);
   fireEvent(iBox, event);
   synthesizeMouse(image, 3, 3, { type: "mousedown" });
   synthesizeMouse(image, 23, 23, { type: "mousemove" });
   synthesizeMouse(iBox, insideBoxX, insideBoxY, { type: "mousemove" });
   ok(window.getComputedStyle(iBox).backgroundColor == "rgb(255, 255, 0)", "The -moz-drag-over style should be applied.");
   synthesizeMouse(iBox, insideBoxX, insideBoxY, { type: "mouseup" });
   window.setTimeout(function () { completeTest(iBox); }, 40);
--- a/dom/events/test/test_dom_keyboard_event.html
+++ b/dom/events/test/test_dom_keyboard_event.html
@@ -37,32 +37,32 @@ function testInitializingUntrustedEvent(
       ctrlKey: false, altKey: true, shiftKey: false, metaKey: false,
       keyCode: 0x11, charCode: 0x30 },
 
     { createEventArg: "keyboardEvent",
       type: "boo", bubbles: false, cancelable: false, view: window,
       ctrlKey: false, altKey: false, shiftKey: true, metaKey: false,
       keyCode: 0x30, charCode: 0x40 },
 
-    { createEventArg: "KeyEvents",
+    { createEventArg: "KeyBoardEvent",
       type: "foo", bubbles: true, cancelable: true, view: null,
       ctrlKey: false, altKey: false, shiftKey: false, metaKey: true,
       keyCode: 0x00, charCode: 0x50 },
 
-    { createEventArg: "keyevents",
+    { createEventArg: "keyboardevEnt",
       type: "bar", bubbles: false, cancelable: true, view: window,
       ctrlKey: true, altKey: true, shiftKey: false, metaKey: false,
       keyCode: 0x00, charCode: 0x60 },
 
-    { createEventArg: "Keyevents",
+    { createEventArg: "KeyboaRdevent",
       type: "keydown", bubbles: true, cancelable: false, view: null,
       ctrlKey: false, altKey: true, shiftKey: false, metaKey: true,
       keyCode: 0x30, charCode: 0x00 },
 
-    { createEventArg: "keyEvents",
+    { createEventArg: "KEYBOARDEVENT",
       type: "keyup", bubbles: false, cancelable: false, view: window,
       ctrlKey: true, altKey: false, shiftKey: true, metaKey: false,
       keyCode: 0x10, charCode: 0x80 },
 
     { createEventArg: "KeyboardEvent",
       type: "keypress", bubbles: false, cancelable: false, view: window,
       ctrlKey: true, altKey: false, shiftKey: true, metaKey: true,
       keyCode: 0x10, charCode: 0x80 },
--- a/dom/events/test/test_dragstart.html
+++ b/dom/events/test/test_dragstart.html
@@ -52,18 +52,18 @@ function afterDragTests()
 
   var evt = document.createEvent("dragevent");
   ok(evt instanceof DragEvent, "synthetic dragevent class")
   ok(evt instanceof MouseEvent, "synthetic event inherits from MouseEvent")
   evt.initDragEvent("dragstart", true, true, window, 1, 40, 35, 20, 15,
                     false, true, false, false, 0, null, null);
   $("synthetic").dispatchEvent(evt);
 
-  var evt = document.createEvent("dragevents");
-  ok(evt instanceof DragEvent, "synthetic dragevents class")
+  var evt = document.createEvent("dragevent");
+  ok(evt instanceof DragEvent, "synthetic dragevent class")
   evt.initDragEvent("dragover", true, true, window, 0, 40, 35, 20, 15,
                     true, false, true, true, 2, document.documentElement, null);
   $("synthetic2").dispatchEvent(evt);
 
   // next, dragging links and images
   sendMouseEventsForDrag("link");
   sendMouseEventsForDrag("image");
 
--- a/dom/html/test/file_fullscreen-api-keys.html
+++ b/dom/html/test/file_fullscreen-api-keys.html
@@ -4,29 +4,29 @@
   <meta charset="UTF-8">
 </head>
 <body>
 <script>
 window.addEventListener("Test:DispatchKeyEvents", aEvent => {
   var keyCode = KeyEvent["DOM_" + aEvent.detail.code];
 
   document.body.focus();
-  var evt = document.createEvent("KeyEvents");
+  var evt = document.createEvent("KeyboardEvent");
   evt.initKeyEvent("keydown", true, true, window,
                    false, false, false, false,
                    keyCode, 0);
   document.body.dispatchEvent(evt);
 
-  evt = document.createEvent("KeyEvents");
+  evt = document.createEvent("KeyboardEvent");
   evt.initKeyEvent("keypress", true, true, window,
                    false, false, false, false,
                    keyCode, 0);
   document.body.dispatchEvent(evt);
 
-  evt = document.createEvent("KeyEvents");
+  evt = document.createEvent("KeyboardEvent");
   evt.initKeyEvent("keyup", true, true, window,
                    false, false, false, false,
                    keyCode, 0);
   document.body.dispatchEvent(evt);
 });
 </script>
 </body>
 </html>
--- a/dom/tests/mochitest/ajax/prototype/test/lib/unittest.js
+++ b/dom/tests/mochitest/ajax/prototype/test/lib/unittest.js
@@ -58,17 +58,17 @@ Event.simulateKey = function(element, ev
     ctrlKey: false,
     altKey: false,
     shiftKey: false,
     metaKey: false,
     keyCode: 0,
     charCode: 0
   }, arguments[2] || {});
 
-  var oEvent = document.createEvent("KeyEvents");
+  var oEvent = document.createEvent("KeyboardEvent");
   oEvent.initKeyEvent(eventName, true, true, window, 
     options.ctrlKey, options.altKey, options.shiftKey, options.metaKey,
     options.keyCode, options.charCode );
   $(element).dispatchEvent(oEvent);
 };
 
 Event.simulateKeys = function(element, command) {
   for (var i=0; i<command.length; i++) {
--- a/dom/tests/mochitest/ajax/scriptaculous/src/unittest.js
+++ b/dom/tests/mochitest/ajax/scriptaculous/src/unittest.js
@@ -49,17 +49,17 @@ Event.simulateKey = function(element, ev
     ctrlKey: false,
     altKey: false,
     shiftKey: false,
     metaKey: false,
     keyCode: 0,
     charCode: 0
   }, arguments[2] || {});
 
-  var oEvent = document.createEvent("KeyEvents");
+  var oEvent = document.createEvent("KeyboardEvent");
   oEvent.initKeyEvent(eventName, true, true, window, 
     options.ctrlKey, options.altKey, options.shiftKey, options.metaKey,
     options.keyCode, options.charCode );
   $(element).dispatchEvent(oEvent);
 };
 
 Event.simulateKeys = function(element, command) {
   for(var i=0; i<command.length; i++) {
--- a/dom/tests/mochitest/whatwg/test_bug477323.html
+++ b/dom/tests/mochitest/whatwg/test_bug477323.html
@@ -25,17 +25,17 @@ function start()
   element.ondragenter = function(event) {gotdragenter = true;}
   element.ondragover = function(event) {gotdragover = true;}
   element.ondragleave = function(event) {gotdragleave = true;}
   element.ondrop = function(event) {gotdrop = true;}
   element.ondragend = function(event) {gotdragend = true;}
   
   function dispatch(eventName)
   {
-    var event = document.createEvent("DragEvents");
+    var event = document.createEvent("DragEvent");
     event.initDragEvent(eventName, true, true, window, 0, 5, 5, 5, 5,
                         false, false, false, false, 0, null, null);
     element.dispatchEvent(event);
   }
   
   dispatch("dragstart");
   dispatch("drag");
   dispatch("dragenter");
--- a/editor/libeditor/tests/test_contenteditable_text_input_handling.html
+++ b/editor/libeditor/tests/test_contenteditable_text_input_handling.html
@@ -160,17 +160,17 @@ function runTests()
     }
 
     // When key events are fired on unfocused editor.
     function testDispatchedKeyEvent(aTarget)
     {
       var targetDescription = " (dispatched to " + aTarget._description + ")";
       function dispatchKeyEvent(aKeyCode, aChar, aTarget)
       {
-        var keyEvent = document.createEvent("KeyEvents");
+        var keyEvent = document.createEvent("KeyboardEvent");
         keyEvent.initKeyEvent("keypress", true, true, null, false, false,
                                false, false, aKeyCode,
                                aChar ? aChar.charCodeAt(0) : 0);
         aTarget.dispatchEvent(keyEvent);
       }
 
       function checkValueForDispatchedKeyEvent(aElement, aInsertedText)
       {
--- a/layout/base/tests/test_bug603550.html
+++ b/layout/base/tests/test_bug603550.html
@@ -53,21 +53,21 @@ function fireEvent(target, event) {
 }
 
 function fireDrop(element) {
   var ds = SpecialPowers.Cc["@mozilla.org/widget/dragservice;1"].
     getService(SpecialPowers.Ci.nsIDragService);
 
   ds.startDragSession();
 
-  var event = document.createEvent("DragEvents");
+  var event = document.createEvent("DragEvent");
   event.initDragEvent("dragover", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null, null);
   fireEvent(element, event);
 
-  event = document.createEvent("DragEvents");
+  event = document.createEvent("DragEvent");
   event.initDragEvent("drop", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null, null);
   fireEvent(element, event);
 
   ds.endDragSession(false);
   ok(!ds.getCurrentSession(), "There shouldn't be a drag session anymore!");
 }
 
 function runTest() {
--- a/layout/xul/test/test_bug381167.xhtml
+++ b/layout/xul/test/test_bug381167.xhtml
@@ -22,17 +22,17 @@ https://bugzilla.mozilla.org/show_bug.cg
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 381167 **/
 
 SimpleTest.waitForExplicitFinish();
 
 function closeit() {
-  var evt = document.createEvent('KeyEvents');
+  var evt = document.createEvent('KeyboardEvent');
                                  evt.initKeyEvent('keypress', true, true,
                                  window,
                                  true, false, false, false,
                                  'W'.charCodeAt(0), 0);
   window.dispatchEvent(evt);
 
   setTimeout(finish, 200);
 }
--- a/services/sync/tps/extensions/mozmill/resource/driver/mozelement.js
+++ b/services/sync/tps/extensions/mozmill/resource/driver/mozelement.js
@@ -213,17 +213,17 @@ MozMillElement.prototype.dragToElement =
 
   try {
     srcWindow.addEventListener("dragstart", trapDrag, true);
     EventUtils.synthesizeMouse(srcNode, srcCoords.x, srcCoords.y,
                                { type: "mousedown" }, srcWindow);
     EventUtils.synthesizeMouse(destNode, destCoords.x, destCoords.y,
                                { type: "mousemove" }, destWindow);
 
-    var event = destWindow.document.createEvent("DragEvents");
+    var event = destWindow.document.createEvent("DragEvent");
     event.initDragEvent("dragenter", true, true, destWindow, 0, 0, 0, 0, 0,
                         false, false, false, false, 0, null, dataTransfer);
     event.initDragEvent("dragover", true, true, destWindow, 0, 0, 0, 0, 0,
                         false, false, false, false, 0, null, dataTransfer);
     event.initDragEvent("drop", true, true, destWindow, 0, 0, 0, 0, 0,
                         false, false, false, false, 0, null, dataTransfer);
     windowUtils.dispatchDOMEventViaPresShell(destNode, event, true);
 
--- a/toolkit/content/tests/chrome/bug304188_window.xul
+++ b/toolkit/content/tests/chrome/bug304188_window.xul
@@ -74,17 +74,17 @@ find-menu appears in editor element whic
 
       ok(gFindBar.hidden,
          "Findfield should have stayed hidden after entering editor test");
     }
 
     function* enterStringIntoEditor(aString) {
       for (let i = 0; i < aString.length; i++) {
         yield ContentTask.spawn(gBrowser, { charCode: aString.charCodeAt(i) }, function* (args) {
-          let event = content.document.createEvent("KeyEvents");
+          let event = content.document.createEvent("KeyboardEvent");
           event.initKeyEvent("keypress", true, true, null, false, false,
                              false, false, 0, args.charCode);
           content.document.body.dispatchEvent(event);
         });
       }
     }
   ]]></script>
 
--- a/toolkit/content/tests/chrome/bug331215_window.xul
+++ b/toolkit/content/tests/chrome/bug331215_window.xul
@@ -73,17 +73,17 @@
       yield enterStringIntoFindField("a");
       ok(gFindBar._findField.getAttribute("status") != "notfound",
          "Findfield status attribute should not have been 'notfound'" +
          " after entering latest");
     }
 
     function* enterStringIntoFindField(aString) {
       for (let i = 0; i < aString.length; i++) {      
-        let event = document.createEvent("KeyEvents");
+        let event = document.createEvent("KeyboardEvent");
         let promise = new Promise(resolve => {
           let listener = {
             onFindResult: function() {
               gFindBar.browser.finder.removeResultListener(listener);
               resolve();
             }
           };
           gFindBar.browser.finder.addResultListener(listener);
--- a/toolkit/content/tests/chrome/bug360437_window.xul
+++ b/toolkit/content/tests/chrome/bug360437_window.xul
@@ -100,17 +100,17 @@
         };
         gFindBar.browser.finder.addResultListener(listener);
       });
     }
 
     function promiseEnterStringIntoFindField(str) {
       let promise = promiseFindResult(str);
       for (let i = 0; i < str.length; i++) {
-        let event = document.createEvent("KeyEvents");
+        let event = document.createEvent("KeyboardEvent");
         event.initKeyEvent("keypress", true, true, null, false, false,
                            false, false, 0, str.charCodeAt(i));
         gFindBar._findField.inputField.dispatchEvent(event);
       }
       return promise;
     }
   ]]></script>
   <textbox id="textbox"/>
--- a/toolkit/content/tests/chrome/bug429723_window.xul
+++ b/toolkit/content/tests/chrome/bug429723_window.xul
@@ -33,17 +33,17 @@
         gBrowser.addEventListener("pageshow", onPageShow, false);
         gBrowser.loadURI("data:text/html,<h2 id='h2'>mozilla</h2>");
       }
       setTimeout(_delayedOnLoad, 1000);
     }
 
     function enterStringIntoFindField(aString) {
       for (var i=0; i < aString.length; i++) {
-        var event = document.createEvent("KeyEvents");
+        var event = document.createEvent("KeyboardEvent");
         event.initKeyEvent("keypress", true, true, null, false, false,
                            false, false, 0, aString.charCodeAt(i));
         gFindBar._findField.inputField.dispatchEvent(event);
       }
     }
 
     function onPageShow() {
       gBrowser.removeEventListener("pageshow", onPageShow, false);
@@ -59,17 +59,17 @@
       enterStringIntoFindField(searchStr);
 
       // Highlight search term
       var highlight = gFindBar.getElement("highlight");
       if (!highlight.checked)
         highlight.click();
 
       // Delete search term
-      var event = document.createEvent("KeyEvents");
+      var event = document.createEvent("KeyboardEvent");
       event.initKeyEvent("keypress", true, true, null, false, false,
                          false, false, KeyEvent.DOM_VK_BACK_SPACE, 0);
       gFindBar._findField.inputField.dispatchEvent(event);
 
       var notRed = !findField.hasAttribute("status") || 
                    (findField.getAttribute("status") != "notfound");
       ok(notRed, "Find Bar textbox is correct colour");
       finish();
--- a/toolkit/content/tests/chrome/findbar_entireword_window.xul
+++ b/toolkit/content/tests/chrome/findbar_entireword_window.xul
@@ -149,17 +149,17 @@
       yield testQuickfind(suite.testQuickfind);
     }
 
     var enterStringIntoFindField = Task.async(function* (str, waitForResult = true) {
       for (let promise, i = 0; i < str.length; i++) {
         if (waitForResult) {
           promise = promiseFindResult();
         }
-        let event = document.createEvent("KeyEvents");
+        let event = document.createEvent("KeyboardEvent");
         event.initKeyEvent("keypress", true, true, null, false, false,
                            false, false, 0, str.charCodeAt(i));
         gFindBar._findField.inputField.dispatchEvent(event);
         if (waitForResult) {
           yield promise;
         }
       }
     });
@@ -243,17 +243,17 @@
       yield* testIterator(tests);
 
       gFindBar.close();
     }
 
     function* testQuickfind(tests) {
       yield ContentTask.spawn(gBrowser, null, function* () {
         let document = content.document;
-        let event = document.createEvent("KeyEvents");
+        let event = document.createEvent("KeyboardEvent");
         event.initKeyEvent("keypress", true, true, null, false, false,
                            false, false, 0, "/".charCodeAt(0));
         document.documentElement.dispatchEvent(event);
       });
 
       ok(!gFindBar.hidden, "testQuickfind: failed to open findbar");
       ok(document.commandDispatcher.focusedElement == gFindBar._findField.inputField,
         "testQuickfind: find field is not focused");
--- a/toolkit/content/tests/chrome/findbar_events_window.xul
+++ b/toolkit/content/tests/chrome/findbar_events_window.xul
@@ -106,17 +106,17 @@
     }
 
     function* testFind() {
       info("Testing normal find.");
       let query = "t";
       let promise = once(gFindBar, "find");
 
       // Put some text in the find box.
-      let event = document.createEvent("KeyEvents");
+      let event = document.createEvent("KeyboardEvent");
       event.initKeyEvent("keypress", true, true, null, false, false,
                          false, false, 0, query.charCodeAt(0));
       gFindBar._findField.inputField.dispatchEvent(event);
 
       let e = yield promise;
       ok(e.detail.query === query, "find event query should match '" + query + "'");
       // Since we're preventing the default make sure nothing was selected.
       yield checkSelection();
--- a/toolkit/content/tests/chrome/findbar_window.xul
+++ b/toolkit/content/tests/chrome/findbar_window.xul
@@ -253,17 +253,17 @@
       });
     }
 
     var enterStringIntoFindField = Task.async(function* (str, waitForResult = true) {
       for (let promise, i = 0; i < str.length; i++) {
         if (waitForResult) {
           promise = promiseFindResult();
         }
-        let event = document.createEvent("KeyEvents");
+        let event = document.createEvent("KeyboardEvent");
         event.initKeyEvent("keypress", true, true, null, false, false,
                            false, false, 0, str.charCodeAt(i));
         gFindBar._findField.inputField.dispatchEvent(event);
         if (waitForResult) {
           yield promise;
         }
       }
     });
@@ -400,17 +400,17 @@
       });
     }
 
     function* testQuickFindLink() {
       yield clearFocus();
 
       yield ContentTask.spawn(gBrowser, null, function* () {
         let document = content.document;
-        let event = document.createEvent("KeyEvents");
+        let event = document.createEvent("KeyboardEvent");
         event.initKeyEvent("keypress", true, true, null, false, false,
                            false, false, 0, "'".charCodeAt(0));
         document.documentElement.dispatchEvent(event);
       });
 
       ok(!gFindBar.hidden, "testQuickFindLink: failed to open findbar");
       ok(document.commandDispatcher.focusedElement == gFindBar._findField.inputField,
          "testQuickFindLink: find field is not focused");
@@ -482,17 +482,17 @@
       ok(!highlightButton.checked, "testFindWithHighlight: Highlight All should be unchecked.");
     }
 
     function* testQuickFindText() {
       yield clearFocus();
 
       yield ContentTask.spawn(gBrowser, null, function* () {
         let document = content.document;
-        let event = document.createEvent("KeyEvents");
+        let event = document.createEvent("KeyboardEvent");
         event.initKeyEvent("keypress", true, true, null, false, false,
                            false, false, 0, "/".charCodeAt(0));
         document.documentElement.dispatchEvent(event);
       });
 
       ok(!gFindBar.hidden, "testQuickFindText: failed to open findbar");
       ok(document.commandDispatcher.focusedElement == gFindBar._findField.inputField,
         "testQuickFindText: find field is not focused");
--- a/toolkit/content/tests/chrome/window_browser_drop.xul
+++ b/toolkit/content/tests/chrome/window_browser_drop.xul
@@ -45,17 +45,17 @@ function doDropAndStopLoad(browser, data
         }
       },
       QueryInterface: XPCOMUtils.generateQI(["nsISupportsWeakReference"])
     };
     wp.addProgressListener(progressListener, wp.NOTIFY_STATE_WINDOW);
 
     let dataTransfer = new content.DataTransfer("dragstart", false);
     dataTransfer.mozSetDataAt(data.type, data.data, 0);
-    let event = content.document.createEvent("DragEvents");
+    let event = content.document.createEvent("DragEvent");
     event.initDragEvent("drop", true, true, content, 0, 0, 0, 0, 0,
                         false, false, false, false, 0, null, dataTransfer);
     content.document.body.dispatchEvent(event);
     let nameGetter = {};
     try {
       Services.droppedLinkHandler.dropLink(event, nameGetter, true);
       nameReturned = nameGetter.value;
     } catch (ex) {
--- a/toolkit/content/widgets/findbar.xml
+++ b/toolkit/content/widgets/findbar.xml
@@ -782,17 +782,17 @@
 
       <method name="_dispatchKeypressEvent">
         <parameter name="aTarget"/>
         <parameter name="aEvent"/>
         <body><![CDATA[
           if (!aTarget)
             return;
 
-          let event = document.createEvent("KeyEvents");
+          let event = document.createEvent("KeyboardEvent");
           event.initKeyEvent(aEvent.type, aEvent.bubbles, aEvent.cancelable,
                              aEvent.view, aEvent.ctrlKey, aEvent.altKey,
                              aEvent.shiftKey, aEvent.metaKey, aEvent.keyCode,
                              aEvent.charCode);
           aTarget.dispatchEvent(event);
         ]]></body>
       </method>
 
--- a/toolkit/modules/tests/browser/browser_FinderHighlighter.js
+++ b/toolkit/modules/tests/browser/browser_FinderHighlighter.js
@@ -41,17 +41,17 @@ function promiseFindResult(findbar, str 
     };
     findbar.browser.finder.addResultListener(listener);
   });
 }
 
 function promiseEnterStringIntoFindField(findbar, str) {
   let promise = promiseFindResult(findbar, str);
   for (let i = 0; i < str.length; i++) {
-    let event = document.createEvent("KeyEvents");
+    let event = document.createEvent("KeyboardEvent");
     event.initKeyEvent("keypress", true, true, null, false, false,
                        false, false, 0, str.charCodeAt(i));
     findbar._findField.inputField.dispatchEvent(event);
   }
   return promise;
 }
 
 function promiseTestHighlighterOutput(browser, word, expectedResult, extraTest = () => {}) {