Skip to content

Commit c2900d9

Browse files
committed
Bug 1642531 - Instead of using RequestMode, using ResponseType for CORP checking in cache APIs r=dom-workers-and-storage-reviewers,perry
According to w3c/ServiceWorker#1516, Replacing RequestMode by ResponseType for CORP checking in cache.match() and cache.matchAll(). Differential Revision: https://phabricator.services.mozilla.com/D77747
1 parent 5450b32 commit c2900d9

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

dom/cache/CacheOpParent.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,21 +221,18 @@ already_AddRefed<nsIInputStream> CacheOpParent::DeserializeCacheStream(
221221
void CacheOpParent::ProcessCrossOriginResourcePolicyHeader(
222222
ErrorResult& aRv, const nsTArray<SavedResponse>& aResponses) {
223223
// Only checking for match/matchAll.
224-
RequestMode mode = RequestMode::No_cors;
225224
nsILoadInfo::CrossOriginEmbedderPolicy loadingCOEP =
226225
nsILoadInfo::EMBEDDER_POLICY_NULL;
227226
Maybe<PrincipalInfo> principalInfo;
228227
switch (mOpArgs.type()) {
229228
case CacheOpArgs::TCacheMatchArgs: {
230-
mode = mOpArgs.get_CacheMatchArgs().request().mode();
231229
loadingCOEP =
232230
mOpArgs.get_CacheMatchArgs().request().loadingEmbedderPolicy();
233231
principalInfo = mOpArgs.get_CacheMatchArgs().request().principalInfo();
234232
break;
235233
}
236234
case CacheOpArgs::TCacheMatchAllArgs: {
237235
if (mOpArgs.get_CacheMatchAllArgs().maybeRequest().isSome()) {
238-
mode = mOpArgs.get_CacheMatchAllArgs().maybeRequest().ref().mode();
239236
loadingCOEP = mOpArgs.get_CacheMatchAllArgs()
240237
.maybeRequest()
241238
.ref()
@@ -252,11 +249,6 @@ void CacheOpParent::ProcessCrossOriginResourcePolicyHeader(
252249
}
253250
}
254251

255-
// skip checking for CORS mode
256-
if (mode == RequestMode::Cors) {
257-
return;
258-
}
259-
260252
// skip checking if the request has no principal for same-origin/same-site
261253
// checking.
262254
if (principalInfo.isNothing() ||
@@ -268,6 +260,10 @@ void CacheOpParent::ProcessCrossOriginResourcePolicyHeader(
268260

269261
nsAutoCString corp;
270262
for (auto it = aResponses.cbegin(); it != aResponses.cend(); ++it) {
263+
if (it->mValue.type() != ResponseType::Opaque &&
264+
it->mValue.type() != ResponseType::Opaqueredirect) {
265+
continue;
266+
}
271267
corp.Assign(EmptyCString());
272268
for (auto headerIt = it->mValue.headers().cbegin();
273269
headerIt != it->mValue.headers().cend(); ++headerIt) {

testing/web-platform/meta/html/cross-origin-embedder-policy/require-corp-load-from-cache-storage.https.html.ini

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)