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

Make step 3 of XHR's SetResponseType method match the specification #9562

Merged
merged 1 commit into from Feb 7, 2016

Conversation

@timvandermeij
Copy link
Contributor

timvandermeij commented Feb 5, 2016

Fixes #9552.

Review on Reviewable

@highfive
Copy link

highfive commented Feb 5, 2016

warning Warning warning

  • These commits modify script code, but no tests are modified. Please consider adding a test!
@KiChjang
Copy link
Member

KiChjang commented Feb 5, 2016

@bors-servo r+

Looks good enough to me. Thanks for taking up the issue!

@bors-servo
Copy link
Contributor

bors-servo commented Feb 5, 2016

📌 Commit 6343e64 has been approved by KiChjang

@KiChjang KiChjang self-assigned this Feb 5, 2016
@bors-servo
Copy link
Contributor

bors-servo commented Feb 5, 2016

Testing commit 6343e64 with merge f4214cd...

bors-servo added a commit that referenced this pull request Feb 5, 2016
Make step 3 of XHR's SetResponseType method match the specification

Fixes #9552.

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

bors-servo commented Feb 6, 2016

💔 Test failed - linux-rel

@KiChjang
Copy link
Member

KiChjang commented Feb 6, 2016

This code actually threw errors on the WPT tests:

Tests with unexpected results:
  ▶ Unexpected subtest result in /XMLHttpRequest/responsetype.html:
  │ FAIL [expected PASS] Set responseType to "" when readyState is DONE and the sync flag is set.
  │   → assert_throws: function "function () {
      xhr.responseType = type;
    }" threw object "InvalidAccessError: The object does not support the opera..." that is not a DOMException InvalidStateError: property "code" is equal to 15, expected 11
  │ FAIL [expected PASS] Set responseType to "json" when readyState is DONE and the sync flag is set.
  │   → assert_throws: function "function () {
      xhr.responseType = type;
    }" threw object "InvalidAccessError: The object does not support the opera..." that is not a DOMException InvalidStateError: property "code" is equal to 15, expected 11
  │ FAIL [expected PASS] Set responseType to "document" when readyState is DONE and the sync flag is set.
  │   → assert_throws: function "function () {
      xhr.responseType = type;
    }" threw object "InvalidAccessError: The object does not support the opera..." that is not a DOMException InvalidStateError: property "code" is equal to 15, expected 11
  │ FAIL [expected PASS] Set responseType to "arraybuffer" when readyState is DONE and the sync flag is set.
  │   → assert_throws: function "function () {
      xhr.responseType = type;
    }" threw object "InvalidAccessError: The object does not support the opera..." that is not a DOMException InvalidStateError: property "code" is equal to 15, expected 11
  │ FAIL [expected PASS] Set responseType to "blob" when readyState is DONE and the sync flag is set.
  │   → assert_throws: function "function () {
      xhr.responseType = type;
    }" threw object "InvalidAccessError: The object does not support the opera..." that is not a DOMException InvalidStateError: property "code" is equal to 15, expected 11
  │ FAIL [expected PASS] Set responseType to "text" when readyState is DONE and the sync flag is set.
  │   → assert_throws: function "function () {
      xhr.responseType = type;
    }" threw object "InvalidAccessError: The object does not support the opera..." that is not a DOMException InvalidStateError: property "code" is equal to 15, expected 11
  │ 
  │ @http://web-platform.test:8000/XMLHttpRequest/responsetype.html:80:5
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1381:20
  │ test@http://web-platform.test:8000/resources/testharness.js:495:9
  │ @http://web-platform.test:8000/XMLHttpRequest/responsetype.html:75:1
  └ @http://web-platform.test:8000/XMLHttpRequest/responsetype.html:7:1
@@ -676,12 +676,12 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
fn SetResponseType(&self, response_type: XMLHttpRequestResponseType) -> ErrorResult {
match self.global() {
GlobalRoot::Worker(_) if response_type == XMLHttpRequestResponseType::Document
=> return Ok(()),
=> return Ok(()),
GlobalRoot::Window(_) if self.sync.get() => return Err(Error::InvalidAccess),

This comment has been minimized.

Copy link
@KiChjang

KiChjang Feb 6, 2016

Member

I suspect that the test failures are due to the re-ordering of steps. The match-arm for GlobalRoot::Worker(_) above is Step 1, whereas the match-arm for GlobalRoot::Window(_) if self.sync.get() is Step 3, and down there the match for self.ready_state.get() is Step 2.

@timvandermeij
Copy link
Contributor Author

timvandermeij commented Feb 6, 2016

Aw, I had hoped that that would work. I have pushed an updated patch that executes the steps in the exact order as provided by the specification. Could you check this again and re-trigger the tests?

_ => {}
}
match self.global() {
GlobalRoot::Window(_) if self.sync.get() => Err(Error::InvalidAccess),

This comment has been minimized.

Copy link
@KiChjang

KiChjang Feb 6, 2016

Member

if let (GlobalRoot::Window(_), true) = (self.global(), self.sync.get()) { ... } else { ... }

This comment has been minimized.

Copy link
@timvandermeij

timvandermeij Feb 6, 2016

Author Contributor

Done in the new commit.

XMLHttpRequestState::Loading | XMLHttpRequestState::Done => Err(Error::InvalidState),
_ if self.sync.get() => Err(Error::InvalidAccess),
XMLHttpRequestState::Loading | XMLHttpRequestState::Done => return Err(Error::InvalidState),
_ => {}

This comment has been minimized.

Copy link
@KiChjang

KiChjang Feb 6, 2016

Member

The next check can be done here, so that we don't need an explicit return keyword.

This comment has been minimized.

Copy link
@timvandermeij

timvandermeij Feb 6, 2016

Author Contributor

Done in the new commit.

@KiChjang
Copy link
Member

KiChjang commented Feb 6, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Feb 6, 2016

Trying commit 40980e0 with merge a6fb768...

bors-servo added a commit that referenced this pull request Feb 6, 2016
Make step 3 of XHR's SetResponseType method match the specification

Fixes #9552.

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

KiChjang commented Feb 6, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Feb 6, 2016

📌 Commit 816c65a has been approved by KiChjang

@bors-servo
Copy link
Contributor

bors-servo commented Feb 6, 2016

Testing commit 816c65a with merge 2f52a16...

bors-servo added a commit that referenced this pull request Feb 6, 2016
Make step 3 of XHR's SetResponseType method match the specification

Fixes #9552.

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

bors-servo commented Feb 6, 2016

💔 Test failed - mac-rel-wpt

@wafflespeanut
Copy link
Member

wafflespeanut commented Feb 6, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Feb 6, 2016

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

@bors-servo
Copy link
Contributor

bors-servo commented Feb 6, 2016

💔 Test failed - mac-rel-css

@wafflespeanut
Copy link
Member

wafflespeanut commented Feb 6, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Feb 6, 2016

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

@bors-servo
Copy link
Contributor

bors-servo commented Feb 7, 2016

@bors-servo bors-servo merged commit 816c65a into servo:master Feb 7, 2016
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@bors-servo bors-servo mentioned this pull request Feb 7, 2016
@timvandermeij timvandermeij deleted the timvandermeij:setresponsetype-spec branch Feb 7, 2016
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

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