From 541e79a24652a245becd731e602e816dd6285ca1 Mon Sep 17 00:00:00 2001 From: Amoghavarsha Kudaligi Date: Tue, 26 Dec 2023 14:37:43 +0530 Subject: [PATCH 1/2] Add unknown frames to the frame url list. --- .../common/src/utils/filterCookiesByFrame.ts | 30 ++++++++++++++++--- .../stateProviders/syncCookieStore/index.tsx | 1 + 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/packages/common/src/utils/filterCookiesByFrame.ts b/packages/common/src/utils/filterCookiesByFrame.ts index dc31b3494..5336fd60a 100644 --- a/packages/common/src/utils/filterCookiesByFrame.ts +++ b/packages/common/src/utils/filterCookiesByFrame.ts @@ -32,17 +32,39 @@ const filterCookiesByFrame = ( frameUrl: string | null ) => { const frameFilteredCookies: { [key: string]: CookieTableData } = {}; + if (!cookies || !frameUrl || !tabFrames || !tabFrames[frameUrl]) { + return Object.values(frameFilteredCookies); + } + let tabFramesIDMap: number[] = []; + + Object.keys(tabFrames).forEach((url) => { + tabFramesIDMap = [ + ...new Set([...tabFrames[url].frameIds, ...tabFramesIDMap]), + ]; + }); - if (cookies && frameUrl && tabFrames && tabFrames[frameUrl]) { + if (tabFrames[frameUrl].frameIds?.length === 0) { Object.entries(cookies).forEach(([key, cookie]) => { - tabFrames[frameUrl].frameIds?.forEach((frameId) => { - if (cookie.frameIdList?.includes(frameId)) { - frameFilteredCookies[key] = cookie; + let hasFrame = false; + cookie.frameIdList?.forEach((frameId) => { + if (tabFramesIDMap.includes(frameId as number)) { + hasFrame = true; } }); + if (!hasFrame && cookie.frameIdList?.length > 0) { + frameFilteredCookies[key] = cookie; + } }); } + Object.entries(cookies).forEach(([key, cookie]) => { + tabFrames[frameUrl].frameIds?.forEach((frameId) => { + if (cookie.frameIdList?.includes(frameId)) { + frameFilteredCookies[key] = cookie; + } + }); + }); + return Object.values(frameFilteredCookies); }; diff --git a/packages/extension/src/view/devtools/stateProviders/syncCookieStore/index.tsx b/packages/extension/src/view/devtools/stateProviders/syncCookieStore/index.tsx index 012506317..f94f88189 100644 --- a/packages/extension/src/view/devtools/stateProviders/syncCookieStore/index.tsx +++ b/packages/extension/src/view/devtools/stateProviders/syncCookieStore/index.tsx @@ -155,6 +155,7 @@ export const Provider = ({ children }: PropsWithChildren) => { return tabFrame; }) ); + modifiedTabFrames['Unknown Frame(s)'] = { frameIds: [] }; setTabFrames(modifiedTabFrames); }, [] From f827f31d06d8fd607ec825f8756fb9977c00b803 Mon Sep 17 00:00:00 2001 From: Amoghavarsha Kudaligi Date: Tue, 26 Dec 2023 15:55:10 +0530 Subject: [PATCH 2/2] Fix blocked cookies count in frae overlay. --- .../extension/src/view/devtools/hooks/useFrameOverlay.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/extension/src/view/devtools/hooks/useFrameOverlay.ts b/packages/extension/src/view/devtools/hooks/useFrameOverlay.ts index 18290541f..5850e05bd 100644 --- a/packages/extension/src/view/devtools/hooks/useFrameOverlay.ts +++ b/packages/extension/src/view/devtools/hooks/useFrameOverlay.ts @@ -265,7 +265,12 @@ const useFrameOverlay = ( ? filteredCookies.filter((cookie) => cookie.isFirstParty) : []; const blockedCookies = filteredCookies - ? filteredCookies.filter((cookie) => cookie.isBlocked) + ? filteredCookies.filter( + (cookie) => + cookie.isBlocked || + (cookie.blockedReasons?.length !== undefined && + cookie.blockedReasons?.length > 0) + ) : []; const blockedReasons = filteredCookies ? filteredCookies