aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/script/dom/xmlhttprequest.rs11
-rw-r--r--tests/wpt/web-platform-tests/XMLHttpRequest/event-readystatechange-loaded.htm4
2 files changed, 11 insertions, 4 deletions
diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs
index 4643921bc2d..caebbddd09e 100644
--- a/components/script/dom/xmlhttprequest.rs
+++ b/components/script/dom/xmlhttprequest.rs
@@ -973,9 +973,16 @@ impl XMLHttpRequest {
*self.response.borrow_mut() = partial_response;
if !self.sync.get() {
if self.ready_state.get() == XMLHttpRequestState::HeadersReceived {
- self.change_ready_state(XMLHttpRequestState::Loading);
- return_if_fetch_was_terminated!();
+ self.ready_state.set(XMLHttpRequestState::Loading);
}
+ let global = self.global();
+ let event = Event::new(
+ global.r(),
+ atom!("readystatechange"),
+ EventBubbles::DoesNotBubble,
+ EventCancelable::Cancelable);
+ event.fire(self.upcast());
+ return_if_fetch_was_terminated!();
self.dispatch_response_progress_event(atom!("progress"));
}
},
diff --git a/tests/wpt/web-platform-tests/XMLHttpRequest/event-readystatechange-loaded.htm b/tests/wpt/web-platform-tests/XMLHttpRequest/event-readystatechange-loaded.htm
index 4368f8c9a5d..67217af748a 100644
--- a/tests/wpt/web-platform-tests/XMLHttpRequest/event-readystatechange-loaded.htm
+++ b/tests/wpt/web-platform-tests/XMLHttpRequest/event-readystatechange-loaded.htm
@@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
- <title>XMLHttpRequest: the LOADING state change should only happen once</title>
+ <title>XMLHttpRequest: the LOADING state change may be emitted multiple times</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="help" href="https://xhr.spec.whatwg.org/#the-send()-method" data-tested-assertations="following::ol[1]/li[10]/dt[1]">
@@ -26,7 +26,7 @@ test.step(function() {
}
if (client.readyState === 4) {
- assert_equals(countedLoading, 1, "LOADING state change may only be emitted once");
+ assert_equals(countedLoading, 10, "LOADING state change may be emitted multiple times");
test.done();
}