w3c / webextensions

Charter and administrivia for the WebExtensions Community Group (WECG)
Other
575 stars 50 forks source link

getPackageDirectoryEntry in service workers #471

Open dotproto opened 8 months ago

dotproto commented 8 months ago

Issue https://github.com/mdn/content/issues/2986 notes that the MDN documentation for runtime.getPackageDirectoryEntry() isn't accurate. In order to help resolve that documentation issue, I'd like to ask the Chrome team for clarification on a couple of questions.

  1. In the future will runtime.getPackageDirectoryEntry() return a promise in Chrome?

  2. Does Chrome plan to support this method in service workers?

  3. I assume that Chrome didn't expose getPackageDirectoryEntry() in service workers because the DirectoryEntry interface isn't exposed in that context. If true, does Chrome have plans to enable extensions to access similar capabilities or data using an alternative API?

tophf commented 8 months ago

It might be possible to "re-base" it on the new File System Access API, which AFAIK uses a very similar API for File and Directory entries that are allowed in a service worker. As for the missing stuff that will need to be emulated or dropped, someone should look at the old FileSystem API and list them.

jpmedley commented 6 months ago

@dotproto Here's an update from Tim: https://chromium-review.googlesource.com/c/chromium/src/+/5112904

jpmedley commented 6 months ago

One other thing:

One note with that particular API though is that it's not exposed to service workers, but is available in other contexts (extension popup, web pages inside the extension, etc.).

tophf commented 6 months ago

That commit is unrelated and won't help because service workers don't have DOM, which is required by this API.

jpmedley commented 6 months ago

Sorry about that. I'm playing catchup, so moving a bit fast. Too fast, clearly.

rdcronin commented 3 days ago

In the future will runtime.getPackageDirectoryEntry() return a promise in Chrome?

Yes. This is done.

Does Chrome plan to support this method in service workers?

Not at any point in the near future.

I assume that Chrome didn't expose getPackageDirectoryEntry() in service workers because the DirectoryEntry interface isn't exposed in that context. If true, does Chrome have plans to enable extensions to access similar capabilities or data using an alternative API?

We're unlikely to add anything specifically for this. Depending on the use case, alternatives exist (e.g., if you just need file content, you can fetch() it).

This is a pretty old API that we've talked about removing in the past, but it has non-trivial usage.