Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement read methods on FileReaderSync #19511
Conversation
highfive
commented
Dec 7, 2017
|
Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @wafflespeanut (or someone else) soon. |
highfive
commented
Dec 7, 2017
|
Heads up! This PR modifies the following files:
|
highfive
commented
Dec 7, 2017
|
I tried to update the manifest with ./mach update-manifest but this changed almost every entry in the files. What is the correct way to only change the entry for the changed test (/tests/wpt/web-platform-tests/FileAPI/FileReaderSync.worker.js) ? |
|
That's the correct way to update it; what were the changes it tried to make? |
|
manifests.zip |
|
This is great! I think it should be possible to avoid duplicating some of the less straightforward parts of the implementation, though. |
|
|
||
| // step 2 | ||
| let blob_contents = blob.get_bytes().unwrap_or(vec![]); | ||
| if blob_contents.is_empty() { |
This comment has been minimized.
This comment has been minimized.
jdm
Jan 29, 2018
Member
What happens if we run a test like readerSync.readAsBinaryString(new Blob([""]));? Won't this incorrectly throw an exception?
|
|
||
| // step 2 | ||
| let blob_contents = blob.get_bytes().unwrap_or(vec![]); | ||
| if blob_contents.is_empty() { |
This comment has been minimized.
This comment has been minimized.
| let blob_type = String::from(blob.Type()); | ||
|
|
||
| //https://w3c.github.io/FileAPI/#encoding-determination | ||
| let mut encoding = blob_label.as_ref() |
This comment has been minimized.
This comment has been minimized.
|
|
||
| // step 2 | ||
| let blob_contents = blob.get_bytes().unwrap_or(vec![]); | ||
| if blob_contents.is_empty() { |
This comment has been minimized.
This comment has been minimized.
| } | ||
|
|
||
| // step 3 | ||
| let base64 = base64::encode(&blob_contents); |
This comment has been minimized.
This comment has been minimized.
|
|
||
| // step 2 | ||
| let blob_contents = blob.get_bytes().unwrap_or(vec![]); | ||
| if blob_contents.is_empty() { |
This comment has been minimized.
This comment has been minimized.
| var data = readerSync.readAsBinaryString(blob); | ||
| assert_equals(data, "test"); | ||
| }, "readAsBinaryString"); | ||
|
|
This comment has been minimized.
This comment has been minimized.
| } | ||
|
|
||
| impl FileReaderSync { | ||
| pub fn new_inherited() -> FileReaderSync { | ||
| FileReaderSync { | ||
| eventtarget: EventTarget::new_inherited(), | ||
| ready_state: Cell::new(FileReaderReadyState::Empty), |
This comment has been minimized.
This comment has been minimized.
jdm
Jan 29, 2018
Member
Since the spec doesn't actually tell us to modify the readyState for synchronous file readers, nor does it describe a way where the LOADING check could actually succeed, let's remove it from our implementation.
This comment has been minimized.
This comment has been minimized.
|
Sorry about the unnecessary delay before this code was reviewed. I promise shorter review cycles if you want to keep working on this! |
|
@jdm No worries about the delay, I'm rather short on time myself right now, so I probably wouldn't have been able to work on this any sooner anyway. That said, I do want to keep working on it! :) |
|
Now I'm the one having to apologize for taking SO long to update this... I am also still unable to properly update the manifest files for the updated tests (same issues as described in an earlier comment) |
|
Error syncing changes upstream. Logs saved in error-snapshot-1527098417542. |
|
Error syncing changes upstream. Logs saved in error-snapshot-1527103060139. |
|
Great work! For sharing code, it's a toss-up as to whether it's worth creating static methods on a type like this PR does, or using free functions. I'm not bothered either way. Please squash all the commits together, too! |
| result: &DomRefCell<Option<FileReaderResult>>, | ||
| data: ReadMetaData, | ||
| blob_bytes: &[u8], | ||
| ) { | ||
| let blob_label = &data.label; | ||
| let blob_type = &data.blobtype; | ||
|
|
||
| //https://w3c.github.io/FileAPI/#encoding-determination |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
DonatJR
May 29, 2018
Author
Contributor
Its in text_decode (link to line) as well, do you want me to remove it here anyway?
This comment has been minimized.
This comment has been minimized.
|
This is the first time I'm attempting to squash commits together, so I just wanted to be sure if I'm doing it correctly. I searched the Thanks for your patience and help :) |
|
@DonatJR What happens if you do |
|
@KiChjang
And it changes nothing about the number of commits when squashing. |
|
@DonatJR Oh sorry, I meant |
|
With
But again, no changes to before when squashing. |
|
It's probably easiest to make a new branch based off of master and cherry-pick all of the non-merge commits like:
Then you can do |
371c770
to
21bf9c3
…nc, r=jdm Implement read methods on FileReaderSync <!-- Please describe your changes on the following line: --> Implemented the read methods on the FileReaderSync struct according to https://w3c.github.io/FileAPI/#dfn-FileReaderSync --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #15114 <!-- Either: --> - [x] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19511) <!-- Reviewable:end -->
|
|
|
|
Oh, right. Yeah, that's super weird, and I don't have any good suggestions. I'll make the change locally and update the PR. |
21bf9c3
to
0fdafb0
|
@bors-servo r+ |
|
|
|
Transplanted upstreamable changes to existing PR. Completed upstream sync of web-platform-test changes at jdm/web-platform-tests#65. |
…nc, r=jdm Implement read methods on FileReaderSync <!-- Please describe your changes on the following line: --> Implemented the read methods on the FileReaderSync struct according to https://w3c.github.io/FileAPI/#dfn-FileReaderSync --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #15114 <!-- Either: --> - [x] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19511) <!-- Reviewable:end -->
|
|
|
@bors-servo retry |
|
|
|
|
Upstreamed from servo/servo#19511 [ci skip]
DonatJR commentedDec 7, 2017
•
edited by jdm
Implemented the read methods on the FileReaderSync struct according to https://w3c.github.io/FileAPI/#dfn-FileReaderSync
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is