-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Means to observe availability of storage access #55
Comments
@johnwilander @annevk Would you mind taking a look at this idea, or advising me on how to properly ask for feedback? I'm not very clear on the etiquette for contributing here. |
Hi! Sorry for the delay. This was talked about in the context of per-frame vs per-page storage access. We eventually agreed to per-page storage access which introduces the problem you're trying to solve. Looking at real world use cases though, the user has just interacted with iframeA from thirdParty.example, the frame called the Storage Access API, and the frame was granted access. What immediately needs to happen in sibling frames? The user is not interacting with them. Are you thinking of speculatively fetching resources in case the user interacts with iframeB from thirdParty.example? |
A few cases:
I will note that I'm particularly motivated by another use case that we're considering using Storage Access API for, which is uncredentialed prerendering (in which a prerendered page would be denied storage access in much the same way as a third-party frame might, and storage access would be granted only if the user chose to navigate to the prerendered page). In this case, the grant of storage access is also a result of an action outside the affected frame, and so it's necessary for the page to be able to observe it, preferably without polling. |
+1. Say we had three components:
On page load, the login box knows it doesn't have storage access, so it puts itself into an indeterminate state. It wants to update this if storage becomes available, but it doesn't want to request storage access. The visual preferences component may want to change page appearance once storage access is gained. The button is the thing that calls In this example, if we don't have something like There's a similar issues with the |
As I mentioned in #62 this seems reasonable to Mozilla. Did you also consider giving a signal before the switch happens to allow for any migration? |
I admit to not being completely current on the state of pre-storage-access (i.e., I think a migration signal might be interesting (though I think this issue makes sense independently from it). If I had to sketch one out, I would imagine it wouldn't affect the shape of this idea, because you could do something like: document.addEventListener('beforestorageaccess', async e => {
let readyToMigrate = (async function() {
// open a database, fetch some rows, etc
// exactly what must be pulled out depends on whether
// database connections, transactions, etc. can persist
// across the change
})();
e.waitUntil(readyToMigrate);
let dataToMigrate = await readyToMigrate;
await document.storageAccessAvailable;
// write into the newly available database
}); The semantics of such a |
Yeah, no disagreement there. (FWIW, MDN matches what we currently ship on release, Firefox Nightly has where we want things to go. Which is approximately that third parties have partitioned storage by default and can get to non-partitioned storage for all same-origin documents within an agent.) |
This is generally a reasonable idea and it doesn't look problematic from a privacy perspective. We still consider this something to have in the next version of the spec, but not for immediate graduation. It would be interesting to see if there are real-world problems that we could solve with such a feature right now. |
Adding a +1 to this request - For Google Workspace, there are scenarios with multiple embeds in the same top-level page (for example, a third-party site that embeds multiple Google Docs, or a Google Doc + a Google Calendar appointment booking page). Having some way for embeds to automatically know when storage access has been granted is key to providing a smooth user experience. |
Note that with #138 we have added formal integration with permissions, and I'll try to verify and test that storage access availability can be observed through the Permissions API. I'll close this issue once that's done. |
I'm not sure that addresses all cases from OP. You can observe that you can now call |
I believe you ought to be able to use the permissions API to observe changes which might be caused by other documents:
|
Correct. I'm talking about observing a successful |
I don't see why @cfredric's code doesn't work for these libraries. Through the permissions API they can ensure that they won't prompt the user and will only call rSA when the main UI code has done so. What might be missing from the example is a |
That pattern encourages swapping Storage Access as soon as possible by all code that wants to do something once Storage Access is there. It doesn't allow for code reacting to Storage Access becoming available and leaving a single piece of code in charge of when to actually make the swap. |
Yeah, that's fair, though I'd personally consider that a lower priority until we have evidence that this is an issue. It feels like allowing cross-frame observation of grants is more impactful but I could be wrong. Certainly don't want to block adding that kind of ability. |
I still think @jeremyroman's suggestion makes sense and as far as I can tell he specifically made it for the single-document case, only later elaborating on multiple documents. I agree it's not quite a priority and #154 might also change things around, but I'd like to keep this open for now. |
The storage access API provides for querying the storage access state (
hasStorageAccess
) and requesting changes (requestStorageAccess
), but not observing changes. Authors could pollhasStorageAccess
, but this is inefficient and unergonomic.A frame might have multiple libraries or widgets which need to be updated when the user approves storage access. Currently, the solutions available to the author are:
requestStorageAccess
with a wrapperhasStorageAccess
(wasting CPU cycles)The first of these gets even harder if the flag set changes due to a change outside the document. For instance, a storage access request originating from a same-origin frame elsewhere on the page causes a change with no notification in the current CG draft (since these share a partitioned storage key and thus flag set).
The simplest solution would seem to be:
which resolves whenever
hasStorageAccess
would start resolving totrue
(i.e., has storage access flag for the flag set corresponding to the document is set and the was expressly denied storage flag is not set).Sample usage:
The text was updated successfully, but these errors were encountered: