зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 5 changesets (bug 1518442) as requested by jdai. CLOSED TREE
Backed out changeset 9143aef9bd5e (bug 1518442) Backed out changeset b1b08f66996c (bug 1518442) Backed out changeset 1f3d36108982 (bug 1518442) Backed out changeset 1ac7b20bb1d8 (bug 1518442) Backed out changeset f280db1076a4 (bug 1518442)
This commit is contained in:
Родитель
518fed5491
Коммит
77240d9965
|
@ -16,19 +16,10 @@
|
|||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
FormData::FormData(nsISupports* aOwner, NotNull<const Encoding*> aEncoding,
|
||||
Element* aOriginatingElement)
|
||||
: HTMLFormSubmission(nullptr, EmptyString(), aEncoding,
|
||||
aOriginatingElement),
|
||||
FormData::FormData(nsISupports* aOwner)
|
||||
: HTMLFormSubmission(nullptr, EmptyString(), UTF_8_ENCODING, nullptr),
|
||||
mOwner(aOwner) {}
|
||||
|
||||
FormData::FormData(const FormData& aFormData)
|
||||
: HTMLFormSubmission(aFormData.mActionURL, aFormData.mTarget,
|
||||
aFormData.mEncoding, aFormData.mOriginatingElement) {
|
||||
mOwner = aFormData.mOwner;
|
||||
mFormData = aFormData.mFormData;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
already_AddRefed<File> GetOrCreateFileCalledBlob(Blob& aBlob,
|
||||
|
@ -299,18 +290,8 @@ already_AddRefed<FormData> FormData::Constructor(
|
|||
const Optional<NonNull<HTMLFormElement> >& aFormElement, ErrorResult& aRv) {
|
||||
RefPtr<FormData> formData = new FormData(aGlobal.GetAsSupports());
|
||||
if (aFormElement.WasPassed()) {
|
||||
aRv = aFormElement.Value().ConstructEntryList(formData);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// 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();
|
||||
}
|
||||
aRv = aFormElement.Value().WalkFormElements(formData);
|
||||
}
|
||||
|
||||
return formData.forget();
|
||||
}
|
||||
|
||||
|
@ -321,8 +302,23 @@ nsresult FormData::GetSendInfo(nsIInputStream** aBody, uint64_t* aContentLength,
|
|||
nsACString& aContentTypeWithCharset,
|
||||
nsACString& aCharset) const {
|
||||
FSMultipartFormData fs(nullptr, EmptyString(), UTF_8_ENCODING, nullptr);
|
||||
nsresult rv = CopySubmissionDataTo(&fs);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
for (uint32_t i = 0; i < mFormData.Length(); ++i) {
|
||||
if (mFormData[i].wasNullBlob) {
|
||||
MOZ_ASSERT(mFormData[i].value.IsUSVString());
|
||||
fs.AddNameBlobOrNullPair(mFormData[i].name, nullptr);
|
||||
} else if (mFormData[i].value.IsUSVString()) {
|
||||
fs.AddNameValuePair(mFormData[i].name,
|
||||
mFormData[i].value.GetAsUSVString());
|
||||
} else if (mFormData[i].value.IsBlob()) {
|
||||
fs.AddNameBlobOrNullPair(mFormData[i].name,
|
||||
mFormData[i].value.GetAsBlob());
|
||||
} else {
|
||||
MOZ_ASSERT(mFormData[i].value.IsDirectory());
|
||||
fs.AddNameDirectoryPair(mFormData[i].name,
|
||||
mFormData[i].value.GetAsDirectory());
|
||||
}
|
||||
}
|
||||
|
||||
fs.GetContentType(aContentTypeWithCharset);
|
||||
aCharset.Truncate();
|
||||
|
@ -331,31 +327,3 @@ nsresult FormData::GetSendInfo(nsIInputStream** aBody, uint64_t* aContentLength,
|
|||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<FormData> FormData::Clone() {
|
||||
RefPtr<FormData> formData = new FormData(*this);
|
||||
return formData.forget();
|
||||
}
|
||||
|
||||
nsresult FormData::CopySubmissionDataTo(
|
||||
HTMLFormSubmission* aFormSubmission) const {
|
||||
MOZ_ASSERT(aFormSubmission, "Must have FormSubmission!");
|
||||
for (size_t i = 0; i < mFormData.Length(); ++i) {
|
||||
if (mFormData[i].wasNullBlob) {
|
||||
MOZ_ASSERT(mFormData[i].value.IsUSVString());
|
||||
aFormSubmission->AddNameBlobOrNullPair(mFormData[i].name, nullptr);
|
||||
} else if (mFormData[i].value.IsUSVString()) {
|
||||
aFormSubmission->AddNameValuePair(mFormData[i].name,
|
||||
mFormData[i].value.GetAsUSVString());
|
||||
} else if (mFormData[i].value.IsBlob()) {
|
||||
aFormSubmission->AddNameBlobOrNullPair(mFormData[i].name,
|
||||
mFormData[i].value.GetAsBlob());
|
||||
} else {
|
||||
MOZ_ASSERT(mFormData[i].value.IsDirectory());
|
||||
aFormSubmission->AddNameDirectoryPair(
|
||||
mFormData[i].name, mFormData[i].value.GetAsDirectory());
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ class FormData final : public nsISupports,
|
|||
public HTMLFormSubmission,
|
||||
public nsWrapperCache {
|
||||
private:
|
||||
FormData(const FormData& aFormData);
|
||||
~FormData() {}
|
||||
|
||||
struct FormDataTuple {
|
||||
|
@ -50,11 +49,7 @@ class FormData final : public nsISupports,
|
|||
Directory* aDirectory);
|
||||
|
||||
public:
|
||||
explicit FormData(nsISupports* aOwner = nullptr,
|
||||
NotNull<const Encoding*> aEncoding = UTF_8_ENCODING,
|
||||
Element* aOriginatingElement = nullptr);
|
||||
|
||||
already_AddRefed<FormData> Clone();
|
||||
explicit FormData(nsISupports* aOwner = nullptr);
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(FormData)
|
||||
|
@ -141,8 +136,6 @@ class FormData final : public nsISupports,
|
|||
nsACString& aContentTypeWithCharset,
|
||||
nsACString& aCharset) const;
|
||||
|
||||
nsresult CopySubmissionDataTo(HTMLFormSubmission* aFormSubmission) const;
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsISupports> mOwner;
|
||||
|
||||
|
|
|
@ -3808,11 +3808,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())) {
|
||||
return false;
|
||||
}
|
||||
if (name[0] != 'o' || name[1] != 'n') return false;
|
||||
|
||||
EventNameMapping mapping;
|
||||
return (sAtomEventTable->Get(aName, &mapping) && mapping.mType & aType);
|
||||
|
|
|
@ -177,7 +177,6 @@ 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)
|
||||
|
|
|
@ -24,7 +24,6 @@ support-files =
|
|||
[test_accel_virtual_modifier.html]
|
||||
[test_addEventListenerExtraArg.html]
|
||||
[test_all_synthetic_events.html]
|
||||
[test_bug1518442.html]
|
||||
[test_bug1539497.html]
|
||||
[test_bug226361.xhtml]
|
||||
[test_bug238987.html]
|
||||
|
|
|
@ -130,12 +130,6 @@ 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);
|
||||
},
|
||||
|
@ -477,8 +471,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();
|
||||
|
|
|
@ -1,39 +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() {
|
||||
try {
|
||||
let eventName = "formdata";
|
||||
window.testValue = "not fired";
|
||||
document.documentElement.setAttribute("on" + eventName, "window.testValue = 'fired'");
|
||||
document.documentElement.dispatchEvent(new Event(eventName));
|
||||
is(window.testValue, "not fired", `${eventName} should not have fired when pref disable`);
|
||||
|
||||
window.testValue = "not fired";
|
||||
document.documentElement.removeAttribute("on" + eventName);
|
||||
document.documentElement.dispatchEvent(new Event(eventName));
|
||||
is(window.testValue, "not fired", `${eventName} should not have fired any event`);
|
||||
|
||||
is(window.onformdata, null, "Should not have window.onformdata");
|
||||
is(document.onformdata, null, "Should not have document.onformdata");
|
||||
is(document.documentElement.onformdata, null, "Should not have document.documentElement.onformdata");
|
||||
} finally {
|
||||
delete window.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>
|
|
@ -39,7 +39,6 @@
|
|||
// form submission
|
||||
#include "HTMLFormSubmissionConstants.h"
|
||||
#include "mozilla/dom/FormData.h"
|
||||
#include "mozilla/dom/FormDataEvent.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "nsIFormSubmitObserver.h"
|
||||
#include "nsIObserverService.h"
|
||||
|
@ -118,8 +117,7 @@ HTMLFormElement::HTMLFormElement(
|
|||
mDeferSubmission(false),
|
||||
mNotifiedObservers(false),
|
||||
mNotifiedObserversResult(false),
|
||||
mEverTriedInvalidSubmit(false),
|
||||
mIsConstructingEntryList(false) {
|
||||
mEverTriedInvalidSubmit(false) {
|
||||
// We start out valid.
|
||||
AddStatesSilently(NS_EVENT_STATE_VALID);
|
||||
}
|
||||
|
@ -506,8 +504,7 @@ nsresult HTMLFormElement::DoSubmitOrReset(WidgetEvent* aEvent,
|
|||
if (eFormSubmit == aMessage) {
|
||||
// Don't submit if we're not in a document or if we're in
|
||||
// a sandboxed frame and form submit is disabled.
|
||||
if (mIsConstructingEntryList || !doc ||
|
||||
(doc->GetSandboxFlags() & SANDBOXED_FORMS)) {
|
||||
if (!doc || (doc->GetSandboxFlags() & SANDBOXED_FORMS)) {
|
||||
return NS_OK;
|
||||
}
|
||||
return DoSubmit(aEvent);
|
||||
|
@ -558,14 +555,6 @@ nsresult HTMLFormElement::DoSubmit(WidgetEvent* aEvent) {
|
|||
// prepare the submission object
|
||||
//
|
||||
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) {
|
||||
mIsSubmitting = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
mIsSubmitting = false;
|
||||
return rv;
|
||||
|
@ -617,33 +606,17 @@ nsresult HTMLFormElement::BuildSubmission(HTMLFormSubmission** aFormSubmission,
|
|||
|
||||
nsresult rv;
|
||||
|
||||
//
|
||||
// Walk over the form elements and call SubmitNamesValues() on them to get
|
||||
// their data.
|
||||
//
|
||||
auto encoding = GetSubmitEncoding()->OutputEncoding();
|
||||
RefPtr<FormData> formData =
|
||||
new FormData(GetOwnerGlobal(), encoding, originatingElement);
|
||||
rv = ConstructEntryList(formData);
|
||||
NS_ENSURE_SUBMIT_SUCCESS(rv);
|
||||
|
||||
// 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()) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
//
|
||||
// Get the submission object
|
||||
//
|
||||
rv = HTMLFormSubmission::GetFromForm(this, originatingElement, encoding,
|
||||
rv = HTMLFormSubmission::GetFromForm(this, originatingElement,
|
||||
aFormSubmission);
|
||||
NS_ENSURE_SUBMIT_SUCCESS(rv);
|
||||
|
||||
//
|
||||
// Dump the data into the submission object
|
||||
//
|
||||
rv = formData->CopySubmissionDataTo(*aFormSubmission);
|
||||
rv = WalkFormElements(*aFormSubmission);
|
||||
NS_ENSURE_SUBMIT_SUCCESS(rv);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -884,16 +857,8 @@ nsresult HTMLFormElement::NotifySubmitObservers(nsIURI* aActionURL,
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsresult HTMLFormElement::ConstructEntryList(FormData* aFormData) {
|
||||
MOZ_ASSERT(aFormData, "Must have FormData!");
|
||||
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;
|
||||
}
|
||||
|
||||
AutoRestore<bool> resetConstructingEntryList(mIsConstructingEntryList);
|
||||
mIsConstructingEntryList = true;
|
||||
nsresult HTMLFormElement::WalkFormElements(
|
||||
HTMLFormSubmission* aFormSubmission) {
|
||||
// This shouldn't be called recursively, so use a rather large value
|
||||
// for the preallocated buffer.
|
||||
AutoTArray<RefPtr<nsGenericHTMLFormElement>, 100> sortedControls;
|
||||
|
@ -907,58 +872,12 @@ nsresult HTMLFormElement::ConstructEntryList(FormData* aFormData) {
|
|||
//
|
||||
for (uint32_t i = 0; i < len; ++i) {
|
||||
// Tell the control to submit its name/value pairs to the submission
|
||||
sortedControls[i]->SubmitNamesValues(aFormData);
|
||||
}
|
||||
|
||||
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);
|
||||
sortedControls[i]->SubmitNamesValues(aFormSubmission);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NotNull<const Encoding*> HTMLFormElement::GetSubmitEncoding() {
|
||||
nsAutoString acceptCharsetValue;
|
||||
GetAttr(kNameSpaceID_None, nsGkAtoms::acceptcharset, acceptCharsetValue);
|
||||
|
||||
int32_t charsetLen = acceptCharsetValue.Length();
|
||||
if (charsetLen > 0) {
|
||||
int32_t offset = 0;
|
||||
int32_t spPos = 0;
|
||||
// get charset from charsets one by one
|
||||
do {
|
||||
spPos = acceptCharsetValue.FindChar(char16_t(' '), offset);
|
||||
int32_t cnt = ((-1 == spPos) ? (charsetLen - offset) : (spPos - offset));
|
||||
if (cnt > 0) {
|
||||
nsAutoString uCharset;
|
||||
acceptCharsetValue.Mid(uCharset, offset, cnt);
|
||||
|
||||
auto encoding = Encoding::ForLabelNoReplacement(uCharset);
|
||||
if (encoding) {
|
||||
return WrapNotNull(encoding);
|
||||
}
|
||||
}
|
||||
offset = spPos + 1;
|
||||
} while (spPos != -1);
|
||||
}
|
||||
// if there are no accept-charset or all the charset are not supported
|
||||
// Get the charset from document
|
||||
Document* doc = GetComposedDoc();
|
||||
if (doc) {
|
||||
return doc->GetDocumentCharacterSet();
|
||||
}
|
||||
return UTF_8_ENCODING;
|
||||
}
|
||||
|
||||
// nsIForm
|
||||
|
||||
NS_IMETHODIMP_(uint32_t)
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "mozilla/AsyncEventDispatcher.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/HTMLFormSubmission.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIForm.h"
|
||||
|
@ -32,7 +33,6 @@ class EventChainPreVisitor;
|
|||
namespace dom {
|
||||
class HTMLFormControlsCollection;
|
||||
class HTMLImageElement;
|
||||
class FormData;
|
||||
|
||||
class HTMLFormElement final : public nsGenericHTMLElement,
|
||||
public nsIWebProgressListener,
|
||||
|
@ -277,13 +277,12 @@ class HTMLFormElement final : public nsGenericHTMLElement,
|
|||
bool SubmissionCanProceed(Element* aSubmitter);
|
||||
|
||||
/**
|
||||
* Contruct the entry list to get their data pumped into the FormData and
|
||||
* fire a `formdata` event with the entry list in formData attribute.
|
||||
* <https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#constructing-form-data-set>
|
||||
* Walk over the form elements and call SubmitNamesValues() on them to get
|
||||
* their data pumped into the FormSubmitter.
|
||||
*
|
||||
* @param aFormData the form data object
|
||||
* @param aFormSubmission the form submission object
|
||||
*/
|
||||
nsresult ConstructEntryList(FormData* aFormData);
|
||||
nsresult WalkFormElements(HTMLFormSubmission* aFormSubmission);
|
||||
|
||||
/**
|
||||
* Whether the submission of this form has been ever prevented because of
|
||||
|
@ -612,11 +611,8 @@ class HTMLFormElement final : public nsGenericHTMLElement,
|
|||
* being invalid.
|
||||
*/
|
||||
bool mEverTriedInvalidSubmit;
|
||||
/** Whether we are constructing entry list */
|
||||
bool mIsConstructingEntryList;
|
||||
|
||||
private:
|
||||
NotNull<const Encoding*> GetSubmitEncoding();
|
||||
~HTMLFormElement();
|
||||
};
|
||||
|
||||
|
|
|
@ -755,6 +755,40 @@ nsresult EncodingFormSubmission::EncodeVal(const nsAString& aStr,
|
|||
|
||||
namespace {
|
||||
|
||||
NotNull<const Encoding*> GetSubmitEncoding(nsGenericHTMLElement* aForm) {
|
||||
nsAutoString acceptCharsetValue;
|
||||
aForm->GetAttr(kNameSpaceID_None, nsGkAtoms::acceptcharset,
|
||||
acceptCharsetValue);
|
||||
|
||||
int32_t charsetLen = acceptCharsetValue.Length();
|
||||
if (charsetLen > 0) {
|
||||
int32_t offset = 0;
|
||||
int32_t spPos = 0;
|
||||
// get charset from charsets one by one
|
||||
do {
|
||||
spPos = acceptCharsetValue.FindChar(char16_t(' '), offset);
|
||||
int32_t cnt = ((-1 == spPos) ? (charsetLen - offset) : (spPos - offset));
|
||||
if (cnt > 0) {
|
||||
nsAutoString uCharset;
|
||||
acceptCharsetValue.Mid(uCharset, offset, cnt);
|
||||
|
||||
auto encoding = Encoding::ForLabelNoReplacement(uCharset);
|
||||
if (encoding) {
|
||||
return WrapNotNull(encoding);
|
||||
}
|
||||
}
|
||||
offset = spPos + 1;
|
||||
} while (spPos != -1);
|
||||
}
|
||||
// if there are no accept-charset or all the charset are not supported
|
||||
// Get the charset from document
|
||||
Document* doc = aForm->GetComposedDoc();
|
||||
if (doc) {
|
||||
return doc->GetDocumentCharacterSet();
|
||||
}
|
||||
return UTF_8_ENCODING;
|
||||
}
|
||||
|
||||
void GetEnumAttr(nsGenericHTMLElement* aContent, nsAtom* atom,
|
||||
int32_t* aValue) {
|
||||
const nsAttrValue* value = aContent->GetParsedAttr(atom);
|
||||
|
@ -768,7 +802,7 @@ void GetEnumAttr(nsGenericHTMLElement* aContent, nsAtom* atom,
|
|||
/* static */
|
||||
nsresult HTMLFormSubmission::GetFromForm(
|
||||
HTMLFormElement* aForm, nsGenericHTMLElement* aOriginatingElement,
|
||||
NotNull<const Encoding*>& aEncoding, HTMLFormSubmission** aFormSubmission) {
|
||||
HTMLFormSubmission** aFormSubmission) {
|
||||
// Get all the information necessary to encode the form data
|
||||
NS_ASSERTION(aForm->GetComposedDoc(),
|
||||
"Should have doc if we're building submission!");
|
||||
|
@ -831,14 +865,17 @@ nsresult HTMLFormSubmission::GetFromForm(
|
|||
GetEnumAttr(aForm, nsGkAtoms::method, &method);
|
||||
}
|
||||
|
||||
// Get encoding
|
||||
auto encoding = GetSubmitEncoding(aForm)->OutputEncoding();
|
||||
|
||||
// Choose encoder
|
||||
if (method == NS_FORM_METHOD_POST && enctype == NS_FORM_ENCTYPE_MULTIPART) {
|
||||
*aFormSubmission = new FSMultipartFormData(actionURL, target, aEncoding,
|
||||
*aFormSubmission = new FSMultipartFormData(actionURL, target, encoding,
|
||||
aOriginatingElement);
|
||||
} else if (method == NS_FORM_METHOD_POST &&
|
||||
enctype == NS_FORM_ENCTYPE_TEXTPLAIN) {
|
||||
*aFormSubmission =
|
||||
new FSTextPlain(actionURL, target, aEncoding, aOriginatingElement);
|
||||
new FSTextPlain(actionURL, target, encoding, aOriginatingElement);
|
||||
} else {
|
||||
Document* doc = aForm->OwnerDoc();
|
||||
if (enctype == NS_FORM_ENCTYPE_MULTIPART ||
|
||||
|
@ -856,7 +893,7 @@ nsresult HTMLFormSubmission::GetFromForm(
|
|||
|
||||
SendJSWarning(doc, "ForgotPostWarning", args);
|
||||
}
|
||||
*aFormSubmission = new FSURLEncoded(actionURL, target, aEncoding, method,
|
||||
*aFormSubmission = new FSURLEncoded(actionURL, target, encoding, method,
|
||||
doc, aOriginatingElement);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,6 @@ class HTMLFormSubmission {
|
|||
*/
|
||||
static nsresult GetFromForm(HTMLFormElement* aForm,
|
||||
nsGenericHTMLElement* aOriginatingElement,
|
||||
NotNull<const Encoding*>& aEncoding,
|
||||
HTMLFormSubmission** aFormSubmission);
|
||||
|
||||
virtual ~HTMLFormSubmission() { MOZ_COUNT_DTOR(HTMLFormSubmission); }
|
||||
|
|
|
@ -384,8 +384,6 @@ 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, 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!
|
||||
{ name: "FontFaceSet", insecureContext: true },
|
||||
|
|
|
@ -50,8 +50,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;
|
||||
attribute EventHandler onkeydown;
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
/* -*- 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 = {}),
|
||||
Pref="dom.formdata.event.enabled"]
|
||||
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;
|
||||
};
|
|
@ -1043,7 +1043,6 @@ GENERATED_EVENTS_WEBIDL_FILES = [
|
|||
'DeviceProximityEvent.webidl',
|
||||
'ErrorEvent.webidl',
|
||||
'FontFaceSetLoadEvent.webidl',
|
||||
'FormDataEvent.webidl',
|
||||
'FrameCrashedEvent.webidl',
|
||||
'GamepadAxisMoveEvent.webidl',
|
||||
'GamepadButtonEvent.webidl',
|
||||
|
|
|
@ -1459,12 +1459,6 @@
|
|||
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
|
||||
|
|
|
@ -41,6 +41,9 @@
|
|||
[OffscreenCanvasRenderingContext2D interface: attribute shadowOffsetX]
|
||||
expected: FAIL
|
||||
|
||||
[FormDataEvent interface object name]
|
||||
expected: FAIL
|
||||
|
||||
[SVGSVGElement interface: attribute onstorage]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -74,6 +77,9 @@
|
|||
[ApplicationCache interface: attribute onprogress]
|
||||
expected: FAIL
|
||||
|
||||
[FormDataEvent interface: existence and properties of interface prototype object's "constructor" property]
|
||||
expected: FAIL
|
||||
|
||||
[VideoTrack interface: attribute kind]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -128,6 +134,9 @@
|
|||
[ElementInternals interface: operation reportValidity()]
|
||||
expected: FAIL
|
||||
|
||||
[FormDataEvent interface: existence and properties of interface prototype object's @@unscopables property]
|
||||
expected: FAIL
|
||||
|
||||
[VideoTrackList interface object length]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -332,6 +341,9 @@
|
|||
[OffscreenCanvasRenderingContext2D interface: operation rect(unrestricted double, unrestricted double, unrestricted double, unrestricted double)]
|
||||
expected: FAIL
|
||||
|
||||
[FormDataEvent interface: attribute formData]
|
||||
expected: FAIL
|
||||
|
||||
[VideoTrackList interface object name]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -500,6 +512,9 @@
|
|||
[OffscreenCanvasRenderingContext2D interface: operation createImageData(ImageData)]
|
||||
expected: FAIL
|
||||
|
||||
[Stringification of new FormDataEvent("formdata", { formData: new FormData() })]
|
||||
expected: FAIL
|
||||
|
||||
[AudioTrackList interface: attribute onchange]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -587,6 +602,12 @@
|
|||
[VideoTrackList interface: attribute length]
|
||||
expected: FAIL
|
||||
|
||||
[FormDataEvent interface: new FormDataEvent("formdata", { formData: new FormData() }) must inherit property "formData" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[FormDataEvent interface: existence and properties of interface object]
|
||||
expected: FAIL
|
||||
|
||||
[VideoTrack interface object length]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -659,6 +680,9 @@
|
|||
[Navigator interface: window.navigator must inherit property "unregisterProtocolHandler(DOMString, USVString)" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[FormDataEvent interface object length]
|
||||
expected: FAIL
|
||||
|
||||
[OffscreenCanvasRenderingContext2D interface: operation isPointInStroke(Path2D, unrestricted double, unrestricted double)]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -686,6 +710,12 @@
|
|||
[AudioTrackList interface: attribute onaddtrack]
|
||||
expected: FAIL
|
||||
|
||||
[FormDataEvent must be primary interface of new FormDataEvent("formdata", { formData: new FormData() })]
|
||||
expected: FAIL
|
||||
|
||||
[FormDataEvent interface: existence and properties of interface prototype object]
|
||||
expected: FAIL
|
||||
|
||||
[External interface object length]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -758,6 +788,9 @@
|
|||
[ElementInternals interface: attribute validationMessage]
|
||||
expected: FAIL
|
||||
|
||||
[SVGElement interface: attribute onformdata]
|
||||
expected: FAIL
|
||||
|
||||
[ApplicationCache interface: attribute onobsolete]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -812,15 +845,27 @@
|
|||
[Document interface: new Document() must inherit property "onsecuritypolicyviolation" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[Window interface: attribute onformdata]
|
||||
expected: FAIL
|
||||
|
||||
[Document interface: iframe.contentDocument must inherit property "all" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[Document interface: documentWithHandlers must inherit property "onformdata" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[Window interface: window must inherit property "parent" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[Window interface: window must inherit property "frames" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[Window interface: window must inherit property "onformdata" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[Document interface: new Document() must inherit property "onformdata" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[Document interface: new Document() must inherit property "oncancel" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -830,6 +875,9 @@
|
|||
[Document interface: attribute onsecuritypolicyviolation]
|
||||
expected: FAIL
|
||||
|
||||
[Document interface: iframe.contentDocument must inherit property "onformdata" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[Document interface: iframe.contentDocument must inherit property "defaultView" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -846,6 +894,9 @@
|
|||
[Document interface: attribute oncancel]
|
||||
expected: FAIL
|
||||
|
||||
[Document interface: attribute onformdata]
|
||||
expected: FAIL
|
||||
|
||||
[Window interface: window must inherit property "oncancel" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -998,6 +1049,9 @@
|
|||
[HTMLInputElement interface: createInput("color") must inherit property "dirName" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLElement interface: attribute onformdata]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLInputElement interface: createInput("week") must inherit property "dirName" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -1079,6 +1133,9 @@
|
|||
[HTMLTextAreaElement interface: document.createElement("textarea") must inherit property "dirName" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLElement interface: document.createElement("noscript") must inherit property "onformdata" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLFormElement interface: document.createElement("form") must inherit property "relList" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
[FormDataEvent.window.html]
|
||||
[Successful FormDataEvent constructor]
|
||||
expected: FAIL
|
||||
|
||||
[Failing FormDataEvent constructor]
|
||||
expected: FAIL
|
||||
|
|
@ -1 +0,0 @@
|
|||
prefs: [dom.formdata.event.enabled:true]
|
|
@ -0,0 +1,13 @@
|
|||
[constructing-form-data-set.html]
|
||||
[Entries added to "formData" IDL attribute should be submitted.]
|
||||
expected: FAIL
|
||||
|
||||
["formData" IDL attribute should have entries for form-associated elements in the first event handler, and the second handler can read entries set by the first handler.]
|
||||
expected: FAIL
|
||||
|
||||
["formdata" event bubbles, and is not cancelable.]
|
||||
expected: FAIL
|
||||
|
||||
["formdata" event bubbles in an orphan tree.]
|
||||
expected: FAIL
|
||||
|
|
@ -1,4 +1,10 @@
|
|||
[form-submission-algorithm.html]
|
||||
[Cannot navigate (after constructing the entry list)]
|
||||
expected: FAIL
|
||||
|
||||
[If constructing entry list flag of form is true, then return]
|
||||
expected: FAIL
|
||||
|
||||
[If form's firing submission events is true, then return; 'invalid' event]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
prefs: [dom.formdata.event.enabled:true]
|
|
@ -23,6 +23,18 @@
|
|||
[onsecuritypolicyviolation: the content attribute must execute when an event is dispatched]
|
||||
expected: FAIL
|
||||
|
||||
[onformdata: the content attribute must execute when an event is dispatched]
|
||||
expected: FAIL
|
||||
|
||||
[onformdata: the content attribute must be compiled into a function as the corresponding property]
|
||||
expected: FAIL
|
||||
|
||||
[onformdata: must be on the appropriate locations for GlobalEventHandlers]
|
||||
expected: FAIL
|
||||
|
||||
[onformdata: the default value must be null]
|
||||
expected: FAIL
|
||||
|
||||
[GlobalEventHandlers]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -71,6 +71,15 @@
|
|||
if not debug and (os == "mac"): FAIL
|
||||
if not debug and (os == "win") and (version == "6.1.7601"): FAIL
|
||||
|
||||
[not shadowed formdata (window)]
|
||||
expected: FAIL
|
||||
|
||||
[not shadowed formdata (document.body)]
|
||||
expected: FAIL
|
||||
|
||||
[not shadowed formdata (document.createElement("body"))]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLBodyElement event handlers]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -50,6 +50,15 @@
|
|||
expected:
|
||||
if not debug and not webrender and e10s and (os == "linux"): FAIL
|
||||
|
||||
[not shadowed formdata (document.body)]
|
||||
expected: FAIL
|
||||
|
||||
[not shadowed formdata (document.createElement("frameset"))]
|
||||
expected: FAIL
|
||||
|
||||
[not shadowed formdata (window)]
|
||||
expected: FAIL
|
||||
|
||||
[event handlers]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -11,6 +11,12 @@
|
|||
[securitypolicyviolation is unaffected on a windowless frameset]
|
||||
expected: FAIL
|
||||
|
||||
[formdata is unaffected on a windowless frameset]
|
||||
expected: FAIL
|
||||
|
||||
[formdata is unaffected on a windowless body]
|
||||
expected: FAIL
|
||||
|
||||
[event-handler-attributes-windowless-body]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
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]
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
[formdata.htm]
|
||||
[|new FormData()| in formdata event handler should throw]
|
||||
expected: FAIL
|
||||
|
||||
[Newly created FormData contains entries added to "formData" IDL attribute of FormDataEvent.]
|
||||
expected: FAIL
|
||||
|
|
@ -1 +0,0 @@
|
|||
prefs: [dom.formdata.event.enabled:true]
|
|
@ -130,7 +130,6 @@ 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)
|
||||
|
|
|
@ -2015,7 +2015,6 @@ STATIC_ATOMS = [
|
|||
Atom("ontimeout", "ontimeout"),
|
||||
Atom("ontimeupdate", "ontimeupdate"),
|
||||
Atom("onended", "onended"),
|
||||
Atom("onformdata", "onformdata"),
|
||||
Atom("onratechange", "onratechange"),
|
||||
Atom("ondurationchange", "ondurationchange"),
|
||||
Atom("onvolumechange", "onvolumechange"),
|
||||
|
|
Загрузка…
Ссылка в новой задаче