Bug 273906
| Summary: | `navigator.storage.getDirectory()` fails in service workers with an `NotSupportedError: The operation is not supported` | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Jiwen Cai <steve> |
| Component: | Service Workers | Assignee: | youenn fablet <youennf> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | ahmad.saleem792, cdumez, karlcow, sihui_liu, webkit-bug-importer, youennf |
| Priority: | P2 | Keywords: | BrowserCompat, InRadar |
| Version: | Safari 17 | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| See Also: |
https://bugs.webkit.org/show_bug.cgi?id=256712 https://github.com/web-platform-tests/wpt/pull/46690 |
||
Jiwen Cai
This is different from https://bugs.webkit.org/show_bug.cgi?id=255458
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Jiwen Cai
To reproduce:
1. Go to https://opfs-in-service-worker.glitch.me/ in Chrome or Firefox.
2. Open the Console.
3. Note how calls to `navigator.storage.getDirectory()` succeed in the service worker.
4. Go to https://opfs-in-service-worker.glitch.me/ in Safari.
5. Open the Console.
6. Note how calls to `navigator.storage.getDirectory()` succeed in the main thread, web worker, but fail in a service worker with an `NotSupportedError`.
Ahmad Saleem
@Jiwen - is it recent regression and use to work earlier?
Radar WebKit Bug Importer
<rdar://problem/127775672>
Jiwen Cai
Hi @Ahmad, this is the first time we attempted to use this. Not sure it's a regression.
Karl Dubost
Probably Youenn might know about it.
youenn fablet
We are exposing StorageManager to service workers but are not setting the service worker StorageProvider.
We should probably set the StorageProvider or alternatively disable StorageManager in service worker contexts.
Jiwen Cai
Hey folks, thanks for taking a look at this. Supporting OPFS in service worker helps a lot for us to better managing large file caching using local storage. It's quite useful feature overall.
youenn fablet
Pull request: https://github.com/WebKit/WebKit/pull/29615
youenn fablet
Submitted web-platform-tests pull request: https://github.com/web-platform-tests/wpt/pull/46690
EWS
Committed 279908@main (c47f4cabd53d): <https://commits.webkit.org/279908@main>
Reviewed commits have been landed. Closing PR #29615 and removing active labels.
Jiwen Cai
Thanks for fixing this. Do we know which Safari version can be expect this to land?