Repository navigation
feat(cookies): add context.cookies and scope page.cookies to the page - #690
Merged
Merged
Conversation
Cookies belong to the context. context.cookies uses Storage.getCookies/setCookies/clearCookies instead of the deprecated Network.getAllCookies, and browser.cookies is the default context's. page.cookies returns only the cookies sent to the page's URL and its frames' (Network.getCookies), set/remove default to the page's host, clear keeps other domains, store/load stay on the context. all keys cookies by name, so of the cookies sharing a name only one survived. It is deprecated, to_a and map(&:name) cover it. [] takes domain: and path: to pick one of them.
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.
Cookies belong to a browser context, every page in it shares them. This puts them there and drops the deprecated
Network.getAllCookies.Changes
context.cookies(new): every cookie in the context whatever its domain, viaStorage.getCookies/setCookies/clearCookies. Haseach,all,[],set,remove,clear,store,load.Storagehas no delete, soremoveexpires the matching cookies.browser.cookiesis the default context's cookies instead of the page's. Same results as before.page.cookies(Page::Cookies) is what the page sees: cookies sent to its URL and its frames' URLs (Network.getCookies), oreach(urls:).set/removedefault to the page's host,clearkeeps other domains, nostore/load.cookies[name, domain:, path:]picks one of the cookies sharing a name.cookies.allis deprecated, keyed by name it kept one of the cookies sharing a name. Useto_a, ormap(&:name).Breaking (0.21)
page.cookies.each/all/[]return only the page's cookies, nothing before the firstgo_to. Usebrowser.cookiesorbrowser.contexts[page.context_id].cookiesfor all of them.page.cookies.clearkeeps other domains,page.cookies.store/loadare gone.page.cookies.set/removedefault to the page's host rather than the:base_urlhost.page.cookiesis aFerrum::Page::Cookies,Ferrum::Cookies.newtakes(client, context_id).browser.cookies.setreturnstrueand raisesBrowserErrorfor an invalid cookie, asNetwork.setCookiedid, with a vaguer message.Cuprite and code using
browser.cookiessee no change apart from theallwarning.Tests
spec/cookies_spec.rb(context scope, contexts kept apart,remove(url:),[]filters,alldeprecation) and the newspec/page/cookies_spec.rb.