Bug 259637

Summary: Unable to use OPFS in web extension because of changing origin
Product: WebKit Reporter: OlegWock <olegwock>
Component: WebKit ExtensionsAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: timothy, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari 16   
Hardware: All   
OS: All   

Description OlegWock 2023-07-30 14:41:01 PDT
I'm porting my Web Extension to Safari. This extension has a feature where user can upload images which later can be used in the extension. In chrome/firefox I currently use OPFS (https://webkit.org/blog/12257/the-file-system-access-api-with-origin-private-file-system/) to store icons. But because Safari changes extension's origin on every browser restart, extension can't utilize OPFS, since it will lost access to it after browser restart (which makes it unusable for persisting data).

This is a bit related to this bug https://bugs.webkit.org/show_bug.cgi?id=244330
In a way that it's caused by same thing

I assume origin is changed on every run to resist fingerprinting, so making it stable probably isn't a feasible solution. But can we have some alternative way to use OPFS in web extension? For example, webkit can use extension id (`browser.runtime.id`) as origin to persist OPFS between runs?
Comment 1 OlegWock 2023-07-30 15:47:14 PDT
After a bit more searching I found mention from Timothy Hatcher (https://github.com/w3c/webextensions/blob/main/_minutes/2023-05-11-wecg.md) that Safari currently migrates DOM Storage when origin changes. So my initial proposal (to use extension id as origin) doesn't make much sense anymore, as there is already established solution for this kind of problem (just for other storage types). If we could get same treatment form OPFS that would be awesome
Comment 2 Radar WebKit Bug Importer 2023-08-06 14:41:12 PDT
<rdar://problem/113473959>