Web Extension : browser.cookies.getAll() does not work

After upgrading to Safari version 18, we encountered an issue with my extension’s background script not being able to access cookies. Previously, in Safari versions 17 and below, the extension worked as expected. Now, when the extension tries to retrieve cookies using browser.cookies.getAll(), it returns an empty list. However, if we open the extension’s developer tools, the cookies are visible and accessible.

It seems that Safari only provides cookie data after the developer tools have been opened. However, after relaunching Safari and launching the extension without opening the developer tools, browser.cookies.getAll() still returns an empty list.

Has anyone else experienced this?

STEPS TO REPRODUCE

  1. Download this minimal app : https://www.icloud.com/iclouddrive/0bajlhnuQaG6T5NsFKXEB0U9Q#test%5Fcookies
  2. Compile test_mv2 extension (in test_cookies.getAll.zip).
  3. Launch test_mv2.app and activate extension.
  4. Click on the extension's button (browserAction).
  5. Open the developer tools.
  6. Observe an empty list of cookies.
  7. Click on the extension's button (browserAction).
  8. Cookies are retrieved as expected.
Web Extension : browser.cookies.getAll() does not work
 
 
Q