diff options
Diffstat (limited to 'components/script/dom')
-rw-r--r-- | components/script/dom/domexception.rs | 48 | ||||
-rw-r--r-- | components/script/dom/xmlhttprequest.rs | 16 |
2 files changed, 34 insertions, 30 deletions
diff --git a/components/script/dom/domexception.rs b/components/script/dom/domexception.rs index c7eb73ea10a..00b9ea5ac03 100644 --- a/components/script/dom/domexception.rs +++ b/components/script/dom/domexception.rs @@ -107,28 +107,30 @@ impl<'a> DOMExceptionMethods for JSRef<'a, DOMException> { // http://dom.spec.whatwg.org/#error-names-0 fn Message(self) -> DOMString { - match self.code { - IndexSizeError => "The index is not in the allowed range.".to_string(), - HierarchyRequestError => "The operation would yield an incorrect node tree.".to_string(), - WrongDocumentError => "The object is in the wrong document.".to_string(), - InvalidCharacterError => "The string contains invalid characters.".to_string(), - NoModificationAllowedError => "The object can not be modified.".to_string(), - NotFoundError => "The object can not be found here.".to_string(), - NotSupportedError => "The operation is not supported.".to_string(), - InvalidStateError => "The object is in an invalid state.".to_string(), - SyntaxError => "The string did not match the expected pattern.".to_string(), - InvalidModificationError => "The object can not be modified in this way.".to_string(), - NamespaceError => "The operation is not allowed by Namespaces in XML.".to_string(), - InvalidAccessError => "The object does not support the operation or argument.".to_string(), - SecurityError => "The operation is insecure.".to_string(), - NetworkError => "A network error occurred.".to_string(), - AbortError => "The operation was aborted.".to_string(), - URLMismatchError => "The given URL does not match another URL.".to_string(), - QuotaExceededError => "The quota has been exceeded.".to_string(), - TimeoutError => "The operation timed out.".to_string(), - InvalidNodeTypeError => "The supplied node is incorrect or has an incorrect ancestor for this operation.".to_string(), - DataCloneError => "The object can not be cloned.".to_string(), - EncodingError => "The encoding operation (either encoded or decoding) failed.".to_string() - } + let message = match self.code { + IndexSizeError => "The index is not in the allowed range.", + HierarchyRequestError => "The operation would yield an incorrect node tree.", + WrongDocumentError => "The object is in the wrong document.", + InvalidCharacterError => "The string contains invalid characters.", + NoModificationAllowedError => "The object can not be modified.", + NotFoundError => "The object can not be found here.", + NotSupportedError => "The operation is not supported.", + InvalidStateError => "The object is in an invalid state.", + SyntaxError => "The string did not match the expected pattern.", + InvalidModificationError => "The object can not be modified in this way.", + NamespaceError => "The operation is not allowed by Namespaces in XML.", + InvalidAccessError => "The object does not support the operation or argument.", + SecurityError => "The operation is insecure.", + NetworkError => "A network error occurred.", + AbortError => "The operation was aborted.", + URLMismatchError => "The given URL does not match another URL.", + QuotaExceededError => "The quota has been exceeded.", + TimeoutError => "The operation timed out.", + InvalidNodeTypeError => "The supplied node is incorrect or has an incorrect ancestor for this operation.", + DataCloneError => "The object can not be cloned.", + EncodingError => "The encoding operation (either encoded or decoding) failed." + }; + + message.to_string() } } diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs index 7b43541a660..0bbc96e72c9 100644 --- a/components/script/dom/xmlhttprequest.rs +++ b/components/script/dom/xmlhttprequest.rs @@ -44,7 +44,7 @@ use js::jsval::{JSVal, NullValue, UndefinedValue}; use libc; use libc::c_void; -use net::resource_task::{ResourceTask, ResourceCORSData, Load, LoadData, Payload, Done}; +use net::resource_task::{ResourceTask, ResourceCORSData, Load, LoadData, LoadResponse, Payload, Done}; use cors::{allow_cross_origin_request, CORSRequest, CORSMode, ForcedPreflightMode}; use script_task::{ScriptChan, XHRProgressMsg, XHRReleaseMsg}; use servo_util::str::DOMString; @@ -207,7 +207,8 @@ impl XMLHttpRequest { fn fetch(fetch_type: &SyncOrAsync, resource_task: ResourceTask, mut load_data: LoadData, terminate_receiver: Receiver<TerminateReason>, - cors_request: Result<Option<CORSRequest>,()>, gen_id: GenerationId) -> ErrorResult { + cors_request: Result<Option<CORSRequest>,()>, gen_id: GenerationId, + start_port: Receiver<LoadResponse>) -> ErrorResult { fn notify_partial_progress(fetch_type: &SyncOrAsync, msg: XHRProgress) { match *fetch_type { @@ -277,8 +278,7 @@ impl XMLHttpRequest { } // Step 10, 13 - let (start_chan, start_port) = channel(); - resource_task.send(Load(load_data, start_chan)); + resource_task.send(Load(load_data)); let progress_port; @@ -557,7 +557,8 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> { let global = self.global.root(); let resource_task = global.root_ref().resource_task(); - let mut load_data = LoadData::new(self.request_url.borrow().clone().unwrap()); + let (start_chan, start_port) = channel(); + let mut load_data = LoadData::new(self.request_url.borrow().clone().unwrap(), start_chan); load_data.data = extracted; // Default headers @@ -620,7 +621,7 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> { let gen_id = self.generation_id.get(); if self.sync.get() { return XMLHttpRequest::fetch(&mut Sync(self), resource_task, load_data, - terminate_receiver, cors_request, gen_id); + terminate_receiver, cors_request, gen_id, start_port); } else { self.fetch_time.set(time::now().to_timespec().sec); let script_chan = global.root_ref().script_chan().clone(); @@ -638,7 +639,8 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> { load_data, terminate_receiver, cors_request, - gen_id); + gen_id, + start_port); let ScriptChan(ref chan) = script_chan; chan.send(XHRReleaseMsg(addr)); }); |