Bug 236254

Summary: Permit simultaneous Apple Pay and script injection
Product: WebKit Reporter: Devin Rousso <hi>
Component: New BugsAssignee: Devin Rousso <hi>
Status: RESOLVED FIXED    
Severity: Normal CC: aestes, bdakin, cdumez, esprehn+autocc, ews-watchlist, hi, japhet, kangil.han, katherine_cheney, kondapallykalyan, megan_gardner, thorton, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
[fast-cq] Patch
katherine_cheney: review+, hi: commit-queue+
[fast-cq] Patch none

Description Devin Rousso 2022-02-07 13:16:14 PST
.
Comment 1 Devin Rousso 2022-02-07 13:16:31 PST
<rdar://problem/87736727>
Comment 2 Radar WebKit Bug Importer 2022-02-07 13:18:02 PST
<rdar://problem/88590628>
Comment 3 Devin Rousso 2022-02-07 13:19:53 PST
Created attachment 451143 [details]
Patch
Comment 4 Devin Rousso 2022-02-07 13:21:24 PST
<rdar://problem/87736727>
Comment 5 Kate Cheney 2022-02-08 13:42:52 PST
Comment on attachment 451143 [details]
Patch

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

code change looks good, only concern is about dropping the weakThis in PaymentCoordinator::canMakePaymentsWithActiveCard

> Source/WebCore/Modules/applepay/PaymentCoordinator.cpp:69
> +bool PaymentCoordinator::canMakePayments(Document&)

Why keep Document around?

> Source/WebCore/Modules/applepay/PaymentCoordinator.cpp:78
> +    m_client.canMakePaymentsWithActiveCard(merchantIdentifier, document.domain(), [this, completionHandler = WTFMove(completionHandler)](bool canMakePayments) {

Seems like we shouldn't drop weakThis, unless I'm missing something

> Source/WebCore/Modules/applepay/PaymentCoordinatorClient.h:69
>      virtual String userAgentScriptsBlockedErrorMessage() const { return { }; }

I think this can be removed too

> Tools/TestWebKitAPI/Tests/WebKitCocoa/ApplePay.mm:-243
> -TEST(ApplePay, ActiveSessionBlocksUserAgentScripts)

Is there a reason we got rid of the ActiveSession test instead if changing it to ActiveSessionDoesNotBlockUserAgentScripts? Might be useful to include in the ChangeLog if so.

> Tools/TestWebKitAPI/Tests/WebKitCocoa/apple-pay-availability-existing-object.html:17
> +        window.wkPaymentRequest ??= new PaymentRequest([applePayMethod()], applePayDetails);

getting fancy with some nullish coalescing operators :P
Comment 6 Devin Rousso 2022-02-08 14:00:10 PST
Comment on attachment 451143 [details]
Patch

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

>> Source/WebCore/Modules/applepay/PaymentCoordinator.cpp:69
>> +bool PaymentCoordinator::canMakePayments(Document&)
> 
> Why keep Document around?

I figured just in case it was needed in the future (just like how `supportsVersion` has it).  I'll remove it.

>> Source/WebCore/Modules/applepay/PaymentCoordinator.cpp:78
>> +    m_client.canMakePaymentsWithActiveCard(merchantIdentifier, document.domain(), [this, completionHandler = WTFMove(completionHandler)](bool canMakePayments) {
> 
> Seems like we shouldn't drop weakThis, unless I'm missing something

Eh, yeah probably.  The only reason we capture `this` is cause `PAYMENT_COORDINATOR_RELEASE_LOG` uses it, and it just logs the raw pointer value (i.e. location).  Nothing actually dereferences `this` inside here.  But probably couldn't hurt to keep it :)

>> Source/WebCore/Modules/applepay/PaymentCoordinatorClient.h:69
>>      virtual String userAgentScriptsBlockedErrorMessage() const { return { }; }
> 
> I think this can be removed too

Oh oops good catch!

>> Tools/TestWebKitAPI/Tests/WebKitCocoa/ApplePay.mm:-243
>> -TEST(ApplePay, ActiveSessionBlocksUserAgentScripts)
> 
> Is there a reason we got rid of the ActiveSession test instead if changing it to ActiveSessionDoesNotBlockUserAgentScripts? Might be useful to include in the ChangeLog if so.

`apple-pay-active-session.html` only simulated that an active session actually took place (via `Internals.prototype.setApplePayIsActive`).  The rest of the tests actually create an active session, so there's not really a benefit to keeping it (it would basically just be a copy of the other tests).

>> Tools/TestWebKitAPI/Tests/WebKitCocoa/apple-pay-availability-existing-object.html:17
>> +        window.wkPaymentRequest ??= new PaymentRequest([applePayMethod()], applePayDetails);
> 
> getting fancy with some nullish coalescing operators :P

(☞゚ヮ゚)☞
Comment 7 Devin Rousso 2022-02-08 15:15:18 PST
Created attachment 451312 [details]
[fast-cq] Patch
Comment 8 Devin Rousso 2022-02-10 11:17:05 PST
Created attachment 451580 [details]
[fast-cq] Patch
Comment 9 EWS 2022-02-10 14:24:37 PST
Committed r289578 (247095@main): <https://commits.webkit.org/247095@main>

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