Skip to content

Commit

Permalink
Follow the spec in giving blobs a 'blob' name attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
KiChjang committed Apr 10, 2017
1 parent b5722e5 commit 912ac62
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
10 changes: 7 additions & 3 deletions components/script/dom/formdata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -137,17 +138,20 @@ 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))),
}]);
}

}


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(""),
};

Expand Down
5 changes: 0 additions & 5 deletions tests/wpt/metadata/XMLHttpRequest/formdata-blob.htm.ini

This file was deleted.

0 comments on commit 912ac62

Please sign in to comment.