Bug 1388069 - Support createEvent("FocusEvent"); r=smaug
authorAryeh Gregor <ayg@aryeh.name>
Mon, 07 Aug 2017 20:52:41 +0300
changeset 373430 e6fb60951529235d6bb0591e47ceaf66ff1b8044
parent 373429 640c562833fcd157368fb86a7da3231b23dedcb3
child 373431 d5a7aa8a32eac634545788aad44117fd48c28432
push id48274
push userayg@aryeh.name
push dateTue, 08 Aug 2017 17:59:00 +0000
treeherderautoland@e6fb60951529 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1388069
milestone57.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 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