mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Bug 1518442 - Part 3: Add dom.formdata.event.enabled preference for Event-based form participation; r=smaug,edgar
Differential Revision: https://phabricator.services.mozilla.com/D43987 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
d2154fae15
commit
5e255f0239
@ -306,8 +306,10 @@ already_AddRefed<FormData> FormData::Constructor(
|
|||||||
|
|
||||||
// Step 9. Return a shallow clone of entry list.
|
// Step 9. Return a shallow clone of entry list.
|
||||||
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#constructing-form-data-set
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#constructing-form-data-set
|
||||||
|
if (StaticPrefs::dom_formdata_event_enabled()) {
|
||||||
formData = formData->Clone();
|
formData = formData->Clone();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return formData.forget();
|
return formData.forget();
|
||||||
}
|
}
|
||||||
|
@ -3808,7 +3808,11 @@ nsIContentPolicy* nsContentUtils::GetContentPolicy() {
|
|||||||
// static
|
// static
|
||||||
bool nsContentUtils::IsEventAttributeName(nsAtom* aName, int32_t aType) {
|
bool nsContentUtils::IsEventAttributeName(nsAtom* aName, int32_t aType) {
|
||||||
const char16_t* name = aName->GetUTF16String();
|
const char16_t* name = aName->GetUTF16String();
|
||||||
if (name[0] != 'o' || name[1] != 'n') return false;
|
if (name[0] != 'o' || name[1] != 'n' ||
|
||||||
|
(aName == nsGkAtoms::onformdata &&
|
||||||
|
!mozilla::StaticPrefs::dom_formdata_event_enabled())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
EventNameMapping mapping;
|
EventNameMapping mapping;
|
||||||
return (sAtomEventTable->Get(aName, &mapping) && mapping.mType & aType);
|
return (sAtomEventTable->Get(aName, &mapping) && mapping.mType & aType);
|
||||||
|
@ -477,7 +477,8 @@ function test() {
|
|||||||
|
|
||||||
SimpleTest.waitForExplicitFinish();
|
SimpleTest.waitForExplicitFinish();
|
||||||
SpecialPowers.pushPrefEnv(
|
SpecialPowers.pushPrefEnv(
|
||||||
{"set": [["dom.w3c_touch_events.legacy_apis.enabled", true]]},
|
{"set": [["dom.w3c_touch_events.legacy_apis.enabled", true],
|
||||||
|
["dom.formdata.event.enabled", true]]},
|
||||||
function() {
|
function() {
|
||||||
test();
|
test();
|
||||||
SimpleTest.finish();
|
SimpleTest.finish();
|
||||||
|
@ -560,7 +560,8 @@ nsresult HTMLFormElement::DoSubmit(WidgetEvent* aEvent) {
|
|||||||
nsresult rv = BuildSubmission(getter_Transfers(submission), aEvent);
|
nsresult rv = BuildSubmission(getter_Transfers(submission), aEvent);
|
||||||
|
|
||||||
// Don't raise an error if form cannot navigate.
|
// Don't raise an error if form cannot navigate.
|
||||||
if (rv == NS_ERROR_NOT_AVAILABLE) {
|
if (StaticPrefs::dom_formdata_event_enabled() &&
|
||||||
|
rv == NS_ERROR_NOT_AVAILABLE) {
|
||||||
mIsSubmitting = false;
|
mIsSubmitting = false;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
@ -628,7 +629,7 @@ nsresult HTMLFormElement::BuildSubmission(HTMLFormSubmission** aFormSubmission,
|
|||||||
|
|
||||||
// Step 9. If form cannot navigate, then return.
|
// Step 9. If form cannot navigate, then return.
|
||||||
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#form-submission-algorithm
|
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#form-submission-algorithm
|
||||||
if (!GetComposedDoc()) {
|
if (StaticPrefs::dom_formdata_event_enabled() && !GetComposedDoc()) {
|
||||||
return NS_ERROR_NOT_AVAILABLE;
|
return NS_ERROR_NOT_AVAILABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -885,7 +886,8 @@ nsresult HTMLFormElement::NotifySubmitObservers(nsIURI* aActionURL,
|
|||||||
|
|
||||||
nsresult HTMLFormElement::ConstructEntryList(FormData* aFormData) {
|
nsresult HTMLFormElement::ConstructEntryList(FormData* aFormData) {
|
||||||
MOZ_ASSERT(aFormData, "Must have FormData!");
|
MOZ_ASSERT(aFormData, "Must have FormData!");
|
||||||
if (mIsConstructingEntryList) {
|
bool isFormDataEventEnabled = StaticPrefs::dom_formdata_event_enabled();
|
||||||
|
if (isFormDataEventEnabled && mIsConstructingEntryList) {
|
||||||
// Step 2.2 of https://xhr.spec.whatwg.org/#dom-formdata.
|
// Step 2.2 of https://xhr.spec.whatwg.org/#dom-formdata.
|
||||||
return NS_ERROR_DOM_INVALID_STATE_ERR;
|
return NS_ERROR_DOM_INVALID_STATE_ERR;
|
||||||
}
|
}
|
||||||
@ -908,6 +910,7 @@ nsresult HTMLFormElement::ConstructEntryList(FormData* aFormData) {
|
|||||||
sortedControls[i]->SubmitNamesValues(aFormData);
|
sortedControls[i]->SubmitNamesValues(aFormData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isFormDataEventEnabled) {
|
||||||
FormDataEventInit init;
|
FormDataEventInit init;
|
||||||
init.mBubbles = true;
|
init.mBubbles = true;
|
||||||
init.mCancelable = false;
|
init.mCancelable = false;
|
||||||
@ -918,6 +921,7 @@ nsresult HTMLFormElement::ConstructEntryList(FormData* aFormData) {
|
|||||||
|
|
||||||
EventDispatcher::DispatchDOMEvent(ToSupports(this), nullptr, event, nullptr,
|
EventDispatcher::DispatchDOMEvent(ToSupports(this), nullptr, event, nullptr,
|
||||||
nullptr);
|
nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -384,7 +384,7 @@ var interfaceNamesInGlobalScope = [
|
|||||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||||
{ name: "FormData", insecureContext: true },
|
{ name: "FormData", insecureContext: true },
|
||||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||||
{ name: "FormDataEvent", insecureContext: true },
|
{ name: "FormDataEvent", insecureContext: true, nightly: true },
|
||||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||||
{ name: "FontFace", insecureContext: true },
|
{ name: "FontFace", insecureContext: true },
|
||||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||||
|
@ -50,6 +50,7 @@ interface mixin GlobalEventHandlers {
|
|||||||
attribute EventHandler ondurationchange;
|
attribute EventHandler ondurationchange;
|
||||||
attribute EventHandler onemptied;
|
attribute EventHandler onemptied;
|
||||||
attribute EventHandler onended;
|
attribute EventHandler onended;
|
||||||
|
[Pref="dom.formdata.event.enabled"]
|
||||||
attribute EventHandler onformdata;
|
attribute EventHandler onformdata;
|
||||||
attribute EventHandler oninput;
|
attribute EventHandler oninput;
|
||||||
attribute EventHandler oninvalid;
|
attribute EventHandler oninvalid;
|
||||||
|
@ -8,7 +8,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
[Exposed=Window,
|
[Exposed=Window,
|
||||||
Constructor(DOMString type, optional FormDataEventInit eventInitDict = {})]
|
Constructor(DOMString type, optional FormDataEventInit eventInitDict = {}),
|
||||||
|
Pref="dom.formdata.event.enabled"]
|
||||||
interface FormDataEvent : Event {
|
interface FormDataEvent : Event {
|
||||||
// C++ can't deal with a method called FormData() in the generated code
|
// C++ can't deal with a method called FormData() in the generated code
|
||||||
[BinaryName="GetFormData"]
|
[BinaryName="GetFormData"]
|
||||||
|
@ -1459,6 +1459,12 @@
|
|||||||
value: false
|
value: false
|
||||||
mirror: always
|
mirror: always
|
||||||
|
|
||||||
|
# Whether or not formData event is enabled.
|
||||||
|
- name: dom.formdata.event.enabled
|
||||||
|
type: bool
|
||||||
|
value: @IS_NIGHTLY_BUILD@
|
||||||
|
mirror: always
|
||||||
|
|
||||||
# Support @autocomplete values for form autofill feature.
|
# Support @autocomplete values for form autofill feature.
|
||||||
- name: dom.forms.autocomplete.formautofill
|
- name: dom.forms.autocomplete.formautofill
|
||||||
type: bool
|
type: bool
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
lsan-allowed: [Alloc, Malloc, NewPage, PLDHashTable::Add, Realloc, SetPropertyAsInterface, mozilla::WeakPtr, mozilla::extensions::ChannelWrapper::ChannelWrapper, mozilla::net::nsUDPSocket::SendWithAddress, nsNodeSupportsWeakRefTearoff::GetWeakReference]
|
lsan-allowed: [Alloc, Malloc, NewPage, PLDHashTable::Add, Realloc, SetPropertyAsInterface, mozilla::WeakPtr, mozilla::extensions::ChannelWrapper::ChannelWrapper, mozilla::net::nsUDPSocket::SendWithAddress, nsNodeSupportsWeakRefTearoff::GetWeakReference]
|
||||||
leak-threshold: [default:51200]
|
leak-threshold: [default:51200]
|
||||||
|
prefs: [dom.formdata.event.enabled:true]
|
@ -0,0 +1 @@
|
|||||||
|
prefs: [dom.formdata.event.enabled:true]
|
@ -0,0 +1 @@
|
|||||||
|
prefs: [dom.formdata.event.enabled:true]
|
@ -1 +1 @@
|
|||||||
prefs: [javascript.options.streams:true, dom.xhr.standard_content_type_normalization:true]
|
prefs: [javascript.options.streams:true, dom.xhr.standard_content_type_normalization:true, dom.formdata.event.enabled:true]
|
||||||
|
Loading…
Reference in New Issue
Block a user