aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/formdata.rs
diff options
context:
space:
mode:
authorKeith Yeung <kungfukeith11@gmail.com>2017-04-09 23:30:40 -0700
committerKeith Yeung <kungfukeith11@gmail.com>2017-04-09 23:30:40 -0700
commit912ac622e7d53d8524186778cc32107a9b7a0b45 (patch)
tree66bd1232cf5f5d4de41706490dad2aa5b011bb52 /components/script/dom/formdata.rs
parentb5722e50bb5f9c0bcd0cb3fb664b2756c849ee6d (diff)
downloadservo-912ac622e7d53d8524186778cc32107a9b7a0b45.tar.gz
servo-912ac622e7d53d8524186778cc32107a9b7a0b45.zip
Follow the spec in giving blobs a 'blob' name attribute
Diffstat (limited to 'components/script/dom/formdata.rs')
-rw-r--r--components/script/dom/formdata.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/components/script/dom/formdata.rs b/components/script/dom/formdata.rs
index 6c429c54743..af4c692e7d9 100644
--- a/components/script/dom/formdata.rs
+++ b/components/script/dom/formdata.rs
@@ -7,6 +7,7 @@ use dom::bindings::codegen::Bindings::FormDataBinding::FormDataMethods;
use dom::bindings::codegen::Bindings::FormDataBinding::FormDataWrap;
use dom::bindings::codegen::UnionTypes::FileOrUSVString;
use dom::bindings::error::Fallible;
+use dom::bindings::inheritance::Castable;
use dom::bindings::iterable::Iterable;
use dom::bindings::js::Root;
use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
@@ -79,7 +80,7 @@ impl FormDataMethods for FormData {
let datum = FormDatum {
ty: DOMString::from("file"),
name: DOMString::from(name.0.clone()),
- value: FormDatumValue::File(Root::from_ref(&*self.get_file(blob, filename))),
+ value: FormDatumValue::File(Root::from_ref(&*self.create_an_entry(blob, filename))),
};
let mut data = self.data.borrow_mut();
@@ -137,7 +138,7 @@ impl FormDataMethods for FormData {
self.data.borrow_mut().insert(LocalName::from(name.0.clone()), vec![FormDatum {
ty: DOMString::from("file"),
name: DOMString::from(name.0),
- value: FormDatumValue::File(Root::from_ref(&*self.get_file(blob, filename))),
+ value: FormDatumValue::File(Root::from_ref(&*self.create_an_entry(blob, filename))),
}]);
}
@@ -145,9 +146,12 @@ impl FormDataMethods for FormData {
impl FormData {
- fn get_file(&self, blob: &Blob, opt_filename: Option<USVString>) -> Root<File> {
+ // https://xhr.spec.whatwg.org/#create-an-entry
+ // Steps 3-4.
+ fn create_an_entry(&self, blob: &Blob, opt_filename: Option<USVString>) -> Root<File> {
let name = match opt_filename {
Some(filename) => DOMString::from(filename.0),
+ None if blob.downcast::<File>().is_none() => DOMString::from("blob"),
None => DOMString::from(""),
};