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

Clean up XHR API #9383

Merged
merged 1 commit into from Feb 18, 2016
Merged

Clean up XHR API #9383

merged 1 commit into from Feb 18, 2016

Conversation

@KiChjang
Copy link
Member

KiChjang commented Jan 20, 2016

I've also added annotations about the steps that we're performing within each method.

Review on Reviewable

@highfive
Copy link

highfive commented Jan 20, 2016

warning Warning warning

  • These commits modify script code, but no tests are modified. Please consider adding a test!
@KiChjang KiChjang force-pushed the KiChjang:xhr-cleanup branch from 0470ffe to 83f5d06 Jan 20, 2016
}
},
// Step 1

This comment has been minimized.

Copy link
@frewsxcv

frewsxcv Jan 20, 2016

Member

Move this above since it is step 1

This comment has been minimized.

Copy link
@frewsxcv

frewsxcv Jan 20, 2016

Member

Nevermind, not trivial since it's matching on _

@KiChjang KiChjang force-pushed the KiChjang:xhr-cleanup branch 3 times, most recently from c1c49dc to 5932923 Jan 20, 2016
@Ms2ger
Copy link
Contributor

Ms2ger commented Jan 20, 2016

How about a sync_allowed method that checks the global and the sync flag?

@KiChjang KiChjang force-pushed the KiChjang:xhr-cleanup branch from 5932923 to a3fb02e Jan 20, 2016
@@ -295,6 +295,9 @@ impl XMLHttpRequestMethods for XMLHttpRequest {

// https://xhr.spec.whatwg.org/#the-open()-method
fn Open(&self, method: ByteString, url: USVString) -> ErrorResult {
// Step 1
if !self.global().r().as_window().Document().r().is_fully_active() { return Err(Error::InvalidState); }

This comment has been minimized.

Copy link
@jdm

jdm Jan 20, 2016

Member

This will cause a panic when calling this method in a worker.

This comment has been minimized.

Copy link
@KiChjang

KiChjang Jan 20, 2016

Author Member

If settings object's responsible document is not fully active, throw an InvalidStateError exception.

Hmm... how would we get a responsible document from a Worker, in that case?

This comment has been minimized.

Copy link
@jdm

jdm Jan 20, 2016

Member

That concept is not implemented yet. We also will not be able to interact with the Document on the worker thread; we would need to block on a runnable sent to the document's associated script thread.

@KiChjang KiChjang force-pushed the KiChjang:xhr-cleanup branch 3 times, most recently from aacaf70 to 1771bb4 Jan 20, 2016
@KiChjang
Copy link
Member Author

KiChjang commented Jan 20, 2016

@Ms2ger Done.

@KiChjang
Copy link
Member Author

KiChjang commented Jan 27, 2016

r? @Ms2ger

@Ms2ger
Copy link
Contributor

Ms2ger commented Feb 1, 2016

Looking at this again, sync_allowed doesn't really make sense as a method name. Maybe sync_in_window? Feels like we should be able to do better.

@KiChjang KiChjang force-pushed the KiChjang:xhr-cleanup branch from 1771bb4 to 7c5295e Feb 1, 2016
@KiChjang
Copy link
Member Author

KiChjang commented Feb 1, 2016

Done that as well.

@Ms2ger
Copy link
Contributor

Ms2ger commented Feb 4, 2016

You made me read through most of the XHR spec, so now you get to file issues for all the bugs I found :)

-S-awaiting-review +S-needs-code-changes


Reviewed 1 of 1 files at r3.
Review status: all files reviewed at latest revision, 17 unresolved discussions.


components/script/dom/xmlhttprequest.rs, line 197 [r3] (raw file):
Now the value you're returning is backwards :)


components/script/dom/xmlhttprequest.rs, line 308 [r3] (raw file):
Not entirely sure this is useful, since it boils down to browsing_context.active_document() == browsing_context.active_document() right now.


components/script/dom/xmlhttprequest.rs, line 310 [r3] (raw file):
This issue has been fixed; remove the reference.


components/script/dom/xmlhttprequest.rs, line 329 [r3] (raw file):
This is no longer step 2.


components/script/dom/xmlhttprequest.rs, line 347 [r3] (raw file):
Please file an issue and point to it here.


components/script/dom/xmlhttprequest.rs, line 388 [r3] (raw file):
We don't seem to do step 3; please file an issue and add a comment here.


components/script/dom/xmlhttprequest.rs, line 416 [r3] (raw file):
What step is this? Is it reachable? If so, do we have tests that reach it?


components/script/dom/xmlhttprequest.rs, line 436 [r3] (raw file):
Pointless to_vec call; file a followup (needs an API on ByteString ).


components/script/dom/xmlhttprequest.rs, line 448 [r3] (raw file):
This fix should cause a test to pass; if not, write one.

Also, wrap into three lines.


components/script/dom/xmlhttprequest.rs, line 451 [r3] (raw file):
Add a pointer to the bit of the spec where this is handled.


components/script/dom/xmlhttprequest.rs, line 483 [r3] (raw file):
Split into two separate match arms for symmetry.


components/script/dom/xmlhttprequest.rs, line 523 [r3] (raw file):
So we didn't do this in the sync case before; check if there's a way to test that.


components/script/dom/xmlhttprequest.rs, line 698 [r3] (raw file):
This seems to ignore "excluding any parameters, and converted to ASCII lowercase." Followup.


components/script/dom/xmlhttprequest.rs, line 702 [r3] (raw file):
Weird indentation.


components/script/dom/xmlhttprequest.rs, line 724 [r3] (raw file):
We need to not do this in workers; followup.

Also not sure of the point of doing this in the match rather than with a plain if below the match.


components/script/dom/xmlhttprequest.rs, line 755 [r3] (raw file):
Followup to move this into a function of its own.


Comments from the review on Reviewable.io

@KiChjang KiChjang force-pushed the KiChjang:xhr-cleanup branch from 7c5295e to 6f40abd Feb 5, 2016
@KiChjang KiChjang force-pushed the KiChjang:xhr-cleanup branch from 6f40abd to ccc43e2 Feb 5, 2016
@KiChjang
Copy link
Member Author

KiChjang commented Feb 5, 2016

Review status: 0 of 1 files reviewed at latest revision, 17 unresolved discussions.


components/script/dom/xmlhttprequest.rs, line 308 [r3] (raw file):
This sounds more like a follow-up issue to fix the Document method. I'd say that we should still keep it here since the spec says so.


components/script/dom/xmlhttprequest.rs, line 416 [r3] (raw file):
This should actually be marked unreachable!(). The .as_str() method returns Some(&str) if the ByteString is encoded using UTF-8, and None otherwise.


components/script/dom/xmlhttprequest.rs, line 436 [r3] (raw file):
http://hyper.rs/hyper/hyper/header/struct.Headers.html#method.set_raw seems to accept a Vec<Vec<u8>>.


components/script/dom/xmlhttprequest.rs, line 451 [r3] (raw file):
I don't actually know which part of the spec this algorithm refers to.


components/script/dom/xmlhttprequest.rs, line 755 [r3] (raw file):
Yeah... all of the Response Document/JSON/ArrayBuffer/Blob methods need to be implemented.


Comments from the review on Reviewable.io

@KiChjang
Copy link
Member Author

KiChjang commented Feb 5, 2016

Review status: 0 of 1 files reviewed at latest revision, 17 unresolved discussions.


components/script/dom/xmlhttprequest.rs, line 523 [r3] (raw file):
This can be tested on a few places - calling the Send method again for example, or SetRequestHeader, SetWithCredentials and Abort.


Comments from the review on Reviewable.io

@bors-servo
Copy link
Contributor

bors-servo commented Feb 7, 2016

The latest upstream changes (presumably #9562) made this pull request unmergeable. Please resolve the merge conflicts.

@bors-servo
Copy link
Contributor

bors-servo commented Feb 18, 2016

Testing commit 066c5ea with merge 01bc4e6...

bors-servo added a commit that referenced this pull request Feb 18, 2016
Clean up XHR API

I've also added annotations about the steps that we're performing within each method.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9383)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Feb 18, 2016

💔 Test failed - linux-rel

@jdm
Copy link
Member

jdm commented Feb 18, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Feb 18, 2016

Previous build results for android, gonk, linux-dev, mac-dev-unit, mac-rel-css, mac-rel-wpt are reusable. Rebuilding only linux-rel...

@bors-servo
Copy link
Contributor

bors-servo commented Feb 18, 2016

💔 Test failed - linux-rel

@KiChjang
Copy link
Member Author

KiChjang commented Feb 18, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Feb 18, 2016

Testing commit 066c5ea with merge 911e9ca...

bors-servo added a commit that referenced this pull request Feb 18, 2016
Clean up XHR API

I've also added annotations about the steps that we're performing within each method.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9383)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Feb 18, 2016

💔 Test failed - mac-rel-wpt

@KiChjang
Copy link
Member Author

KiChjang commented Feb 18, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Feb 18, 2016

Testing commit 066c5ea with merge 96d1853...

bors-servo added a commit that referenced this pull request Feb 18, 2016
Clean up XHR API

I've also added annotations about the steps that we're performing within each method.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9383)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Feb 18, 2016

@bors-servo bors-servo merged commit 066c5ea into servo:master Feb 18, 2016
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@KiChjang KiChjang deleted the KiChjang:xhr-cleanup branch Oct 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

7 participants
You can’t perform that action at this time.