mirror of
https://github.com/servo/servo.git
synced 2025-06-21 07:38:59 +01:00
Implement XHR progress event changes
This commit is contained in:
parent
05623b36a1
commit
f938c955a3
2 changed files with 10 additions and 16 deletions
|
@ -42,7 +42,7 @@ use encoding::types::{DecoderTrap, EncoderTrap, Encoding, EncodingRef};
|
||||||
use euclid::length::Length;
|
use euclid::length::Length;
|
||||||
use html5ever::serialize;
|
use html5ever::serialize;
|
||||||
use html5ever::serialize::SerializeOpts;
|
use html5ever::serialize::SerializeOpts;
|
||||||
use hyper::header::{ContentLength, ContentType};
|
use hyper::header::{ContentLength, ContentType, ContentEncoding};
|
||||||
use hyper::header::Headers;
|
use hyper::header::Headers;
|
||||||
use hyper::method::Method;
|
use hyper::method::Method;
|
||||||
use hyper::mime::{self, Attr as MimeAttr, Mime, Value as MimeValue};
|
use hyper::mime::{self, Attr as MimeAttr, Mime, Value as MimeValue};
|
||||||
|
@ -979,14 +979,12 @@ impl XMLHttpRequest {
|
||||||
// Part of step 11, send() (processing response end of file)
|
// Part of step 11, send() (processing response end of file)
|
||||||
// XXXManishearth handle errors, if any (substep 2)
|
// XXXManishearth handle errors, if any (substep 2)
|
||||||
|
|
||||||
// Subsubsteps 5-7
|
// Subsubsteps 6-8
|
||||||
self.send_flag.set(false);
|
self.send_flag.set(false);
|
||||||
|
|
||||||
self.change_ready_state(XMLHttpRequestState::Done);
|
self.change_ready_state(XMLHttpRequestState::Done);
|
||||||
return_if_fetch_was_terminated!();
|
return_if_fetch_was_terminated!();
|
||||||
// Subsubsteps 10-12
|
// Subsubsteps 11-12
|
||||||
self.dispatch_response_progress_event(atom!("progress"));
|
|
||||||
return_if_fetch_was_terminated!();
|
|
||||||
self.dispatch_response_progress_event(atom!("load"));
|
self.dispatch_response_progress_event(atom!("load"));
|
||||||
return_if_fetch_was_terminated!();
|
return_if_fetch_was_terminated!();
|
||||||
self.dispatch_response_progress_event(atom!("loadend"));
|
self.dispatch_response_progress_event(atom!("loadend"));
|
||||||
|
@ -1009,15 +1007,11 @@ impl XMLHttpRequest {
|
||||||
let upload_complete = &self.upload_complete;
|
let upload_complete = &self.upload_complete;
|
||||||
if !upload_complete.get() {
|
if !upload_complete.get() {
|
||||||
upload_complete.set(true);
|
upload_complete.set(true);
|
||||||
self.dispatch_upload_progress_event(atom!("progress"), None);
|
|
||||||
return_if_fetch_was_terminated!();
|
|
||||||
self.dispatch_upload_progress_event(Atom::from(errormsg), None);
|
self.dispatch_upload_progress_event(Atom::from(errormsg), None);
|
||||||
return_if_fetch_was_terminated!();
|
return_if_fetch_was_terminated!();
|
||||||
self.dispatch_upload_progress_event(atom!("loadend"), None);
|
self.dispatch_upload_progress_event(atom!("loadend"), None);
|
||||||
return_if_fetch_was_terminated!();
|
return_if_fetch_was_terminated!();
|
||||||
}
|
}
|
||||||
self.dispatch_response_progress_event(atom!("progress"));
|
|
||||||
return_if_fetch_was_terminated!();
|
|
||||||
self.dispatch_response_progress_event(Atom::from(errormsg));
|
self.dispatch_response_progress_event(Atom::from(errormsg));
|
||||||
return_if_fetch_was_terminated!();
|
return_if_fetch_was_terminated!();
|
||||||
self.dispatch_response_progress_event(atom!("loadend"));
|
self.dispatch_response_progress_event(atom!("loadend"));
|
||||||
|
@ -1032,12 +1026,17 @@ impl XMLHttpRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dispatch_progress_event(&self, upload: bool, type_: Atom, loaded: u64, total: Option<u64>) {
|
fn dispatch_progress_event(&self, upload: bool, type_: Atom, loaded: u64, total: Option<u64>) {
|
||||||
|
let (total_length, length_computable) = if self.response_headers.borrow().has::<ContentEncoding>() {
|
||||||
|
(0, false)
|
||||||
|
} else {
|
||||||
|
(total.unwrap_or(0), total.is_some())
|
||||||
|
};
|
||||||
let progressevent = ProgressEvent::new(&self.global(),
|
let progressevent = ProgressEvent::new(&self.global(),
|
||||||
type_,
|
type_,
|
||||||
EventBubbles::DoesNotBubble,
|
EventBubbles::DoesNotBubble,
|
||||||
EventCancelable::NotCancelable,
|
EventCancelable::NotCancelable,
|
||||||
total.is_some(), loaded,
|
length_computable, loaded,
|
||||||
total.unwrap_or(0));
|
total_length);
|
||||||
let target = if upload {
|
let target = if upload {
|
||||||
self.upload.upcast()
|
self.upload.upcast()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
[progress-events-response-data-gzip.htm]
|
|
||||||
type: testharness
|
|
||||||
[XMLHttpRequest: progress events and GZIP encoding]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue