Bug 199755

Summary: SOAuthorizationSession::presentViewController should check WebPageProxy::isClosed()
Product: WebKit Reporter: Jiewen Tan <jiewen_tan>
Component: WebKit2Assignee: Jiewen Tan <jiewen_tan>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, commit-queue, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch none

Description Jiewen Tan 2019-07-12 13:36:31 PDT
Check m_isClosed in WebPageProxy::platformWindow.
Comment 1 Jiewen Tan 2019-07-12 13:36:40 PDT
<rdar://problem/52323585>
Comment 2 Jiewen Tan 2019-07-12 13:40:14 PDT
Created attachment 374031 [details]
Patch
Comment 3 Chris Dumez 2019-07-12 14:14:21 PDT
Comment on attachment 374031 [details]
Patch

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

> Source/WebKit/UIProcess/mac/WebPageProxyMac.mm:640
> +    if (m_isClosed)

I would instead update this check in SSO code:
if (!m_page || m_viewController) {
        uiCallback(NO, adoptNS([[NSError alloc] initWithDomain:SOErrorDomain code:kSOErrorAuthorizationPresentationFailed userInfo:nil]).get());
        return;
    }

->

if (!m_page || m_page->isClosed() || m_viewController) {
        uiCallback(NO, adoptNS([[NSError alloc] initWithDomain:SOErrorDomain code:kSOErrorAuthorizationPresentationFailed userInfo:nil]).get());
        return;
    }
Comment 4 Chris Dumez 2019-07-12 14:33:04 PDT
(In reply to Chris Dumez from comment #3)
> Comment on attachment 374031 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=374031&action=review
> 
> > Source/WebKit/UIProcess/mac/WebPageProxyMac.mm:640
> > +    if (m_isClosed)
> 
> I would instead update this check in SSO code:
> if (!m_page || m_viewController) {
>         uiCallback(NO, adoptNS([[NSError alloc] initWithDomain:SOErrorDomain
> code:kSOErrorAuthorizationPresentationFailed userInfo:nil]).get());
>         return;
>     }
> 
> ->
> 
> if (!m_page || m_page->isClosed() || m_viewController) {
>         uiCallback(NO, adoptNS([[NSError alloc] initWithDomain:SOErrorDomain
> code:kSOErrorAuthorizationPresentationFailed userInfo:nil]).get());
>         return;
>     }

Also, do we have API testing for SSO? If so, it'd be good to have a test that starts an SSO request then calls _close on the webView right away.
Comment 5 Jiewen Tan 2019-07-12 15:05:06 PDT
Comment on attachment 374031 [details]
Patch

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

Thanks Chris for reviewing the patch.

>>> Source/WebKit/UIProcess/mac/WebPageProxyMac.mm:640
>>> +    if (m_isClosed)
>> 
>> I would instead update this check in SSO code:
>> if (!m_page || m_viewController) {
>>         uiCallback(NO, adoptNS([[NSError alloc] initWithDomain:SOErrorDomain code:kSOErrorAuthorizationPresentationFailed userInfo:nil]).get());
>>         return;
>>     }
>> 
>> ->
>> 
>> if (!m_page || m_page->isClosed() || m_viewController) {
>>         uiCallback(NO, adoptNS([[NSError alloc] initWithDomain:SOErrorDomain code:kSOErrorAuthorizationPresentationFailed userInfo:nil]).get());
>>         return;
>>     }
> 
> Also, do we have API testing for SSO? If so, it'd be good to have a test that starts an SSO request then calls _close on the webView right away.

Sure thing. However, it still feels weird that caller of m_page->platformWindow() needs to check m_page->isClosed(). SSO tests are all API tests which should be able to reproduce what you suggest. Let me try.
Comment 6 Jiewen Tan 2019-07-12 15:54:36 PDT
Created attachment 374045 [details]
Patch
Comment 7 Chris Dumez 2019-07-12 16:03:14 PDT
Comment on attachment 374045 [details]
Patch

r=me
Comment 8 Jiewen Tan 2019-07-12 16:08:07 PDT
(In reply to Chris Dumez from comment #7)
> Comment on attachment 374045 [details]
> Patch
> 
> r=me

Thanks, Chris.
Comment 9 WebKit Commit Bot 2019-07-12 17:53:36 PDT
Comment on attachment 374045 [details]
Patch

Clearing flags on attachment: 374045

Committed r247410: <https://trac.webkit.org/changeset/247410>
Comment 10 WebKit Commit Bot 2019-07-12 17:53:37 PDT
All reviewed patches have been landed.  Closing bug.