Bug 170763

Summary: Resource Load Statistics: Check both origins and cookieHostNames for domain matches in data removal
Product: WebKit Reporter: John Wilander <wilander>
Component: WebKit2Assignee: John Wilander <wilander>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, beidson, bfulgham, buildbot, commit-queue, rniwa, webkit-bug-importer, wilander, youennf
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=170798
Attachments:
Description Flags
Patch
none
Archive of layout-test-results from ews106 for mac-elcapitan-wk2
none
Patch
none
Patch for landing none

Description John Wilander 2017-04-11 22:26:18 PDT
WebsiteDataRecords either have origins, cookieHostNames, or both depending on their WebsiteDataTypes. We need to check both for a match during data record removal.
Comment 1 Radar WebKit Bug Importer 2017-04-11 22:28:14 PDT
<rdar://problem/31573091>
Comment 2 John Wilander 2017-04-11 22:55:58 PDT
Created attachment 306890 [details]
Patch
Comment 3 Build Bot 2017-04-12 00:13:13 PDT
Comment on attachment 306890 [details]
Patch

Attachment 306890 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/3522314

New failing tests:
webrtc/negotiatedneeded-event-addStream.html
Comment 4 Build Bot 2017-04-12 00:13:14 PDT
Created attachment 306892 [details]
Archive of layout-test-results from ews106 for mac-elcapitan-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews106  Port: mac-elcapitan-wk2  Platform: Mac OS X 10.11.6
Comment 5 youenn fablet 2017-04-12 11:25:44 PDT
(In reply to Build Bot from comment #3)
> Comment on attachment 306890 [details]
> Patch
> 
> Attachment 306890 [details] did not pass mac-wk2-ews (mac-wk2):
> Output: http://webkit-queues.webkit.org/results/3522314
> 
> New failing tests:
> webrtc/negotiatedneeded-event-addStream.html

Crash is unrelated to this patch.
This is a new regression tracked in bug 170754
Comment 6 John Wilander 2017-04-12 18:20:43 PDT
Testing requires https://bugs.webkit.org/show_bug.cgi?id=170798.
Comment 7 Brent Fulgham 2017-04-13 09:32:16 PDT
Comment on attachment 306890 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=306890&action=review

I think this looks good, but we need a WK2 reviewer.

> Source/WebKit2/UIProcess/WebsiteData/WebsiteDataRecord.cpp:120
> +bool WebsiteDataRecord::validForTopPrivatelyControlledDomain(const String& topPrivatelyControlledDomain)

It seems like this could be 'const'.

> Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp:501
> +    fetchData(dataTypes, fetchOptions, [topPrivatelyControlledDomains, completionHandler, this](auto existingDataRecords) {

Since ebsiteDataStore::fetchData does a WTFMove on the records it passes to this completion handler, it seems like "auto existingDataRecords" should really be "auto&& existingDataRecords".

> Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp:507
> +                    matchingDataRecords.append(dataRecord);

Maybe this could be WTFMove'd into matchindDataRecords? Might need to make "auto& dataRecord" -> "auto&& dataRecord"? Not sure if that works.

> Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp:508
> +                    domainsWithMatchingDataRecords.append(topPrivatelyControlledDomain);

Maybe this could be WTFMove'd, too?
Comment 8 John Wilander 2017-04-17 17:48:29 PDT
Created attachment 307325 [details]
Patch
Comment 9 John Wilander 2017-04-17 17:52:26 PDT
Thanks, Brent! I could fix all the things you mentioned except for the last WTFMove of topPrivatelyControlledDomain. I suspect the compiler gets upset because I'm moving an element in the set I'm iterating over but if you can spot a mistake I've made I'm happy to try again I had to introduce move semantics for that vector all the way from the call in WebResourceLoadStatisticsStore::removeDataRecords().
Comment 10 Alex Christensen 2017-04-18 14:41:00 PDT
Comment on attachment 307325 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=307325&action=review

r=me

> Source/WebKit2/UIProcess/WebsiteData/WebsiteDataRecord.cpp:132
> +    for (auto& dataRecordOriginData : origins) {

Can this be const auto&?

> Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp:507
> +                if (dataRecord.validForTopPrivatelyControlledDomain(topPrivatelyControlledDomain)) {
> +                    matchingDataRecords.append(WTFMove(dataRecord));

Maybe matchesTopPrivatelyControlledDomain would be a better name than validForTopPrivatelyControlledDomain.
Comment 11 John Wilander 2017-04-18 17:22:43 PDT
Created attachment 307441 [details]
Patch for landing
Comment 12 WebKit Commit Bot 2017-04-18 18:07:08 PDT
Comment on attachment 307441 [details]
Patch for landing

Clearing flags on attachment: 307441

Committed r215491: <http://trac.webkit.org/changeset/215491>
Comment 13 WebKit Commit Bot 2017-04-18 18:07:09 PDT
All reviewed patches have been landed.  Closing bug.