From 17ae93c73a4cca9af8d103da45b08cebe14db544 Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Fri, 13 Dec 2024 03:49:59 +0000 Subject: [PATCH] Bug 1895215 - [devtools] Display cookie's partitionKey in storage panel. r=timhuang,devtools-reviewers,ochameau Differential Revision: https://phabricator.services.mozilla.com/D216397 UltraBlame original commit: a551f98b192c80a6b84cf2e9d9f441251d522f67 --- .../browser_storage_cookies_partitioned.js | 128 ++++++++++++++ devtools/client/storage/ui.js | 6 + devtools/client/themes/storage.css | 2 + .../actors/resources/storage/cookies.js | 162 +++++++++++++++++- .../resources/utils/parent-process-storage.js | 10 +- 5 files changed, 298 insertions(+), 10 deletions(-) diff --git a/devtools/client/storage/test/browser_storage_cookies_partitioned.js b/devtools/client/storage/test/browser_storage_cookies_partitioned.js index 0d01dd3e3d270..45c5fc25ae872 100644 --- a/devtools/client/storage/test/browser_storage_cookies_partitioned.js +++ b/devtools/client/storage/test/browser_storage_cookies_partitioned.js @@ -295,6 +295,14 @@ expandAll ( ) ; +showColumn +( +" +partitionKey +" +true +) +; info ( " @@ -366,6 +374,36 @@ top " ) ; +checkCell +( +topLevelExampleComFooId +" +partitionKey +" +" +" +) +; +await +findVariableViewProperties +( +[ +{ +name +: +" +foo +. +Partition +Key +" +dontMatch +: +true +} +] +) +; const nestedExampleComFooId = @@ -412,6 +450,51 @@ nested " ) ; +checkCell +( +nestedExampleComFooId +" +partitionKey +" +" +https +: +/ +/ +example +. +com +" +) +; +await +findVariableViewProperties +( +[ +{ +name +: +" +foo +. +Partition +Key +" +value +: +" +https +: +/ +/ +example +. +com +" +} +] +) +; await selectTreeItem ( @@ -478,6 +561,51 @@ party " ) ; +checkCell +( +thirdPartyPartitionedId +" +partitionKey +" +" +https +: +/ +/ +example +. +com +" +) +; +await +findVariableViewProperties +( +[ +{ +name +: +" +fooThirdPartyPartitioned +. +Partition +Key +" +value +: +" +https +: +/ +/ +example +. +com +" +} +] +) +; info ( " diff --git a/devtools/client/storage/ui.js b/devtools/client/storage/ui.js index ba1d6a0fc09e0..2de01f57aac56 100644 --- a/devtools/client/storage/ui.js +++ b/devtools/client/storage/ui.js @@ -558,6 +558,12 @@ isSecure " Secure " +partitionKey +: +" +Partition +Key +" path : " diff --git a/devtools/client/themes/storage.css b/devtools/client/themes/storage.css index b3f034fb25719..c4dd59e199edf 100644 --- a/devtools/client/themes/storage.css +++ b/devtools/client/themes/storage.css @@ -365,6 +365,8 @@ hostOnly isHttpOnly # sameSite +# +partitioned { min - diff --git a/devtools/server/actors/resources/storage/cookies.js b/devtools/server/actors/resources/storage/cookies.js index 457ce11bad453..3f2ff2b554ec8 100644 --- a/devtools/server/actors/resources/storage/cookies.js +++ b/devtools/server/actors/resources/storage/cookies.js @@ -924,7 +924,9 @@ return null ; } -return +const +obj += { uniqueKey : @@ -1045,6 +1047,116 @@ cookie ) } ; +if +( +cookie +. +isPartitioned +) +{ +const +rawPartitionKey += +cookie +. +originAttributes +. +partitionKey +; +const +[ +scheme +baseDomain +port +] += +rawPartitionKey +. +replace +( +/ +( +? +< +openingparen +> +^ +\ +( +) +| +( +? +< +closingparen +> +\ +) +) +/ +g +" +" +) +. +split +( +" +" +) +; +const +partitionKey += +{ +scheme +} +: +/ +/ +{ +baseDomain +} +{ +port +! += += +undefined +& +& +/ +^ +\ +d ++ +/ +. +test +( +port +) +? +" +: +" ++ +port +: +" +" +} +; +obj +. +partitionKey += +partitionKey +; +} +return +obj +; } getSameSiteStringFromCookie ( @@ -1439,7 +1551,9 @@ getFields ( ) { -return +const +fields += [ { name @@ -1612,6 +1726,50 @@ true } ] ; +if +( +Services +. +prefs +. +getBoolPref +( +" +network +. +cookie +. +CHIPS +. +enabled +" +false +) +) +{ +fields +. +push +( +{ +name +: +" +partitionKey +" +editable +: +false +hidden +: +false +} +) +; +} +return +fields +; } async editItem diff --git a/devtools/server/actors/resources/utils/parent-process-storage.js b/devtools/server/actors/resources/utils/parent-process-storage.js index 90bc66e337e65..50e9fd4e74e2d 100644 --- a/devtools/server/actors/resources/utils/parent-process-storage.js +++ b/devtools/server/actors/resources/utils/parent-process-storage.js @@ -1636,14 +1636,6 @@ principal getBrowsingContextsFromHost ( host -{ -acceptSameProcessIframes -= -true -} -= -{ -} ) { return @@ -1655,6 +1647,8 @@ getAllBrowsingContexts ( { acceptSameProcessIframes +: +true } ) .