chrome.cookies.getAll returns incorrect results in version 128.

513 views
Skip to first unread message

tom mak

unread,
Aug 29, 2024, 3:38:31 AMAug 29
to Chromium Extensions

The following screenshot shows the results returned by the same JavaScript code logging into the same website in different versions.

20240829-153510.jpg


Reproduction method: When retrieving cookies, if the topLevelSite parameter of partitionKey is specified, the corresponding partition's cookies cannot be retrieved in version 128, but they can be in version 122. It is uncertain from which version the behavior became incorrect.

Patrick Kettner

unread,
Aug 29, 2024, 9:19:20 AMAug 29
to tom mak, Chromium Extensions
I wasnt able to quickly replicate this - it may be possible that you are in two different A/B groups for features that are in trial within Chrome. If you check out chrome://version/?show-variations-cmd, there is a "Command-line variations" section that will show the exact configuration used in each build of chrome. Try grabbing the values from 122, and launching 128 with those flags. Does the issue still exist?

--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/60ee89fa-164e-4a0f-ba3e-a919474e852bn%40chromium.org.

Jan Biniok

unread,
Sep 2, 2024, 5:12:36 AMSep 2
to Chromium Extensions, Patrick Kettner, Chromium Extensions, tom mak
Same here: Just visit both links, to install two cookies 


and then visit 


to verify that both are set.

Now install this Tampermonkey script to retrieve the cookies via GM.xmlHttpRequest. just reload this page and check the console output.
Tampermonkey will use cookies.getAll to send the the right cookies, but can't get the partitioned cookie via API.

```
// ==UserScript==
// @name         xxx
// @namespace    xxx
// @version      xxx
// @description  xxx
// @author       xxx
// @match        https://*/*
// @grant        GM.xmlHttpRequest
// @connect      httpbin.org
// ==/UserScript==
GM.xmlHttpRequest({
  url: 'https://httpbin.org/cookies',
  onload: r=>console.log(r.responseText),
  onerror: console.error,
  cookiePartition: {
      topLevelSite: 'https://httpbin.org'
  }
})
```

Not working:

```
Google Chrome 129.0.6668.12 (Official Build) beta (64-bit)
Revision 922b748e54231a05e37811687975b116912300f8-refs/branch-heads/6668@{#93}
OS Linux
JavaScript V8 12.9.202.3
User Agent Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36
Command Line /usr/bin/google-chrome-beta --user-data-dir=/tmp/foo2 --flag-switches-begin --flag-switches-end
Executable Path /opt/google/chrome-beta/google-chrome-beta
Profile Path /tmp/foo2/Default
Command-line variations --force-fieldtrials="UkmSamplingRate/Sampled_NoSeed_Other" --force-fieldtrial-params="UkmSamplingRate.Sampled_NoSeed_Other:_default_sampling/1" --enable-features="UkmSamplingRate<UkmSamplingRate" --disable-field-trial-config
```

Working:
```
Chromium 127.0.6522.0 (Developer Build) (64-bit)
Revision 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
OS Linux
JavaScript V8 12.7.192
User Agent Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36
Command Line ./chrome --user-data-dir=/tmp/foo4 --no-sandbox --force-fieldtrials=UkmSamplingRate/Sampled_NoSeed_Other --force-fieldtrial-params=UkmSamplingRate.Sampled_NoSeed_Other:_default_sampling/1 --enable-features=UkmSamplingRate<UkmSamplingRate --disable-field-trial-config --flag-switches-begin --flag-switches-end
Executable Path /home/janb/Projekte/tampermonkey.svn/chrome-linux-127.0.6522.0/chrome
Profile Path /tmp/foo4/Default
Command-line variations --force-fieldtrials="UkmSamplingRate/Sampled_NoSeed_Other" --force-fieldtrial-params="UkmSamplingRate.Sampled_NoSeed_Other:_default_sampling/1" --enable-features="UkmSamplingRate<UkmSamplingRate" --disable-field-trial-config
```

Patrick Kettner

unread,
Sep 4, 2024, 3:43:35 PMSep 4
to Jan Biniok, Chromium Extensions, tom mak
Hey y'all
Thanks so much, I believe this is going to be crbug.com/361862746. There is an open CL with a fix that will hopefully land soon.

Chris Zalcman

unread,
Sep 14, 2024, 7:59:29 AMSep 14
to Chromium Extensions, Patrick Kettner, Chromium Extensions, tom mak, Jan Biniok
chrome.cookie.set not working with partitioned cookies also.

For example run the following code into an extension context with <all_urls> and cookies permission: 
await chrome.cookies.set({
  name:'test',
  partitionKey:{ topLevelSite: 'https://example.com/' },
  url: 'https://example.com/',
  expirationDate: 1757830860,
  httpOnly: false,
  secure: true,
  value: 'test',
  sameSite: 'no_restriction'
});

then open https://example.com > console > application, cookie not set and is not found via document.cookie

chrome.cookie.set can't set or overwrite existing cookie:
document.cookie='test=test;Path=/;Expires=Sun, 14 Sep 2025 06:21:00 GMT;SameSite=None;Secure;Partitioned';

chrome.cookie.remove also not working correctly with partitioned cookies.
Reply all
Reply to author
Forward
0 new messages