From c01608b314334b1e2fb9e8a8f8f7d3d9984cebdf Mon Sep 17 00:00:00 2001 From: John Dai Date: Fri, 6 Sep 2019 20:50:43 +0000 Subject: [PATCH] Bug 1518442 - Part 1: Implement FormDataEvent interface; r=smaug,edgar Differential Revision: https://phabricator.services.mozilla.com/D43985 --HG-- extra : moz-landing-system : lando --- dom/events/EventNameList.h | 1 + .../test/test_all_synthetic_events.html | 6 ++++++ .../mochitest/general/test_interfaces.js | 2 ++ dom/webidl/EventHandler.webidl | 1 + dom/webidl/FormDataEvent.webidl | 20 +++++++++++++++++++ dom/webidl/moz.build | 1 + widget/EventMessageList.h | 1 + xpcom/ds/StaticAtoms.py | 1 + 8 files changed, 33 insertions(+) create mode 100644 dom/webidl/FormDataEvent.webidl diff --git a/dom/events/EventNameList.h b/dom/events/EventNameList.h index 71a39c92c558..2624f3d36b0f 100644 --- a/dom/events/EventNameList.h +++ b/dom/events/EventNameList.h @@ -177,6 +177,7 @@ EVENT(durationchange, eDurationChange, EventNameType_HTML, eBasicEventClass) EVENT(emptied, eEmptied, EventNameType_HTML, eBasicEventClass) EVENT(ended, eEnded, EventNameType_HTML, eBasicEventClass) EVENT(finish, eMarqueeFinish, EventNameType_HTMLMarqueeOnly, eBasicEventClass) +EVENT(formdata, eFormData, EventNameType_HTML, eBasicEventClass) EVENT(fullscreenchange, eFullscreenChange, EventNameType_HTML, eBasicEventClass) EVENT(fullscreenerror, eFullscreenError, EventNameType_HTML, eBasicEventClass) EVENT(input, eEditorInput, EventNameType_HTMLXUL, eEditorInputEventClass) diff --git a/dom/events/test/test_all_synthetic_events.html b/dom/events/test/test_all_synthetic_events.html index 1d228b3a878b..a5b4366f7ba8 100644 --- a/dom/events/test/test_all_synthetic_events.html +++ b/dom/events/test/test_all_synthetic_events.html @@ -130,6 +130,12 @@ const kEventConstructors = { return new FontFaceSetLoadEvent(aName, aProps); }, }, + FormDataEvent: { create (aName, aProps) { + return new FormDataEvent(aName, { + formData: new FormData() + }); + }, + }, GamepadEvent: { create (aName, aProps) { return new GamepadEvent(aName, aProps); }, diff --git a/dom/tests/mochitest/general/test_interfaces.js b/dom/tests/mochitest/general/test_interfaces.js index 418a4f22fef6..304353b43e91 100644 --- a/dom/tests/mochitest/general/test_interfaces.js +++ b/dom/tests/mochitest/general/test_interfaces.js @@ -384,6 +384,8 @@ var interfaceNamesInGlobalScope = [ // IMPORTANT: Do not change this list without review from a DOM peer! { name: "FormData", insecureContext: true }, // IMPORTANT: Do not change this list without review from a DOM peer! + { name: "FormDataEvent", insecureContext: true }, + // IMPORTANT: Do not change this list without review from a DOM peer! { name: "FontFace", insecureContext: true }, // IMPORTANT: Do not change this list without review from a DOM peer! { name: "FontFaceSet", insecureContext: true }, diff --git a/dom/webidl/EventHandler.webidl b/dom/webidl/EventHandler.webidl index eda811c83296..a40e2322c998 100644 --- a/dom/webidl/EventHandler.webidl +++ b/dom/webidl/EventHandler.webidl @@ -50,6 +50,7 @@ interface mixin GlobalEventHandlers { attribute EventHandler ondurationchange; attribute EventHandler onemptied; attribute EventHandler onended; + attribute EventHandler onformdata; attribute EventHandler oninput; attribute EventHandler oninvalid; attribute EventHandler onkeydown; diff --git a/dom/webidl/FormDataEvent.webidl b/dom/webidl/FormDataEvent.webidl new file mode 100644 index 000000000000..71a87fcbf598 --- /dev/null +++ b/dom/webidl/FormDataEvent.webidl @@ -0,0 +1,20 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The origin of this IDL file is + * https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#the-formdataevent-interface + */ + +[Exposed=Window, + Constructor(DOMString type, optional FormDataEventInit eventInitDict = {})] +interface FormDataEvent : Event { + // C++ can't deal with a method called FormData() in the generated code + [BinaryName="GetFormData"] + readonly attribute FormData formData; +}; + +dictionary FormDataEventInit : EventInit { + required FormData formData; +}; diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build index 62d38504b991..53ea068b16cd 100644 --- a/dom/webidl/moz.build +++ b/dom/webidl/moz.build @@ -1043,6 +1043,7 @@ GENERATED_EVENTS_WEBIDL_FILES = [ 'DeviceProximityEvent.webidl', 'ErrorEvent.webidl', 'FontFaceSetLoadEvent.webidl', + 'FormDataEvent.webidl', 'FrameCrashedEvent.webidl', 'GamepadAxisMoveEvent.webidl', 'GamepadButtonEvent.webidl', diff --git a/widget/EventMessageList.h b/widget/EventMessageList.h index 7c4b221f4a61..34ecec1ef9d5 100644 --- a/widget/EventMessageList.h +++ b/widget/EventMessageList.h @@ -130,6 +130,7 @@ NS_EVENT_MESSAGE(eFormSelect) NS_EVENT_MESSAGE(eFormInvalid) NS_EVENT_MESSAGE(eFormCheckboxStateChange) NS_EVENT_MESSAGE(eFormRadioStateChange) +NS_EVENT_MESSAGE(eFormData) // Need separate focus/blur notifications for non-native widgets NS_EVENT_MESSAGE(eFocus) diff --git a/xpcom/ds/StaticAtoms.py b/xpcom/ds/StaticAtoms.py index 2334e143f011..f81e792f4cf4 100644 --- a/xpcom/ds/StaticAtoms.py +++ b/xpcom/ds/StaticAtoms.py @@ -2015,6 +2015,7 @@ STATIC_ATOMS = [ Atom("ontimeout", "ontimeout"), Atom("ontimeupdate", "ontimeupdate"), Atom("onended", "onended"), + Atom("onformdata", "onformdata"), Atom("onratechange", "onratechange"), Atom("ondurationchange", "ondurationchange"), Atom("onvolumechange", "onvolumechange"),