Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patches of File API #12544

Merged
merged 1 commit into from Jul 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions components/script/dom/blob.rs
Expand Up @@ -20,6 +20,7 @@ use net_traits::filemanager_thread::{FileManagerThreadMsg, SelectedFileId, Relat
use std::cell::Cell;
use std::ops::Index;
use std::path::PathBuf;
use uuid::Uuid;

/// File-based blob
#[derive(JSTraceable)]
Expand Down Expand Up @@ -183,7 +184,7 @@ impl Blob {

match rx.recv().unwrap() {
Ok(_) => f.id.clone(),
Err(_) => SelectedFileId("".to_string()) // Return a dummy id on error
Err(_) => SelectedFileId(Uuid::new_v4().simple().to_string()) // Return a dummy id on error
}
}
BlobImpl::Memory(ref slice) => {
Expand All @@ -194,7 +195,7 @@ impl Blob {
BlobImpl::Sliced(_, _) => {
debug!("Sliced can't have a sliced parent");
// Return dummy id
SelectedFileId("".to_string())
SelectedFileId(Uuid::new_v4().simple().to_string())
}
BlobImpl::File(ref f) =>
self.create_sliced_url_id(&f.id, rel_pos),
Expand Down Expand Up @@ -230,7 +231,7 @@ impl Blob {
match rx.recv().unwrap() {
Ok(new_id) => SelectedFileId(new_id.0),
// Dummy id
Err(_) => SelectedFileId("".to_string()),
Err(_) => SelectedFileId(Uuid::new_v4().simple().to_string()),
}
}

Expand Down
5 changes: 4 additions & 1 deletion components/script/dom/file.rs
Expand Up @@ -73,7 +73,10 @@ impl File {
let ref typeString = blobPropertyBag.type_;

let modified = filePropertyBag.lastModified;
Ok(File::new(global, BlobImpl::new_from_bytes(bytes), filename, modified, typeString))
// NOTE: Following behaviour might be removed in future,
// see https://github.com/w3c/FileAPI/issues/41
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Manishearth added

let replaced_filename = DOMString::from_string(filename.replace("/", ":"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Link to the spec bug here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by "spec bug"? Regarding link, this tiny replace operation is specified in the url above this function pub fn Constructor (which I unfortunately neglected at first)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sorry, I was talking about w3c/FileAPI#41 (the bug that wishes to remove this behavior)

Ok(File::new(global, BlobImpl::new_from_bytes(bytes), replaced_filename, modified, typeString))
}

pub fn name(&self) -> &DOMString {
Expand Down
5 changes: 0 additions & 5 deletions tests/wpt/metadata/FileAPI/file/File-constructor.html.ini
Expand Up @@ -11,8 +11,3 @@
[Various fileBits]
expected: FAIL
bug: https://github.com/servo/servo/issues/10911

[Using special character in fileName]
expected: FAIL
bug: https://github.com/w3c/FileAPI/issues/41