diff --git a/components/net/fetch/methods.rs b/components/net/fetch/methods.rs index f7934fc6b41..9a7d5d203ff 100644 --- a/components/net/fetch/methods.rs +++ b/components/net/fetch/methods.rs @@ -176,7 +176,7 @@ pub async fn fetch_with_cors_cache( } // Step 17: Run main fetch given fetchParams. - main_fetch(request, cache, false, false, target, &mut None, context).await; + main_fetch(request, cache, false, target, &mut None, context).await; // Step 18: Return fetchParams’s controller. // TODO: We don't implement fetchParams as defined in the spec @@ -215,7 +215,6 @@ pub fn should_request_be_blocked_by_csp( pub async fn main_fetch( request: &mut Request, cache: &mut CorsCache, - cors_flag: bool, recursive_flag: bool, target: Target<'_>, done_chan: &mut DoneChannel, @@ -323,18 +322,21 @@ pub async fn main_fetch( false }; - if (same_origin && !cors_flag) || - current_scheme == "chrome" || - context.protocols.is_fetchable(current_scheme) || + // request's current URL's origin is same origin with request's origin, and request's + // response tainting is "basic" + if (same_origin && request.response_tainting == ResponseTainting::Basic) || + // request's current URL's scheme is "data" + current_scheme == "data" || + // request's mode is "navigate" or "websocket" matches!( request.mode, RequestMode::Navigate | RequestMode::WebSocket { .. } ) { - // Substep 1. + // Substep 1. Set request’s response tainting to "basic". request.response_tainting = ResponseTainting::Basic; - // Substep 2. + // Substep 2. Return the result of running scheme fetch given fetchParams. scheme_fetch(request, cache, target, done_chan, context).await } else if request.mode == RequestMode::SameOrigin { Response::network_error(NetworkError::Internal("Cross-origin response".into())) diff --git a/components/net/http_loader.rs b/components/net/http_loader.rs index ad74820012f..d73076b21c7 100644 --- a/components/net/http_loader.rs +++ b/components/net/http_loader.rs @@ -1086,16 +1086,8 @@ pub async fn http_redirect_fetch( let recursive_flag = request.redirect_mode != RedirectMode::Manual; // Step 22: Return the result of running main fetch given fetchParams and recursive. - let fetch_response = main_fetch( - request, - cache, - cors_flag, - recursive_flag, - target, - done_chan, - context, - ) - .await; + let fetch_response = + main_fetch(request, cache, recursive_flag, target, done_chan, context).await; // TODO: timing allow check context diff --git a/tests/wpt/meta/css/cssom/stylesheet-same-origin.sub.html.ini b/tests/wpt/meta/css/cssom/stylesheet-same-origin.sub.html.ini index e4e933e9fbf..6a3026f73da 100644 --- a/tests/wpt/meta/css/cssom/stylesheet-same-origin.sub.html.ini +++ b/tests/wpt/meta/css/cssom/stylesheet-same-origin.sub.html.ini @@ -1,7 +1,3 @@ [stylesheet-same-origin.sub.html] - [Origin-clean check in cross-origin CSSOM Stylesheets (redirect from cross-origin to same-origin)] - expected: FAIL - [Origin-clean check in loading error CSSOM Stylesheets] expected: FAIL - diff --git a/tests/wpt/meta/fetch/api/redirect/redirect-back-to-original-origin.any.js.ini b/tests/wpt/meta/fetch/api/redirect/redirect-back-to-original-origin.any.js.ini index 0225b01c4b2..4a82368032d 100644 --- a/tests/wpt/meta/fetch/api/redirect/redirect-back-to-original-origin.any.js.ini +++ b/tests/wpt/meta/fetch/api/redirect/redirect-back-to-original-origin.any.js.ini @@ -1,12 +1,6 @@ [redirect-back-to-original-origin.any.html] - [original => remote => original with mode: "no-cors"] - expected: FAIL - [redirect-back-to-original-origin.any.worker.html] - [original => remote => original with mode: "no-cors"] - expected: FAIL - [redirect-back-to-original-origin.any.serviceworker.html] expected: ERROR diff --git a/tests/wpt/meta/fetch/images/canvas-remote-read-remote-image-redirect.html.ini b/tests/wpt/meta/fetch/images/canvas-remote-read-remote-image-redirect.html.ini deleted file mode 100644 index cced5585dbe..00000000000 --- a/tests/wpt/meta/fetch/images/canvas-remote-read-remote-image-redirect.html.ini +++ /dev/null @@ -1,3 +0,0 @@ -[canvas-remote-read-remote-image-redirect.html] - [Load a no-cors image from a same-origin URL that redirects to a cross-origin URL that redirects to the initial origin] - expected: FAIL