Skip to content

Commit

Permalink
Auto merge of #25610 - pshaughn:abortfix, r=Manishearth
Browse files Browse the repository at this point in the history
do less on abort if not done

Abort() was resetting state when it didn't need to, and possibly also not resetting as much of it as it needed to. I'm not sure if this is a completely correct fix but it passes some WPT tests.

---
<!-- 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 #24931

<!-- Either: -->
- [X] There are tests for these change

<!-- 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. -->
  • Loading branch information
bors-servo committed Jan 27, 2020
2 parents da31405 + 52d8336 commit d0f64d9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 29 deletions.
23 changes: 15 additions & 8 deletions components/script/dom/xmlhttprequest.rs
Expand Up @@ -758,7 +758,12 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
}
}
// Step 3
self.ready_state.set(XMLHttpRequestState::Unsent);
if self.ready_state.get() == XMLHttpRequestState::Done {
self.change_ready_state(XMLHttpRequestState::Unsent);
self.response_status.set(Err(()));
self.response.borrow_mut().clear();
self.response_headers.borrow_mut().clear();
}
}

// https://xhr.spec.whatwg.org/#the-responseurl-attribute
Expand Down Expand Up @@ -961,13 +966,15 @@ impl XMLHttpRequest {
fn change_ready_state(&self, rs: XMLHttpRequestState) {
assert_ne!(self.ready_state.get(), rs);
self.ready_state.set(rs);
let event = Event::new(
&self.global(),
atom!("readystatechange"),
EventBubbles::DoesNotBubble,
EventCancelable::Cancelable,
);
event.fire(self.upcast());
if rs != XMLHttpRequestState::Unsent {
let event = Event::new(
&self.global(),
atom!("readystatechange"),
EventBubbles::DoesNotBubble,
EventCancelable::Cancelable,
);
event.fire(self.upcast());
}
}

fn process_headers_available(
Expand Down
9 changes: 0 additions & 9 deletions tests/wpt/metadata/xhr/abort-during-open.any.js.ini

This file was deleted.

9 changes: 0 additions & 9 deletions tests/wpt/metadata/xhr/abort-event-abort.any.js.ini

This file was deleted.

3 changes: 0 additions & 3 deletions tests/wpt/metadata/xhr/send-data-unexpected-tostring.htm.ini
@@ -1,8 +1,5 @@
[send-data-unexpected-tostring.htm]
type: testharness
[abort() called from data stringification]
expected: FAIL

[open() called from data stringification]
expected: FAIL

0 comments on commit d0f64d9

Please sign in to comment.