Bug 229204 - PCM: Allow measurement of links in nested, cross-site iframes
Summary: PCM: Allow measurement of links in nested, cross-site iframes
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: Safari 14
Hardware: All All
: P2 Normal
Assignee: John Wilander
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-08-17 14:43 PDT by Pranay Prabhat
Modified: 2021-10-05 17:46 PDT (History)
8 users (show)

See Also:


Attachments
Patch (10.25 KB, patch)
2021-10-04 15:21 PDT, John Wilander
no flags Details | Formatted Diff | Diff
Patch (10.14 KB, patch)
2021-10-04 16:38 PDT, John Wilander
no flags Details | Formatted Diff | Diff
Patch (10.29 KB, patch)
2021-10-05 07:58 PDT, John Wilander
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pranay Prabhat 2021-08-17 14:43:04 PDT
https://github.com/privacycg/private-click-measurement/issues/7 has highlighted the needs but for majority of publishers , ads are rendered in a secondary domain usually rendered by Google Ad Manager. PCM's click based anchor tags within secondary domain need to be propagated to publisher context in order to register the click for conversion reporting.
Comment 1 Radar WebKit Bug Importer 2021-08-24 14:44:54 PDT
<rdar://problem/82310386>
Comment 2 John Wilander 2021-10-04 15:21:04 PDT
Created attachment 440110 [details]
Patch
Comment 3 Alex Christensen 2021-10-04 15:28:29 PDT
Comment on attachment 440110 [details]
Patch

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

> Source/WebCore/html/HTMLAnchorElement.cpp:446
> +    if (frame->isMainFrame())
> +        mainDocumentRegistrableDomain = RegistrableDomain { document().url() };
> +    else if (auto mainDocument = frame->mainFrame().document())
> +        mainDocumentRegistrableDomain = RegistrableDomain { mainDocument->url() };

I think you can simplify this because Frame::mainFrame() returns itself if it's the main frame.
Comment 4 John Wilander 2021-10-04 15:35:04 PDT
(In reply to Alex Christensen from comment #3)
> Comment on attachment 440110 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=440110&action=review
> 
> > Source/WebCore/html/HTMLAnchorElement.cpp:446
> > +    if (frame->isMainFrame())
> > +        mainDocumentRegistrableDomain = RegistrableDomain { document().url() };
> > +    else if (auto mainDocument = frame->mainFrame().document())
> > +        mainDocumentRegistrableDomain = RegistrableDomain { mainDocument->url() };
> 
> I think you can simplify this because Frame::mainFrame() returns itself if
> it's the main frame.

Thanks! Will fix before landing.
Comment 5 Chris Dumez 2021-10-04 15:36:16 PDT
Comment on attachment 440110 [details]
Patch

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

>>> Source/WebCore/html/HTMLAnchorElement.cpp:446
>>> +        mainDocumentRegistrableDomain = RegistrableDomain { mainDocument->url() };
>> 
>> I think you can simplify this because Frame::mainFrame() returns itself if it's the main frame.
> 
> Thanks! Will fix before landing.

You don't even need frames, document().topDocument().url()
Comment 6 John Wilander 2021-10-04 16:26:03 PDT
(In reply to Chris Dumez from comment #5)
> Comment on attachment 440110 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=440110&action=review
> 
> >>> Source/WebCore/html/HTMLAnchorElement.cpp:446
> >>> +        mainDocumentRegistrableDomain = RegistrableDomain { mainDocument->url() };
> >> 
> >> I think you can simplify this because Frame::mainFrame() returns itself if it's the main frame.
> > 
> > Thanks! Will fix before landing.
> 
> You don't even need frames, document().topDocument().url()

I looked at the implementation of topDocument() and this part has me worried about potential misuse vectors:

if (backForwardCacheState() == NotInBackForwardCache && !m_renderTreeBeingDestroyed) {
    if (!m_frame)
        return const_cast<Document&>(*this);
    // This should always be non-null.
    Document* mainFrameDocument = m_frame->mainFrame().document();
    return mainFrameDocument ? *mainFrameDocument : const_cast<Document&>(*this);
}

I'll go with if (auto mainDocument = frame->mainFrame().document()).
Comment 7 John Wilander 2021-10-04 16:38:41 PDT
Created attachment 440122 [details]
Patch
Comment 8 John Wilander 2021-10-05 07:58:52 PDT
Created attachment 440215 [details]
Patch
Comment 9 John Wilander 2021-10-05 07:59:20 PDT
Fixed test for iOS.
Comment 10 EWS 2021-10-05 17:46:50 PDT
Committed r283593 (242549@main): <https://commits.webkit.org/242549@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 440215 [details].