From 65a774786444065eaa59a727e9c8851ef2bb40d5 Mon Sep 17 00:00:00 2001 From: Atte Lautanala Date: Sat, 22 Oct 2016 18:37:36 +0300 Subject: [PATCH] Implement response API Clone step 1 --- components/script/dom/response.rs | 4 +++- tests/wpt/metadata/fetch/api/response/response-clone.html.ini | 3 --- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/components/script/dom/response.rs b/components/script/dom/response.rs index a1226204418..7607cacc972 100644 --- a/components/script/dom/response.rs +++ b/components/script/dom/response.rs @@ -298,7 +298,9 @@ impl ResponseMethods for Response { // https://fetch.spec.whatwg.org/#dom-response-clone fn Clone(&self) -> Fallible> { // Step 1 - // TODO: This step relies on body and stream, which are still unimplemented. + if self.is_locked() || self.body_used.get() { + return Err(Error::Type("cannot clone a disturbed response".to_string())); + } // Step 2 let new_response = Response::new(&self.global()); diff --git a/tests/wpt/metadata/fetch/api/response/response-clone.html.ini b/tests/wpt/metadata/fetch/api/response/response-clone.html.ini index ecd4656a2dc..dc3c577e415 100644 --- a/tests/wpt/metadata/fetch/api/response/response-clone.html.ini +++ b/tests/wpt/metadata/fetch/api/response/response-clone.html.ini @@ -6,9 +6,6 @@ [Check cloned response's body] expected: FAIL - [Cannot clone a disturbed response] - expected: FAIL - [Cloned responses should provide the same data] expected: FAIL