Bug 1690897 - Get rid of dom.formdata.event.enabled pref; r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D104103
This commit is contained in:
Edgar Chen 2021-02-05 13:51:33 +00:00
parent b4afded0ed
commit 448e1644a0
14 changed files with 17 additions and 107 deletions

View File

@ -301,9 +301,7 @@ 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
if (StaticPrefs::dom_formdata_event_enabled()) {
formData = formData->Clone();
}
formData = formData->Clone();
}
return formData.forget();

View File

@ -4040,9 +4040,7 @@ 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' ||
(aName == nsGkAtoms::onformdata &&
!mozilla::StaticPrefs::dom_formdata_event_enabled())) {
if (name[0] != 'o' || name[1] != 'n') {
return false;
}

View File

@ -29,7 +29,6 @@ support-files =
[test_accel_virtual_modifier.html]
[test_addEventListenerExtraArg.html]
[test_all_synthetic_events.html]
[test_bug1518442.html]
[test_bug1539497.html]
[test_bug1686716.html]
[test_bug226361.xhtml]

View File

@ -458,8 +458,7 @@ function test() {
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv(
{"set": [["dom.w3c_touch_events.legacy_apis.enabled", true],
["dom.formdata.event.enabled", true]]},
{"set": [["dom.w3c_touch_events.legacy_apis.enabled", true]]},
function() {
test();
SimpleTest.finish();

View File

@ -1,49 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test for Bug 1518442</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
<script>
function runTest() {
var iframe = document.createElement("iframe");
iframe.src = "about:blank";
iframe.onload = () => frameLoaded(iframe);
document.body.appendChild(iframe);
}
function frameLoaded(iframe) {
let win = iframe.contentWindow;
let doc = iframe.contentDocument;
let element = iframe.contentDocument.documentElement;
is(win.onformdata, undefined, "Should not have window.onformdata");
is(doc.onformdata, undefined, "Should not have document.onformdata");
is(element.onformdata, undefined, "Should not have document.documentElement.onformdata");
let eventName = "formdata";
win.testValue = "not fired";
element.setAttribute("on" + eventName, "window.testValue = 'fired'");
element.dispatchEvent(new Event(eventName));
is(win.testValue, "not fired", `${eventName} should not have fired when pref disable`);
win.testValue = "not fired";
element.removeAttribute("on" + eventName);
element.dispatchEvent(new Event(eventName));
is(win.testValue, "not fired", `${eventName} should not have fired any event`);
delete win.testValue;
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({"set": [["dom.formdata.event.enabled", false]]}, runTest);
</script>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test"></pre>
</body>
</html>

View File

@ -663,8 +663,7 @@ nsresult HTMLFormElement::DoSubmit(Event* aEvent) {
nsresult rv = BuildSubmission(getter_Transfers(submission), aEvent);
// Don't raise an error if form cannot navigate.
if (StaticPrefs::dom_formdata_event_enabled() &&
rv == NS_ERROR_NOT_AVAILABLE) {
if (rv == NS_ERROR_NOT_AVAILABLE) {
return NS_OK;
}
@ -739,7 +738,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 (StaticPrefs::dom_formdata_event_enabled() && !GetComposedDoc()) {
if (!GetComposedDoc()) {
return NS_ERROR_NOT_AVAILABLE;
}
@ -1008,8 +1007,7 @@ nsresult HTMLFormElement::NotifySubmitObservers(nsIURI* aActionURL,
nsresult HTMLFormElement::ConstructEntryList(FormData* aFormData) {
MOZ_ASSERT(aFormData, "Must have FormData!");
bool isFormDataEventEnabled = StaticPrefs::dom_formdata_event_enabled();
if (isFormDataEventEnabled && mIsConstructingEntryList) {
if (mIsConstructingEntryList) {
// Step 2.2 of https://xhr.spec.whatwg.org/#dom-formdata.
return NS_ERROR_DOM_INVALID_STATE_ERR;
}
@ -1032,18 +1030,16 @@ nsresult HTMLFormElement::ConstructEntryList(FormData* aFormData) {
sortedControls[i]->SubmitNamesValues(aFormData);
}
if (isFormDataEventEnabled) {
FormDataEventInit init;
init.mBubbles = true;
init.mCancelable = false;
init.mFormData = aFormData;
RefPtr<FormDataEvent> event =
FormDataEvent::Constructor(this, u"formdata"_ns, init);
event->SetTrusted(true);
FormDataEventInit init;
init.mBubbles = true;
init.mCancelable = false;
init.mFormData = aFormData;
RefPtr<FormDataEvent> event =
FormDataEvent::Constructor(this, u"formdata"_ns, init);
event->SetTrusted(true);
EventDispatcher::DispatchDOMEvent(ToSupports(this), nullptr, event, nullptr,
nullptr);
}
EventDispatcher::DispatchDOMEvent(ToSupports(this), nullptr, event, nullptr,
nullptr);
return NS_OK;
}

View File

@ -52,7 +52,6 @@ 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;

View File

@ -7,8 +7,7 @@
* https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#the-formdataevent-interface
*/
[Exposed=Window,
Pref="dom.formdata.event.enabled"]
[Exposed=Window]
interface FormDataEvent : Event {
constructor(DOMString type, optional FormDataEventInit eventInitDict = {});

View File

@ -1858,12 +1858,6 @@
value: false
mirror: always
# Enable formData event
- name: dom.formdata.event.enabled
type: bool
value: true
mirror: always
# Support @autocomplete values for form autofill feature.
- name: dom.forms.autocomplete.formautofill
type: bool

View File

@ -1,3 +1,2 @@
prefs: [dom.formdata.event.enabled:true]
lsan-disabled: true
leak-threshold: [default:51200]

View File

@ -1 +0,0 @@
prefs: [dom.formdata.event.enabled:true]

View File

@ -1 +0,0 @@
prefs: [dom.formdata.event.enabled:true]

View File

@ -44,23 +44,3 @@
[onslotchange: dispatching an Event at a <math> element must trigger element.onslotchange]
expected: FAIL
[onformdata: must be on the appropriate locations for GlobalEventHandlers]
expected:
if release_or_beta: [FAIL, PASS]
[onformdata: the default value must be null]
expected:
if release_or_beta: [FAIL, PASS]
[onformdata: the content attribute must be compiled into a function as the corresponding property]
expected:
if release_or_beta: [FAIL, PASS]
[onformdata: dynamic changes on the attribute]
expected:
if release_or_beta: [FAIL, PASS]
[onformdata: dispatching an Event at a <math> element must trigger element.onformdata]
expected:
if release_or_beta: [FAIL, PASS]

View File

@ -1,3 +1,3 @@
prefs: [javascript.options.streams:true, dom.xhr.standard_content_type_normalization:true, dom.formdata.event.enabled:true]
prefs: [javascript.options.streams:true, dom.xhr.standard_content_type_normalization:true]
lsan-allowed: [Alloc, mozilla::net::nsServerSocket::CreateClientTransport]
leak-threshold: [default:51200]