aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/script/dom/response.rs28
-rw-r--r--components/script/fetch.rs18
-rw-r--r--tests/wpt/metadata/fetch/api/basic/integrity.sub.any.js.ini6
-rw-r--r--tests/wpt/metadata/fetch/api/basic/mode-no-cors.sub.any.js.ini15
-rw-r--r--tests/wpt/metadata/fetch/api/cors/cors-basic.any.js.ini31
-rw-r--r--tests/wpt/metadata/fetch/api/redirect/redirect-empty-location.any.js.ini9
-rw-r--r--tests/wpt/metadata/fetch/api/redirect/redirect-location.any.js.ini93
7 files changed, 38 insertions, 162 deletions
diff --git a/components/script/dom/response.rs b/components/script/dom/response.rs
index 7dfa24439fc..dc80cc74c2e 100644
--- a/components/script/dom/response.rs
+++ b/components/script/dom/response.rs
@@ -395,6 +395,7 @@ fn serialize_without_fragment(url: &ServoUrl) -> &str {
impl Response {
pub fn set_type(&self, new_response_type: DOMResponseType) {
*self.response_type.borrow_mut() = new_response_type;
+ self.set_response_members_by_type(new_response_type);
}
pub fn set_headers(&self, option_hyper_headers: Option<Serde<HyperHeaders>>) {
@@ -412,6 +413,33 @@ impl Response {
*self.url.borrow_mut() = Some(final_url);
}
+ fn set_response_members_by_type(&self, response_type: DOMResponseType) {
+ match response_type {
+ DOMResponseType::Error => {
+ *self.status.borrow_mut() = None;
+ self.set_raw_status(None);
+ self.set_headers(None);
+ *self.body.borrow_mut() = NetTraitsResponseBody::Done(vec![]);
+ },
+ DOMResponseType::Opaque => {
+ *self.url_list.borrow_mut() = vec![];
+ *self.status.borrow_mut() = None;
+ self.set_raw_status(None);
+ self.set_headers(None);
+ *self.body.borrow_mut() = NetTraitsResponseBody::Done(vec![]);
+ },
+ DOMResponseType::Opaqueredirect => {
+ *self.status.borrow_mut() = None;
+ self.set_raw_status(None);
+ self.set_headers(None);
+ *self.body.borrow_mut() = NetTraitsResponseBody::Done(vec![]);
+ },
+ DOMResponseType::Default => {},
+ DOMResponseType::Basic => {},
+ DOMResponseType::Cors => {},
+ }
+ }
+
#[allow(unrooted_must_root)]
pub fn finish(&self, body: Vec<u8>) {
*self.body.borrow_mut() = NetTraitsResponseBody::Done(body);
diff --git a/components/script/fetch.rs b/components/script/fetch.rs
index 0b093c5501d..894e645cbd9 100644
--- a/components/script/fetch.rs
+++ b/components/script/fetch.rs
@@ -236,14 +236,16 @@ impl FetchResponseListener for FetchContext {
fill_headers_with_metadata(self.response_object.root(), m);
self.response_object.root().set_type(DOMResponseType::Cors);
},
- FilteredMetadata::Opaque => self
- .response_object
- .root()
- .set_type(DOMResponseType::Opaque),
- FilteredMetadata::OpaqueRedirect => self
- .response_object
- .root()
- .set_type(DOMResponseType::Opaqueredirect),
+ FilteredMetadata::Opaque => {
+ self.response_object
+ .root()
+ .set_type(DOMResponseType::Opaque);
+ },
+ FilteredMetadata::OpaqueRedirect => {
+ self.response_object
+ .root()
+ .set_type(DOMResponseType::Opaqueredirect);
+ },
},
},
}
diff --git a/tests/wpt/metadata/fetch/api/basic/integrity.sub.any.js.ini b/tests/wpt/metadata/fetch/api/basic/integrity.sub.any.js.ini
index 239e0a52a13..fa99bafd6cc 100644
--- a/tests/wpt/metadata/fetch/api/basic/integrity.sub.any.js.ini
+++ b/tests/wpt/metadata/fetch/api/basic/integrity.sub.any.js.ini
@@ -19,9 +19,6 @@
[CORS invalid integrity]
expected: FAIL
- [Empty string integrity for opaque response]
- expected: FAIL
-
[SHA-* integrity for opaque response]
expected: FAIL
@@ -39,9 +36,6 @@
[CORS invalid integrity]
expected: FAIL
- [Empty string integrity for opaque response]
- expected: FAIL
-
[SHA-* integrity for opaque response]
expected: FAIL
diff --git a/tests/wpt/metadata/fetch/api/basic/mode-no-cors.sub.any.js.ini b/tests/wpt/metadata/fetch/api/basic/mode-no-cors.sub.any.js.ini
deleted file mode 100644
index 2f4e3c3d3b6..00000000000
--- a/tests/wpt/metadata/fetch/api/basic/mode-no-cors.sub.any.js.ini
+++ /dev/null
@@ -1,15 +0,0 @@
-[mode-no-cors.sub.any.worker.html]
- [Fetch https://web-platform.test:8443/fetch/api/resources/top.txt with no-cors mode]
- expected: FAIL
-
- [Fetch http://web-platform.test:8001/fetch/api/resources/top.txt with no-cors mode]
- expected: FAIL
-
-
-[mode-no-cors.sub.any.html]
- [Fetch https://web-platform.test:8443/fetch/api/resources/top.txt with no-cors mode]
- expected: FAIL
-
- [Fetch http://web-platform.test:8001/fetch/api/resources/top.txt with no-cors mode]
- expected: FAIL
-
diff --git a/tests/wpt/metadata/fetch/api/cors/cors-basic.any.js.ini b/tests/wpt/metadata/fetch/api/cors/cors-basic.any.js.ini
index e3a99c31a3b..88f02274dde 100644
--- a/tests/wpt/metadata/fetch/api/cors/cors-basic.any.js.ini
+++ b/tests/wpt/metadata/fetch/api/cors/cors-basic.any.js.ini
@@ -1,38 +1,7 @@
[cors-basic.any.worker.html]
type: testharness
- [Same domain different port [no-cors mode\]]
- expected: FAIL
-
- [Same domain different protocol different port [no-cors mode\]]
- expected: FAIL
-
- [Cross domain basic usage [no-cors mode\]]
- expected: FAIL
-
- [Cross domain different port [no-cors mode\]]
- expected: FAIL
-
- [Cross domain different protocol [no-cors mode\]]
- expected: FAIL
[cors-basic]
expected: FAIL
-[cors-basic.any.html]
- type: testharness
- [Same domain different port [no-cors mode\]]
- expected: FAIL
-
- [Same domain different protocol different port [no-cors mode\]]
- expected: FAIL
-
- [Cross domain basic usage [no-cors mode\]]
- expected: FAIL
-
- [Cross domain different port [no-cors mode\]]
- expected: FAIL
-
- [Cross domain different protocol [no-cors mode\]]
- expected: FAIL
-
diff --git a/tests/wpt/metadata/fetch/api/redirect/redirect-empty-location.any.js.ini b/tests/wpt/metadata/fetch/api/redirect/redirect-empty-location.any.js.ini
deleted file mode 100644
index f7d8e67b4b3..00000000000
--- a/tests/wpt/metadata/fetch/api/redirect/redirect-empty-location.any.js.ini
+++ /dev/null
@@ -1,9 +0,0 @@
-[redirect-empty-location.any.worker.html]
- [redirect response with empty Location, manual mode]
- expected: FAIL
-
-
-[redirect-empty-location.any.html]
- [redirect response with empty Location, manual mode]
- expected: FAIL
-
diff --git a/tests/wpt/metadata/fetch/api/redirect/redirect-location.any.js.ini b/tests/wpt/metadata/fetch/api/redirect/redirect-location.any.js.ini
deleted file mode 100644
index 28e581bd13b..00000000000
--- a/tests/wpt/metadata/fetch/api/redirect/redirect-location.any.js.ini
+++ /dev/null
@@ -1,93 +0,0 @@
-[redirect-location.any.worker.html]
- [Redirect 301 in "manual" mode without location]
- expected: FAIL
-
- [Redirect 301 in "manual" mode with invalid location]
- expected: FAIL
-
- [Redirect 301 in "manual" mode with data location]
- expected: FAIL
-
- [Redirect 302 in "manual" mode without location]
- expected: FAIL
-
- [Redirect 302 in "manual" mode with invalid location]
- expected: FAIL
-
- [Redirect 302 in "manual" mode with data location]
- expected: FAIL
-
- [Redirect 303 in "manual" mode without location]
- expected: FAIL
-
- [Redirect 303 in "manual" mode with invalid location]
- expected: FAIL
-
- [Redirect 303 in "manual" mode with data location]
- expected: FAIL
-
- [Redirect 307 in "manual" mode without location]
- expected: FAIL
-
- [Redirect 307 in "manual" mode with invalid location]
- expected: FAIL
-
- [Redirect 307 in "manual" mode with data location]
- expected: FAIL
-
- [Redirect 308 in "manual" mode without location]
- expected: FAIL
-
- [Redirect 308 in "manual" mode with invalid location]
- expected: FAIL
-
- [Redirect 308 in "manual" mode with data location]
- expected: FAIL
-
-
-[redirect-location.any.html]
- [Redirect 301 in "manual" mode without location]
- expected: FAIL
-
- [Redirect 301 in "manual" mode with invalid location]
- expected: FAIL
-
- [Redirect 301 in "manual" mode with data location]
- expected: FAIL
-
- [Redirect 302 in "manual" mode without location]
- expected: FAIL
-
- [Redirect 302 in "manual" mode with invalid location]
- expected: FAIL
-
- [Redirect 302 in "manual" mode with data location]
- expected: FAIL
-
- [Redirect 303 in "manual" mode without location]
- expected: FAIL
-
- [Redirect 303 in "manual" mode with invalid location]
- expected: FAIL
-
- [Redirect 303 in "manual" mode with data location]
- expected: FAIL
-
- [Redirect 307 in "manual" mode without location]
- expected: FAIL
-
- [Redirect 307 in "manual" mode with invalid location]
- expected: FAIL
-
- [Redirect 307 in "manual" mode with data location]
- expected: FAIL
-
- [Redirect 308 in "manual" mode without location]
- expected: FAIL
-
- [Redirect 308 in "manual" mode with invalid location]
- expected: FAIL
-
- [Redirect 308 in "manual" mode with data location]
- expected: FAIL
-