From ad49a0cb1945454a5e5edde19abe193bf1802213 Mon Sep 17 00:00:00 2001 From: Amoghavarsha Kudaligi Date: Wed, 8 May 2024 16:09:03 +0530 Subject: [PATCH 1/2] Fix reasons. --- packages/common/src/data/index.ts | 12 ++++++++++++ packages/extension/src/serviceWorker/index.ts | 5 ++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/common/src/data/index.ts b/packages/common/src/data/index.ts index 62c0d39c7..77898ff79 100644 --- a/packages/common/src/data/index.ts +++ b/packages/common/src/data/index.ts @@ -15,3 +15,15 @@ */ export { default as cookieIssueDetails } from './cookieExclusionAndWarningReasons'; export { cookieExemptionReason } from './cookieExemptionReason'; +export const auditsToNetworkMap = { + ExcludeSameSiteUnspecifiedTreatedAsLax: 'SameSiteUnspecifiedTreatedAsLax', + ExcludeSameSiteNoneInsecure: 'SameSiteNoneInsecure', + ExcludeSameSiteLax: 'SameSiteLax', + ExcludeSameSiteStrict: 'SameSiteStrict', + ExcludeInvalidSameParty: 'InvalidSameParty', + ExcludeSamePartyCrossPartyContext: 'SamePartyCrossPartyContext', + ExcludeDomainNonASCII: 'DomainNonASCII', + ExcludeThirdPartyCookieBlockedInFirstPartySet: + 'ThirdPartyBlockedInFirstPartySet', + ExcludeThirdPartyPhaseout: 'ThirdPartyPhaseout', +}; diff --git a/packages/extension/src/serviceWorker/index.ts b/packages/extension/src/serviceWorker/index.ts index 6f22762f4..1b5bca9d7 100644 --- a/packages/extension/src/serviceWorker/index.ts +++ b/packages/extension/src/serviceWorker/index.ts @@ -22,6 +22,7 @@ import { type CookieData, parseResponseReceivedExtraInfo, parseRequestWillBeSentExtraInfo, + auditsToNetworkMap, } from '@ps-analysis-tool/common'; /** @@ -439,7 +440,9 @@ chrome.debugger.onEvent.addListener((source, method, params) => { const modifiedCookieExclusionReasons = cookieExclusionReasons.map( (reason) => { if (reason.toLowerCase().startsWith('exclude')) { - return reason.substring(7) as Protocol.Network.CookieBlockedReason; + return auditsToNetworkMap[ + reason + ] as Protocol.Network.CookieBlockedReason; } return reason as Protocol.Network.CookieBlockedReason; } From a2cd8d2128cd18d24a573231e186d011282d4718 Mon Sep 17 00:00:00 2001 From: Amoghavarsha Kudaligi Date: Wed, 8 May 2024 16:40:21 +0530 Subject: [PATCH 2/2] Reinstantiate syncCookieStore if not available. --- packages/extension/src/serviceWorker/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/extension/src/serviceWorker/index.ts b/packages/extension/src/serviceWorker/index.ts index 1b5bca9d7..43297720d 100644 --- a/packages/extension/src/serviceWorker/index.ts +++ b/packages/extension/src/serviceWorker/index.ts @@ -225,6 +225,10 @@ chrome.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => { return; } + if (!syncCookieStore) { + syncCookieStore = new SynchnorousCookieStore(); + } + const queryParams = getQueryParams(tab.url); if (queryParams.psat_cdp || queryParams.psat_multitab) {