Bug 203087 - ApplePaySession should never prevent entering the back/forward cache
Summary: ApplePaySession should never prevent entering the back/forward cache
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Andy Estes
URL:
Keywords: InRadar
Depends on:
Blocks: 202293
  Show dependency treegraph
 
Reported: 2019-10-17 09:40 PDT by Chris Dumez
Modified: 2019-11-05 09:13 PST (History)
8 users (show)

See Also:


Attachments
Patch (14.68 KB, patch)
2019-11-04 20:40 PST, Andy Estes
no flags Details | Formatted Diff | Diff
Patch (10.83 KB, patch)
2019-11-04 21:51 PST, Andy Estes
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2019-10-17 09:40:25 PDT
ApplePaySession should never prevent entering the back/forward cache.
Comment 1 Radar WebKit Bug Importer 2019-10-30 08:20:52 PDT
<rdar://problem/56744401>
Comment 2 Andy Estes 2019-11-04 20:40:21 PST
Created attachment 382805 [details]
Patch
Comment 3 Chris Dumez 2019-11-04 20:52:28 PST
Comment on attachment 382805 [details]
Patch

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

> Source/WebCore/Modules/applepay/ApplePaySession.cpp:831
> +bool ApplePaySession::canSuspendWhileActive() const

I find the naming very confusing. How about something like "needsAbortingOnSuspension" ?

> Source/WebCore/Modules/applepay/ApplePaySession.cpp:838
> +    case State::SuspendedWhileActive:

Do we really need a new state? Why not go directly to canceled?

> Source/WebCore/Modules/applepay/ApplePaySession.cpp:860
> +    // FIXME: Is TaskSource::UserInteraction correct here?

I know but it is not the same spec but UserInteraction is what's used in this spec at least: https://w3c.github.io/payment-request/

> Source/WebCore/Modules/applepay/ApplePaySession.cpp:861
> +    context.eventLoop().queueTask(TaskSource::UserInteraction, context, [this, pendingActivity = makePendingActivity(*this)] {

Why not queue the task in the suspend()? Since you're using the event loop, it would fire until you resume anyway. This way, you don't need a resume() method.

Also, you should consider using ActiveDOMObject::queueTaskKeepingObjectAlive() instead to queue the task.
Comment 4 Chris Dumez 2019-11-04 20:53:28 PST
(In reply to Chris Dumez from comment #3)
> Comment on attachment 382805 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=382805&action=review
> 
> > Source/WebCore/Modules/applepay/ApplePaySession.cpp:831
> > +bool ApplePaySession::canSuspendWhileActive() const
> 
> I find the naming very confusing. How about something like
> "needsAbortingOnSuspension" ?
> 
> > Source/WebCore/Modules/applepay/ApplePaySession.cpp:838
> > +    case State::SuspendedWhileActive:
> 
> Do we really need a new state? Why not go directly to canceled?
> 
> > Source/WebCore/Modules/applepay/ApplePaySession.cpp:860
> > +    // FIXME: Is TaskSource::UserInteraction correct here?
> 
> I know but it is not the same spec but UserInteraction is what's used in
> this spec at least: https://w3c.github.io/payment-request/
> 
> > Source/WebCore/Modules/applepay/ApplePaySession.cpp:861
> > +    context.eventLoop().queueTask(TaskSource::UserInteraction, context, [this, pendingActivity = makePendingActivity(*this)] {
> 
> Why not queue the task in the suspend()? Since you're using the event loop,
> it would fire until you resume anyway. This way, you don't need a resume()
> method.

it would *NOT* fire until you resume anyway
Comment 5 Andy Estes 2019-11-04 21:51:00 PST
Created attachment 382806 [details]
Patch
Comment 6 Chris Dumez 2019-11-05 08:12:51 PST
Comment on attachment 382806 [details]
Patch

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

> Source/WebCore/Modules/applepay/ApplePaySession.cpp:866
> +    queueTaskToDispatchEvent(*this, TaskSource::UserInteraction, ApplePayCancelEvent::create(eventNames().cancelEvent, { }));

nice.
Comment 7 WebKit Commit Bot 2019-11-05 09:13:08 PST
Comment on attachment 382806 [details]
Patch

Clearing flags on attachment: 382806

Committed r252057: <https://trac.webkit.org/changeset/252057>
Comment 8 WebKit Commit Bot 2019-11-05 09:13:10 PST
All reviewed patches have been landed.  Closing bug.