Open Bug 1493002 Opened 3 years ago Updated 2 years ago

QuotaManager needs a way to wipe origins based on protocol scheme in support of libdweb

Categories

(Core :: Storage: Quota Manager, enhancement, P3)

enhancement

Tracking

()

People

(Reporter: asuth, Unassigned)

References

(Blocks 2 open bugs)

Details

libdweb (https://github.com/mozilla/libdweb) is an experimental WebExtensions API thing provides a means of registering custom protocols[1] whose loaded pages actually have the origin of the custom protocol.  (Compare with navigator.registerProtocolHandler[2] and the similar WebExtensions Firefox-only "protocol_handlers"[3] mechanism which use the origin of the triggering page/extension instead.)

We need a way to clean up after these custom protocols when they're uninstalled.  I don't believe OriginScope[4] supports this currently.  "Prefix" sounds like it should, but the naming there is misleading; prefix is just an origin match without checking the OriginAttributes suffix.

For safety reasons, it would likely make sense to add a new permutation to OriginScope that is explicitly about the protocol scheme rather than doing bare string prefix matching.  It would also make sense to expose this on nsIQuotaManagerService.  (Compare with the "pattern" clearing which is used to clear based on OriginAttributes that happens via the "clear-origin-attributes-data" observer subject.

1: https://github.com/mozilla/libdweb/blob/master/Readme.md#protocol-api
2: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/registerProtocolHandler
3: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/protocol_handlers
4: https://searchfox.org/mozilla-central/source/dom/quota/OriginScope.h
I filed https://github.com/mozilla/libdweb/issues/83 on libdweb for the need to clear storage on protocol uninstall, and it references back to this bug.
Priority: -- → P3

From my testing, at present custom protocol pages have issues with storage access, seemingly related to this issue:

  1. localStorage access seems to work, but triggers the following error in the browser console:
    Quota originNoSuffix (moz-nullprincipal:{948a55e1-6c93-4153-b353-68d5df20a0a9}) doesn't match passed one (test://origin/)!: ActorsParent.cpp:6077
  2. IndexedDB fails on access with the same error, plus IndexedDB UnknownErr: IDBFactory.cpp:134.

These issues can be reproduced from code in this repo: https://github.com/sammacbeth/libdweb-protocol-bugs

Those errors are related to the custom protocol implementation not having a self-consistent principal. It'll be a separate set of errors when it's QuotaManager not liking the "test" protocol scheme.

You need to log in before you can comment on or make changes to this bug.