do less on abort if not done

This commit is contained in:
Patrick Shaughnessy 2020-01-25 17:47:47 -05:00
parent 937efba0cd
commit 52d8336d7f
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,13 +966,15 @@ 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);
let event = Event::new( if rs != XMLHttpRequestState::Unsent {
&self.global(), let event = Event::new(
atom!("readystatechange"), &self.global(),
EventBubbles::DoesNotBubble, atom!("readystatechange"),
EventCancelable::Cancelable, EventBubbles::DoesNotBubble,
); EventCancelable::Cancelable,
event.fire(self.upcast()); );
event.fire(self.upcast());
}
} }
fn process_headers_available( fn process_headers_available(

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