Bug 267623

Summary: Quirks.cpp: Fix and extend domain method
Product: WebKit Reporter: Karl Dubost <karlcow>
Component: WebKit Misc.Assignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: annevk, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari 17   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=260938
https://bugs.webkit.org/show_bug.cgi?id=267569
Bug Depends on:    
Bug Blocks: 258603    

Description Karl Dubost 2024-01-16 23:45:19 PST
bool Quirks::isDomain(const String& domainString) const
{
    return RegistrableDomain(m_document->topDocument().url()).string() == domainString;
}

was added with 
Bug 260938
https://github.com/WebKit/WebKit/pull/17329

but it broke at least one Quirk Bug 267569

Indeed 
Quirks::isDomain("www.example.com") will return false
Quirks::isDomain("example.com") will return true

because RegistrableDomain(m_document->topDocument().url()).string()
returns only the top domain.

So probably we need something along

Quirks::isFullDomain("www.example.com") matches only www.example.com
Quirks::isTopDomain("example.com")      matches only example.com

And maybe something along 
Quirks::isSubDomain("example.com") matching everything *.example.com

Real names to be determined.
Comment 1 Anne van Kesteren 2024-01-17 05:43:39 PST
isDomain should be renamed to isRegistrableDomain or maybe even topLevelDocumentRegistrableDomainIs.

However it's not clear you want isRegistrableDomain to begin with here. After all, it can lead to bug 267569 happening. I would expect these to be useful:

- topLevelDocumentDomainIs
- topLevelDocumentDomainIsSubDomainOf / topLevelDocumentDomainEndsWith
Comment 2 Radar WebKit Bug Importer 2024-01-23 23:46:14 PST
<rdar://problem/121499128>