Skip to content

Commit

Permalink
Bug 1642531 - Instead of using RequestMode, using ResponseType for CO…
Browse files Browse the repository at this point in the history
…RP 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
  • Loading branch information
edenchuang committed Jun 18, 2020
1 parent eaf8e5f commit 400b466
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
12 changes: 4 additions & 8 deletions dom/cache/CacheOpParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,21 +221,18 @@ already_AddRefed<nsIInputStream> CacheOpParent::DeserializeCacheStream(
void CacheOpParent::ProcessCrossOriginResourcePolicyHeader(
ErrorResult& aRv, const nsTArray<SavedResponse>& aResponses) {
// Only checking for match/matchAll.
RequestMode mode = RequestMode::No_cors;
nsILoadInfo::CrossOriginEmbedderPolicy loadingCOEP =
nsILoadInfo::EMBEDDER_POLICY_NULL;
Maybe<PrincipalInfo> principalInfo;
switch (mOpArgs.type()) {
case CacheOpArgs::TCacheMatchArgs: {
mode = mOpArgs.get_CacheMatchArgs().request().mode();
loadingCOEP =
mOpArgs.get_CacheMatchArgs().request().loadingEmbedderPolicy();
principalInfo = mOpArgs.get_CacheMatchArgs().request().principalInfo();
break;
}
case CacheOpArgs::TCacheMatchAllArgs: {
if (mOpArgs.get_CacheMatchAllArgs().maybeRequest().isSome()) {
mode = mOpArgs.get_CacheMatchAllArgs().maybeRequest().ref().mode();
loadingCOEP = mOpArgs.get_CacheMatchAllArgs()
.maybeRequest()
.ref()
Expand All @@ -252,11 +249,6 @@ void CacheOpParent::ProcessCrossOriginResourcePolicyHeader(
}
}

// skip checking for CORS mode
if (mode == RequestMode::Cors) {
return;
}

// skip checking if the request has no principal for same-origin/same-site
// checking.
if (principalInfo.isNothing() ||
Expand All @@ -268,6 +260,10 @@ void CacheOpParent::ProcessCrossOriginResourcePolicyHeader(

nsAutoCString corp;
for (auto it = aResponses.cbegin(); it != aResponses.cend(); ++it) {
if (it->mValue.type() != ResponseType::Opaque &&
it->mValue.type() != ResponseType::Opaqueredirect) {
continue;
}
corp.Assign(EmptyCString());
for (auto headerIt = it->mValue.headers().cbegin();
headerIt != it->mValue.headers().cend(); ++headerIt) {
Expand Down

This file was deleted.

0 comments on commit 400b466

Please sign in to comment.