-
Notifications
You must be signed in to change notification settings - Fork 15.4k
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
feat: Options parameter for Session.clearData
API
#41355
feat: Options parameter for Session.clearData
API
#41355
Conversation
Session.clearBrowsingData
APISession.clearData
API
172271f
to
2a7614b
Compare
cfd34fc
to
ccb1696
Compare
ccb1696
to
3ad52b7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API LGTM
Love the docs and options validation 👍
@clavin is there any more work to be done here or can this be merged? |
@codebytere No more work, please do merge! 😄 |
Release Notes Persisted
|
Description of Change
Adds an options parameter to the recent
Session.clearData
API (#40983) to configure what types of data are cleared and scope the behavior to include or exclude specific origins.Checklist
npm test
passesRelease Notes
Notes: Added options parameter to
Session.clearData
API.Proposed API (Docs)
ses.clearData([options])
options
Object (optional)dataTypes
String[] (optional) - The types of data to clear. If undefined, will clear all types of data. See method details for possible values.origins
String[] (optional) - Clear data for only these origins. Cannot be used withexcludeOrigins
.excludeOrigins
String[] (optional) - Clear data for all origins except these ones. Cannot be used withorigins
.avoidClosingConnections
boolean (optional) - Skips deleting cookies that would close current network connections.originMatchingMode
String (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.
dataTypes
may include the following case-sensitive string values:backgroundFetch
cache
cookies
downloads
fileSystems
indexedDB
localStorage
serviceWorkers
webSQL
This method clears more types of data and is more thourough than the
clearStorageData
method.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
BrowsingDataRemover
interface.Future Work
This may allow us to deprecate some other data clearing APIs we have:
clearCache
can be deprecated/reimplemented on top of this API.clearStorageData
can be equivalently deprecated/reimplemented on top of this API.quotas
option, 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 ofclearStorageData
have equivalents in this API.)shadercache
option would no longer be specifiable on its own, but would be part ofcache
. All other currentstorages
options have direct mappings in this API.clearStorageData
method, but I suspect these side effects are generally intended when calling a method to clear data.clearHostResolverCache
cannot be deprecated or replaced by this API. The underlying Chromium API is not called as part of this API.clearAuthCache
cannot 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.clearCodeCaches
cannot 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.