зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1187157
- new FormData::get() should return an empty string if the file is not set - part 1, r=smaug
This commit is contained in:
Родитель
fe16183e75
Коммит
c1e3e74d6e
|
@ -256,6 +256,30 @@ nsFormData::GetValueAtIndex(uint32_t aIndex) const
|
|||
return mFormData[aIndex].value;
|
||||
}
|
||||
|
||||
void
|
||||
nsFormData::SetNameValuePair(FormDataTuple* aData,
|
||||
const nsAString& aName,
|
||||
const nsAString& aValue)
|
||||
{
|
||||
MOZ_ASSERT(aData);
|
||||
aData->name = aName;
|
||||
aData->value.SetAsUSVString() = aValue;
|
||||
}
|
||||
|
||||
void
|
||||
nsFormData::SetNameFilePair(FormDataTuple* aData,
|
||||
const nsAString& aName,
|
||||
File* aFile)
|
||||
{
|
||||
MOZ_ASSERT(aData);
|
||||
aData->name = aName;
|
||||
if (aFile) {
|
||||
aData->value.SetAsFile() = aFile;
|
||||
} else {
|
||||
aData->value.SetAsUSVString() = EmptyString();
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// nsIDOMFormData
|
||||
|
||||
|
|
|
@ -52,23 +52,11 @@ private:
|
|||
|
||||
void SetNameValuePair(FormDataTuple* aData,
|
||||
const nsAString& aName,
|
||||
const nsAString& aValue)
|
||||
{
|
||||
MOZ_ASSERT(aData);
|
||||
aData->name = aName;
|
||||
aData->value.SetAsUSVString() = aValue;
|
||||
}
|
||||
const nsAString& aValue);
|
||||
|
||||
void SetNameFilePair(FormDataTuple* aData,
|
||||
const nsAString& aName,
|
||||
File* aFile)
|
||||
{
|
||||
MOZ_ASSERT(aData);
|
||||
aData->name = aName;
|
||||
if (aFile) {
|
||||
aData->value.SetAsFile() = aFile;
|
||||
}
|
||||
}
|
||||
File* aFile);
|
||||
|
||||
public:
|
||||
explicit nsFormData(nsISupports* aOwner = nullptr);
|
||||
|
|
|
@ -862,3 +862,4 @@ skip-if = buildapp == 'b2g' #no ssl support
|
|||
[test_document.all_iteration.html]
|
||||
[test_performance_translate.html]
|
||||
[test_bug1198095.html]
|
||||
[test_bug1187157.html]
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=789315
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 789315</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=789315">Mozilla Bug 789315</a>
|
||||
<form id="a"><input name="b" type="file"/></form>
|
||||
|
||||
<script type="text/javascript">
|
||||
is(new FormData(document.getElementById('a')).get('b'), "", "This should return an empty string.");
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -5596,7 +5596,6 @@ HTMLInputElement::SubmitNamesValues(nsFormSubmission* aFormSubmission)
|
|||
// If no file was selected, pretend we had an empty file with an
|
||||
// empty filename.
|
||||
aFormSubmission->AddNameFilePair(name, nullptr);
|
||||
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
|
Загрузка…
Ссылка в новой задаче