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
- Download this minimal app : https://www.icloud.com/iclouddrive/0bajlhnuQaG6T5NsFKXEB0U9Q#test%5Fcookies
- Compile test_mv2 extension (in test_cookies.getAll.zip).
- Launch test_mv2.app and activate extension.
- Click on the extension's button (browserAction).
- Open the developer tools.
- Observe an empty list of cookies.
- Click on the extension's button (browserAction).
- Cookies are retrieved as expected.