Bug 1322736 part.1 Remove "before keydown" and "before keyup" events r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 16 Dec 2016 15:59:25 +0900
changeset 373775 c7e1c554e15f732d5f395e97d5628b1653f3a568
parent 373774 2fecf01d89106376f7791f8eb12f82aba223bdb3
child 373776 5506b339ec9cc067810165e9158e6815b29249b0
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1322736
milestone53.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 1322736 part.1 Remove "before keydown" and "before keyup" events r=smaug MozReview-Commit-ID: 3umPBwTowLc
dom/base/nsGkAtomList.h
dom/events/EventNameList.h
dom/events/EventStateManager.cpp
dom/events/KeyboardEvent.cpp
dom/events/test/bug1096146_embedded.html
dom/events/test/bug989198_helper.js
dom/events/test/mochitest.ini
dom/events/test/test_bug1096146.html
dom/events/test/test_dom_before_after_keyboard_event.html
dom/events/test/test_dom_before_after_keyboard_event_remote.html
dom/webidl/BeforeAfterKeyboardEvent.webidl
layout/base/PresShell.cpp
layout/base/PresShell.h
widget/EventMessageList.h
widget/TextEvents.h
widget/WidgetEventImpl.cpp
--- a/dom/base/nsGkAtomList.h
+++ b/dom/base/nsGkAtomList.h
@@ -837,18 +837,16 @@ GK_ATOM(onmouselongtap, "onmouselongtap"
 GK_ATOM(onmousemove, "onmousemove")
 GK_ATOM(onmouseout, "onmouseout")
 GK_ATOM(onmouseover, "onmouseover")
 GK_ATOM(onMozMouseHittest, "onMozMouseHittest")
 GK_ATOM(onmouseup, "onmouseup")
 GK_ATOM(onMozAfterPaint, "onMozAfterPaint")
 GK_ATOM(onmozbrowserafterkeydown, "onmozbrowserafterkeydown")
 GK_ATOM(onmozbrowserafterkeyup, "onmozbrowserafterkeyup")
-GK_ATOM(onmozbrowserbeforekeydown, "onmozbrowserbeforekeydown")
-GK_ATOM(onmozbrowserbeforekeyup, "onmozbrowserbeforekeyup")
 GK_ATOM(onmozfullscreenchange, "onmozfullscreenchange")
 GK_ATOM(onmozfullscreenerror, "onmozfullscreenerror")
 GK_ATOM(onmozkeydownonplugin, "onmozkeydownonplugin")
 GK_ATOM(onmozkeyuponplugin, "onmozkeyuponplugin")
 GK_ATOM(onmozpointerlockchange, "onmozpointerlockchange")
 GK_ATOM(onmozpointerlockerror, "onmozpointerlockerror")
 GK_ATOM(onmoztimechange, "onmoztimechange")
 GK_ATOM(onMozMousePixelScroll, "onMozMousePixelScroll")
--- a/dom/events/EventNameList.h
+++ b/dom/events/EventNameList.h
@@ -261,28 +261,20 @@ EVENT(keyup,
 EVENT(mozkeydownonplugin,
       eKeyDownOnPlugin,
       EventNameType_None,
       eKeyboardEventClass)
 EVENT(mozkeyuponplugin,
       eKeyUpOnPlugin,
       EventNameType_None,
       eKeyboardEventClass)
-NON_IDL_EVENT(mozbrowserbeforekeydown,
-              eBeforeKeyDown,
-              EventNameType_None,
-              eBeforeAfterKeyboardEventClass)
 NON_IDL_EVENT(mozbrowserafterkeydown,
               eAfterKeyDown,
               EventNameType_None,
               eBeforeAfterKeyboardEventClass)
-NON_IDL_EVENT(mozbrowserbeforekeyup,
-              eBeforeKeyUp,
-              EventNameType_None,
-              eBeforeAfterKeyboardEventClass)
 NON_IDL_EVENT(mozbrowserafterkeyup,
               eAfterKeyUp,
               EventNameType_None,
               eBeforeAfterKeyboardEventClass)
 NON_IDL_EVENT(mozaccesskeynotfound,
               eAccessKeyNotFound,
               EventNameType_None,
               eKeyboardEventClass)
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -752,20 +752,18 @@ EventStateManager::PreHandleEvent(nsPres
                               modifierMask, matchesContentAccessKey)) {
             *aStatus = nsEventStatus_eConsumeNoDefault;
           }
         }
       }
     }
     // then fall through...
     MOZ_FALLTHROUGH;
-  case eBeforeKeyDown:
   case eKeyDown:
   case eAfterKeyDown:
-  case eBeforeKeyUp:
   case eKeyUp:
   case eAfterKeyUp:
     {
       nsIContent* content = GetFocusedContent();
       if (content)
         mCurrentTargetContent = content;
 
       // NOTE: Don't refer TextComposition::IsComposing() since UI Events
@@ -3448,17 +3446,16 @@ EventStateManager::PostHandleEvent(nsPre
       break;
     }
   case eDragExit:
      // make sure to fire the enter and exit_synth events after the
      // eDragExit event, otherwise we'll clean up too early
     GenerateDragDropEnterExit(presContext, aEvent->AsDragEvent());
     break;
 
-  case eBeforeKeyUp:
   case eKeyUp:
   case eAfterKeyUp:
     break;
 
   case eKeyPress:
     {
       WidgetKeyboardEvent* keyEvent = aEvent->AsKeyboardEvent();
       PostHandleKeyboardEvent(keyEvent, *aStatus, dispatchedToContentProcess);
--- a/dom/events/KeyboardEvent.cpp
+++ b/dom/events/KeyboardEvent.cpp
@@ -183,21 +183,19 @@ uint32_t
 KeyboardEvent::CharCode()
 {
   // If this event is initialized with ctor, we shouldn't check event type.
   if (mInitializedByCtor) {
     return mEvent->AsKeyboardEvent()->mCharCode;
   }
 
   switch (mEvent->mMessage) {
-  case eBeforeKeyDown:
   case eKeyDown:
   case eKeyDownOnPlugin:
   case eAfterKeyDown:
-  case eBeforeKeyUp:
   case eKeyUp:
   case eKeyUpOnPlugin:
   case eAfterKeyUp:
     return 0;
   case eKeyPress:
   case eAccessKeyNotFound:
     return mEvent->AsKeyboardEvent()->mCharCode;
   default:
@@ -232,21 +230,19 @@ uint32_t
 KeyboardEvent::Which()
 {
   // If this event is initialized with ctor, which can have independent value.
   if (mInitializedByCtor) {
     return mInitializedWhichValue;
   }
 
   switch (mEvent->mMessage) {
-    case eBeforeKeyDown:
     case eKeyDown:
     case eKeyDownOnPlugin:
     case eAfterKeyDown:
-    case eBeforeKeyUp:
     case eKeyUp:
     case eKeyUpOnPlugin:
     case eAfterKeyUp:
       return KeyCode();
     case eKeyPress:
       //Special case for 4xp bug 62878.  Try to make value of which
       //more closely mirror the values that 4.x gave for RETURN and BACKSPACE
       {
deleted file mode 100644
--- a/dom/events/test/bug1096146_embedded.html
+++ /dev/null
@@ -1,16 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>Embedded iframe</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body onload="">
-  <p id="display"></p>
-  <h1>Top</h1>
-  <input id="input" style="display: block;">
-  <pre id="test">
-  <div id="content" style="height: 2000px;"></div>
-  <h1>Bottom</h1>
-</body>
-</html>
--- a/dom/events/test/bug989198_helper.js
+++ b/dom/events/test/bug989198_helper.js
@@ -1,34 +1,31 @@
 /*
  * Helper functions for testing BeforeAfterKeyboardEvent.
  */
 
 const kUnknownEvent       = 0x000;
 const kKeyDownEvent       = 0x001;
 const kKeyUpEvent         = 0x002;
-const kBeforeEvent        = 0x010;
 const kAfterEvent         = 0x020;
 const kParent             = 0x100;
 const kChild              = 0x200;
 
 var gCurrentTest;
 
 function frameScript()
 {
   function handler(e) {
     var results = sendSyncMessage("forwardevent", { type: e.type });
     if (results[0]) {
       e.preventDefault();
     }
   }
   addEventListener('keydown', handler);
   addEventListener('keyup', handler);
-  addEventListener('mozbrowserbeforekeydown', handler);
-  addEventListener('mozbrowserbeforekeyup', handler);
   addEventListener('mozbrowserafterkeydown', handler);
   addEventListener('mozbrowserafterkeyup', handler);
 }
 
 function prepareTest(useRemote)
 {
   if (useRemote) {
     setupHandlers(window, embedderHandler);
@@ -56,41 +53,33 @@ function prepareTest(useRemote)
 
   document.body.appendChild(iframe);
 }
 
 function setupHandlers(element, handler)
 {
   element.addEventListener('keydown', handler);
   element.addEventListener('keyup', handler);
-  element.addEventListener('mozbrowserbeforekeydown', handler);
-  element.addEventListener('mozbrowserbeforekeyup', handler);
   element.addEventListener('mozbrowserafterkeydown', handler);
   element.addEventListener('mozbrowserafterkeyup', handler);
 }
 
 function teardownHandlers(element, handler)
 {
   element.removeEventListener('keydown', handler);
   element.removeEventListener('keyup', handler);
-  element.removeEventListener('mozbrowserbeforekeydown', handler);
-  element.removeEventListener('mozbrowserbeforekeyup', handler);
   element.removeEventListener('mozbrowserafterkeydown', handler);
   element.removeEventListener('mozbrowserafterkeyup', handler);
 }
 
 function convertNameToCode(name)
 {
   switch (name) {
-    case "mozbrowserbeforekeydown":
-      return kBeforeEvent | kKeyDownEvent;
     case "mozbrowserafterkeydown":
       return kAfterEvent | kKeyDownEvent;
-    case "mozbrowserbeforekeyup":
-      return kBeforeEvent | kKeyUpEvent;
     case "mozbrowserafterkeyup":
       return kAfterEvent | kKeyUpEvent;
     case "keydown":
       return kKeyDownEvent;
     case "keyup":
       return kKeyUpEvent;
     default:
       return kUnknownEvent;
@@ -157,21 +146,16 @@ function handler(e, highBit, callback)
   }
 }
 
 function embedderHandlerWithCheck(e)
 {
   // Verify value of attribute embeddedCancelled
   embedderHandler(e, function checkEmbeddedCancelled(code){
   switch (code) {
-    case kBeforeEvent | kKeyDownEvent:
-    case kBeforeEvent | kKeyUpEvent:
-      is(e.embeddedCancelled, null,
-         gCurrentTest.description + ": embeddedCancelled should be null");
-      break;
     case kAfterEvent | kKeyDownEvent:
       if ((gCurrentTest.doPreventDefaultAt & 0xFF) == kKeyDownEvent) {
         is(e.embeddedCancelled, true,
            gCurrentTest.description + ": embeddedCancelled should be true");
       } else {
         is(e.embeddedCancelled, false,
            gCurrentTest.description + ": embeddedCancelled should be false");
       }
--- a/dom/events/test/mochitest.ini
+++ b/dom/events/test/mochitest.ini
@@ -129,19 +129,16 @@ skip-if = (e10s && os == "mac") # bug 12
 [test_bug1003432.html]
 support-files = test_bug1003432.js
 [test_bug1013412.html]
 [test_bug1017086_disable.html]
 support-files = bug1017086_inner.html
 [test_bug1017086_enable.html]
 support-files = bug1017086_inner.html
 [test_bug1079236.html]
-[test_bug1096146.html]
-support-files =
-  bug1096146_embedded.html
 [test_bug1145910.html]
 [test_bug1150308.html]
 [test_bug1248459.html]
 [test_bug1264380.html]
 run-if = (e10s && os != "win") # Bug 1270043, crash at windows platforms; Bug1264380 comment 20, nsDragService::InvokeDragSessionImpl behaves differently among platform implementations in non-e10s mode which prevents us to check the validity of nsIDragService::getCurrentSession() consistently via synthesize mouse clicks in non-e10s mode.
 [test_clickevent_on_input.html]
 skip-if = toolkit == 'android' #CRASH_DUMP, RANDOM
 [test_continuous_wheel_events.html]
deleted file mode 100644
--- a/dom/events/test/test_bug1096146.html
+++ /dev/null
@@ -1,187 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=1096146
--->
-<head>
-  <meta charset="utf-8">
-  <title>Test for Bug 1096146</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body onload="runTests();">
-<a target="_blank"
-   href="https://bugzilla.mozilla.org/show_bug.cgi?id=1096146">Mozilla Bug 1096146</a>
-<div id="content" style="display: none;">
-</div>
-<pre id="test">
-<script type="application/javascript">
-
-const kKeydownEvent = 0x1;
-const kScrollEvent  = 0x2;
-
-var gCurrentTest = 0;
-var gNumEvents = 0;
-var kTests = [
-  {
-    description: "no preventDefault at 'mozbrowserbeforekeydown'",
-    expectedEvents: kKeydownEvent | kScrollEvent,
-    resultEvents: 0x0,
-    doPreventDefault: false
-  },
-  {
-    description: "do preventDefault at 'mozbrowserbeforekeydown'",
-    expectedEvents: 0x0,
-    resultEvents: 0x0,
-    doPreventDefault: true
-  }
-]
-
-function frameScript()
-{
-  function handler(e) {
-    sendSyncMessage("forwardevent", { type: e.type });
-  }
-  addEventListener('keydown', handler);
-  addEventListener('scroll', handler);
-}
-
-
-function waitAndVerifyResult(count) {
-  if (gNumEvents >= 3 || count > 10) {
-    is(kTests[gCurrentTest].resultEvents,
-       kTests[gCurrentTest].expectedEvents,
-       "verify result");
-    runTests();
-	} else {
-    SimpleTest.requestFlakyTimeout("We must delay to wait for scroll/keydown events.");
-    setTimeout(() => waitAndVerifyResult(count + 1), 100);
-  }
-}
-
-function testDefaultAction()
-{
-  synthesizeKey('VK_END', {}, document.getElementById("embedded").contentWindow);
-  waitAndVerifyResult(0);
-}
-
-function prepareTest()
-{
-  gNumEvents = 0;
-
-  var handler;
-  if (kTests[gCurrentTest].doPreventDefault) {
-    handler = preventDefaultHandler;
-  } else {
-    handler = noPreventDefaultHandler;
-  }
-  window.addEventListener("mozbrowserbeforekeydown", handler);
-
-  var iframe = document.createElement("iframe");
-  iframe.id = "embedded";
-  iframe.src = "bug1096146_embedded.html";
-  iframe.setAttribute("remote", "false");
-  SpecialPowers.wrap(iframe).mozbrowser = true;
-
-  iframe.addEventListener("mozbrowserloadend", function onloadend() {
-    iframe.removeEventListener("mozbrowserloadend", onloadend);
-    iframe.focus();
-    var mm = SpecialPowers.getBrowserFrameMessageManager(iframe);
-    mm.addMessageListener("forwardevent", function(msg) {
-      var value = 0;
-      switch(msg.json.type) {
-        case "scroll":
-          ++gNumEvents;
-          value = kScrollEvent;
-          break;
-        case "keydown":
-          ++gNumEvents;
-          value = kKeydownEvent;
-          break;
-        default:
-          ok(false, "unexpected event");
-      }
-
-      kTests[gCurrentTest].resultEvents =
-        kTests[gCurrentTest].resultEvents | value;
-    });
-    mm.loadFrameScript("data:,(" + frameScript.toString() + ")();", false);
-    runTests();
-    return;
-  });
-
-  document.body.appendChild(iframe);
-}
-
-function preventDefaultHandler(evt)
-{
-  ok(true, "receive " + evt.type + " and do preventDefault.");
-	++gNumEvents;
-  evt.preventDefault();
-}
-
-function noPreventDefaultHandler(evt)
-{
-  ok(true, "receive " + evt.type + ".");
-	++gNumEvents;
-}
-
-function teardownHandler()
-{
-  var handler;
-  if (kTests[gCurrentTest].doPreventDefault) {
-    handler = preventDefaultHandler;
-  } else {
-    handler = noPreventDefaultHandler;
-  }
-  window.removeEventListener("mozbrowserbeforekeydown", handler);
-  document.body.removeChild(document.getElementById("embedded"));
-
-  runTests();
-}
-
-var tests = [
-  function addPermissions() {
-    SpecialPowers.pushPermissions(
-      [{ type: "before-after-keyboard-event", allow: true, context: document },
-       { type: "browser", allow: true, context: document }],
-      runTests);
-  },
-  function addPreferences() {
-    SpecialPowers.pushPrefEnv(
-      { "set": [["dom.beforeAfterKeyboardEvent.enabled", true],
-                ["dom.mozBrowserFramesEnabled", true],
-                ["dom.ipc.tabs.disabled", false],
-                ["network.disable.ipc.security", true]] },
-      runTests);
-  },
-
-  prepareTest,
-  testDefaultAction,
-  teardownHandler,
-
-  function() {
-    gCurrentTest++;
-    runTests();
-  },
-  prepareTest,
-  testDefaultAction,
-  teardownHandler
-];
-
-function runTests()
-{
-  if (!tests.length) {
-    SimpleTest.finish();
-    return;
-  }
-
-  var test = tests.shift();
-  test();
-}
-
-</script>
-</pre>
-</body>
-</html>
--- a/dom/events/test/test_dom_before_after_keyboard_event.html
+++ b/dom/events/test/test_dom_before_after_keyboard_event.html
@@ -23,67 +23,39 @@ function cleanupTest()
   runTests();
 }
 
 function testEventOrderAndAttr()
 {
   const kTests = [
     {
       description: "Testing the order of the events",
-      expectedEvents: [ [ kParent | kBeforeEvent | kKeyDownEvent,
-                          kChild | kKeyDownEvent,
+      expectedEvents: [ [ kChild | kKeyDownEvent,
                           kParent | kAfterEvent | kKeyDownEvent ],
-                        [ kParent | kBeforeEvent | kKeyUpEvent,
-                          kChild | kKeyUpEvent,
+                        [ kChild | kKeyUpEvent,
                           kParent | kAfterEvent | kKeyUpEvent ] ],
       resultEvents: [],
       classifiedEvents: [ [], [] ],
       doPreventDefaultAt: kUnknownEvent
     },
     {
-      description: "Testing the order of the events, calling preventDefault() at \"mozbrowserbeforekeydown\" event",
-      expectedEvents: [ [ kParent | kBeforeEvent | kKeyDownEvent,
+      description: "Testing the order of the events, calling preventDefault() at \"keydown\" event",
+      expectedEvents: [ [ kChild | kKeyDownEvent,
                           kParent | kAfterEvent | kKeyDownEvent ],
-                        [ kParent | kBeforeEvent | kKeyUpEvent,
-                          kChild | kKeyUpEvent,
-                          kParent | kAfterEvent | kKeyUpEvent ] ],
-      resultEvents: [],
-      classifiedEvents: [ [], [] ],
-      doPreventDefaultAt: kParent | kBeforeEvent | kKeyDownEvent
-    },
-    {
-      description: "Testing the order of the events, calling preventDefault() at \"mozbrowserbeforekeyup\" event",
-      expectedEvents: [ [ kParent | kBeforeEvent | kKeyDownEvent,
-                          kChild | kKeyDownEvent,
-                          kParent | kAfterEvent | kKeyDownEvent ],
-                        [ kParent | kBeforeEvent | kKeyUpEvent,
-                          kParent | kAfterEvent | kKeyUpEvent ] ],
-      resultEvents: [],
-      classifiedEvents: [ [], [] ],
-      doPreventDefaultAt: kParent | kBeforeEvent | kKeyUpEvent
-    },
-    {
-      description: "Testing the order of the events, calling preventDefault() at \"keydown\" event",
-      expectedEvents: [ [ kParent | kBeforeEvent | kKeyDownEvent,
-                          kChild | kKeyDownEvent,
-                          kParent | kAfterEvent | kKeyDownEvent ],
-                        [ kParent | kBeforeEvent | kKeyUpEvent,
-                          kChild | kKeyUpEvent,
+                        [ kChild | kKeyUpEvent,
                           kParent | kAfterEvent | kKeyUpEvent ] ],
       resultEvents: [],
       classifiedEvents: [ [], [] ],
       doPreventDefaultAt: kChild | kKeyDownEvent
     },
     {
       description: "Testing the order of the events, calling preventDefault() at \"keyup\" event",
-      expectedEvents: [ [ kParent | kBeforeEvent | kKeyDownEvent,
-                          kChild | kKeyDownEvent,
+      expectedEvents: [ [ kChild | kKeyDownEvent,
                           kParent | kAfterEvent | kKeyDownEvent ],
-                        [ kParent | kBeforeEvent | kKeyUpEvent,
-                          kChild | kKeyUpEvent,
+                        [ kChild | kKeyUpEvent,
                           kParent | kAfterEvent | kKeyUpEvent ] ],
       resultEvents: [],
       classifiedEvents: [ [], [] ],
       doPreventDefaultAt: kChild | kKeyUpEvent
     }
   ];
 
   for (var k = 0; k < kTests.length; k++ ) {
--- a/dom/events/test/test_dom_before_after_keyboard_event_remote.html
+++ b/dom/events/test/test_dom_before_after_keyboard_event_remote.html
@@ -18,106 +18,70 @@
 <script type="application/javascript">
 
 SimpleTest.waitForExplicitFinish();
 SimpleTest.requestFlakyTimeout("untriaged");
 
 var testsForEventOrder = [
   {
     description: "Testing the order of the events (OOP)",
-    expectedEvents: [ [ kParent | kBeforeEvent | kKeyDownEvent,
-                        kParent | kKeyDownEvent,
+    expectedEvents: [ [ kParent | kKeyDownEvent,
                         kChild | kKeyDownEvent,
                         kParent | kAfterEvent | kKeyDownEvent ],
-                      [ kParent | kBeforeEvent | kKeyUpEvent,
-                        kParent | kKeyUpEvent,
+                      [ kParent | kKeyUpEvent,
                         kChild | kKeyUpEvent,
                         kParent | kAfterEvent | kKeyUpEvent ] ],
     resultEvents: [],
     classifiedEvents: [ [], [] ],
     doPreventDefaultAt: kUnknownEvent
   },
   {
     description: "Testing the order of the events (OOP), calling " +
-                 "preventDefault() at \"mozbrowserbeforekeydown\" event",
-    expectedEvents: [ [ kParent | kBeforeEvent | kKeyDownEvent,
+                 "preventDefault() at \"keydown\" event in parent process",
+    expectedEvents: [ [ kParent | kKeyDownEvent,
                         kParent | kAfterEvent | kKeyDownEvent ],
-                      [ kParent | kBeforeEvent | kKeyUpEvent,
-                        kParent | kKeyUpEvent,
-                        kChild | kKeyUpEvent,
-                        kParent | kAfterEvent | kKeyUpEvent ] ],
-    resultEvents: [],
-    classifiedEvents: [ [], [] ],
-    doPreventDefaultAt: kParent | kBeforeEvent | kKeyDownEvent
-  },
-  {
-    description: "Testing the order of the events (OOP), calling " +
-                 "preventDefault() at \"mozbrowserbeforekeyup\" event",
-    expectedEvents: [ [ kParent | kBeforeEvent | kKeyDownEvent,
-                        kParent | kKeyDownEvent,
-                        kChild | kKeyDownEvent,
-                        kParent | kAfterEvent | kKeyDownEvent ],
-                      [ kParent | kBeforeEvent | kKeyUpEvent,
-                        kParent | kAfterEvent | kKeyUpEvent ] ],
-    resultEvents: [],
-    classifiedEvents: [ [], [] ],
-    doPreventDefaultAt: kParent | kBeforeEvent | kKeyUpEvent
-  },
-  {
-    description: "Testing the order of the events (OOP), calling " +
-                 "preventDefault() at \"keydown\" event in parent process",
-    expectedEvents: [ [ kParent | kBeforeEvent | kKeyDownEvent,
-                        kParent | kKeyDownEvent,
-                        kParent | kAfterEvent | kKeyDownEvent ],
-                      [ kParent | kBeforeEvent | kKeyUpEvent,
-                        kParent | kKeyUpEvent,
+                      [ kParent | kKeyUpEvent,
                         kChild | kKeyUpEvent,
                         kParent | kAfterEvent | kKeyUpEvent ] ],
     resultEvents: [],
     classifiedEvents: [ [], [] ],
     doPreventDefaultAt: kParent | kKeyDownEvent
   },
   {
     description: "Testing the order of the events (OOP), calling " +
                  "preventDefault() at \"keydown\" event in child process",
-    expectedEvents: [ [ kParent | kBeforeEvent | kKeyDownEvent,
-                        kParent | kKeyDownEvent,
+    expectedEvents: [ [ kParent | kKeyDownEvent,
                         kChild | kKeyDownEvent,
                         kParent | kAfterEvent | kKeyDownEvent ],
-                      [ kParent | kBeforeEvent | kKeyUpEvent,
-                        kParent | kKeyUpEvent,
+                      [ kParent | kKeyUpEvent,
                         kChild | kKeyUpEvent,
                         kParent | kAfterEvent | kKeyUpEvent ] ],
     resultEvents: [],
     classifiedEvents: [ [], [] ],
     doPreventDefaultAt: kChild | kKeyDownEvent
   },
   {
     description: "Testing the order of the events (OOP), calling " +
                  "preventDefault() at \"keyup\" event in parent process",
-    expectedEvents: [ [ kParent | kBeforeEvent | kKeyDownEvent,
-                        kParent | kKeyDownEvent,
+    expectedEvents: [ [ kParent | kKeyDownEvent,
                         kChild | kKeyDownEvent,
                         kParent | kAfterEvent | kKeyDownEvent ],
-                      [ kParent | kBeforeEvent | kKeyUpEvent,
-                        kParent | kKeyUpEvent,
+                      [ kParent | kKeyUpEvent,
                         kParent | kAfterEvent | kKeyUpEvent ] ],
     resultEvents: [],
     classifiedEvents: [ [], [] ],
     doPreventDefaultAt: kParent | kKeyUpEvent
   },
   {
     description: "Testing the order of the events (OOP), calling " +
                  "preventDefault() at \"keyup\" event in child process",
-    expectedEvents: [ [ kParent | kBeforeEvent | kKeyDownEvent,
-                        kParent | kKeyDownEvent,
+    expectedEvents: [ [ kParent | kKeyDownEvent,
                         kChild | kKeyDownEvent,
                         kParent | kAfterEvent | kKeyDownEvent ],
-                      [ kParent | kBeforeEvent | kKeyUpEvent,
-                        kParent | kKeyUpEvent,
+                      [ kParent | kKeyUpEvent,
                         kChild | kKeyUpEvent,
                         kParent | kAfterEvent | kKeyUpEvent ] ],
     resultEvents: [],
     classifiedEvents: [ [], [] ],
     doPreventDefaultAt: kChild | kKeyUpEvent
   }
 ];
 
--- a/dom/webidl/BeforeAfterKeyboardEvent.webidl
+++ b/dom/webidl/BeforeAfterKeyboardEvent.webidl
@@ -6,18 +6,16 @@
 
 [Constructor(DOMString typeArg,
  optional BeforeAfterKeyboardEventInit eventInitDict),
  Pref="dom.beforeAfterKeyboardEvent.enabled",
  ChromeOnly]
 interface BeforeAfterKeyboardEvent : KeyboardEvent
 {
   // The valid value of embeddedCancelled is:
-  // - "mozbrowserbeforekeydown": null
-  // - "mozbrowserbeforekeyup": null
   // - "mozbrowserafterkeydown": true/false
   // - "mozbrowserafterkeyup": true/false
   readonly attribute boolean? embeddedCancelled;
 };
 
 dictionary BeforeAfterKeyboardEventInit : KeyboardEventInit
 {
   boolean? embeddedCancelled = null;
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -7089,50 +7089,16 @@ BuildTargetChainForBeforeAfterKeyboardEv
       aChain.AppendElement(frameElement);
     }
     nsPIDOMWindowOuter* window = frameElement->OwnerDoc()->GetWindow();
     frameElement = window ? window->GetFrameElementInternal() : nullptr;
   }
 }
 
 void
-PresShell::DispatchBeforeKeyboardEventInternal(const nsTArray<nsCOMPtr<Element> >& aChain,
-                                               const WidgetKeyboardEvent& aEvent,
-                                               size_t& aChainIndex,
-                                               bool& aDefaultPrevented)
-{
-  size_t length = aChain.Length();
-  if (!CanDispatchEvent(&aEvent) || !length) {
-    return;
-  }
-
-  EventMessage message =
-    (aEvent.mMessage == eKeyDown) ? eBeforeKeyDown : eBeforeKeyUp;
-  nsCOMPtr<EventTarget> eventTarget;
-  // Dispatch before events from the outermost element.
-  for (int32_t i = length - 1; i >= 0; i--) {
-    eventTarget = do_QueryInterface(aChain[i]->OwnerDoc()->GetWindow());
-    if (!eventTarget || !CanDispatchEvent(&aEvent)) {
-      return;
-    }
-
-    aChainIndex = i;
-    InternalBeforeAfterKeyboardEvent beforeEvent(aEvent.IsTrusted(),
-                                                 message, aEvent.mWidget);
-    beforeEvent.AssignBeforeAfterKeyEventData(aEvent, false);
-    EventDispatcher::Dispatch(eventTarget, mPresContext, &beforeEvent);
-
-    if (beforeEvent.DefaultPrevented()) {
-      aDefaultPrevented = true;
-      return;
-    }
-  }
-}
-
-void
 PresShell::DispatchAfterKeyboardEventInternal(const nsTArray<nsCOMPtr<Element> >& aChain,
                                               const WidgetKeyboardEvent& aEvent,
                                               bool aEmbeddedCancelled,
                                               size_t aStartOffset)
 {
   size_t length = aChain.Length();
   if (!CanDispatchEvent(&aEvent) || !length) {
     return;
@@ -7211,52 +7177,27 @@ PresShell::HandleKeyboardEvent(nsINode* 
   }
 
   MOZ_ASSERT(aEvent.mMessage == eKeyDown || aEvent.mMessage == eKeyUp);
 
   // Build up a target chain. Each item in the chain will receive a before event.
   AutoTArray<nsCOMPtr<Element>, 5> chain;
   BuildTargetChainForBeforeAfterKeyboardEvent(aTarget, chain, targetIsIframe);
 
-  // Dispatch before events. If each item in the chain consumes the before
-  // event and doesn't prevent the default action, we will go further to
-  // dispatch the actual key event and after events in the reverse order.
-  // Otherwise, only items which has handled the before event will receive an
-  // after event.
-  size_t chainIndex;
-  bool defaultPrevented = false;
-  DispatchBeforeKeyboardEventInternal(chain, aEvent, chainIndex,
-                                      defaultPrevented);
-
-  // Before event is default-prevented. Dispatch after events with
-  // embeddedCancelled = false to partial items.
-  if (defaultPrevented) {
-    *aStatus = nsEventStatus_eConsumeNoDefault;
-    DispatchAfterKeyboardEventInternal(chain, aEvent, false, chainIndex);
-    // No need to forward the event to child process.
-    aEvent.StopCrossProcessForwarding();
-    return;
-  }
-
-  // Event listeners may kill nsPresContext and nsPresShell.
-  if (!CanDispatchEvent()) {
-    return;
-  }
-
   if (ForwardKeyToInputMethodAppOrDispatch(targetIsIframe, aTarget, aEvent,
                                            aStatus, aEventCB)) {
     return;
   }
 
   if (aEvent.DefaultPrevented()) {
     // When embedder prevents the default action of actual key event, attribute
     // 'embeddedCancelled' of after event is false, i.e. |!targetIsIframe|.
     // On the contrary, if the defult action is prevented by embedded iframe,
     // 'embeddedCancelled' is true which equals to |!targetIsIframe|.
-    DispatchAfterKeyboardEventInternal(chain, aEvent, !targetIsIframe, chainIndex);
+    DispatchAfterKeyboardEventInternal(chain, aEvent, !targetIsIframe, 0);
     return;
   }
 
   // Event listeners may kill nsPresContext and nsPresShell.
   if (targetIsIframe || !CanDispatchEvent()) {
     return;
   }
 
--- a/layout/base/PresShell.h
+++ b/layout/base/PresShell.h
@@ -791,21 +791,16 @@ protected:
   // Methods for dispatching KeyboardEvent and BeforeAfterKeyboardEvent.
   //////////////////////////////////////////////////////////////////////////////
 
   void HandleKeyboardEvent(nsINode* aTarget,
                            mozilla::WidgetKeyboardEvent& aEvent,
                            bool aEmbeddedCancelled,
                            nsEventStatus* aStatus,
                            mozilla::EventDispatchingCallback* aEventCB);
-  void DispatchBeforeKeyboardEventInternal(
-         const nsTArray<nsCOMPtr<mozilla::dom::Element> >& aChain,
-         const mozilla::WidgetKeyboardEvent& aEvent,
-         size_t& aChainIndex,
-         bool& aDefaultPrevented);
   void DispatchAfterKeyboardEventInternal(
          const nsTArray<nsCOMPtr<mozilla::dom::Element> >& aChain,
          const mozilla::WidgetKeyboardEvent& aEvent,
          bool aEmbeddedCancelled,
          size_t aChainIndex = 0);
 
 #ifdef MOZ_B2G
   // This method is used to forward the keyboard event to the input-method-app
--- a/widget/EventMessageList.h
+++ b/widget/EventMessageList.h
@@ -42,19 +42,17 @@ NS_EVENT_MESSAGE(eKeyDown)
 
 // These messages are dispatched when PluginInstaceChild receives native
 // keyboard events directly and it posts the information to the widget.
 // These messages shouldn't be handled by content and non-reserved chrome
 // event handlers.
 NS_EVENT_MESSAGE(eKeyDownOnPlugin)
 NS_EVENT_MESSAGE(eKeyUpOnPlugin)
 
-NS_EVENT_MESSAGE(eBeforeKeyDown)
 NS_EVENT_MESSAGE(eAfterKeyDown)
-NS_EVENT_MESSAGE(eBeforeKeyUp)
 NS_EVENT_MESSAGE(eAfterKeyUp)
 
 // This message is sent after a content process handles a key event or accesskey
 // to indicate that an potential accesskey was not found. The parent process may
 // then respond by, for example, opening menus and processing other shortcuts.
 // It inherits its properties from a keypress event.
 NS_EVENT_MESSAGE(eAccessKeyNotFound)
 
--- a/widget/TextEvents.h
+++ b/widget/TextEvents.h
@@ -422,19 +422,17 @@ private:
 
 
 /******************************************************************************
  * mozilla::InternalBeforeAfterKeyboardEvent
  *
  * This is extended from WidgetKeyboardEvent and is mapped to DOM event
  * "BeforeAfterKeyboardEvent".
  *
- * Event mMessage: eBeforeKeyDown
- *                 eBeforeKeyUp
- *                 eAfterKeyDown
+ * Event mMessage: eAfterKeyDown
  *                 eAfterKeyUp
  ******************************************************************************/
 class InternalBeforeAfterKeyboardEvent : public WidgetKeyboardEvent
 {
 private:
   friend class dom::PBrowserParent;
   friend class dom::PBrowserChild;
 
--- a/widget/WidgetEventImpl.cpp
+++ b/widget/WidgetEventImpl.cpp
@@ -272,18 +272,16 @@ bool
 WidgetEvent::HasKeyEventMessage() const
 {
   switch (mMessage) {
     case eKeyDown:
     case eKeyPress:
     case eKeyUp:
     case eKeyDownOnPlugin:
     case eKeyUpOnPlugin:
-    case eBeforeKeyDown:
-    case eBeforeKeyUp:
     case eAfterKeyDown:
     case eAfterKeyUp:
     case eAccessKeyNotFound:
       return true;
     default:
       return false;
   }
 }