WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
215595
Third party domains are not stored in the case of back/forward navigations
https://bugs.webkit.org/show_bug.cgi?id=215595
Summary
Third party domains are not stored in the case of back/forward navigations
Kate Cheney
Reported
2020-08-17 17:01:21 PDT
We should keep per-page loaded third party domains somewhere for when we navigate back/forward.
Attachments
Patch
(21.30 KB, patch)
2020-08-17 17:27 PDT
,
Kate Cheney
no flags
Details
Formatted Diff
Diff
Patch
(17.00 KB, patch)
2020-08-18 11:38 PDT
,
Kate Cheney
no flags
Details
Formatted Diff
Diff
Patch
(18.67 KB, patch)
2020-08-19 11:42 PDT
,
Kate Cheney
no flags
Details
Formatted Diff
Diff
Patch
(18.71 KB, patch)
2020-08-19 11:52 PDT
,
Kate Cheney
no flags
Details
Formatted Diff
Diff
Patch
(18.69 KB, patch)
2020-08-19 12:10 PDT
,
Kate Cheney
no flags
Details
Formatted Diff
Diff
Patch for landing
(43.55 KB, patch)
2020-08-19 16:54 PDT
,
Kate Cheney
no flags
Details
Formatted Diff
Diff
Show Obsolete
(5)
View All
Add attachment
proposed patch, testcase, etc.
Kate Cheney
Comment 1
2020-08-17 17:02:17 PDT
<
rdar://problem/66642893
>
Kate Cheney
Comment 2
2020-08-17 17:27:39 PDT
Created
attachment 406756
[details]
Patch
Darin Adler
Comment 3
2020-08-18 09:31:50 PDT
Comment on
attachment 406756
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=406756&action=review
Should upload a new version to fix the Windows build.
> Source/WebCore/history/CachedPage.h:40 > + explicit CachedPage(Page&, Vector<RegistrableDomain>&&);
Most of the benefit of the explicit keyword is gone now that this has two arguments, so we could remove it. A bit strange that we have to pass this explicitly here. This seems to possibly indicate a problem with the design pattern.
Kate Cheney
Comment 4
2020-08-18 09:34:31 PDT
(In reply to Darin Adler from
comment #3
)
> Comment on
attachment 406756
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=406756&action=review
> > Should upload a new version to fix the Windows build.
Will do.
> > > Source/WebCore/history/CachedPage.h:40 > > + explicit CachedPage(Page&, Vector<RegistrableDomain>&&); > > Most of the benefit of the explicit keyword is gone now that this has two > arguments, so we could remove it. > > A bit strange that we have to pass this explicitly here. This seems to > possibly indicate a problem with the design pattern.
I can probably change it to use a setter instead.
Chris Dumez
Comment 5
2020-08-18 09:44:57 PDT
Comment on
attachment 406756
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=406756&action=review
> Source/WebCore/loader/FrameLoader.cpp:2005 > + BackForwardCache::singleton().addIfCacheable(*history().currentItem(), m_frame.page(), m_frame.loader().client().loadedThirdPartyDomainsForCache());
Why do we need to pass the domain here at the call site. Cannot the CachedPage constructor simply call m_frame.loader().client().loadedThirdPartyDomainsForCache() itself if caching does end up happening?
> Source/WebCore/loader/FrameLoader.cpp:2054 > + m_client->restoreThirdPartyDomains(cachedPage->loadedThirdPartyDomains());
May be nicer to have this inside CachedPage so that all the logic for saving and restoring is inside CachedPage.
> Source/WebCore/loader/FrameLoaderClient.h:377 > + virtual void restoreThirdPartyDomains(Vector<RegistrableDomain>&) { }
Odd to pass a Vector<RegistrableDomain>& here. You probably want a Vector<RegistrableDomain>&& Come to think of it though, do we really need a new client function? Cannot we simply replay and call didLoadFromRegistrableDomain() in a loop?
Kate Cheney
Comment 6
2020-08-18 10:56:45 PDT
(In reply to Chris Dumez from
comment #5
)
> Comment on
attachment 406756
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=406756&action=review
> > > Source/WebCore/loader/FrameLoader.cpp:2005 > > + BackForwardCache::singleton().addIfCacheable(*history().currentItem(), m_frame.page(), m_frame.loader().client().loadedThirdPartyDomainsForCache()); > > Why do we need to pass the domain here at the call site. Cannot the > CachedPage constructor simply call > m_frame.loader().client().loadedThirdPartyDomainsForCache() itself if > caching does end up happening? >
Yes, good idea.
> > Source/WebCore/loader/FrameLoader.cpp:2054 > > + m_client->restoreThirdPartyDomains(cachedPage->loadedThirdPartyDomains()); > > May be nicer to have this inside CachedPage so that all the logic for saving > and restoring is inside CachedPage. > > > Source/WebCore/loader/FrameLoaderClient.h:377 > > + virtual void restoreThirdPartyDomains(Vector<RegistrableDomain>&) { } > > Odd to pass a Vector<RegistrableDomain>& here. You probably want a > Vector<RegistrableDomain>&& > > Come to think of it though, do we really need a new client function? Cannot > we simply replay and call didLoadFromRegistrableDomain() in a loop?
Good point, I will remove this function.
Kate Cheney
Comment 7
2020-08-18 11:38:08 PDT
Created
attachment 406795
[details]
Patch
Chris Dumez
Comment 8
2020-08-18 16:51:18 PDT
Comment on
attachment 406795
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=406795&action=review
> Source/WebCore/loader/FrameLoader.cpp:2055 > + for (auto& domain : cachedPage->loadedThirdPartyDomains())
Why didn't you move this inside CachedPage::restore() like I suggested? We want cache / restore logic inside CachedPage / CachedFrame as much as possible.
Chris Dumez
Comment 9
2020-08-18 16:59:47 PDT
Comment on
attachment 406795
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=406795&action=review
> Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h:355 > +- (void)_setloadedThirdPartyDomain:(NSString *)domain completionHandler:(void (^)(void))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
I don't think "set" in the name is great, given what the method actually does. I think we should use "add" prefix instead. Also, I like when we use "ForTesting" suffix for such things to make it clear what it is for.
> Source/WebKit/WebProcess/WebPage/WebPage.h:1218 > + Vector<WebCore::RegistrableDomain> loadedThirdPartyDomainsForCache();
Not sure we need the "ForCache" suffix here. Also, this getter should be const. Finally, I think this should return a 'const HashSet<RegistrableDomain>&' since this is the most efficient. The call site can call copyToVector() as needed.
> Source/WebKit/WebProcess/WebPage/WebPage.h:1219 > + void setloadedThirdPartyDomain(WebCore::RegistrableDomain&&, CompletionHandler<void()>&&);
addLoadedThirdPartyDomainForTesting
> Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm:1664 > + [webView _setloadedThirdPartyDomain:@"example1.com" completionHandler: ^(void) {
I don't even think we need this setter. Why can't you simply actually load different domains in the view? At least it would be a real test. Now it is half faked. See ProcessSwapOnNavigation.mm tests to see how you can load different registrable domains in tests.
Sam Weinig
Comment 10
2020-08-19 09:38:38 PDT
Comment on
attachment 406795
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=406795&action=review
> Source/WebCore/history/CachedPage.h:62 > + Vector<RegistrableDomain>& loadedThirdPartyDomains() { return m_loadedThirdPartyDomains; }
Can we give this a clearer name? I don't know from looking at this what this represents?
Kate Cheney
Comment 11
2020-08-19 09:45:46 PDT
(In reply to Chris Dumez from
comment #9
)
> Comment on
attachment 406795
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=406795&action=review
> > > Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h:355 > > +- (void)_setloadedThirdPartyDomain:(NSString *)domain completionHandler:(void (^)(void))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); > > I don't think "set" in the name is great, given what the method actually > does. I think we should use "add" prefix instead. Also, I like when we use > "ForTesting" suffix for such things to make it clear what it is for. >
Ok -- can remove this after changing the test probably.
> > Source/WebKit/WebProcess/WebPage/WebPage.h:1218 > > + Vector<WebCore::RegistrableDomain> loadedThirdPartyDomainsForCache(); > > Not sure we need the "ForCache" suffix here. Also, this getter should be > const. Finally, I think this should return a 'const > HashSet<RegistrableDomain>&' since this is the most efficient. The call site > can call copyToVector() as needed. >
I used ForCache because there is already a loadedThirdPartyDomains() function in WebPage.cpp, so the compiler was unhappy. I will change it to be const and return const HashSet<RegistrableDomain>& though. I can change the ForCache name if you have a suggestion.
> > Source/WebKit/WebProcess/WebPage/WebPage.h:1219 > > + void setloadedThirdPartyDomain(WebCore::RegistrableDomain&&, CompletionHandler<void()>&&); > > addLoadedThirdPartyDomainForTesting > > > Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm:1664 > > + [webView _setloadedThirdPartyDomain:@"example1.com" completionHandler: ^(void) { > > I don't even think we need this setter. Why can't you simply actually load > different domains in the view? At least it would be a real test. Now it is > half faked. > See ProcessSwapOnNavigation.mm tests to see how you can load different > registrable domains in tests.
Will change.
Chris Dumez
Comment 12
2020-08-19 10:03:18 PDT
(In reply to katherine_cheney from
comment #11
)
> (In reply to Chris Dumez from
comment #9
) > > Comment on
attachment 406795
[details]
> > Patch > > > > View in context: > >
https://bugs.webkit.org/attachment.cgi?id=406795&action=review
> > > > > Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h:355 > > > +- (void)_setloadedThirdPartyDomain:(NSString *)domain completionHandler:(void (^)(void))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); > > > > I don't think "set" in the name is great, given what the method actually > > does. I think we should use "add" prefix instead. Also, I like when we use > > "ForTesting" suffix for such things to make it clear what it is for. > > > > Ok -- can remove this after changing the test probably. > > > > Source/WebKit/WebProcess/WebPage/WebPage.h:1218 > > > + Vector<WebCore::RegistrableDomain> loadedThirdPartyDomainsForCache(); > > > > Not sure we need the "ForCache" suffix here. Also, this getter should be > > const. Finally, I think this should return a 'const > > HashSet<RegistrableDomain>&' since this is the most efficient. The call site > > can call copyToVector() as needed. > > > > I used ForCache because there is already a loadedThirdPartyDomains() > function in WebPage.cpp, so the compiler was unhappy. I will change it to be > const and return const HashSet<RegistrableDomain>& though. I can change the > ForCache name if you have a suggestion.
Maybe we can rename the existing one (which is used for IPC and has a completion handler) to something like: requestLoadedThirdPartyDomains
> > > > Source/WebKit/WebProcess/WebPage/WebPage.h:1219 > > > + void setloadedThirdPartyDomain(WebCore::RegistrableDomain&&, CompletionHandler<void()>&&); > > > > addLoadedThirdPartyDomainForTesting > > > > > Tools/TestWebKitAPI/Tests/WebKitCocoa/ResourceLoadStatistics.mm:1664 > > > + [webView _setloadedThirdPartyDomain:@"example1.com" completionHandler: ^(void) { > > > > I don't even think we need this setter. Why can't you simply actually load > > different domains in the view? At least it would be a real test. Now it is > > half faked. > > See ProcessSwapOnNavigation.mm tests to see how you can load different > > registrable domains in tests. > > Will change.
Kate Cheney
Comment 13
2020-08-19 10:06:40 PDT
(In reply to Sam Weinig from
comment #10
)
> Comment on
attachment 406795
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=406795&action=review
> > > Source/WebCore/history/CachedPage.h:62 > > + Vector<RegistrableDomain>& loadedThirdPartyDomains() { return m_loadedThirdPartyDomains; } > > Can we give this a clearer name? I don't know from looking at this what this > represents?
I would be open to that if you think it is unclear. It represents a list of third party domains that have been loaded on a page via resources/iframes, etc. Other possible ideas: loadedCrossSiteDomains, loadedSubResourceDomains. Let me know if you have other ideas!
Darin Adler
Comment 14
2020-08-19 10:24:20 PDT
(In reply to Chris Dumez from
comment #12
)
> Maybe we can rename the existing one (which is used for IPC and has a > completion handler) to something like: requestLoadedThirdPartyDomains
Or even getXXX. This is part of why we reserve the word get; I think it’s good for completion handler based asynchronous functions as well as ones with out arguments.
Kate Cheney
Comment 15
2020-08-19 11:42:11 PDT
Created
attachment 406862
[details]
Patch
Kate Cheney
Comment 16
2020-08-19 11:52:08 PDT
Created
attachment 406863
[details]
Patch
Chris Dumez
Comment 17
2020-08-19 11:53:03 PDT
Comment on
attachment 406862
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=406862&action=review
> Source/WebCore/loader/FrameLoaderClient.h:378 > + virtual const HashSet<RegistrableDomain> loadedThirdPartyDomains() const { return { }; }
const without & is not useful. This should either return a 'HashSet<RegistrableDomain>' or a 'const HashSet<RegistrableDomain>&'. Likely 'HashSet<RegistrableDomain>' here because of this override and this is not performance sensitive code. Note that maybe FrameLoaderClient::loadedThirdPartyDomains() could return a Vector<RegistrableDomain> (WebPage:: loadedThirdPartyDomains() would keep returning a const HashSet<RegistrableDomain>& though), since we need to make a copy anyway and we end up needing a Vector. Right now we go from HashSet -> HashSet copy -> Vector. Ideally, we'd go from HashSet -> Vector directly.
Kate Cheney
Comment 18
2020-08-19 11:56:39 PDT
(In reply to Chris Dumez from
comment #17
)
> Comment on
attachment 406862
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=406862&action=review
> > > Source/WebCore/loader/FrameLoaderClient.h:378 > > + virtual const HashSet<RegistrableDomain> loadedThirdPartyDomains() const { return { }; } > > const without & is not useful. This should either return a > 'HashSet<RegistrableDomain>' or a 'const HashSet<RegistrableDomain>&'. > Likely 'HashSet<RegistrableDomain>' here because of this override and this > is not performance sensitive code. > Note that maybe FrameLoaderClient::loadedThirdPartyDomains() could return a > Vector<RegistrableDomain> (WebPage:: loadedThirdPartyDomains() would keep > returning a const HashSet<RegistrableDomain>& though), since we need to make > a copy anyway and we end up needing a Vector. > > Right now we go from HashSet -> HashSet copy -> Vector. > Ideally, we'd go from HashSet -> Vector directly.
Ahh smart, I see. Thanks for explaining, will fix.
Kate Cheney
Comment 19
2020-08-19 12:10:00 PDT
Created
attachment 406865
[details]
Patch
Sam Weinig
Comment 20
2020-08-19 13:36:53 PDT
(In reply to katherine_cheney from
comment #13
)
> (In reply to Sam Weinig from
comment #10
) > > Comment on
attachment 406795
[details]
> > Patch > > > > View in context: > >
https://bugs.webkit.org/attachment.cgi?id=406795&action=review
> > > > > Source/WebCore/history/CachedPage.h:62 > > > + Vector<RegistrableDomain>& loadedThirdPartyDomains() { return m_loadedThirdPartyDomains; } > > > > Can we give this a clearer name? I don't know from looking at this what this > > represents? > > I would be open to that if you think it is unclear. It represents a list of > third party domains that have been loaded on a page via resources/iframes, > etc. Other possible ideas: loadedCrossSiteDomains, loadedSubResourceDomains. > Let me know if you have other ideas!
So its the set of domains that the page (including any subframes) has loaded any resources from? Does this include all subresource types? (e.g. iframes, images, scripts, etc?)
Kate Cheney
Comment 21
2020-08-19 13:40:37 PDT
(In reply to Sam Weinig from
comment #20
)
> (In reply to katherine_cheney from
comment #13
) > > (In reply to Sam Weinig from
comment #10
) > > > Comment on
attachment 406795
[details]
> > > Patch > > > > > > View in context: > > >
https://bugs.webkit.org/attachment.cgi?id=406795&action=review
> > > > > > > Source/WebCore/history/CachedPage.h:62 > > > > + Vector<RegistrableDomain>& loadedThirdPartyDomains() { return m_loadedThirdPartyDomains; } > > > > > > Can we give this a clearer name? I don't know from looking at this what this > > > represents? > > > > I would be open to that if you think it is unclear. It represents a list of > > third party domains that have been loaded on a page via resources/iframes, > > etc. Other possible ideas: loadedCrossSiteDomains, loadedSubResourceDomains. > > Let me know if you have other ideas! > > So its the set of domains that the page (including any subframes) has loaded > any resources from? Does this include all subresource types? (e.g. iframes, > images, scripts, etc?)
Yes, as long as the domain is not the same as the first party domain.
Darin Adler
Comment 22
2020-08-19 13:46:55 PDT
I think we really want the word "subresource" in there. (One word, not two words "sub resource".)
Kate Cheney
Comment 23
2020-08-19 13:55:34 PDT
(In reply to Darin Adler from
comment #22
)
> I think we really want the word "subresource" in there. (One word, not two > words "sub resource".)
Ok. Maybe loadedSubresourceDomains, or even just subresourceDomains?
Chris Dumez
Comment 24
2020-08-19 15:16:56 PDT
Comment on
attachment 406865
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=406865&action=review
r=me with nit fix. Please address naming issue raised by Darin & Sam before landing too.
> Source/WebKit/WebProcess/WebPage/WebPage.cpp:6836 > +const HashSet<WebCore::RegistrableDomain>& WebPage::loadedThirdPartyDomains() const
This could be inlined in the header given how trivial it is.
Kate Cheney
Comment 25
2020-08-19 16:54:52 PDT
Created
attachment 406888
[details]
Patch for landing
Kate Cheney
Comment 26
2020-08-19 16:55:08 PDT
This patch changes the name from loadedThirdPartyDomains to loadedSubresourceDomains based on the comments on this thread. Sam or Darin, if you have more thoughts on the name I can post a followup patch.
Darin Adler
Comment 27
2020-08-19 17:21:01 PDT
(In reply to katherine_cheney from
comment #26
)
> This patch changes the name from loadedThirdPartyDomains to > loadedSubresourceDomains based on the comments on this thread. Sam or Darin, > if you have more thoughts on the name I can post a followup patch.
I like that name. I think being explicit about "these are the domains all the subresources are in" but implicit about "but we leave out the first party domain" is the right call. A comment somewhere could state the latter rule if we think someone will be confused about it.
EWS
Comment 28
2020-08-19 17:39:09 PDT
Committed
r265916
: <
https://trac.webkit.org/changeset/265916
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 406888
[details]
.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug