Skip to content

Implement read methods on FileReaderSync - #19511

Merged
bors-servo merged 1 commit into
servo:masterfrom
DonatJR:implement-read-methods-on-filereadersync
Jun 4, 2018
Merged

bors-servo merged 1 commit into
servo:masterfrom
DonatJR:implement-read-methods-on-filereadersync

Conversation

@DonatJR

@DonatJR DonatJR commented Dec 7, 2017 •

Copy link
Copy Markdown
Contributor

Implemented the read methods on the FileReaderSync struct according to https://w3c.github.io/FileAPI/#dfn-FileReaderSync


  • There are tests for these changes

This change is Reviewable

@highfive highfive assigned ghost Dec 7, 2017
@highfive

highfive commented Dec 7, 2017

Copy link
Copy Markdown

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

highfive commented Dec 7, 2017

Copy link
Copy Markdown

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/dom/filereadersync.rs, components/script/dom/webidls/FileReaderSync.webidl, components/script/dom/bindings/error.rs, components/script/dom/webidls/DOMException.webidl, components/script/dom/domexception.rs
  • @fitzgen: components/script/dom/filereadersync.rs, components/script/dom/webidls/FileReaderSync.webidl, components/script/dom/bindings/error.rs, components/script/dom/webidls/DOMException.webidl, components/script/dom/domexception.rs
  • @KiChjang: components/script/dom/filereadersync.rs, components/script/dom/webidls/FileReaderSync.webidl, components/script/dom/bindings/error.rs, components/script/dom/webidls/DOMException.webidl, components/script/dom/domexception.rs

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Dec 7, 2017
@highfive

highfive commented Dec 7, 2017

Copy link
Copy Markdown

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!

@DonatJR

DonatJR commented Dec 7, 2017

Copy link
Copy Markdown
Contributor Author

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) ?

@jdm

jdm commented Dec 8, 2017

Copy link
Copy Markdown
Member

That's the correct way to update it; what were the changes it tried to make?

@DonatJR

DonatJR commented Dec 8, 2017

Copy link
Copy Markdown
Contributor Author

manifests.zip
For tests/wpt/metadata/MANIFEST.json there are a few timeout changes in the WebCryptoAPI tests and a lot of changed hashes for the tests themselves.
For tests/wpt/mozilla/meta/MANIFEST.json there are only changes to the test hashes.
I atteched all 4 files so you can have a look at them (they also have different line endings - probably because I'm on Windows).

@jdm jdm assigned jdm and unassigned ghost Jan 29, 2018

@jdm jdm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is great! I think it should be possible to avoid duplicating some of the less straightforward parts of the implementation, though.

Comment thread components/script/dom/filereadersync.rs Outdated

// step 2
let blob_contents = blob.get_bytes().unwrap_or(vec![]);
if blob_contents.is_empty() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What happens if we run a test like readerSync.readAsBinaryString(new Blob([""]));? Won't this incorrectly throw an exception?

Comment thread components/script/dom/filereadersync.rs Outdated

// step 2
let blob_contents = blob.get_bytes().unwrap_or(vec![]);
if blob_contents.is_empty() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same question as readAsBinaryString.

Comment thread components/script/dom/filereadersync.rs Outdated
let blob_type = String::from(blob.Type());

//https://w3c.github.io/FileAPI/#encoding-determination
let mut encoding = blob_label.as_ref()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could we share this code with filereader.rs instead of duplicating it?

Comment thread components/script/dom/filereadersync.rs Outdated

// step 2
let blob_contents = blob.get_bytes().unwrap_or(vec![]);
if blob_contents.is_empty() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same question as other methods.

Comment thread components/script/dom/filereadersync.rs Outdated
}

// step 3
let base64 = base64::encode(&blob_contents);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's share this code with filereader.rs.

Comment thread components/script/dom/filereadersync.rs Outdated

// step 2
let blob_contents = blob.get_bytes().unwrap_or(vec![]);
if blob_contents.is_empty() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same question as other methods.

var data = readerSync.readAsBinaryString(blob);
assert_equals(data, "test");
}, "readAsBinaryString");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's add tests with empty blobs in this file as well.

Comment thread components/script/dom/filereadersync.rs Outdated
pub fn new_inherited() -> FileReaderSync {
FileReaderSync {
eventtarget: EventTarget::new_inherited(),
ready_state: Cell::new(FileReaderReadyState::Empty),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've filed w3c/FileAPI#96 against the spec.

@jdm jdm added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Jan 29, 2018
@jdm

jdm commented Jan 29, 2018

Copy link
Copy Markdown
Member

Sorry about the unnecessary delay before this code was reviewed. I promise shorter review cycles if you want to keep working on this!

@DonatJR

DonatJR commented Jan 30, 2018

Copy link
Copy Markdown
Contributor Author

@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! :)

@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels May 23, 2018
@DonatJR

DonatJR commented May 23, 2018

Copy link
Copy Markdown
Contributor Author

Now I'm the one having to apologize for taking SO long to update this...
I adressed your comments but I'm not completely happy with my solution for sharing the code between FileReader and FileReaderSync - if you have any suggestions on how to improve it I'd be happy to make the necessary changes.

I am also still unable to properly update the manifest files for the updated tests (same issues as described in an earlier comment)

@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

Error syncing changes upstream. Logs saved in error-snapshot-1527098417542.

@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

Error syncing changes upstream. Logs saved in error-snapshot-1527103060139.

@jdm jdm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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!

Comment thread components/script/dom/filereader.rs Outdated
let blob_label = &data.label;
let blob_type = &data.blobtype;

//https://w3c.github.io/FileAPI/#encoding-determination

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This comment should be moved into the text_decode function.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Its in text_decode (link to line) as well, do you want me to remove it here anyway?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah, my mistake. You can just remove it from this location, in that case.

@jdm jdm added S-needs-squash Some (or all) of the commits in the PR should be combined. and removed S-awaiting-review There is new code that needs to be reviewed. labels May 29, 2018
@DonatJR

DonatJR commented Jun 3, 2018

Copy link
Copy Markdown
Contributor Author

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 log for the commit hash that came right before my first change, ran git rebase -i <hash> and replaced pick with squash for all commits except the first. So far this seems to be easy enough, but because of the fact that I merged the master branch back into this one to resolve conflicts the rebase is now also processing these merged commits. Is this correct or should I have only picked my commits from this PR in the list at the beginning of the rebase?

Thanks for your patience and help :)

@KiChjang

KiChjang commented Jun 3, 2018

Copy link
Copy Markdown
Contributor

@DonatJR What happens if you do git rebase origin master first before you squash?

@DonatJR

DonatJR commented Jun 3, 2018

Copy link
Copy Markdown
Contributor Author

@KiChjang git rebase origin master says that master is already up to date:

Current branch master is up to date.

And it changes nothing about the number of commits when squashing.

@KiChjang

KiChjang commented Jun 3, 2018

Copy link
Copy Markdown
Contributor

@DonatJR Oh sorry, I meant git rebase origin/master.

@DonatJR

DonatJR commented Jun 3, 2018

Copy link
Copy Markdown
Contributor Author

With git rebase origin/master my commits from this PR are getting rebased:

First, rewinding head to replay your work on top of it...
Applying: implemented readAsText, readAsBinaryString and readAsDataUrl on FileReaderSync
...

But again, no changes to before when squashing.

@jdm

jdm commented Jun 4, 2018

Copy link
Copy Markdown
Member

It's probably easiest to make a new branch based off of master and cherry-pick all of the non-merge commits like:

git cherry-pick b290a5b
git cherry-pick a343a77
git cherry-pick 90db19a
git cherry-pick e2abae0
git cherry-pick 7b7b3d1
git cherry-pick 5550449
git cherry-pick d0a5e2b
git cherry-pick 00700fa
git cherry-pick a0748c3
git cherry-pick 8ffa7a4
git cherry-pick 371c770

Then you can do git push [fork] [newbranchname]:implement-read-methods-on-filereadersync -f to overwrite the changes in this PR, where [fork] is the remote pointing at your github fork, and [newbranchname] is the name of the new branch you created locally.

@DonatJR
DonatJR force-pushed the implement-read-methods-on-filereadersync branch from 371c770 to 21bf9c3 Compare June 4, 2018 18:39
@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-needs-squash Some (or all) of the commits in the PR should be combined. labels Jun 4, 2018
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 21bf9c3 with merge 49b2367...

bors-servo pushed a commit that referenced this pull request Jun 4, 2018
…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

Copy link
Copy Markdown
Contributor

💔 Test failed - android

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Jun 4, 2018
@jdm

jdm commented Jun 4, 2018

Copy link
Copy Markdown
Member
 0:24.76 INFO Diffing old and new manifests /Users/servo/buildbot/slave/mac-dev-unit/build/tests/wpt/mozilla/meta/MANIFEST.json
 0:25.38 INFO Diffing old and new manifests /Users/servo/buildbot/slave/mac-dev-unit/build/tests/wpt/metadata/MANIFEST.json
 0:29.87 WARNING Manifest /Users/servo/buildbot/slave/mac-dev-unit/build/tests/wpt/metadata/MANIFEST.json contains correct tests but file hashes changed.
 0:29.95 ERROR Manifest /Users/servo/buildbot/slave/mac-dev-unit/build/tests/wpt/metadata/MANIFEST.json is outdated, use |./mach update-manifest| to fix.

@DonatJR

DonatJR commented Jun 4, 2018 •

Copy link
Copy Markdown
Contributor Author

This is because of the issues I talked about earlier in the PR (here, here and here). I am not sure how to correctly generate the manifests, ./mach update-manifest changes a lot of hashes (among some other changes) for tests I never touched. :(

@jdm

jdm commented Jun 4, 2018

Copy link
Copy Markdown
Member

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.

@jdm
jdm force-pushed the implement-read-methods-on-filereadersync branch from 21bf9c3 to 0fdafb0 Compare June 4, 2018 19:53
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-tests-failed The changes caused existing tests to fail. labels Jun 4, 2018
@jdm

jdm commented Jun 4, 2018

Copy link
Copy Markdown
Member

@bors-servo r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 0fdafb0 has been approved by jdm

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Jun 4, 2018
@servo-wpt-sync

Copy link
Copy Markdown
Collaborator

Transplanted upstreamable changes to existing PR.

Completed upstream sync of web-platform-test changes at jdm/web-platform-tests#65.

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 0fdafb0 with merge 652a177...

bors-servo pushed a commit that referenced this pull request Jun 4, 2018
…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

Copy link
Copy Markdown
Contributor

💔 Test failed - mac-rel-css2

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Jun 4, 2018
@jdm

jdm commented Jun 4, 2018

Copy link
Copy Markdown
Member

@bors-servo retry
#20917

@bors-servo

Copy link
Copy Markdown
Contributor

⚡ Previous build results for android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev are reusable. Rebuilding only mac-rel-css2...

@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev
Approved by: jdm
Pushing 652a177 to master...

@bors-servo
bors-servo merged commit 0fdafb0 into servo:master Jun 4, 2018
jdm pushed a commit to web-platform-tests/wpt that referenced this pull request Jun 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-tests-failed The changes caused existing tests to fail.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement read methods on FileReaderSync

6 participants