feat: Options parameter for Session.clearData API#41355
Merged
Conversation
172271f to
2a7614b
Compare
cfd34fc to
ccb1696
Compare
ccb1696 to
3ad52b7
Compare
erickzhao
reviewed
Feb 27, 2024
samuelmaddock
approved these changes
Mar 13, 2024
samuelmaddock
left a comment
Member
There was a problem hiding this comment.
API LGTM
Love the docs and options validation 👍
Member
|
@clavin is there any more work to be done here or can this be merged? |
Member
Author
|
@codebytere No more work, please do merge! 😄 |
|
Release Notes Persisted
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Change
Adds an options parameter to the recent
Session.clearDataAPI (#40983) to configure what types of data are cleared and scope the behavior to include or exclude specific origins.Checklist
npm testpassesRelease Notes
Notes: Added options parameter to
Session.clearDataAPI.Proposed API (Docs)
ses.clearData([options])optionsObject (optional)dataTypesString[] (optional) - The types of data to clear. If undefined, will clear all types of data. See method details for possible values.originsString[] (optional) - Clear data for only these origins. Cannot be used withexcludeOrigins.excludeOriginsString[] (optional) - Clear data for all origins except these ones. Cannot be used withorigins.avoidClosingConnectionsboolean (optional) - Skips deleting cookies that would close current network connections.originMatchingModeString (optional) - The behavior for matching data to origins. Valid values are"third-parties-included"and"origin-in-all-contexts".Returns
Promise<void>- resolves when all data has been cleared.Clears various different types of data.
dataTypesmay include the following case-sensitive string values:backgroundFetchcachecookiesdownloadsfileSystemsindexedDBlocalStorageserviceWorkerswebSQLThis method clears more types of data and is more thourough than the
clearStorageDatamethod.Note: Cookies are stored at a broader scope than origins. When removing cookies and filtering by
origins(orexcludeOrigins), the cookies will be removed at the registrable domain level. For example, clearing cookies for the originhttps://really.specific.origin.example.com/will end up clearing all cookies forexample.com. Clearing cookies for the originhttps://my.website.example.co.uk/will end up clearing all cookies forexample.co.uk.For more information, refer to Chromium's
BrowsingDataRemoverinterface.Future Work
This may allow us to deprecate some other data clearing APIs we have:
clearCachecan be deprecated/reimplemented on top of this API.clearStorageDatacan be equivalently deprecated/reimplemented on top of this API.quotasoption, which there is no equivalent for in this proposed API; however, the"syncable"option is now deprecated and open to be cleaned up/removed in the future, and it is treated as the same as the other option. So, put short, this option no longer has a purpose and can be ignored. (To be clear: the other options ofclearStorageDatahave equivalents in this API.)shadercacheoption would no longer be specifiable on its own, but would be part ofcache. All other currentstoragesoptions have direct mappings in this API.clearStorageDatamethod, but I suspect these side effects are generally intended when calling a method to clear data.clearHostResolverCachecannot be deprecated or replaced by this API. The underlying Chromium API is not called as part of this API.clearAuthCachecannot be easily replaced by this API, but is called as part of this API. While the underlying Chromium API powering this method is called by this API as part of clearingcookies, this API cannot be narrowed down to just calling only this method since clearing cookies has many other effects beyond clearing the auth cache.clearCodeCachescannot be easily replaced by this API, but is called as part of this API. While the underlying Chromium API powering this method is called by this API as part of clearingcache, this API cannot be narrowed down to just calling only this method since clearing cache has many other effects beyond clearing the code cache.