Hello fellow storage users,
I've long had the mental model that the WebContentsObserver::OnCookiesAccessed() callback was called in basically the same order that actual cookie reads and writes happened (at least for a single primary main frame).
But lately I was investigating some test flakiness and I was surprised what I saw:
(1) Some cookie reads were reported before the writes that set the value.
(2) Some cookie accesses are reported for pages visited later before ones visited earlier
For example: I visit
http://b.test/empty.html, execute "document.cookie = 'bounce=true';", then navigate (by assigning window.location and waiting for the navigation to complete) to
http://c.test/empty.html, and finally execute "document.cookie = 'final=yes';" on that page.
I sometimes see the c.test/favicon.ico cookie read before the b.test/empty.html cookie write
Interestingly, both unexpected cases involve the favicon request. (Is that a coincidence or not?)
Is this type of ordering expected?
If so, is there any other way to be notified for cookie accesses that would ensure ordering, and be attributed to the URLs that performed them? For example, I see the CookieManager mojo interface has an AddGlobalChangeListener(), but (1) it's only for changes; and (2) it doesn't include the URL. I think we could adapt to (1), but not (2).
Our code is currently in //chrome but is in the process of moving to //content. Will being in //content (and seeing all the Impls instead of just the public API) make this any easier?
Thanks,
Ryan