w3c / webextensions

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

Proposal: `StorageArea.getKeys()` #601

Open polywock opened 7 months ago

polywock commented 7 months ago

Taken from #505, as an alternative proposal suggested by @tophf and @Rob--W. It's significantly different from my original proposal, so I'm creating a separate proposal for it.

Background

I regularly need to use storage keys that involve dynamic elements like flag:[tabId]. The only way to get all keys starting with the prefix flag: is using StorageArea.get() to get all the storage items and then to filter.

This isn't efficient. The storage areas support 10MB of data and even more with the unlimitedStorage permission. That's potentially a huge amount of storage data that needs to be serialized and sent over. There's also a special concern when using the Sync storage area.

Proposal

A method to get all keys without the corresponding values.

browser.storage.local.getAllKeys(): Promise<string[]> 

Resources

https://developer.mozilla.org/en-US/docs/Web/API/IDBIndex/getAllKeys

oliverdunk commented 5 months ago

@polywock I plan to implement this in Chromium as part of some work I am doing on the storage API. I’ve started a proposal PR using the template - would you like to work together on finishing that, or are you happy for me to open it? Thanks!

polywock commented 5 months ago

@oliverdunk I appreciate the offer to be involved. But, I'll probably slow down the process.

Please go ahead without me. Thank you!

oliverdunk commented 5 months ago

I have opened a proposal for this in https://github.com/w3c/webextensions/pull/649.

polywock commented 4 months ago

Pull request has been approved and merged. 🚀

Rob--W commented 3 months ago

Re-opening this ticket because we usually keep tickets open until there is nothing left to be done. In this case, we can use this ticket to signal the cross-browser implementation status of the feature (as issue labels here).

I have opened https://bugzilla.mozilla.org/show_bug.cgi?id=1910669 to track the implementation in Firefox.

oliverdunk commented 3 months ago

I've just landed the CL for this in Chromium (link). It will be available in Canary later today and more generally Chrome 130 as that rolls out across channels (schedule).

fregante commented 1 month ago

Safari landed this in the their technology preview release: 🎉

Missing: