Commit c1240bf3 authored by Kinuko Yasuda's avatar Kinuko Yasuda Committed by Commit Bot

Prepare for deprecation of FetchAPIRequest::request_context_type

This patch tries to make sure if not setting the given
request_context_type for Fetch request doesn't
break anything, before actually deprecating them.

End state should be:
* We remove FetchAPIRequest::request_context_type and
  URLRequest::fetch_request_context_type
  (if this doesn't break anything)
* As a follow-up we can add the code to serialize/deserialize
  'Request.destination' into CacheStorage, but it's not
  happening now (i.e. it's broken)

More details:

* Request's context type is not used when it's propagated
  to SW's fetch event or used for Cache Storage, and it seems
  it's WAI per spec (and request context type's not a spec'ed anymore)
* Cache Storage's matching logic doesn't use them either.
* Cache.keys() seem to be supposed to return the original request,
  therefore destination would need to be stored there, while the part's
  currently (already) broken

Bug: 1045925
Change-Id: I4e95fe51b9a6b1d9f91226017e931f8a1d357a02
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2066359
Commit-Queue: Kinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#743442}
parent f7ebeb43
...@@ -102,7 +102,11 @@ FetchRequestData* FetchRequestData::Create( ...@@ -102,7 +102,11 @@ FetchRequestData* FetchRequestData::Create(
nullptr /* AbortSignal */)); nullptr /* AbortSignal */));
} }
request->SetContext(fetch_api_request.request_context_type); // Context is always set to FETCH later, so we don't copy it
// from fetch_api_request here.
// TODO(crbug.com/1045925): Remove this comment too when
// we deprecate SetContext.
request->SetDestination(fetch_api_request.destination); request->SetDestination(fetch_api_request.destination);
request->SetReferrerString(AtomicString(Referrer::NoReferrer())); request->SetReferrerString(AtomicString(Referrer::NoReferrer()));
if (fetch_api_request.referrer) { if (fetch_api_request.referrer) {
......
...@@ -59,7 +59,6 @@ TEST(ServiceWorkerRequestTest, FromAndToFetchAPIRequest) { ...@@ -59,7 +59,6 @@ TEST(ServiceWorkerRequestTest, FromAndToFetchAPIRequest) {
const String referrer = "http://www.referrer.com/"; const String referrer = "http://www.referrer.com/";
const network::mojom::ReferrerPolicy kReferrerPolicy = const network::mojom::ReferrerPolicy kReferrerPolicy =
network::mojom::ReferrerPolicy::kAlways; network::mojom::ReferrerPolicy::kAlways;
const mojom::RequestContextType kContext = mojom::RequestContextType::AUDIO;
const network::mojom::RequestDestination kDestination = const network::mojom::RequestDestination kDestination =
network::mojom::RequestDestination::kAudio; network::mojom::RequestDestination::kAudio;
const network::mojom::RequestMode kMode = const network::mojom::RequestMode kMode =
...@@ -76,7 +75,6 @@ TEST(ServiceWorkerRequestTest, FromAndToFetchAPIRequest) { ...@@ -76,7 +75,6 @@ TEST(ServiceWorkerRequestTest, FromAndToFetchAPIRequest) {
fetch_api_request->credentials_mode = kCredentialsMode; fetch_api_request->credentials_mode = kCredentialsMode;
fetch_api_request->cache_mode = kCacheMode; fetch_api_request->cache_mode = kCacheMode;
fetch_api_request->redirect_mode = kRedirectMode; fetch_api_request->redirect_mode = kRedirectMode;
fetch_api_request->request_context_type = kContext;
fetch_api_request->destination = kDestination; fetch_api_request->destination = kDestination;
for (int i = 0; headers[i].key; ++i) { for (int i = 0; headers[i].key; ++i) {
fetch_api_request->headers.insert(String(headers[i].key), fetch_api_request->headers.insert(String(headers[i].key),
...@@ -116,7 +114,6 @@ TEST(ServiceWorkerRequestTest, FromAndToFetchAPIRequest) { ...@@ -116,7 +114,6 @@ TEST(ServiceWorkerRequestTest, FromAndToFetchAPIRequest) {
EXPECT_EQ(kCredentialsMode, second_fetch_api_request->credentials_mode); EXPECT_EQ(kCredentialsMode, second_fetch_api_request->credentials_mode);
EXPECT_EQ(kCacheMode, second_fetch_api_request->cache_mode); EXPECT_EQ(kCacheMode, second_fetch_api_request->cache_mode);
EXPECT_EQ(kRedirectMode, second_fetch_api_request->redirect_mode); EXPECT_EQ(kRedirectMode, second_fetch_api_request->redirect_mode);
EXPECT_EQ(kContext, second_fetch_api_request->request_context_type);
EXPECT_EQ(referrer, second_fetch_api_request->referrer->url); EXPECT_EQ(referrer, second_fetch_api_request->referrer->url);
EXPECT_EQ(network::mojom::ReferrerPolicy::kAlways, EXPECT_EQ(network::mojom::ReferrerPolicy::kAlways,
second_fetch_api_request->referrer->policy); second_fetch_api_request->referrer->policy);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment