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

Store Memory Blob for script thread with more File information #22744

Open
CYBAI opened this issue Jan 22, 2019 · 0 comments
Open

Store Memory Blob for script thread with more File information #22744

CYBAI opened this issue Jan 22, 2019 · 0 comments
Labels
A-content/dom Interacting with the DOM from web content

Comments

@CYBAI
Copy link
Member

CYBAI commented Jan 22, 2019

As I mentioned in #22736 (comment), after implementing FormData in Vec<(LocalName, FormDatum)> in #22736, we only passed the keys test case. We cannot pass these test cases which has values comparison with File because we don't have the same lastModified and filename between BlobImpl::Memory and the File object constructed by File constructor.

In Gecko and Blink, both of them have a ToFile function for Blob

In Servo, we have a similar thing which is the BlobImpl::Memory; however, we only save the bytes for script thread.

/// Memory-based blob, whose content lives in the script process
Memory(Vec<u8>),

So, to have more information for Blob in script thread, it's better to save more necessary fields like what FileBlob did.

We should have a new struct like MemoryBlob to save filename and last_modified timestamp (and more fields if needed). With this implementation, we should be able to pass the values related tests in xhr/formdata-foreach.html

Ex.

#[derive(JSTraceable)]
pub struct MemoryBlob {
    name: Option<DOMString>,
    cache: Vec<u8>,
    last_modified: Option<i64>,
}

#[derive(JSTraceable)]
pub enum BlobImpl {
    ...
    Memory(MemoryBlob),
    ...
}

impl BlobImpl {
    /// Construct memory-backed BlobImpl
    #[allow(unrooted_must_root)]
    pub fn new_from_bytes(name: DOMString, bytes: Vec<u8>, last_modified: i64) -> BlobImpl {
        BlobImpl::Memory(MemoryBlob {
            name,
            cache: bytes,
            last_modified
        })
    }
}
@CYBAI CYBAI added the A-content/dom Interacting with the DOM from web content label Jan 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-content/dom Interacting with the DOM from web content
Projects
None yet
Development

No branches or pull requests

1 participant