Clear ephemeral storage partitions after a small time period (original) (raw)
Currently all 3p partitioned storage under a 1p is cleared the moment there are no more tabs with the 1p as the top level document. This mostly works great, but doesn't handle some oauth style flows.
For example:
- example.org includes a 3p frame that handles SSO
- interacting with the 3p frame redirects the top level frame to an origin controlled by the SSO provider
- the top level frame then redirects back to example.org
- the SSO provider (embedded under example.org) expects that its state will still be there when the top level frame loads example.org
Right now the above flow breaks, since the embedded SSO provider state is cleared the moment the top level document is navigated.
We should handle such cases by modifying when we clear the 3p storage areas. Instead of clearing them the moment there are no more top level documents for the site doing the embedding, we should instead clear them after a brief pause (e.g., 30 seconds after there are no more top level documents for the site).
This will handle most cases of the above flow. We can expand the time out further if needed (for example, if someone needs to type in credentials for the SSO provider, 30 sec may not be enough), but this issue suggests 30 seconds for an initial approach.
There are QA tests for this behavior (assuming a 30 second timer) here: https://dev-pages.brave.software/storage/keep-alive.html