mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Do not include request progress/total values on XHR timeout
This commit is contained in:
parent
6d220d02de
commit
cc2d68a15d
1 changed files with 18 additions and 10 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue