<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[279305] trunk/Source/WebKit</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/279305">279305</a></dd>
<dt>Author</dt> <dd>bfulgham@apple.com</dd>
<dt>Date</dt> <dd>2021-06-25 18:47:28 -0700 (Fri, 25 Jun 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>[macOS] Add logging and clean up AppSSO flows
https://bugs.webkit.org/show_bug.cgi?id=227379

Reviewed by Kate Cheney.

This patch adds detailed logging to understand the flows through the AppSSO authentication code,
and adds clean-up code in more places to ensure that the modal sheet used by AppSSO is dismissed
in cases where the authentication has completed (or failed).

* UIProcess/Cocoa/SOAuthorization/NavigationSOAuthorizationSession.mm:
(WebKit::NavigationSOAuthorizationSession::shouldStartInternal): Adds new logging.
(WebKit::NavigationSOAuthorizationSession::webViewDidMoveToWindow): Ditto.
(WebKit::NavigationSOAuthorizationSession::pageActiveURLDidChangeDuringWaiting const): Ditto.
* UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.mm:
(WebKit::PopUpSOAuthorizationSession::shouldStartInternal): Adds new logging.
(WebKit::PopUpSOAuthorizationSession::fallBackToWebPathInternal): Ditto.
(WebKit::PopUpSOAuthorizationSession::abortInternal): Ditto.
(WebKit::PopUpSOAuthorizationSession::completeInternal): Ditto.
(WebKit::PopUpSOAuthorizationSession::close): Ditto.
(WebKit::PopUpSOAuthorizationSession::initSecretWebView): Ditto.
* UIProcess/Cocoa/SOAuthorization/RedirectSOAuthorizationSession.mm:
(WebKit::RedirectSOAuthorizationSession::fallBackToWebPathInternal): Adds new logging.
(WebKit::RedirectSOAuthorizationSession::abortInternal): Ditto.
(WebKit::RedirectSOAuthorizationSession::completeInternal): Ditto.
(WebKit::RedirectSOAuthorizationSession::beforeStart): Ditto.
* UIProcess/Cocoa/SOAuthorization/SOAuthorizationCoordinator.mm:
(WebKit::SOAuthorizationCoordinator::tryAuthorize): Adds new logging.
* UIProcess/Cocoa/SOAuthorization/SOAuthorizationSession.h:
* UIProcess/Cocoa/SOAuthorization/SOAuthorizationSession.mm:
(WebKit::SOAuthorizationSession::stateString const): Added.
(WebKit::SOAuthorizationSession::~SOAuthorizationSession): Add new logging, and ensure modal sheet is dismissed.
(WebKit::SOAuthorizationSession::becomeCompleted): Added new logging.
(WebKit::SOAuthorizationSession::shouldStart): Ditto.
(WebKit::SOAuthorizationSession::start): Ditto.
(WebKit::SOAuthorizationSession::continueStartAfterGetAuthorizationHints): Ditto.
(WebKit::SOAuthorizationSession::continueStartAfterDecidePolicy): Ditto.
(WebKit::SOAuthorizationSession::fallBackToWebPath): Add new logging, and ensure modal sheet is dismissed.
(WebKit::SOAuthorizationSession::abort): Ditto.
(WebKit::SOAuthorizationSession::complete): Ditto.
(WebKit::SOAuthorizationSession::presentViewController): Added new logging, and dismiss modal if an existing
view is in place.
(WebKit::SOAuthorizationSession::dismissModalSheetIfNecessary): Added.
(WebKit::SOAuthorizationSession::dismissViewController): Use new helper function.
* UIProcess/Cocoa/SOAuthorization/SubFrameSOAuthorizationSession.mm:
(WebKit::SubFrameSOAuthorizationSession::fallBackToWebPathInternal): Adds new logging.
(WebKit::SubFrameSOAuthorizationSession::abortInternal): Ditto.
(WebKit::SubFrameSOAuthorizationSession::completeInternal): Ditto.
(WebKit::SubFrameSOAuthorizationSession::beforeStart): Ditto.
(WebKit::SubFrameSOAuthorizationSession::didFinishLoad): Ditto.
(WebKit::SubFrameSOAuthorizationSession::loadRequestToFrame): Ditto.
* UIProcess/Cocoa/SOAuthorization/WKSOAuthorizationDelegate.mm:
(-[WKSOAuthorizationDelegate authorization:presentViewController:withCompletion:]): Adds new logging.
(-[WKSOAuthorizationDelegate authorizationDidNotHandle:]): Ditto.
(-[WKSOAuthorizationDelegate authorizationDidCancel:]): Ditto.
(-[WKSOAuthorizationDelegate authorizationDidComplete:]): Ditto.
(-[WKSOAuthorizationDelegate authorization:didCompleteWithHTTPAuthorizationHeaders:]): Ditto.
(-[WKSOAuthorizationDelegate authorization:didCompleteWithHTTPResponse:httpBody:]): Ditto.
(-[WKSOAuthorizationDelegate authorization:didCompleteWithError:]): Ditto.
(-[WKSOAuthorizationDelegate setSession:]): Ditto.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitUIProcessCocoaSOAuthorizationNavigationSOAuthorizationSessionmm">trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/NavigationSOAuthorizationSession.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessCocoaSOAuthorizationPopUpSOAuthorizationSessionmm">trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessCocoaSOAuthorizationRedirectSOAuthorizationSessionmm">trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/RedirectSOAuthorizationSession.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessCocoaSOAuthorizationSOAuthorizationCoordinatormm">trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/SOAuthorizationCoordinator.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessCocoaSOAuthorizationSOAuthorizationSessionh">trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/SOAuthorizationSession.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessCocoaSOAuthorizationSOAuthorizationSessionmm">trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/SOAuthorizationSession.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessCocoaSOAuthorizationSubFrameSOAuthorizationSessionmm">trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/SubFrameSOAuthorizationSession.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessCocoaSOAuthorizationWKSOAuthorizationDelegatemm">trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/WKSOAuthorizationDelegate.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (279304 => 279305)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2021-06-26 00:49:17 UTC (rev 279304)
+++ trunk/Source/WebKit/ChangeLog       2021-06-26 01:47:28 UTC (rev 279305)
</span><span class="lines">@@ -1,3 +1,65 @@
</span><ins>+2021-06-25  Brent Fulgham  <bfulgham@apple.com>
+
+        [macOS] Add logging and clean up AppSSO flows 
+        https://bugs.webkit.org/show_bug.cgi?id=227379
+
+        Reviewed by Kate Cheney.
+
+        This patch adds detailed logging to understand the flows through the AppSSO authentication code,
+        and adds clean-up code in more places to ensure that the modal sheet used by AppSSO is dismissed
+        in cases where the authentication has completed (or failed).
+
+        * UIProcess/Cocoa/SOAuthorization/NavigationSOAuthorizationSession.mm:
+        (WebKit::NavigationSOAuthorizationSession::shouldStartInternal): Adds new logging.
+        (WebKit::NavigationSOAuthorizationSession::webViewDidMoveToWindow): Ditto.
+        (WebKit::NavigationSOAuthorizationSession::pageActiveURLDidChangeDuringWaiting const): Ditto.
+        * UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.mm:
+        (WebKit::PopUpSOAuthorizationSession::shouldStartInternal): Adds new logging.
+        (WebKit::PopUpSOAuthorizationSession::fallBackToWebPathInternal): Ditto.
+        (WebKit::PopUpSOAuthorizationSession::abortInternal): Ditto.
+        (WebKit::PopUpSOAuthorizationSession::completeInternal): Ditto.
+        (WebKit::PopUpSOAuthorizationSession::close): Ditto.
+        (WebKit::PopUpSOAuthorizationSession::initSecretWebView): Ditto.
+        * UIProcess/Cocoa/SOAuthorization/RedirectSOAuthorizationSession.mm:
+        (WebKit::RedirectSOAuthorizationSession::fallBackToWebPathInternal): Adds new logging.
+        (WebKit::RedirectSOAuthorizationSession::abortInternal): Ditto.
+        (WebKit::RedirectSOAuthorizationSession::completeInternal): Ditto.
+        (WebKit::RedirectSOAuthorizationSession::beforeStart): Ditto.
+        * UIProcess/Cocoa/SOAuthorization/SOAuthorizationCoordinator.mm:
+        (WebKit::SOAuthorizationCoordinator::tryAuthorize): Adds new logging.
+        * UIProcess/Cocoa/SOAuthorization/SOAuthorizationSession.h:
+        * UIProcess/Cocoa/SOAuthorization/SOAuthorizationSession.mm:
+        (WebKit::SOAuthorizationSession::stateString const): Added.
+        (WebKit::SOAuthorizationSession::~SOAuthorizationSession): Add new logging, and ensure modal sheet is dismissed.
+        (WebKit::SOAuthorizationSession::becomeCompleted): Added new logging.
+        (WebKit::SOAuthorizationSession::shouldStart): Ditto.
+        (WebKit::SOAuthorizationSession::start): Ditto.
+        (WebKit::SOAuthorizationSession::continueStartAfterGetAuthorizationHints): Ditto.
+        (WebKit::SOAuthorizationSession::continueStartAfterDecidePolicy): Ditto.
+        (WebKit::SOAuthorizationSession::fallBackToWebPath): Add new logging, and ensure modal sheet is dismissed.
+        (WebKit::SOAuthorizationSession::abort): Ditto.
+        (WebKit::SOAuthorizationSession::complete): Ditto.
+        (WebKit::SOAuthorizationSession::presentViewController): Added new logging, and dismiss modal if an existing
+        view is in place.
+        (WebKit::SOAuthorizationSession::dismissModalSheetIfNecessary): Added.
+        (WebKit::SOAuthorizationSession::dismissViewController): Use new helper function.
+        * UIProcess/Cocoa/SOAuthorization/SubFrameSOAuthorizationSession.mm:
+        (WebKit::SubFrameSOAuthorizationSession::fallBackToWebPathInternal): Adds new logging.
+        (WebKit::SubFrameSOAuthorizationSession::abortInternal): Ditto.
+        (WebKit::SubFrameSOAuthorizationSession::completeInternal): Ditto.
+        (WebKit::SubFrameSOAuthorizationSession::beforeStart): Ditto.
+        (WebKit::SubFrameSOAuthorizationSession::didFinishLoad): Ditto.
+        (WebKit::SubFrameSOAuthorizationSession::loadRequestToFrame): Ditto.
+        * UIProcess/Cocoa/SOAuthorization/WKSOAuthorizationDelegate.mm:
+        (-[WKSOAuthorizationDelegate authorization:presentViewController:withCompletion:]): Adds new logging.
+        (-[WKSOAuthorizationDelegate authorizationDidNotHandle:]): Ditto.
+        (-[WKSOAuthorizationDelegate authorizationDidCancel:]): Ditto.
+        (-[WKSOAuthorizationDelegate authorizationDidComplete:]): Ditto.
+        (-[WKSOAuthorizationDelegate authorization:didCompleteWithHTTPAuthorizationHeaders:]): Ditto.
+        (-[WKSOAuthorizationDelegate authorization:didCompleteWithHTTPResponse:httpBody:]): Ditto.
+        (-[WKSOAuthorizationDelegate authorization:didCompleteWithError:]): Ditto.
+        (-[WKSOAuthorizationDelegate setSession:]): Ditto.
+
</ins><span class="cx"> 2021-06-25  Wenson Hsieh  <wenson_hsieh@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [iOS] Web process sometimes crashes under findDataDetectionResultElementInImageOverlay
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessCocoaSOAuthorizationNavigationSOAuthorizationSessionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/NavigationSOAuthorizationSession.mm (279304 => 279305)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/NavigationSOAuthorizationSession.mm  2021-06-26 00:49:17 UTC (rev 279304)
+++ trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/NavigationSOAuthorizationSession.mm     2021-06-26 01:47:28 UTC (rev 279305)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2019 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2019-2021 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -31,6 +31,8 @@
</span><span class="cx"> #import "WebPageProxy.h"
</span><span class="cx"> #import <WebCore/ResourceResponse.h>
</span><span class="cx"> 
</span><ins>+#define AUTHORIZATIONSESSION_RELEASE_LOG(fmt, ...) RELEASE_LOG(AppSSO, "%p - [InitiatingAction=%s][State=%s] NavigationSOAuthorizationSession::" fmt, this, initiatingActionString(), stateString(), ##__VA_ARGS__)
+
</ins><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="cx"> NavigationSOAuthorizationSession::NavigationSOAuthorizationSession(SOAuthorization *soAuthorization, Ref<API::NavigationAction>&& navigationAction, WebPageProxy& page, InitiatingAction action, Callback&& completionHandler)
</span><span class="lines">@@ -49,6 +51,8 @@
</span><span class="cx"> 
</span><span class="cx"> void NavigationSOAuthorizationSession::shouldStartInternal()
</span><span class="cx"> {
</span><ins>+    AUTHORIZATIONSESSION_RELEASE_LOG("shouldStartInternal: m_page=%p", page());
+
</ins><span class="cx">     auto* page = this->page();
</span><span class="cx">     ASSERT(page);
</span><span class="cx">     beforeStart();
</span><span class="lines">@@ -64,6 +68,7 @@
</span><span class="cx"> 
</span><span class="cx"> void NavigationSOAuthorizationSession::webViewDidMoveToWindow()
</span><span class="cx"> {
</span><ins>+    AUTHORIZATIONSESSION_RELEASE_LOG("webViewDidMoveToWindow");
</ins><span class="cx">     auto* page = this->page();
</span><span class="cx">     if (state() != State::Waiting || !page || !page->isInWindow())
</span><span class="cx">         return;
</span><span class="lines">@@ -78,6 +83,7 @@
</span><span class="cx"> 
</span><span class="cx"> bool NavigationSOAuthorizationSession::pageActiveURLDidChangeDuringWaiting() const
</span><span class="cx"> {
</span><ins>+    AUTHORIZATIONSESSION_RELEASE_LOG("pageActiveURLDidChangeDuringWaiting");
</ins><span class="cx">     auto* page = this->page();
</span><span class="cx">     return !page || page->pageLoadState().activeURL() != m_waitingPageActiveURL;
</span><span class="cx"> }
</span><span class="lines">@@ -84,4 +90,6 @@
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span><span class="cx"> 
</span><ins>+#undef AUTHORIZATIONSESSION_RELEASE_LOG
+
</ins><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessCocoaSOAuthorizationPopUpSOAuthorizationSessionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.mm (279304 => 279305)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.mm       2021-06-26 00:49:17 UTC (rev 279304)
+++ trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.mm  2021-06-26 01:47:28 UTC (rev 279305)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2019 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2019-2021 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -89,6 +89,8 @@
</span><span class="cx"> 
</span><span class="cx"> @end
</span><span class="cx"> 
</span><ins>+#define AUTHORIZATIONSESSION_RELEASE_LOG(fmt, ...) RELEASE_LOG(AppSSO, "%p - [InitiatingAction=%s][State=%s] PopUpSOAuthorizationSession::" fmt, this, initiatingActionString(), stateString(), ##__VA_ARGS__)
+
</ins><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="cx"> Ref<SOAuthorizationSession> PopUpSOAuthorizationSession::create(SOAuthorization *soAuthorization, WebPageProxy& page, Ref<API::NavigationAction>&& navigationAction, NewPageCallback&& newPageCallback, UIClientCallback&& uiClientCallback)
</span><span class="lines">@@ -112,6 +114,7 @@
</span><span class="cx"> 
</span><span class="cx"> void PopUpSOAuthorizationSession::shouldStartInternal()
</span><span class="cx"> {
</span><ins>+    AUTHORIZATIONSESSION_RELEASE_LOG("shouldStartInternal: m_page=%p", page());
</ins><span class="cx">     ASSERT(page() && page()->isInWindow());
</span><span class="cx">     start();
</span><span class="cx"> }
</span><span class="lines">@@ -118,11 +121,13 @@
</span><span class="cx"> 
</span><span class="cx"> void PopUpSOAuthorizationSession::fallBackToWebPathInternal()
</span><span class="cx"> {
</span><ins>+    AUTHORIZATIONSESSION_RELEASE_LOG("fallBackToWebPathInternal");
</ins><span class="cx">     m_uiClientCallback(releaseNavigationAction(), WTFMove(m_newPageCallback));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PopUpSOAuthorizationSession::abortInternal()
</span><span class="cx"> {
</span><ins>+    AUTHORIZATIONSESSION_RELEASE_LOG("abortInternal: m_page=%p", page());
</ins><span class="cx">     if (!page()) {
</span><span class="cx">         m_newPageCallback(nullptr);
</span><span class="cx">         return;
</span><span class="lines">@@ -140,6 +145,7 @@
</span><span class="cx"> 
</span><span class="cx"> void PopUpSOAuthorizationSession::completeInternal(const WebCore::ResourceResponse& response, NSData *data)
</span><span class="cx"> {
</span><ins>+    AUTHORIZATIONSESSION_RELEASE_LOG("completeInternal: httpState=%d", response.httpStatusCode());
</ins><span class="cx">     if (response.httpStatusCode() != 200 || !page()) {
</span><span class="cx">         fallBackToWebPathInternal();
</span><span class="cx">         return;
</span><span class="lines">@@ -157,6 +163,7 @@
</span><span class="cx"> 
</span><span class="cx"> void PopUpSOAuthorizationSession::close(WKWebView *webView)
</span><span class="cx"> {
</span><ins>+    AUTHORIZATIONSESSION_RELEASE_LOG("close");
</ins><span class="cx">     if (!m_secretWebView)
</span><span class="cx">         return;
</span><span class="cx">     if (state() != State::Completed || webView != m_secretWebView.get()) {
</span><span class="lines">@@ -169,6 +176,7 @@
</span><span class="cx"> 
</span><span class="cx"> void PopUpSOAuthorizationSession::initSecretWebView()
</span><span class="cx"> {
</span><ins>+    AUTHORIZATIONSESSION_RELEASE_LOG("initSecretWebView");
</ins><span class="cx">     ASSERT(page());
</span><span class="cx">     auto initiatorWebView = page()->cocoaView();
</span><span class="cx">     if (!initiatorWebView)
</span><span class="lines">@@ -187,4 +195,6 @@
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span><span class="cx"> 
</span><ins>+#undef AUTHORIZATIONSESSION_RELEASE_LOG
+
</ins><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessCocoaSOAuthorizationRedirectSOAuthorizationSessionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/RedirectSOAuthorizationSession.mm (279304 => 279305)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/RedirectSOAuthorizationSession.mm    2021-06-26 00:49:17 UTC (rev 279304)
+++ trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/RedirectSOAuthorizationSession.mm       2021-06-26 01:47:28 UTC (rev 279305)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2019 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2019-2021 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -33,6 +33,8 @@
</span><span class="cx"> #import "WebPageProxy.h"
</span><span class="cx"> #import <WebCore/ResourceResponse.h>
</span><span class="cx"> 
</span><ins>+#define AUTHORIZATIONSESSION_RELEASE_LOG(fmt, ...) RELEASE_LOG(AppSSO, "%p - [InitiatingAction=%s][State=%s] RedirectSOAuthorizationSession::" fmt, this, initiatingActionString(), stateString(), ##__VA_ARGS__)
+
</ins><span class="cx"> namespace WebKit {
</span><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><span class="lines">@@ -48,20 +50,25 @@
</span><span class="cx"> 
</span><span class="cx"> void RedirectSOAuthorizationSession::fallBackToWebPathInternal()
</span><span class="cx"> {
</span><ins>+    AUTHORIZATIONSESSION_RELEASE_LOG("fallBackToWebPathInternal: navigationAction=%p", navigationAction());
</ins><span class="cx">     invokeCallback(false);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RedirectSOAuthorizationSession::abortInternal()
</span><span class="cx"> {
</span><ins>+    AUTHORIZATIONSESSION_RELEASE_LOG("abortInternal");
</ins><span class="cx">     invokeCallback(true);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RedirectSOAuthorizationSession::completeInternal(const ResourceResponse& response, NSData *data)
</span><span class="cx"> {
</span><ins>+    AUTHORIZATIONSESSION_RELEASE_LOG("completeInternal: httpState=%d, navigationAction=%p", response.httpStatusCode(), navigationAction());
+
</ins><span class="cx">     auto* navigationAction = this->navigationAction();
</span><span class="cx">     ASSERT(navigationAction);
</span><span class="cx">     auto* page = this->page();
</span><span class="cx">     if ((response.httpStatusCode() != 302 && response.httpStatusCode() != 200) || !page) {
</span><ins>+        AUTHORIZATIONSESSION_RELEASE_LOG("completeInternal: httpState=%d page=%d, so falling back to web path.", response.httpStatusCode(), !!page);
</ins><span class="cx">         fallBackToWebPathInternal();
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="lines">@@ -92,8 +99,11 @@
</span><span class="cx"> 
</span><span class="cx"> void RedirectSOAuthorizationSession::beforeStart()
</span><span class="cx"> {
</span><ins>+    AUTHORIZATIONSESSION_RELEASE_LOG("beforeStart");
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span><span class="cx"> 
</span><ins>+#undef AUTHORIZATIONSESSION_RELEASE_LOG
+
</ins><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessCocoaSOAuthorizationSOAuthorizationCoordinatormm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/SOAuthorizationCoordinator.mm (279304 => 279305)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/SOAuthorizationCoordinator.mm        2021-06-26 00:49:17 UTC (rev 279304)
+++ trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/SOAuthorizationCoordinator.mm   2021-06-26 01:47:28 UTC (rev 279305)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2019 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2019-2021 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -41,6 +41,8 @@
</span><span class="cx"> #import <pal/spi/cocoa/AuthKitSPI.h>
</span><span class="cx"> #import <wtf/Function.h>
</span><span class="cx"> 
</span><ins>+#define AUTHORIZATIONCOORDINATOR_RELEASE_LOG(fmt, ...) RELEASE_LOG(AppSSO, "%p - SOAuthorizationCoordinator::" fmt, this, ##__VA_ARGS__)
+
</ins><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="cx"> SOAuthorizationCoordinator::SOAuthorizationCoordinator()
</span><span class="lines">@@ -63,7 +65,9 @@
</span><span class="cx"> 
</span><span class="cx"> void SOAuthorizationCoordinator::tryAuthorize(Ref<API::NavigationAction>&& navigationAction, WebPageProxy& page, Function<void(bool)>&& completionHandler)
</span><span class="cx"> {
</span><ins>+    AUTHORIZATIONCOORDINATOR_RELEASE_LOG("tryAuthorize");
</ins><span class="cx">     if (!canAuthorize(navigationAction->request().url())) {
</span><ins>+        AUTHORIZATIONCOORDINATOR_RELEASE_LOG("tryAuthorize: Cannot authorize the requested URL.");
</ins><span class="cx">         completionHandler(false);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="lines">@@ -72,6 +76,7 @@
</span><span class="cx">     auto* targetFrame = navigationAction->targetFrame();
</span><span class="cx">     bool subframeNavigation = targetFrame && !targetFrame->isMainFrame();
</span><span class="cx">     if (subframeNavigation && (!page.mainFrame() || ![AKAuthorizationController isURLFromAppleOwnedDomain:page.mainFrame()->url()])) {
</span><ins>+        AUTHORIZATIONCOORDINATOR_RELEASE_LOG("tryAuthorize: Attempting to perform subframe navigation for non-Apple authorization URL.");
</ins><span class="cx">         completionHandler(false);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="lines">@@ -82,8 +87,10 @@
</span><span class="cx"> 
</span><span class="cx"> void SOAuthorizationCoordinator::tryAuthorize(Ref<API::NavigationAction>&& navigationAction, WebPageProxy& page, NewPageCallback&& newPageCallback, UIClientCallback&& uiClientCallback)
</span><span class="cx"> {
</span><ins>+    AUTHORIZATIONCOORDINATOR_RELEASE_LOG("tryAuthorize (2)");
</ins><span class="cx">     bool subframeNavigation = navigationAction->sourceFrame() && !navigationAction->sourceFrame()->isMainFrame();
</span><span class="cx">     if (subframeNavigation || !navigationAction->isProcessingUserGesture() || !canAuthorize(navigationAction->request().url())) {
</span><ins>+        AUTHORIZATIONCOORDINATOR_RELEASE_LOG("tryAuthorize (2): Attempting to perform invalid auth.");
</ins><span class="cx">         uiClientCallback(WTFMove(navigationAction), WTFMove(newPageCallback));
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="lines">@@ -94,4 +101,6 @@
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span><span class="cx"> 
</span><ins>+#undef AUTHORIZATIONCOORDINATOR_RELEASE_LOG
+
</ins><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessCocoaSOAuthorizationSOAuthorizationSessionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/SOAuthorizationSession.h (279304 => 279305)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/SOAuthorizationSession.h     2021-06-26 00:49:17 UTC (rev 279304)
+++ trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/SOAuthorizationSession.h        2021-06-26 01:47:28 UTC (rev 279305)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2019 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2019-2021 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -92,6 +92,8 @@
</span><span class="cx">     void start();
</span><span class="cx">     WebPageProxy* page() const { return m_page.get(); }
</span><span class="cx">     State state() const { return m_state; }
</span><ins>+    const char* stateString() const;
+    const char* initiatingActionString() const;
</ins><span class="cx">     void setState(State state) { m_state = state; }
</span><span class="cx">     const API::NavigationAction* navigationAction() { return m_navigationAction.get(); }
</span><span class="cx">     Ref<API::NavigationAction> releaseNavigationAction();
</span><span class="lines">@@ -104,6 +106,9 @@
</span><span class="cx"> 
</span><span class="cx">     void becomeCompleted();
</span><span class="cx">     void dismissViewController();
</span><ins>+#if PLATFORM(MAC)
+    void dismissModalSheetIfNecessary();
+#endif
</ins><span class="cx">     void continueStartAfterGetAuthorizationHints(const String&);
</span><span class="cx">     void continueStartAfterDecidePolicy(const SOAuthorizationLoadPolicy&);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessCocoaSOAuthorizationSOAuthorizationSessionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/SOAuthorizationSession.mm (279304 => 279305)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/SOAuthorizationSession.mm    2021-06-26 00:49:17 UTC (rev 279304)
+++ trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/SOAuthorizationSession.mm       2021-06-26 01:47:28 UTC (rev 279305)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2019 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2019-2021 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -44,7 +44,7 @@
</span><span class="cx"> #import <wtf/BlockPtr.h>
</span><span class="cx"> #import <wtf/Vector.h>
</span><span class="cx"> 
</span><del>-#define AUTHORIZATIONSESSION_RELEASE_LOG(fmt, ...) RELEASE_LOG(AppSSO, "%p - [InitiatingAction=%s] SOAuthorizationSession::" fmt, this, toString(m_action), ##__VA_ARGS__)
</del><ins>+#define AUTHORIZATIONSESSION_RELEASE_LOG(fmt, ...) RELEASE_LOG(AppSSO, "%p - [InitiatingAction=%s][State=%s] SOAuthorizationSession::" fmt, this, toString(m_action), stateString(), ##__VA_ARGS__)
</ins><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="lines">@@ -96,12 +96,47 @@
</span><span class="cx"> 
</span><span class="cx"> SOAuthorizationSession::~SOAuthorizationSession()
</span><span class="cx"> {
</span><ins>+    AUTHORIZATIONSESSION_RELEASE_LOG("~SOAuthorizationSession: m_viewController=%p", m_viewController.get());
+#if PLATFORM(MAC)
+    AUTHORIZATIONSESSION_RELEASE_LOG("~SOAuthorizationSession: m_sheetWindow=%p", m_sheetWindow.get());
+#endif
+
</ins><span class="cx">     if (m_state == State::Active && !!m_soAuthorization)
</span><span class="cx">         [m_soAuthorization cancelAuthorization];
</span><span class="cx">     if (m_state != State::Idle && m_state != State::Completed)
</span><span class="cx">         becomeCompleted();
</span><ins>+    else
+        dismissViewController();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+const char* SOAuthorizationSession::initiatingActionString() const
+{
+    return toString(m_action);
+}
+
+const char* SOAuthorizationSession::stateString() const
+{
+    static const char* Idle = "Idle";
+    static const char* Active = "Active";
+    static const char* Waiting = "Waiting";
+    static const char* Completed = "Completed";
+
+    switch (m_state) {
+    case State::Idle:
+        return Idle;
+    case State::Active:
+        return Active;
+    case State::Waiting:
+        return Waiting;
+    case State::Completed:
+        return Completed;
+    }
+
+    ASSERT_NOT_REACHED();
+    return nullptr;
+}
+
+
</ins><span class="cx"> Ref<API::NavigationAction> SOAuthorizationSession::releaseNavigationAction()
</span><span class="cx"> {
</span><span class="cx">     return m_navigationAction.releaseNonNull();
</span><span class="lines">@@ -109,15 +144,19 @@
</span><span class="cx"> 
</span><span class="cx"> void SOAuthorizationSession::becomeCompleted()
</span><span class="cx"> {
</span><ins>+    AUTHORIZATIONSESSION_RELEASE_LOG("becomeCompleted: m_viewController=%p", m_viewController.get());
+
</ins><span class="cx">     ASSERT(m_state == State::Active || m_state == State::Waiting);
</span><span class="cx">     m_state = State::Completed;
</span><del>-    if (m_viewController)
-        dismissViewController();
</del><ins>+    dismissViewController();
+#if PLATFORM(MAC)
+    ASSERT(!m_sheetWindow);
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void SOAuthorizationSession::shouldStart()
</span><span class="cx"> {
</span><del>-    AUTHORIZATIONSESSION_RELEASE_LOG("shouldStart:");
</del><ins>+    AUTHORIZATIONSESSION_RELEASE_LOG("shouldStart: m_page=%p", page());
</ins><span class="cx"> 
</span><span class="cx">     ASSERT(m_state == State::Idle);
</span><span class="cx">     if (!m_page)
</span><span class="lines">@@ -127,15 +166,25 @@
</span><span class="cx"> 
</span><span class="cx"> void SOAuthorizationSession::start()
</span><span class="cx"> {
</span><del>-    AUTHORIZATIONSESSION_RELEASE_LOG("start:");
</del><ins>+    AUTHORIZATIONSESSION_RELEASE_LOG("start: navigationAction=%p", navigationAction());
</ins><span class="cx"> 
</span><span class="cx">     ASSERT((m_state == State::Idle || m_state == State::Waiting) && m_navigationAction);
</span><span class="cx">     m_state = State::Active;
</span><ins>+    AUTHORIZATIONSESSION_RELEASE_LOG("start: Moving m_state to Active.");
</ins><span class="cx">     [m_soAuthorization getAuthorizationHintsWithURL:m_navigationAction->request().url() responseCode:0 completion:makeBlockPtr([this, weakThis = makeWeakPtr(*this)] (SOAuthorizationHints *authorizationHints, NSError *error) {
</span><span class="cx">         AUTHORIZATIONSESSION_RELEASE_LOG("start: Receive SOAuthorizationHints (error=%ld)", error ? error.code : 0);
</span><span class="cx"> 
</span><del>-        if (!weakThis || error || !authorizationHints)
</del><ins>+        if (!weakThis) {
+            RELEASE_LOG_ERROR(AppSSO, "SOAuthorizationSession::start (getAuthorizationHintsWithURL completion handler): Returning early because weakThis is now null.");
</ins><span class="cx">             return;
</span><ins>+        }
+
+        if (error || !authorizationHints) {
+            AUTHORIZATIONSESSION_RELEASE_LOG("start (getAuthorizationHintsWithURL completion handler): Returning early due to error or lack of hints.");
+            return;
+        }
+
+        AUTHORIZATIONSESSION_RELEASE_LOG("start (getAuthorizationHintsWithURL completion handler): Receive SOAuthorizationHints.");
</ins><span class="cx">         continueStartAfterGetAuthorizationHints(authorizationHints.localizedExtensionBundleDisplayName);
</span><span class="cx">     }).get()];
</span><span class="cx"> }
</span><span class="lines">@@ -145,9 +194,12 @@
</span><span class="cx">     AUTHORIZATIONSESSION_RELEASE_LOG("continueStartAfterGetAuthorizationHints: (hints=%s)", hints.utf8().data());
</span><span class="cx"> 
</span><span class="cx">     ASSERT(m_state == State::Active);
</span><del>-    if (!m_page)
</del><ins>+    if (!m_page) {
+        AUTHORIZATIONSESSION_RELEASE_LOG("continueStartAfterGetAuthorizationHints: Early return due to null m_page");
</ins><span class="cx">         return;
</span><ins>+    }
</ins><span class="cx"> 
</span><ins>+    AUTHORIZATIONSESSION_RELEASE_LOG("continueStartAfterGetAuthorizationHints: Checking page for policy choice.");
</ins><span class="cx">     m_page->decidePolicyForSOAuthorizationLoad(hints, [this, weakThis = makeWeakPtr(*this)] (SOAuthorizationLoadPolicy policy) {
</span><span class="cx">         if (!weakThis)
</span><span class="cx">             return;
</span><span class="lines">@@ -158,8 +210,7 @@
</span><span class="cx"> void SOAuthorizationSession::continueStartAfterDecidePolicy(const SOAuthorizationLoadPolicy& policy)
</span><span class="cx"> {
</span><span class="cx">     if (policy == SOAuthorizationLoadPolicy::Ignore) {
</span><del>-        AUTHORIZATIONSESSION_RELEASE_LOG("continueStartAfterDecidePolicy: Receive SOAuthorizationLoadPolicy::Ignore");
-
</del><ins>+        AUTHORIZATIONSESSION_RELEASE_LOG("continueStartAfterDecidePolicy: Receive SOAuthorizationLoadPolicy::Ignore. Falling back to web path.");
</ins><span class="cx">         fallBackToWebPath();
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="lines">@@ -166,8 +217,10 @@
</span><span class="cx"> 
</span><span class="cx">     AUTHORIZATIONSESSION_RELEASE_LOG("continueStartAfterDecidePolicy: Receive SOAuthorizationLoadPolicy::Allow");
</span><span class="cx"> 
</span><del>-    if (!m_soAuthorization || !m_page || !m_navigationAction)
</del><ins>+    if (!m_soAuthorization || !m_page || !m_navigationAction) {
+        AUTHORIZATIONSESSION_RELEASE_LOG("continueStartAfterGetAuthorizationHints: Early return m_soAuthorization=%d, m_page=%p, navigationAction=%p.", !!m_soAuthorization, page(), navigationAction());
</ins><span class="cx">         return;
</span><ins>+    }
</ins><span class="cx"> 
</span><span class="cx">     auto initiatorOrigin = emptyString();
</span><span class="cx">     if (m_navigationAction->sourceFrame())
</span><span class="lines">@@ -187,15 +240,20 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     auto *nsRequest = m_navigationAction->request().nsURLRequest(WebCore::HTTPBodyUpdatePolicy::UpdateHTTPBody);
</span><ins>+    AUTHORIZATIONSESSION_RELEASE_LOG("continueStartAfterGetAuthorizationHints: Beginning authorization with AppSSO.");
</ins><span class="cx">     [m_soAuthorization beginAuthorizationWithURL:nsRequest.URL httpHeaders:nsRequest.allHTTPHeaderFields httpBody:nsRequest.HTTPBody];
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void SOAuthorizationSession::fallBackToWebPath()
</span><span class="cx"> {
</span><del>-    AUTHORIZATIONSESSION_RELEASE_LOG("fallBackToWebPath:");
</del><ins>+    AUTHORIZATIONSESSION_RELEASE_LOG("fallBackToWebPath");
</ins><span class="cx"> 
</span><del>-    if (m_state != State::Active)
</del><ins>+    if (m_state != State::Active) {
+        AUTHORIZATIONSESSION_RELEASE_LOG("fallBackToWebPath: Returning early since not active.");
+        dismissViewController();
</ins><span class="cx">         return;
</span><ins>+    }
+
</ins><span class="cx">     becomeCompleted();
</span><span class="cx">     fallBackToWebPathInternal();
</span><span class="cx"> }
</span><span class="lines">@@ -202,10 +260,17 @@
</span><span class="cx"> 
</span><span class="cx"> void SOAuthorizationSession::abort()
</span><span class="cx"> {
</span><del>-    AUTHORIZATIONSESSION_RELEASE_LOG("abort:");
</del><ins>+    AUTHORIZATIONSESSION_RELEASE_LOG("abort: m_viewController=%p", m_viewController.get());
+#if PLATFORM(MAC)
+    AUTHORIZATIONSESSION_RELEASE_LOG("abort: m_sheetWindow=%p", m_sheetWindow.get());
+#endif
</ins><span class="cx"> 
</span><del>-    if (m_state == State::Idle || m_state == State::Completed)
</del><ins>+    if (m_state == State::Idle || m_state == State::Completed) {
+        AUTHORIZATIONSESSION_RELEASE_LOG("abort: Returning early since idle or already completed.");
+        dismissViewController();
</ins><span class="cx">         return;
</span><ins>+    }
+
</ins><span class="cx">     becomeCompleted();
</span><span class="cx">     abortInternal();
</span><span class="cx"> }
</span><span class="lines">@@ -212,13 +277,23 @@
</span><span class="cx"> 
</span><span class="cx"> void SOAuthorizationSession::complete(NSHTTPURLResponse *httpResponse, NSData *data)
</span><span class="cx"> {
</span><del>-    if (m_state != State::Active)
</del><ins>+    AUTHORIZATIONSESSION_RELEASE_LOG("complete: httpState=%d, m_viewController=%p", static_cast<int>(httpResponse.statusCode), m_viewController.get());
+#if PLATFORM(MAC)
+    AUTHORIZATIONSESSION_RELEASE_LOG("complete: m_sheetWindow=%p", m_sheetWindow.get());
+#endif
+
+    if (m_state != State::Active) {
+        AUTHORIZATIONSESSION_RELEASE_LOG("complete: Returning early since not active.");
+        dismissViewController();
</ins><span class="cx">         return;
</span><ins>+    }
+
</ins><span class="cx">     ASSERT(m_navigationAction);
</span><span class="cx">     becomeCompleted();
</span><span class="cx"> 
</span><span class="cx">     auto response = WebCore::ResourceResponse(httpResponse);
</span><span class="cx">     if (!isSameOrigin(m_navigationAction->request(), response)) {
</span><ins>+        AUTHORIZATIONSESSION_RELEASE_LOG("complete:  Origins don't match. Falling back to web path.");
</ins><span class="cx">         fallBackToWebPathInternal();
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="lines">@@ -229,12 +304,16 @@
</span><span class="cx">     AUTHORIZATIONSESSION_RELEASE_LOG("complete: (httpStatusCode=%d, hasCookies=%d, hasData=%d)", response.httpStatusCode(), !cookies.isEmpty(), !!data.length);
</span><span class="cx"> 
</span><span class="cx">     if (cookies.isEmpty()) {
</span><ins>+        AUTHORIZATIONSESSION_RELEASE_LOG("complete:  No cookies to set. Completing (internal).");
</ins><span class="cx">         completeInternal(response, data);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (!m_page)
</del><ins>+    if (!m_page) {
+        AUTHORIZATIONSESSION_RELEASE_LOG("complete:  Returning early because m_page is null.");
</ins><span class="cx">         return;
</span><ins>+    }
+
</ins><span class="cx">     m_page->websiteDataStore().cookieStore().setCookies(WTFMove(cookies), [this, weakThis = makeWeakPtr(*this), response = WTFMove(response), data = adoptNS([[NSData alloc] initWithData:data])] () mutable {
</span><span class="cx">         if (!weakThis)
</span><span class="cx">             return;
</span><span class="lines">@@ -247,11 +326,15 @@
</span><span class="cx"> 
</span><span class="cx"> void SOAuthorizationSession::presentViewController(SOAuthorizationViewController viewController, UICallback uiCallback)
</span><span class="cx"> {
</span><del>-    AUTHORIZATIONSESSION_RELEASE_LOG("presentViewController:");
</del><ins>+    AUTHORIZATIONSESSION_RELEASE_LOG("presentViewController: m_viewController=%p", m_viewController.get());
+#if PLATFORM(MAC)
+    AUTHORIZATIONSESSION_RELEASE_LOG("presentViewController: m_sheetWindow=%p", m_sheetWindow.get());
+#endif
</ins><span class="cx"> 
</span><span class="cx">     ASSERT(m_state == State::Active);
</span><span class="cx">     // Only expect at most one UI session for the whole authorization session.
</span><span class="cx">     if (!m_page || m_page->isClosed() || m_viewController) {
</span><ins>+        AUTHORIZATIONSESSION_RELEASE_LOG("presentViewController: m_page=%p, m_page->isClosed=%d, m_viewController=%p", m_page.get(), m_page ? m_page->isClosed() : 0, m_viewController.get());
</ins><span class="cx">         uiCallback(NO, adoptNS([[NSError alloc] initWithDomain:SOErrorDomain code:kSOErrorAuthorizationPresentationFailed userInfo:nil]).get());
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="lines">@@ -259,9 +342,12 @@
</span><span class="cx">     m_viewController = viewController;
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx">     ASSERT(!m_sheetWindow);
</span><ins>+    ASSERT(!m_sheetWindowWillCloseObserver);
+
+    dismissModalSheetIfNecessary();
+
</ins><span class="cx">     m_sheetWindow = [NSWindow windowWithContentViewController:m_viewController.get()];
</span><span class="cx"> 
</span><del>-    ASSERT(!m_sheetWindowWillCloseObserver);
</del><span class="cx">     m_sheetWindowWillCloseObserver = [[NSNotificationCenter defaultCenter] addObserverForName:NSWindowWillCloseNotification object:m_sheetWindow.get() queue:nil usingBlock:[weakThis = makeWeakPtr(*this)] (NSNotification *) {
</span><span class="cx">         if (!weakThis)
</span><span class="cx">             return;
</span><span class="lines">@@ -268,9 +354,11 @@
</span><span class="cx">         RELEASE_LOG(AppSSO, "presentViewController: Received NSWindowWillCloseNotification. Dismissing the view controller.");
</span><span class="cx">         weakThis->dismissViewController();
</span><span class="cx">     }];
</span><ins>+    AUTHORIZATIONSESSION_RELEASE_LOG("presentViewController: Added m_sheetWindowWillCloseObserver (%p)", m_sheetWindowWillCloseObserver.get());
</ins><span class="cx"> 
</span><span class="cx">     NSWindow *presentingWindow = m_page->platformWindow();
</span><span class="cx">     if (!presentingWindow) {
</span><ins>+        AUTHORIZATIONSESSION_RELEASE_LOG("presentViewController: No presenting window. Returning early.");
</ins><span class="cx">         uiCallback(NO, adoptNS([[NSError alloc] initWithDomain:SOErrorDomain code:kSOErrorAuthorizationPresentationFailed userInfo:nil]).get());
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="lines">@@ -290,14 +378,40 @@
</span><span class="cx">     uiCallback(YES, nil);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if PLATFORM(MAC)
+void SOAuthorizationSession::dismissModalSheetIfNecessary()
+{
+    if (auto *presentingWindow = m_sheetWindow.get().sheetParent) {
+        AUTHORIZATIONSESSION_RELEASE_LOG("dismissModalSheetIfNecessary: Calling endSheet on %p for sheet %p.", presentingWindow, m_sheetWindow.get());
+        [presentingWindow endSheet:m_sheetWindow.get()];
+    }
+    m_sheetWindow = nullptr;
+
+    if (m_sheetWindowWillCloseObserver.get()) {
+        AUTHORIZATIONSESSION_RELEASE_LOG("dismissModalSheetIfNecessary: Removing m_sheetWindowWillCloseObserver (%p)", m_sheetWindowWillCloseObserver.get());
+        [[NSNotificationCenter defaultCenter] removeObserver:m_sheetWindowWillCloseObserver.get()];
+    }
+    m_sheetWindowWillCloseObserver = nullptr;
+}
+#endif
+
</ins><span class="cx"> void SOAuthorizationSession::dismissViewController()
</span><span class="cx"> {
</span><del>-    AUTHORIZATIONSESSION_RELEASE_LOG("dismissViewController:");
</del><ins>+    AUTHORIZATIONSESSION_RELEASE_LOG("dismissViewController: m_viewController=%p", m_viewController.get());
+    if (!m_viewController) {
+        AUTHORIZATIONSESSION_RELEASE_LOG("dismissViewController: No view controller, so returning early.");
+        return;
+    }
</ins><span class="cx"> 
</span><del>-    ASSERT(m_viewController);
</del><span class="cx"> #if PLATFORM(MAC)
</span><del>-    ASSERT(m_sheetWindow && m_sheetWindowWillCloseObserver);
</del><ins>+    if (!m_sheetWindow) {
+        ASSERT(!m_sheetWindowWillCloseObserver);
+        AUTHORIZATIONSESSION_RELEASE_LOG("dismissViewController: No view controller or sheet window, so returning early.");
+        return;
+    }
</ins><span class="cx"> 
</span><ins>+    ASSERT(m_sheetWindowWillCloseObserver);
+
</ins><span class="cx">     // This is a workaround for an AppKit issue: <rdar://problem/59125329>.
</span><span class="cx">     // [m_sheetWindow sheetParent] is null if the parent is minimized or the host app is hidden.
</span><span class="cx">     if (m_page && m_page->platformWindow()) {
</span><span class="lines">@@ -333,13 +447,7 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    [[NSNotificationCenter defaultCenter] removeObserver:m_sheetWindowWillCloseObserver.get()];
-    m_sheetWindowWillCloseObserver = nullptr;
-
-    auto *presentingWindow = m_sheetWindow.get().sheetParent;
-    AUTHORIZATIONSESSION_RELEASE_LOG("dismissViewController: Calling endSheet on %p for sheet %p.", presentingWindow, m_sheetWindow.get());
-    [presentingWindow endSheet:m_sheetWindow.get()];
-    m_sheetWindow = nullptr;
</del><ins>+    dismissModalSheetIfNecessary();
</ins><span class="cx">     AUTHORIZATIONSESSION_RELEASE_LOG("dismissViewController: Finished call with deminiaturized observer (%p) and Hidden observer (%p)", m_presentingWindowDidDeminiaturizeObserver.get(), m_applicationDidUnhideObserver.get());
</span><span class="cx"> #elif PLATFORM(IOS)
</span><span class="cx">     [[m_viewController presentingViewController] dismissViewControllerAnimated:YES completion:nil];
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessCocoaSOAuthorizationSubFrameSOAuthorizationSessionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/SubFrameSOAuthorizationSession.mm (279304 => 279305)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/SubFrameSOAuthorizationSession.mm    2021-06-26 00:49:17 UTC (rev 279304)
+++ trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/SubFrameSOAuthorizationSession.mm       2021-06-26 01:47:28 UTC (rev 279305)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2019 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2019-2021 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -38,6 +38,8 @@
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> using namespace WebCore;
</span><span class="cx"> 
</span><ins>+#define AUTHORIZATIONSESSION_RELEASE_LOG(fmt, ...) RELEASE_LOG(AppSSO, "%p - [InitiatingAction=%s][State=%s] SubFrameSOAuthorizationSession::" fmt, this, initiatingActionString(), stateString(), ##__VA_ARGS__)
+
</ins><span class="cx"> namespace {
</span><span class="cx"> 
</span><span class="cx"> const char* soAuthorizationPostDidStartMessageToParent = "<script>parent.postMessage('SOAuthorizationDidStart', '*');</script>";
</span><span class="lines">@@ -69,6 +71,7 @@
</span><span class="cx"> 
</span><span class="cx"> void SubFrameSOAuthorizationSession::fallBackToWebPathInternal()
</span><span class="cx"> {
</span><ins>+    AUTHORIZATIONSESSION_RELEASE_LOG("fallBackToWebPathInternal: navigationAction=%p", navigationAction());
</ins><span class="cx">     ASSERT(navigationAction());
</span><span class="cx">     appendRequestToLoad(URL(navigationAction()->request().url()), Vector { reinterpret_cast<const uint8_t*>(soAuthorizationPostDidCancelMessageToParent), strlen(soAuthorizationPostDidCancelMessageToParent) });
</span><span class="cx">     appendRequestToLoad(URL(navigationAction()->request().url()), String(navigationAction()->request().httpReferrer()));
</span><span class="lines">@@ -76,11 +79,13 @@
</span><span class="cx"> 
</span><span class="cx"> void SubFrameSOAuthorizationSession::abortInternal()
</span><span class="cx"> {
</span><ins>+    AUTHORIZATIONSESSION_RELEASE_LOG("abortInternal");
</ins><span class="cx">     fallBackToWebPathInternal();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void SubFrameSOAuthorizationSession::completeInternal(const WebCore::ResourceResponse& response, NSData *data)
</span><span class="cx"> {
</span><ins>+    AUTHORIZATIONSESSION_RELEASE_LOG("completeInternal: httpState=%d", response.httpStatusCode());
</ins><span class="cx">     if (response.httpStatusCode() != 200) {
</span><span class="cx">         fallBackToWebPathInternal();
</span><span class="cx">         return;
</span><span class="lines">@@ -90,6 +95,7 @@
</span><span class="cx"> 
</span><span class="cx"> void SubFrameSOAuthorizationSession::beforeStart()
</span><span class="cx"> {
</span><ins>+    AUTHORIZATIONSESSION_RELEASE_LOG("beforeStart");
</ins><span class="cx">     // Cancelled the current load before loading the data to post SOAuthorizationDidStart to the parent frame.
</span><span class="cx">     invokeCallback(true);
</span><span class="cx">     ASSERT(navigationAction());
</span><span class="lines">@@ -98,6 +104,7 @@
</span><span class="cx"> 
</span><span class="cx"> void SubFrameSOAuthorizationSession::didFinishLoad()
</span><span class="cx"> {
</span><ins>+    AUTHORIZATIONSESSION_RELEASE_LOG("didFinishLoad");
</ins><span class="cx">     auto* page = this->page();
</span><span class="cx">     if (!page)
</span><span class="cx">         return;
</span><span class="lines">@@ -118,6 +125,7 @@
</span><span class="cx"> 
</span><span class="cx"> void SubFrameSOAuthorizationSession::loadRequestToFrame()
</span><span class="cx"> {
</span><ins>+    AUTHORIZATIONSESSION_RELEASE_LOG("loadRequestToFrame");
</ins><span class="cx">     auto* page = this->page();
</span><span class="cx">     if (!page || m_requestsToLoad.isEmpty())
</span><span class="cx">         return;
</span><span class="lines">@@ -135,4 +143,6 @@
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span><span class="cx"> 
</span><ins>+#undef AUTHORIZATIONSESSION_RELEASE_LOG
+
</ins><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessCocoaSOAuthorizationWKSOAuthorizationDelegatemm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/WKSOAuthorizationDelegate.mm (279304 => 279305)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/WKSOAuthorizationDelegate.mm 2021-06-26 00:49:17 UTC (rev 279304)
+++ trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/WKSOAuthorizationDelegate.mm    2021-06-26 01:47:28 UTC (rev 279305)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2019 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2019-2021 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -32,16 +32,21 @@
</span><span class="cx"> #import "WebPageProxy.h"
</span><span class="cx"> #import <wtf/RunLoop.h>
</span><span class="cx"> 
</span><ins>+#define WKSOAUTHORIZATIONDELEGATE_RELEASE_LOG(fmt, ...) RELEASE_LOG(AppSSO, "%p - WKSOAuthorizationDelegate::" fmt, &self, ##__VA_ARGS__)
+
</ins><span class="cx"> @implementation WKSOAuthorizationDelegate
</span><span class="cx"> 
</span><span class="cx"> - (void)authorization:(SOAuthorization *)authorization presentViewController:(SOAuthorizationViewController)viewController withCompletion:(void (^)(BOOL success, NSError *error))completion
</span><span class="cx"> {
</span><span class="cx">     ASSERT(RunLoop::isMain() && completion);
</span><ins>+    WKSOAUTHORIZATIONDELEGATE_RELEASE_LOG("authorization (authorization = %p, _session = %p)", authorization, _session.get());
</ins><span class="cx">     if (!_session) {
</span><ins>+        WKSOAUTHORIZATIONDELEGATE_RELEASE_LOG("authorization: No session, so completing with NO as success state.");
</ins><span class="cx">         ASSERT_NOT_REACHED();
</span><span class="cx">         completion(NO, nil);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><ins>+    WKSOAUTHORIZATIONDELEGATE_RELEASE_LOG("authorization: presentingViewController %p", viewController);
</ins><span class="cx">     _session->presentViewController(viewController, completion);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -48,11 +53,14 @@
</span><span class="cx"> - (void)authorizationDidNotHandle:(SOAuthorization *)authorization
</span><span class="cx"> {
</span><span class="cx">     ASSERT(RunLoop::isMain());
</span><ins>+    WKSOAUTHORIZATIONDELEGATE_RELEASE_LOG("authorizationDidNotHandle: (authorization = %p, _session = %p)", authorization, _session.get());
</ins><span class="cx">     LOG_ERROR("Could not handle AppSSO.");
</span><span class="cx">     if (!_session) {
</span><ins>+        WKSOAUTHORIZATIONDELEGATE_RELEASE_LOG("authorizationDidNotHandle: No session, so returning early.");
</ins><span class="cx">         ASSERT_NOT_REACHED();
</span><span class="cx">         return;
</span><span class="cx">     }
</span><ins>+    WKSOAUTHORIZATIONDELEGATE_RELEASE_LOG("authorizationDidNotHandle: Falling back to web path.");
</ins><span class="cx">     _session->fallBackToWebPath();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -59,10 +67,13 @@
</span><span class="cx"> - (void)authorizationDidCancel:(SOAuthorization *)authorization
</span><span class="cx"> {
</span><span class="cx">     ASSERT(RunLoop::isMain());
</span><ins>+    WKSOAUTHORIZATIONDELEGATE_RELEASE_LOG("authorizationDidCancel: (authorization = %p, _session = %p)", authorization, _session.get());
</ins><span class="cx">     if (!_session) {
</span><ins>+        WKSOAUTHORIZATIONDELEGATE_RELEASE_LOG("authorizationDidCancel: No session, so returning early.");
</ins><span class="cx">         ASSERT_NOT_REACHED();
</span><span class="cx">         return;
</span><span class="cx">     }
</span><ins>+    WKSOAUTHORIZATIONDELEGATE_RELEASE_LOG("authorizationDidCancel: Aborting session.");
</ins><span class="cx">     _session->abort();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -69,11 +80,14 @@
</span><span class="cx"> - (void)authorizationDidComplete:(SOAuthorization *)authorization
</span><span class="cx"> {
</span><span class="cx">     ASSERT(RunLoop::isMain());
</span><ins>+    WKSOAUTHORIZATIONDELEGATE_RELEASE_LOG("authorizationDidComplete: (authorization = %p, _session = %p)", authorization, _session.get());
</ins><span class="cx">     LOG_ERROR("Complete AppSSO without any data.");
</span><span class="cx">     if (!_session) {
</span><ins>+        WKSOAUTHORIZATIONDELEGATE_RELEASE_LOG("authorizationDidComplete: No session, so returning early.");
</ins><span class="cx">         ASSERT_NOT_REACHED();
</span><span class="cx">         return;
</span><span class="cx">     }
</span><ins>+    WKSOAUTHORIZATIONDELEGATE_RELEASE_LOG("authorizationDidComplete: Falling back to web path.");
</ins><span class="cx">     _session->fallBackToWebPath();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -80,11 +94,14 @@
</span><span class="cx"> - (void)authorization:(SOAuthorization *)authorization didCompleteWithHTTPAuthorizationHeaders:(NSDictionary *)httpAuthorizationHeaders
</span><span class="cx"> {
</span><span class="cx">     ASSERT(RunLoop::isMain());
</span><ins>+    WKSOAUTHORIZATIONDELEGATE_RELEASE_LOG("authorization:didCompleteWithHTTPAuthorizationHeaders: (authorization = %p, _session = %p)", authorization, _session.get());
</ins><span class="cx">     LOG_ERROR("Complete AppSSO with unexpected callback.");
</span><span class="cx">     if (!_session) {
</span><ins>+        WKSOAUTHORIZATIONDELEGATE_RELEASE_LOG("authorization:didCompleteWithHTTPAuthorizationHeaders: No session, so returning early.");
</ins><span class="cx">         ASSERT_NOT_REACHED();
</span><span class="cx">         return;
</span><span class="cx">     }
</span><ins>+    WKSOAUTHORIZATIONDELEGATE_RELEASE_LOG("authorization:didCompleteWithHTTPAuthorizationHeaders: Falling back to web path.");
</ins><span class="cx">     _session->fallBackToWebPath();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -91,10 +108,13 @@
</span><span class="cx"> - (void)authorization:(SOAuthorization *)authorization didCompleteWithHTTPResponse:(NSHTTPURLResponse *)httpResponse httpBody:(NSData *)httpBody
</span><span class="cx"> {
</span><span class="cx">     ASSERT(RunLoop::isMain());
</span><ins>+    WKSOAUTHORIZATIONDELEGATE_RELEASE_LOG("authorization:didCompleteWithHTTPResponse: (authorization = %p, _session = %p)", authorization, _session.get());
</ins><span class="cx">     if (!_session) {
</span><ins>+        WKSOAUTHORIZATIONDELEGATE_RELEASE_LOG("authorization:didCompleteWithHTTPResponse: No session, so returning early.");
</ins><span class="cx">         ASSERT_NOT_REACHED();
</span><span class="cx">         return;
</span><span class="cx">     }
</span><ins>+    WKSOAUTHORIZATIONDELEGATE_RELEASE_LOG("authorization:didCompleteWithHTTPResponse: Completing.");
</ins><span class="cx">     _session->complete(httpResponse, httpBody);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -101,21 +121,27 @@
</span><span class="cx"> - (void)authorization:(SOAuthorization *)authorization didCompleteWithError:(NSError *)error
</span><span class="cx"> {
</span><span class="cx">     ASSERT(RunLoop::isMain());
</span><ins>+    WKSOAUTHORIZATIONDELEGATE_RELEASE_LOG("authorization:didCompleteWithError: (authorization = %p, _session = %p)", authorization, _session.get());
</ins><span class="cx">     LOG_ERROR("Could not complete AppSSO: %d", error.code);
</span><span class="cx">     if (!_session) {
</span><ins>+        WKSOAUTHORIZATIONDELEGATE_RELEASE_LOG("authorization:didCompleteWithError: No session, so returning early.");
</ins><span class="cx">         ASSERT_NOT_REACHED();
</span><span class="cx">         return;
</span><span class="cx">     }
</span><ins>+    WKSOAUTHORIZATIONDELEGATE_RELEASE_LOG("authorization:didCompleteWithError: Falling back to web path.");
</ins><span class="cx">     _session->fallBackToWebPath();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)setSession:(RefPtr<WebKit::SOAuthorizationSession>&&)session
</span><span class="cx"> {
</span><ins>+    RELEASE_ASSERT(RunLoop::isMain());
+    WKSOAUTHORIZATIONDELEGATE_RELEASE_LOG("setSession: (existing session = %p, new session = %p)", _session.get(), session.get());
</ins><span class="cx">     _session = WTFMove(session);
</span><span class="cx">     if (_session)
</span><span class="cx">         _session->shouldStart();
</span><span class="cx"> }
</span><del>-
</del><span class="cx"> @end
</span><span class="cx"> 
</span><ins>+#undef WKSOAUTHORIZATIONDELEGATE_RELEASE_LOG
+
</ins><span class="cx"> #endif
</span></span></pre>
</div>
</div>

</body>
</html>