Bug 1388069 - Support createEvent("FocusEvent"); r?smaug draft
authorAryeh Gregor <ayg@aryeh.name>
Mon, 07 Aug 2017 20:52:41 +0300
changeset 642525 da347ff2196d114e682efc62f646c96691993d30
parent 642520 bc7dc8defbc0a52ef8d09543f1f52259a8234816
child 725026 79303484c6858e1f4819bbe2d28d32337a379f1d
push id72785
push userbmo:ayg@aryeh.name
push dateTue, 08 Aug 2017 11:44:59 +0000
reviewerssmaug
bugs1388069
milestone57.0a1
Bug 1388069 - Support createEvent("FocusEvent"); r?smaug This is the one event we don't support in createEvent() that Blink doesn't want to drop support for because they see nontrivial usage: https://www.chromestatus.com/metrics/feature/timeline/popularity/1171 Supporting it shouldn't hurt us and might make us work better on whatever the sites are that Blink is hitting. MozReview-Commit-ID: FbfTd6AYnDg
dom/events/EventDispatcher.cpp
testing/web-platform/meta/dom/events/EventTarget-dispatchEvent.html.ini
testing/web-platform/meta/dom/nodes/Document-createEvent.html.ini
--- a/dom/events/EventDispatcher.cpp
+++ b/dom/events/EventDispatcher.cpp
@@ -1079,16 +1079,21 @@ EventDispatcher::CreateEvent(EventTarget
   }
   if (aEventType.LowerCaseEqualsLiteral("storageevent")) {
     LOG_EVENT_CREATION(STORAGEEVENT);
     RefPtr<Event> event =
       StorageEvent::Constructor(aOwner, EmptyString(), StorageEventInit());
     event->MarkUninitialized();
     return event.forget();
   }
+  if (aEventType.LowerCaseEqualsLiteral("focusevent")) {
+    RefPtr<Event> event = NS_NewDOMFocusEvent(aOwner, aPresContext, nullptr);
+    event->MarkUninitialized();
+    return event.forget();
+  }
 
   // Only allow these events for chrome
   if (aCallerType == CallerType::System) {
     if (aEventType.LowerCaseEqualsLiteral("simplegestureevent")) {
       return NS_NewDOMSimpleGestureEvent(aOwner, aPresContext, nullptr);
     }
     if (aEventType.LowerCaseEqualsLiteral("xulcommandevent")) {
       LOG_EVENT_CREATION(XULCOMMANDEVENT);
deleted file mode 100644
--- a/testing/web-platform/meta/dom/events/EventTarget-dispatchEvent.html.ini
+++ /dev/null
@@ -1,6 +0,0 @@
-[EventTarget-dispatchEvent.html]
-  type: testharness
-  [If the event's initialized flag is not set, an InvalidStateError must be thrown (FocusEvent).]
-    expected: FAIL
-    bug: https://github.com/whatwg/dom/issues/362, 1314303
-
--- a/testing/web-platform/meta/dom/nodes/Document-createEvent.html.ini
+++ b/testing/web-platform/meta/dom/nodes/Document-createEvent.html.ini
@@ -1,33 +1,10 @@
 [Document-createEvent.html]
   type: testharness
-  [FocusEvent should be an alias for FocusEvent.]
-    expected: FAIL
-    bug: https://github.com/whatwg/dom/issues/362, 1314303
-
-  [createEvent('FocusEvent') should be initialized correctly.]
-    expected: FAIL
-    bug: https://github.com/whatwg/dom/issues/362, 1314303
-
-  [focusevent should be an alias for FocusEvent.]
-    expected: FAIL
-    bug: https://github.com/whatwg/dom/issues/362, 1314303
-
-  [createEvent('focusevent') should be initialized correctly.]
-    expected: FAIL
-    bug: https://github.com/whatwg/dom/issues/362, 1314303
-
-  [FOCUSEVENT should be an alias for FocusEvent.]
-    expected: FAIL
-    bug: https://github.com/whatwg/dom/issues/362, 1314303
-
-  [createEvent('FOCUSEVENT') should be initialized correctly.]
-    expected: FAIL
-    bug: https://github.com/whatwg/dom/issues/362, 1314303
 
   [Should throw NOT_SUPPORTED_ERR for pluralized non-legacy event interface "KeyEvents"]
     expected: FAIL
     bug: 1251198
 
   [Should throw NOT_SUPPORTED_ERR for pluralized non-legacy event interface "MouseScrollEvents"]
     expected: FAIL
     bug: 1251198