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
--- 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