Auto merge of #25610 - pshaughn:abortfix, r=Manishearth

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. -->
This commit is contained in:
bors-servo 2020-01-27 11:49:02 -05:00 committed by GitHub
commit d0f64d9d56
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 29 deletions

View file

@ -758,7 +758,12 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
} }
} }
// Step 3 // 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 // https://xhr.spec.whatwg.org/#the-responseurl-attribute
@ -961,6 +966,7 @@ impl XMLHttpRequest {
fn change_ready_state(&self, rs: XMLHttpRequestState) { fn change_ready_state(&self, rs: XMLHttpRequestState) {
assert_ne!(self.ready_state.get(), rs); assert_ne!(self.ready_state.get(), rs);
self.ready_state.set(rs); self.ready_state.set(rs);
if rs != XMLHttpRequestState::Unsent {
let event = Event::new( let event = Event::new(
&self.global(), &self.global(),
atom!("readystatechange"), atom!("readystatechange"),
@ -969,6 +975,7 @@ impl XMLHttpRequest {
); );
event.fire(self.upcast()); event.fire(self.upcast());
} }
}
fn process_headers_available( fn process_headers_available(
&self, &self,

View file

@ -1,9 +0,0 @@
[abort-during-open.any.worker.html]
[XMLHttpRequest: abort() during OPEN]
expected: FAIL
[abort-during-open.any.html]
[XMLHttpRequest: abort() during OPEN]
expected: FAIL

View file

@ -1,9 +0,0 @@
[abort-event-abort.any.html]
[XMLHttpRequest: The abort() method: do not fire abort event in OPENED state when send() flag is unset.]
expected: FAIL
[abort-event-abort.any.worker.html]
[XMLHttpRequest: The abort() method: do not fire abort event in OPENED state when send() flag is unset.]
expected: FAIL

View file

@ -1,8 +1,5 @@
[send-data-unexpected-tostring.htm] [send-data-unexpected-tostring.htm]
type: testharness type: testharness
[abort() called from data stringification]
expected: FAIL
[open() called from data stringification] [open() called from data stringification]
expected: FAIL expected: FAIL