aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2020-02-01 04:59:58 -0500
committerGitHub <noreply@github.com>2020-02-01 04:59:58 -0500
commite71dc9977cdf483b9a7f9bc284cae2596811283e (patch)
treeabba857593725c130b15d00cc075f5e3e09df407 /components/script
parent04268147c58ea7478b214b762cb79454d2388aa5 (diff)
parentb3ca098f6427aba5cc454d6d1e46b41f194a9e84 (diff)
downloadservo-e71dc9977cdf483b9a7f9bc284cae2596811283e.tar.gz
servo-e71dc9977cdf483b9a7f9bc284cae2596811283e.zip
Auto merge of #25651 - medimatrix:xhr-progress-timeout, r=jdm
Do not include request progress/total values on XHR timeout <!-- Please describe your changes on the following line: --> Do not include request progress/total values on XHR timeout as [the specification]( https://xhr.spec.whatwg.org/#request-error-steps) states that upload events when errors occur should always pass 0 for both values. --- <!-- 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 #24286 <!-- Either: --> - [x] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- 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. -->
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/xmlhttprequest.rs28
1 files changed, 18 insertions, 10 deletions
diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs
index 08b37c946c5..6c531e5b4d6 100644
--- a/components/script/dom/xmlhttprequest.rs
+++ b/components/script/dom/xmlhttprequest.rs
@@ -618,7 +618,7 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
}
// Substep 2
if !self.upload_complete.get() {
- self.dispatch_upload_progress_event(atom!("loadstart"), Some(0));
+ self.dispatch_upload_progress_event(atom!("loadstart"), Ok(Some(0)));
if self.generation_id.get() != gen_id {
return Ok(());
}
@@ -1062,11 +1062,11 @@ impl XMLHttpRequest {
self.upload_complete.set(true);
// Substeps 2-4
if !self.sync.get() {
- self.dispatch_upload_progress_event(atom!("progress"), None);
+ self.dispatch_upload_progress_event(atom!("progress"), Ok(None));
return_if_fetch_was_terminated!();
- self.dispatch_upload_progress_event(atom!("load"), None);
+ self.dispatch_upload_progress_event(atom!("load"), Ok(None));
return_if_fetch_was_terminated!();
- self.dispatch_upload_progress_event(atom!("loadend"), None);
+ self.dispatch_upload_progress_event(atom!("loadend"), Ok(None));
return_if_fetch_was_terminated!();
}
// Part of step 13, send() (processing response)
@@ -1164,9 +1164,9 @@ impl XMLHttpRequest {
let upload_complete = &self.upload_complete;
if !upload_complete.get() {
upload_complete.set(true);
- self.dispatch_upload_progress_event(Atom::from(errormsg), None);
+ self.dispatch_upload_progress_event(Atom::from(errormsg), Err(()));
return_if_fetch_was_terminated!();
- self.dispatch_upload_progress_event(atom!("loadend"), None);
+ self.dispatch_upload_progress_event(atom!("loadend"), Err(()));
return_if_fetch_was_terminated!();
}
self.dispatch_response_progress_event(Atom::from(errormsg));
@@ -1210,11 +1210,19 @@ impl XMLHttpRequest {
progressevent.upcast::<Event>().fire(target);
}
- fn dispatch_upload_progress_event(&self, type_: Atom, partial_load: Option<u64>) {
- // If partial_load is None, loading has completed and we can just use the value from the request body
+ fn dispatch_upload_progress_event(&self, type_: Atom, partial_load: Result<Option<u64>, ()>) {
+ // If partial_load is Ok(None), loading has completed and we can just use the value from the request body
+ // If an error occured, we pass 0 for both loaded and total
- let total = self.request_body_len.get() as u64;
- self.dispatch_progress_event(true, type_, partial_load.unwrap_or(total), Some(total));
+ let request_body_len = self.request_body_len.get() as u64;
+ let (loaded, total) = match partial_load {
+ Ok(l) => match l {
+ Some(loaded) => (loaded, Some(request_body_len)),
+ None => (request_body_len, Some(request_body_len)),
+ },
+ Err(()) => (0, None),
+ };
+ self.dispatch_progress_event(true, type_, loaded, total);
}
fn dispatch_response_progress_event(&self, type_: Atom) {