mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +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,7 +306,9 @@ already_AddRefed<FormData> FormData::Constructor(
|
||||
|
||||
// Step 9. Return a shallow clone of entry list.
|
||||
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#constructing-form-data-set
|
||||
formData = formData->Clone();
|
||||
if (StaticPrefs::dom_formdata_event_enabled()) {
|
||||
formData = formData->Clone();
|
||||
}
|
||||
}
|
||||
|
||||
return formData.forget();
|
||||
|
@ -3808,7 +3808,11 @@ nsIContentPolicy* nsContentUtils::GetContentPolicy() {
|
||||
// static
|
||||
bool nsContentUtils::IsEventAttributeName(nsAtom* aName, int32_t aType) {
|
||||
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;
|
||||
return (sAtomEventTable->Get(aName, &mapping) && mapping.mType & aType);
|
||||
|
@ -477,7 +477,8 @@ function test() {
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
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() {
|
||||
test();
|
||||
SimpleTest.finish();
|
||||
|
@ -560,7 +560,8 @@ nsresult HTMLFormElement::DoSubmit(WidgetEvent* aEvent) {
|
||||
nsresult rv = BuildSubmission(getter_Transfers(submission), aEvent);
|
||||
|
||||
// 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;
|
||||
return NS_OK;
|
||||
}
|
||||
@ -628,7 +629,7 @@ nsresult HTMLFormElement::BuildSubmission(HTMLFormSubmission** aFormSubmission,
|
||||
|
||||
// Step 9. If form cannot navigate, then return.
|
||||
// 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;
|
||||
}
|
||||
|
||||
@ -885,7 +886,8 @@ nsresult HTMLFormElement::NotifySubmitObservers(nsIURI* aActionURL,
|
||||
|
||||
nsresult HTMLFormElement::ConstructEntryList(FormData* aFormData) {
|
||||
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.
|
||||
return NS_ERROR_DOM_INVALID_STATE_ERR;
|
||||
}
|
||||
@ -908,16 +910,18 @@ nsresult HTMLFormElement::ConstructEntryList(FormData* aFormData) {
|
||||
sortedControls[i]->SubmitNamesValues(aFormData);
|
||||
}
|
||||
|
||||
FormDataEventInit init;
|
||||
init.mBubbles = true;
|
||||
init.mCancelable = false;
|
||||
init.mFormData = aFormData;
|
||||
RefPtr<FormDataEvent> event =
|
||||
FormDataEvent::Constructor(this, NS_LITERAL_STRING("formdata"), init);
|
||||
event->SetTrusted(true);
|
||||
if (isFormDataEventEnabled) {
|
||||
FormDataEventInit init;
|
||||
init.mBubbles = true;
|
||||
init.mCancelable = false;
|
||||
init.mFormData = aFormData;
|
||||
RefPtr<FormDataEvent> event =
|
||||
FormDataEvent::Constructor(this, NS_LITERAL_STRING("formdata"), init);
|
||||
event->SetTrusted(true);
|
||||
|
||||
EventDispatcher::DispatchDOMEvent(ToSupports(this), nullptr, event, nullptr,
|
||||
nullptr);
|
||||
EventDispatcher::DispatchDOMEvent(ToSupports(this), nullptr, event, nullptr,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -384,7 +384,7 @@ 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 },
|
||||
{ name: "FormDataEvent", insecureContext: true, nightly: 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!
|
||||
|
@ -50,6 +50,7 @@ interface mixin GlobalEventHandlers {
|
||||
attribute EventHandler ondurationchange;
|
||||
attribute EventHandler onemptied;
|
||||
attribute EventHandler onended;
|
||||
[Pref="dom.formdata.event.enabled"]
|
||||
attribute EventHandler onformdata;
|
||||
attribute EventHandler oninput;
|
||||
attribute EventHandler oninvalid;
|
||||
|
@ -8,7 +8,8 @@
|
||||
*/
|
||||
|
||||
[Exposed=Window,
|
||||
Constructor(DOMString type, optional FormDataEventInit eventInitDict = {})]
|
||||
Constructor(DOMString type, optional FormDataEventInit eventInitDict = {}),
|
||||
Pref="dom.formdata.event.enabled"]
|
||||
interface FormDataEvent : Event {
|
||||
// C++ can't deal with a method called FormData() in the generated code
|
||||
[BinaryName="GetFormData"]
|
||||
|
@ -1459,6 +1459,12 @@
|
||||
value: false
|
||||
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.
|
||||
- name: dom.forms.autocomplete.formautofill
|
||||
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]
|
||||
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