Skip to content

Commit

Permalink
Properly set the url on the Response object when the response is an o…
Browse files Browse the repository at this point in the history
…paqueredirect
  • Loading branch information
Eijebong committed May 6, 2020
1 parent b290ad9 commit ec665d9
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 100 deletions.
2 changes: 1 addition & 1 deletion components/net/image_cache.rs
Expand Up @@ -592,7 +592,7 @@ impl ImageCache for ImageCacheImpl {
FilteredMetadata::Basic(_) | FilteredMetadata::Cors(_) => {
CorsStatus::Safe
},
FilteredMetadata::Opaque | FilteredMetadata::OpaqueRedirect => {
FilteredMetadata::Opaque | FilteredMetadata::OpaqueRedirect(_) => {
CorsStatus::Unsafe
},
},
Expand Down
2 changes: 1 addition & 1 deletion components/net_traits/lib.rs
Expand Up @@ -186,7 +186,7 @@ pub enum FilteredMetadata {
Basic(Metadata),
Cors(Metadata),
Opaque,
OpaqueRedirect,
OpaqueRedirect(ServoUrl),
}

#[derive(Clone, Debug, Deserialize, Serialize)]
Expand Down
2 changes: 1 addition & 1 deletion components/net_traits/response.rs
Expand Up @@ -341,7 +341,7 @@ impl Response {
unsafe_: unsafe_metadata,
}),
ResponseType::OpaqueRedirect => Ok(FetchMetadata::Filtered {
filtered: FilteredMetadata::OpaqueRedirect,
filtered: FilteredMetadata::OpaqueRedirect(url.clone()),
unsafe_: unsafe_metadata,
}),
}
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/eventsource.rs
Expand Up @@ -340,7 +340,7 @@ impl FetchResponseListener for EventSourceContext {
let meta = match fm {
FetchMetadata::Unfiltered(m) => m,
FetchMetadata::Filtered { unsafe_, filtered } => match filtered {
FilteredMetadata::Opaque | FilteredMetadata::OpaqueRedirect => {
FilteredMetadata::Opaque | FilteredMetadata::OpaqueRedirect(_) => {
return self.fail_the_connection()
},
_ => unsafe_,
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/xmlhttprequest.rs
Expand Up @@ -984,7 +984,7 @@ impl XMLHttpRequest {
FilteredMetadata::Basic(m) => m,
FilteredMetadata::Cors(m) => m,
FilteredMetadata::Opaque => return Err(Error::Network),
FilteredMetadata::OpaqueRedirect => return Err(Error::Network),
FilteredMetadata::OpaqueRedirect(_) => return Err(Error::Network),
},
},
Err(_) => {
Expand Down
8 changes: 4 additions & 4 deletions components/script/fetch.rs
Expand Up @@ -246,10 +246,10 @@ impl FetchResponseListener for FetchContext {
.root()
.set_type(DOMResponseType::Opaque);
},
FilteredMetadata::OpaqueRedirect => {
self.response_object
.root()
.set_type(DOMResponseType::Opaqueredirect);
FilteredMetadata::OpaqueRedirect(url) => {
let r = self.response_object.root();
r.set_type(DOMResponseType::Opaqueredirect);
r.set_final_url(url);
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion components/script/stylesheet_loader.rs
Expand Up @@ -101,7 +101,7 @@ impl FetchResponseListener for StylesheetContext {
fn process_response(&mut self, metadata: Result<FetchMetadata, NetworkError>) {
if let Ok(FetchMetadata::Filtered { ref filtered, .. }) = metadata {
match *filtered {
FilteredMetadata::Opaque | FilteredMetadata::OpaqueRedirect => {
FilteredMetadata::Opaque | FilteredMetadata::OpaqueRedirect(_) => {
self.origin_clean = false;
},
_ => {},
Expand Down
90 changes: 0 additions & 90 deletions tests/wpt/metadata/fetch/api/redirect/redirect-mode.any.js.ini
@@ -1,123 +1,33 @@
[redirect-mode.any.worker.html]
[same-origin redirect 301 in manual redirect and cors mode]
expected: FAIL

[same-origin redirect 301 in manual redirect and no-cors mode]
expected: FAIL

[same-origin redirect 302 in manual redirect and cors mode]
expected: FAIL

[same-origin redirect 302 in manual redirect and no-cors mode]
expected: FAIL

[same-origin redirect 303 in manual redirect and cors mode]
expected: FAIL

[same-origin redirect 303 in manual redirect and no-cors mode]
expected: FAIL

[same-origin redirect 307 in manual redirect and cors mode]
expected: FAIL

[same-origin redirect 307 in manual redirect and no-cors mode]
expected: FAIL

[same-origin redirect 308 in manual redirect and cors mode]
expected: FAIL

[same-origin redirect 308 in manual redirect and no-cors mode]
expected: FAIL

[cross-origin redirect 301 in manual redirect and cors mode]
expected: FAIL

[cross-origin redirect 301 in manual redirect and no-cors mode]
expected: FAIL

[cross-origin redirect 302 in manual redirect and cors mode]
expected: FAIL

[cross-origin redirect 302 in manual redirect and no-cors mode]
expected: FAIL

[cross-origin redirect 303 in manual redirect and cors mode]
expected: FAIL

[cross-origin redirect 303 in manual redirect and no-cors mode]
expected: FAIL

[cross-origin redirect 307 in manual redirect and cors mode]
expected: FAIL

[cross-origin redirect 307 in manual redirect and no-cors mode]
expected: FAIL

[cross-origin redirect 308 in manual redirect and cors mode]
expected: FAIL

[cross-origin redirect 308 in manual redirect and no-cors mode]
expected: FAIL


[redirect-mode.any.html]
[same-origin redirect 301 in manual redirect and cors mode]
expected: FAIL

[same-origin redirect 301 in manual redirect and no-cors mode]
expected: FAIL

[same-origin redirect 302 in manual redirect and cors mode]
expected: FAIL

[same-origin redirect 302 in manual redirect and no-cors mode]
expected: FAIL

[same-origin redirect 303 in manual redirect and cors mode]
expected: FAIL

[same-origin redirect 303 in manual redirect and no-cors mode]
expected: FAIL

[same-origin redirect 307 in manual redirect and cors mode]
expected: FAIL

[same-origin redirect 307 in manual redirect and no-cors mode]
expected: FAIL

[same-origin redirect 308 in manual redirect and cors mode]
expected: FAIL

[same-origin redirect 308 in manual redirect and no-cors mode]
expected: FAIL

[cross-origin redirect 301 in manual redirect and cors mode]
expected: FAIL

[cross-origin redirect 301 in manual redirect and no-cors mode]
expected: FAIL

[cross-origin redirect 302 in manual redirect and cors mode]
expected: FAIL

[cross-origin redirect 302 in manual redirect and no-cors mode]
expected: FAIL

[cross-origin redirect 303 in manual redirect and cors mode]
expected: FAIL

[cross-origin redirect 303 in manual redirect and no-cors mode]
expected: FAIL

[cross-origin redirect 307 in manual redirect and cors mode]
expected: FAIL

[cross-origin redirect 307 in manual redirect and no-cors mode]
expected: FAIL

[cross-origin redirect 308 in manual redirect and cors mode]
expected: FAIL

[cross-origin redirect 308 in manual redirect and no-cors mode]
expected: FAIL

0 comments on commit ec665d9

Please sign in to comment.