<!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>[213304] trunk/Source/WebKit2</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/213304">213304</a></dd>
<dt>Author</dt> <dd>bburg@apple.com</dd>
<dt>Date</dt> <dd>2017-03-02 14:30:23 -0800 (Thu, 02 Mar 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>Web Automation: _WKAutomationSessionDelegate should work with WKWebViews
https://bugs.webkit.org/show_bug.cgi?id=169091
<rdar://problem/30810538>
Reviewed by Tim Horton.
As a first step towards fixing the mistake of using WKPageRef in an Objective-C SPI,
add the correct delegate methods that take WKWebView so that Objective-C clients can
use this functionality.
In a future patch, we'll remove the WKPageRef delegate methods when they are no longer
being used by clients. Clients should switch to using WKWebView, or wait for a C SPI
with equivalent functionality (something like WKAutomationSessionClient) to be ported.
While I'm fixing this mess, make API::AutomationSessionClient use references instead
of pointers. We null-check all WebPageProxy parameters before calling its methods.
* UIProcess/API/APIAutomationSessionClient.h:
(API::AutomationSessionClient::didDisconnectFromRemote):
(API::AutomationSessionClient::didRequestNewWindow):
(API::AutomationSessionClient::isShowingJavaScriptDialogOnPage):
(API::AutomationSessionClient::dismissCurrentJavaScriptDialogOnPage):
(API::AutomationSessionClient::acceptCurrentJavaScriptDialogOnPage):
(API::AutomationSessionClient::messageOfCurrentJavaScriptDialogOnPage):
(API::AutomationSessionClient::setUserInputForCurrentJavaScriptPromptOnPage):
Change pointer to reference.
* UIProcess/API/Cocoa/_WKAutomationSessionDelegate.h:
Add duplicate delegate methods that take/return WKWebView instead of WKPageRef.
Adjust the delegate method names to reflect parameter type and avoid conflicts with the
WKPageRef-using methods that we need to remove eventually.
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::terminate):
(WebKit::WebAutomationSession::createBrowsingContext):
(WebKit::WebAutomationSession::isShowingJavaScriptDialog):
(WebKit::WebAutomationSession::dismissCurrentJavaScriptDialog):
(WebKit::WebAutomationSession::acceptCurrentJavaScriptDialog):
(WebKit::WebAutomationSession::messageOfCurrentJavaScriptDialog):
(WebKit::WebAutomationSession::setUserInputForCurrentJavaScriptPrompt):
Dereference `this` and `webPageProxy` when calling API::AutomationSessionClient methods.
* UIProcess/Cocoa/AutomationSessionClient.h:
* UIProcess/Cocoa/AutomationSessionClient.mm:
(WebKit::AutomationSessionClient::AutomationSessionClient):
(WebKit::AutomationSessionClient::didDisconnectFromRemote):
(WebKit::AutomationSessionClient::didRequestNewWindow):
(WebKit::AutomationSessionClient::isShowingJavaScriptDialogOnPage):
(WebKit::AutomationSessionClient::dismissCurrentJavaScriptDialogOnPage):
(WebKit::AutomationSessionClient::acceptCurrentJavaScriptDialogOnPage):
(WebKit::AutomationSessionClient::messageOfCurrentJavaScriptDialogOnPage):
(WebKit::AutomationSessionClient::setUserInputForCurrentJavaScriptPromptOnPage):
Now there are two possible delegate methods for most of these, so try to use the
WKWebView-based delegate method first and fall back to the WKPageRef delegate method.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIAPIAutomationSessionClienth">trunk/Source/WebKit2/UIProcess/API/APIAutomationSessionClient.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoa_WKAutomationSessionDelegateh">trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKAutomationSessionDelegate.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAutomationWebAutomationSessioncpp">trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaAutomationSessionClienth">trunk/Source/WebKit2/UIProcess/Cocoa/AutomationSessionClient.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaAutomationSessionClientmm">trunk/Source/WebKit2/UIProcess/Cocoa/AutomationSessionClient.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (213303 => 213304)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2017-03-02 22:09:29 UTC (rev 213303)
+++ trunk/Source/WebKit2/ChangeLog        2017-03-02 22:30:23 UTC (rev 213304)
</span><span class="lines">@@ -1,3 +1,60 @@
</span><ins>+2017-03-02 Brian Burg <bburg@apple.com>
+
+ Web Automation: _WKAutomationSessionDelegate should work with WKWebViews
+ https://bugs.webkit.org/show_bug.cgi?id=169091
+ <rdar://problem/30810538>
+
+ Reviewed by Tim Horton.
+
+ As a first step towards fixing the mistake of using WKPageRef in an Objective-C SPI,
+ add the correct delegate methods that take WKWebView so that Objective-C clients can
+ use this functionality.
+
+ In a future patch, we'll remove the WKPageRef delegate methods when they are no longer
+ being used by clients. Clients should switch to using WKWebView, or wait for a C SPI
+ with equivalent functionality (something like WKAutomationSessionClient) to be ported.
+
+ While I'm fixing this mess, make API::AutomationSessionClient use references instead
+ of pointers. We null-check all WebPageProxy parameters before calling its methods.
+
+ * UIProcess/API/APIAutomationSessionClient.h:
+ (API::AutomationSessionClient::didDisconnectFromRemote):
+ (API::AutomationSessionClient::didRequestNewWindow):
+ (API::AutomationSessionClient::isShowingJavaScriptDialogOnPage):
+ (API::AutomationSessionClient::dismissCurrentJavaScriptDialogOnPage):
+ (API::AutomationSessionClient::acceptCurrentJavaScriptDialogOnPage):
+ (API::AutomationSessionClient::messageOfCurrentJavaScriptDialogOnPage):
+ (API::AutomationSessionClient::setUserInputForCurrentJavaScriptPromptOnPage):
+ Change pointer to reference.
+
+ * UIProcess/API/Cocoa/_WKAutomationSessionDelegate.h:
+ Add duplicate delegate methods that take/return WKWebView instead of WKPageRef.
+ Adjust the delegate method names to reflect parameter type and avoid conflicts with the
+ WKPageRef-using methods that we need to remove eventually.
+
+ * UIProcess/Automation/WebAutomationSession.cpp:
+ (WebKit::WebAutomationSession::terminate):
+ (WebKit::WebAutomationSession::createBrowsingContext):
+ (WebKit::WebAutomationSession::isShowingJavaScriptDialog):
+ (WebKit::WebAutomationSession::dismissCurrentJavaScriptDialog):
+ (WebKit::WebAutomationSession::acceptCurrentJavaScriptDialog):
+ (WebKit::WebAutomationSession::messageOfCurrentJavaScriptDialog):
+ (WebKit::WebAutomationSession::setUserInputForCurrentJavaScriptPrompt):
+ Dereference `this` and `webPageProxy` when calling API::AutomationSessionClient methods.
+
+ * UIProcess/Cocoa/AutomationSessionClient.h:
+ * UIProcess/Cocoa/AutomationSessionClient.mm:
+ (WebKit::AutomationSessionClient::AutomationSessionClient):
+ (WebKit::AutomationSessionClient::didDisconnectFromRemote):
+ (WebKit::AutomationSessionClient::didRequestNewWindow):
+ (WebKit::AutomationSessionClient::isShowingJavaScriptDialogOnPage):
+ (WebKit::AutomationSessionClient::dismissCurrentJavaScriptDialogOnPage):
+ (WebKit::AutomationSessionClient::acceptCurrentJavaScriptDialogOnPage):
+ (WebKit::AutomationSessionClient::messageOfCurrentJavaScriptDialogOnPage):
+ (WebKit::AutomationSessionClient::setUserInputForCurrentJavaScriptPromptOnPage):
+ Now there are two possible delegate methods for most of these, so try to use the
+ WKWebView-based delegate method first and fall back to the WKPageRef delegate method.
+
</ins><span class="cx"> 2017-03-02 Alex Christensen <achristensen@webkit.org>
</span><span class="cx">
</span><span class="cx"> Continue enabling WebRTC
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIAPIAutomationSessionClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/APIAutomationSessionClient.h (213303 => 213304)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/APIAutomationSessionClient.h        2017-03-02 22:09:29 UTC (rev 213303)
+++ trunk/Source/WebKit2/UIProcess/API/APIAutomationSessionClient.h        2017-03-02 22:30:23 UTC (rev 213304)
</span><span class="lines">@@ -40,13 +40,13 @@
</span><span class="cx"> virtual ~AutomationSessionClient() { }
</span><span class="cx">
</span><span class="cx"> virtual String sessionIdentifier() const { return String(); }
</span><del>- virtual void didDisconnectFromRemote(WebKit::WebAutomationSession*) { }
- virtual WebKit::WebPageProxy* didRequestNewWindow(WebKit::WebAutomationSession*) { return nullptr; }
- virtual bool isShowingJavaScriptDialogOnPage(WebKit::WebAutomationSession*, WebKit::WebPageProxy*) { return false; }
- virtual void dismissCurrentJavaScriptDialogOnPage(WebKit::WebAutomationSession*, WebKit::WebPageProxy*) { }
- virtual void acceptCurrentJavaScriptDialogOnPage(WebKit::WebAutomationSession*, WebKit::WebPageProxy*) { }
- virtual String messageOfCurrentJavaScriptDialogOnPage(WebKit::WebAutomationSession*, WebKit::WebPageProxy*) { return String(); }
- virtual void setUserInputForCurrentJavaScriptPromptOnPage(WebKit::WebAutomationSession*, WebKit::WebPageProxy*, const String&) { }
</del><ins>+ virtual void didDisconnectFromRemote(WebKit::WebAutomationSession&) { }
+ virtual WebKit::WebPageProxy* didRequestNewWindow(WebKit::WebAutomationSession&) { return nullptr; }
+ virtual bool isShowingJavaScriptDialogOnPage(WebKit::WebAutomationSession&, WebKit::WebPageProxy&) { return false; }
+ virtual void dismissCurrentJavaScriptDialogOnPage(WebKit::WebAutomationSession&, WebKit::WebPageProxy&) { }
+ virtual void acceptCurrentJavaScriptDialogOnPage(WebKit::WebAutomationSession&, WebKit::WebPageProxy&) { }
+ virtual String messageOfCurrentJavaScriptDialogOnPage(WebKit::WebAutomationSession&, WebKit::WebPageProxy&) { return String(); }
+ virtual void setUserInputForCurrentJavaScriptPromptOnPage(WebKit::WebAutomationSession&, WebKit::WebPageProxy&, const String&) { }
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace API
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoa_WKAutomationSessionDelegateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKAutomationSessionDelegate.h (213303 => 213304)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKAutomationSessionDelegate.h        2017-03-02 22:09:29 UTC (rev 213303)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKAutomationSessionDelegate.h        2017-03-02 22:30:23 UTC (rev 213304)
</span><span class="lines">@@ -30,13 +30,24 @@
</span><span class="cx"> #import <Foundation/Foundation.h>
</span><span class="cx"> #import <WebKit/WKBase.h>
</span><span class="cx">
</span><ins>+@class WKWebView;
</ins><span class="cx"> @class _WKAutomationSession;
</span><span class="cx">
</span><span class="cx"> @protocol _WKAutomationSessionDelegate <NSObject>
</span><span class="cx"> @optional
</span><del>-- (WKPageRef)_automationSessionDidRequestNewWindow:(_WKAutomationSession *)automationSession;
</del><ins>+
</ins><span class="cx"> - (void)_automationSessionDidDisconnectFromRemote:(_WKAutomationSession *)automationSession;
</span><span class="cx">
</span><ins>+- (WKWebView *)_automationSessionDidRequestNewWebView:(_WKAutomationSession *)automationSession;
+- (BOOL)_automationSession:(_WKAutomationSession *)automationSession isShowingJavaScriptDialogForWebView:(WKWebView *)webView;
+- (void)_automationSession:(_WKAutomationSession *)automationSession dismissCurrentJavaScriptDialogForWebView:(WKWebView *)webView;
+- (void)_automationSession:(_WKAutomationSession *)automationSession acceptCurrentJavaScriptDialogForWebView:(WKWebView *)webView;
+- (NSString *)_automationSession:(_WKAutomationSession *)automationSession messageOfCurrentJavaScriptDialogForWebView:(WKWebView *)webView;
+- (void)_automationSession:(_WKAutomationSession *)automationSession setUserInput:(NSString *)value forCurrentJavaScriptDialogForWebView:(WKWebView *)webView;
+
+// FIXME: Objective-C delegate methods shouldn't use C API types like WKPageRef. We need to
+// migrate clients to use WKWebView, or expose the same behavior via a C SPI for those clients.
+- (WKPageRef)_automationSessionDidRequestNewWindow:(_WKAutomationSession *)automationSession;
</ins><span class="cx"> - (BOOL)_automationSession:(_WKAutomationSession *)automationSession isShowingJavaScriptDialogOnPage:(WKPageRef)page;
</span><span class="cx"> - (void)_automationSession:(_WKAutomationSession *)automationSession dismissCurrentJavaScriptDialogOnPage:(WKPageRef)page;
</span><span class="cx"> - (void)_automationSession:(_WKAutomationSession *)automationSession acceptCurrentJavaScriptDialogOnPage:(WKPageRef)page;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAutomationWebAutomationSessioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp (213303 => 213304)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp        2017-03-02 22:09:29 UTC (rev 213303)
+++ trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp        2017-03-02 22:30:23 UTC (rev 213304)
</span><span class="lines">@@ -121,7 +121,7 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> if (m_client)
</span><del>- m_client->didDisconnectFromRemote(this);
</del><ins>+ m_client->didDisconnectFromRemote(*this);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> WebPageProxy* WebAutomationSession::webPageProxyForHandle(const String& handle)
</span><span class="lines">@@ -252,7 +252,7 @@
</span><span class="cx"> if (!m_client)
</span><span class="cx"> FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InternalError, "The remote session could not request a new browsing context.");
</span><span class="cx">
</span><del>- WebPageProxy* page = m_client->didRequestNewWindow(this);
</del><ins>+ WebPageProxy* page = m_client->didRequestNewWindow(*this);
</ins><span class="cx"> if (!page)
</span><span class="cx"> FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InternalError, "The remote session failed to create a new browsing context.");
</span><span class="cx">
</span><span class="lines">@@ -531,7 +531,7 @@
</span><span class="cx"> if (!page)
</span><span class="cx"> FAIL_WITH_PREDEFINED_ERROR(WindowNotFound);
</span><span class="cx">
</span><del>- *result = m_client->isShowingJavaScriptDialogOnPage(this, page);
</del><ins>+ *result = m_client->isShowingJavaScriptDialogOnPage(*this, *page);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void WebAutomationSession::dismissCurrentJavaScriptDialog(Inspector::ErrorString& errorString, const String& browsingContextHandle)
</span><span class="lines">@@ -544,10 +544,10 @@
</span><span class="cx"> if (!page)
</span><span class="cx"> FAIL_WITH_PREDEFINED_ERROR(WindowNotFound);
</span><span class="cx">
</span><del>- if (!m_client->isShowingJavaScriptDialogOnPage(this, page))
</del><ins>+ if (!m_client->isShowingJavaScriptDialogOnPage(*this, *page))
</ins><span class="cx"> FAIL_WITH_PREDEFINED_ERROR(NoJavaScriptDialog);
</span><span class="cx">
</span><del>- m_client->dismissCurrentJavaScriptDialogOnPage(this, page);
</del><ins>+ m_client->dismissCurrentJavaScriptDialogOnPage(*this, *page);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void WebAutomationSession::acceptCurrentJavaScriptDialog(Inspector::ErrorString& errorString, const String& browsingContextHandle)
</span><span class="lines">@@ -560,10 +560,10 @@
</span><span class="cx"> if (!page)
</span><span class="cx"> FAIL_WITH_PREDEFINED_ERROR(WindowNotFound);
</span><span class="cx">
</span><del>- if (!m_client->isShowingJavaScriptDialogOnPage(this, page))
</del><ins>+ if (!m_client->isShowingJavaScriptDialogOnPage(*this, *page))
</ins><span class="cx"> FAIL_WITH_PREDEFINED_ERROR(NoJavaScriptDialog);
</span><span class="cx">
</span><del>- m_client->acceptCurrentJavaScriptDialogOnPage(this, page);
</del><ins>+ m_client->acceptCurrentJavaScriptDialogOnPage(*this, *page);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void WebAutomationSession::messageOfCurrentJavaScriptDialog(Inspector::ErrorString& errorString, const String& browsingContextHandle, String* text)
</span><span class="lines">@@ -576,10 +576,10 @@
</span><span class="cx"> if (!page)
</span><span class="cx"> FAIL_WITH_PREDEFINED_ERROR(WindowNotFound);
</span><span class="cx">
</span><del>- if (!m_client->isShowingJavaScriptDialogOnPage(this, page))
</del><ins>+ if (!m_client->isShowingJavaScriptDialogOnPage(*this, *page))
</ins><span class="cx"> FAIL_WITH_PREDEFINED_ERROR(NoJavaScriptDialog);
</span><span class="cx">
</span><del>- *text = m_client->messageOfCurrentJavaScriptDialogOnPage(this, page);
</del><ins>+ *text = m_client->messageOfCurrentJavaScriptDialogOnPage(*this, *page);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void WebAutomationSession::setUserInputForCurrentJavaScriptPrompt(Inspector::ErrorString& errorString, const String& browsingContextHandle, const String& promptValue)
</span><span class="lines">@@ -592,10 +592,10 @@
</span><span class="cx"> if (!page)
</span><span class="cx"> FAIL_WITH_PREDEFINED_ERROR(WindowNotFound);
</span><span class="cx">
</span><del>- if (!m_client->isShowingJavaScriptDialogOnPage(this, page))
</del><ins>+ if (!m_client->isShowingJavaScriptDialogOnPage(*this, *page))
</ins><span class="cx"> FAIL_WITH_PREDEFINED_ERROR(NoJavaScriptDialog);
</span><span class="cx">
</span><del>- m_client->setUserInputForCurrentJavaScriptPromptOnPage(this, page, promptValue);
</del><ins>+ m_client->setUserInputForCurrentJavaScriptPromptOnPage(*this, *page, promptValue);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void WebAutomationSession::getAllCookies(ErrorString& errorString, const String& browsingContextHandle, Ref<GetAllCookiesCallback>&& callback)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaAutomationSessionClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/AutomationSessionClient.h (213303 => 213304)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/AutomationSessionClient.h        2017-03-02 22:09:29 UTC (rev 213303)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/AutomationSessionClient.h        2017-03-02 22:30:23 UTC (rev 213304)
</span><span class="lines">@@ -43,20 +43,29 @@
</span><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> // From API::AutomationSessionClient
</span><del>- WebPageProxy* didRequestNewWindow(WebAutomationSession*) override;
- void didDisconnectFromRemote(WebAutomationSession *) override;
</del><ins>+ WebPageProxy* didRequestNewWindow(WebAutomationSession&) override;
+ void didDisconnectFromRemote(WebAutomationSession&) override;
</ins><span class="cx">
</span><del>- bool isShowingJavaScriptDialogOnPage(WebAutomationSession*, WebPageProxy*) override;
- void dismissCurrentJavaScriptDialogOnPage(WebAutomationSession*, WebPageProxy*) override;
- void acceptCurrentJavaScriptDialogOnPage(WebAutomationSession*, WebPageProxy*) override;
- String messageOfCurrentJavaScriptDialogOnPage(WebAutomationSession*, WebPageProxy*) override;
- void setUserInputForCurrentJavaScriptPromptOnPage(WebAutomationSession*, WebPageProxy*, const String&) override;
</del><ins>+ bool isShowingJavaScriptDialogOnPage(WebAutomationSession&, WebPageProxy&) override;
+ void dismissCurrentJavaScriptDialogOnPage(WebAutomationSession&, WebPageProxy&) override;
+ void acceptCurrentJavaScriptDialogOnPage(WebAutomationSession&, WebPageProxy&) override;
+ String messageOfCurrentJavaScriptDialogOnPage(WebAutomationSession&, WebPageProxy&) override;
+ void setUserInputForCurrentJavaScriptPromptOnPage(WebAutomationSession&, WebPageProxy&, const String&) override;
</ins><span class="cx">
</span><span class="cx"> WeakObjCPtr<id <_WKAutomationSessionDelegate>> m_delegate;
</span><span class="cx">
</span><span class="cx"> struct {
</span><ins>+ bool didDisconnectFromRemote : 1;
+
+ bool didRequestNewWebView : 1;
+ bool isShowingJavaScriptDialogForWebView : 1;
+ bool dismissCurrentJavaScriptDialogForWebView : 1;
+ bool acceptCurrentJavaScriptDialogForWebView : 1;
+ bool messageOfCurrentJavaScriptDialogForWebView : 1;
+ bool setUserInputForCurrentJavaScriptPromptForWebView : 1;
+
+ // FIXME 28524687: these delegate methods should be removed.
</ins><span class="cx"> bool didRequestNewWindow : 1;
</span><del>- bool didDisconnectFromRemote : 1;
</del><span class="cx"> bool isShowingJavaScriptDialogOnPage : 1;
</span><span class="cx"> bool dismissCurrentJavaScriptDialogOnPage : 1;
</span><span class="cx"> bool acceptCurrentJavaScriptDialogOnPage : 1;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaAutomationSessionClientmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/AutomationSessionClient.mm (213303 => 213304)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/AutomationSessionClient.mm        2017-03-02 22:09:29 UTC (rev 213303)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/AutomationSessionClient.mm        2017-03-02 22:30:23 UTC (rev 213304)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #if WK_API_ENABLED
</span><span class="cx">
</span><span class="cx"> #import "WKSharedAPICast.h"
</span><ins>+#import "WKWebViewInternal.h"
</ins><span class="cx"> #import "WebAutomationSession.h"
</span><span class="cx"> #import "WebPageProxy.h"
</span><span class="cx"> #import "_WKAutomationSessionDelegate.h"
</span><span class="lines">@@ -39,8 +40,17 @@
</span><span class="cx"> AutomationSessionClient::AutomationSessionClient(id <_WKAutomationSessionDelegate> delegate)
</span><span class="cx"> : m_delegate(delegate)
</span><span class="cx"> {
</span><ins>+ m_delegateMethods.didDisconnectFromRemote = [delegate respondsToSelector:@selector(_automationSessionDidDisconnectFromRemote:)];
+
+ m_delegateMethods.didRequestNewWebView = [delegate respondsToSelector:@selector(_automationSessionDidRequestNewWebView:)];
+ m_delegateMethods.isShowingJavaScriptDialogForWebView = [delegate respondsToSelector:@selector(_automationSession:isShowingJavaScriptDialogForWebView:)];
+ m_delegateMethods.dismissCurrentJavaScriptDialogForWebView = [delegate respondsToSelector:@selector(_automationSession:dismissCurrentJavaScriptDialogForWebView:)];
+ m_delegateMethods.acceptCurrentJavaScriptDialogForWebView = [delegate respondsToSelector:@selector(_automationSession:acceptCurrentJavaScriptDialogForWebView:)];
+ m_delegateMethods.messageOfCurrentJavaScriptDialogForWebView = [delegate respondsToSelector:@selector(_automationSession:messageOfCurrentJavaScriptDialogForWebView:)];
+ m_delegateMethods.setUserInputForCurrentJavaScriptPromptForWebView = [delegate respondsToSelector:@selector(_automationSession:setUserInput:forCurrentJavaScriptDialogForWebView:)];
+
+ // FIXME 28524687: these delegate methods should be removed.
</ins><span class="cx"> m_delegateMethods.didRequestNewWindow = [delegate respondsToSelector:@selector(_automationSessionDidRequestNewWindow:)];
</span><del>- m_delegateMethods.didDisconnectFromRemote = [delegate respondsToSelector:@selector(_automationSessionDidDisconnectFromRemote:)];
</del><span class="cx"> m_delegateMethods.isShowingJavaScriptDialogOnPage = [delegate respondsToSelector:@selector(_automationSession:isShowingJavaScriptDialogOnPage:)];
</span><span class="cx"> m_delegateMethods.dismissCurrentJavaScriptDialogOnPage = [delegate respondsToSelector:@selector(_automationSession:dismissCurrentJavaScriptDialogOnPage:)];
</span><span class="cx"> m_delegateMethods.acceptCurrentJavaScriptDialogOnPage = [delegate respondsToSelector:@selector(_automationSession:acceptCurrentJavaScriptDialogOnPage:)];
</span><span class="lines">@@ -48,49 +58,69 @@
</span><span class="cx"> m_delegateMethods.setUserInputForCurrentJavaScriptPromptOnPage = [delegate respondsToSelector:@selector(_automationSession:setUserInput:forCurrentJavaScriptDialogOnPage:)];
</span><span class="cx"> }
</span><span class="cx">
</span><del>-WebPageProxy* AutomationSessionClient::didRequestNewWindow(WebAutomationSession* session)
</del><ins>+void AutomationSessionClient::didDisconnectFromRemote(WebAutomationSession& session)
</ins><span class="cx"> {
</span><ins>+ if (m_delegateMethods.didDisconnectFromRemote)
+ [m_delegate.get() _automationSessionDidDisconnectFromRemote:wrapper(session)];
+}
+
+// FIXME 28524687: support for WKPageRef-based delegate methods should be removed.
+// Until these are removed, prefer to use the WKWebView delegate methods if implemented.
+WebPageProxy* AutomationSessionClient::didRequestNewWindow(WebAutomationSession& session)
+{
+ if (m_delegateMethods.didRequestNewWebView)
+ return [m_delegate.get() _automationSessionDidRequestNewWebView:wrapper(session)]->_page.get();
+
</ins><span class="cx"> if (m_delegateMethods.didRequestNewWindow)
</span><del>- return toImpl([m_delegate.get() _automationSessionDidRequestNewWindow:wrapper(*session)]);
</del><ins>+ return toImpl([m_delegate.get() _automationSessionDidRequestNewWindow:wrapper(session)]);
+
</ins><span class="cx"> return nullptr;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void AutomationSessionClient::didDisconnectFromRemote(WebAutomationSession* session)
</del><ins>+bool AutomationSessionClient::isShowingJavaScriptDialogOnPage(WebAutomationSession& session, WebPageProxy& page)
</ins><span class="cx"> {
</span><del>- if (m_delegateMethods.didDisconnectFromRemote)
- [m_delegate.get() _automationSessionDidDisconnectFromRemote:wrapper(*session)];
-}
</del><ins>+ if (m_delegateMethods.isShowingJavaScriptDialogForWebView)
+ return [m_delegate.get() _automationSession:wrapper(session) isShowingJavaScriptDialogForWebView:fromWebPageProxy(page)];
</ins><span class="cx">
</span><del>-bool AutomationSessionClient::isShowingJavaScriptDialogOnPage(WebAutomationSession* session, WebPageProxy* page)
-{
</del><span class="cx"> if (m_delegateMethods.isShowingJavaScriptDialogOnPage)
</span><del>- return [m_delegate.get() _automationSession:wrapper(*session) isShowingJavaScriptDialogOnPage:toAPI(page)];
</del><ins>+ return [m_delegate.get() _automationSession:wrapper(session) isShowingJavaScriptDialogOnPage:toAPI(&page)];
+
</ins><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void AutomationSessionClient::dismissCurrentJavaScriptDialogOnPage(WebAutomationSession* session, WebPageProxy* page)
</del><ins>+void AutomationSessionClient::dismissCurrentJavaScriptDialogOnPage(WebAutomationSession& session, WebPageProxy& page)
</ins><span class="cx"> {
</span><del>- if (m_delegateMethods.dismissCurrentJavaScriptDialogOnPage)
- [m_delegate.get() _automationSession:wrapper(*session) dismissCurrentJavaScriptDialogOnPage:toAPI(page)];
</del><ins>+ if (m_delegateMethods.dismissCurrentJavaScriptDialogForWebView)
+ [m_delegate.get() _automationSession:wrapper(session) dismissCurrentJavaScriptDialogForWebView:fromWebPageProxy(page)];
+ else if (m_delegateMethods.dismissCurrentJavaScriptDialogOnPage)
+ [m_delegate.get() _automationSession:wrapper(session) dismissCurrentJavaScriptDialogOnPage:toAPI(&page)];
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void AutomationSessionClient::acceptCurrentJavaScriptDialogOnPage(WebAutomationSession* session, WebPageProxy* page)
</del><ins>+void AutomationSessionClient::acceptCurrentJavaScriptDialogOnPage(WebAutomationSession& session, WebPageProxy& page)
</ins><span class="cx"> {
</span><del>- if (m_delegateMethods.acceptCurrentJavaScriptDialogOnPage)
- [m_delegate.get() _automationSession:wrapper(*session) acceptCurrentJavaScriptDialogOnPage:toAPI(page)];
</del><ins>+ if (m_delegateMethods.acceptCurrentJavaScriptDialogForWebView)
+ [m_delegate.get() _automationSession:wrapper(session) acceptCurrentJavaScriptDialogForWebView:fromWebPageProxy(page)];
+ else if (m_delegateMethods.acceptCurrentJavaScriptDialogOnPage)
+ [m_delegate.get() _automationSession:wrapper(session) acceptCurrentJavaScriptDialogOnPage:toAPI(&page)];
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-String AutomationSessionClient::messageOfCurrentJavaScriptDialogOnPage(WebAutomationSession* session, WebPageProxy* page)
</del><ins>+String AutomationSessionClient::messageOfCurrentJavaScriptDialogOnPage(WebAutomationSession& session, WebPageProxy& page)
</ins><span class="cx"> {
</span><ins>+ if (m_delegateMethods.messageOfCurrentJavaScriptDialogForWebView)
+ return [m_delegate.get() _automationSession:wrapper(session) messageOfCurrentJavaScriptDialogForWebView:fromWebPageProxy(page)];
+
</ins><span class="cx"> if (m_delegateMethods.messageOfCurrentJavaScriptDialogOnPage)
</span><del>- return [m_delegate.get() _automationSession:wrapper(*session) messageOfCurrentJavaScriptDialogOnPage:toAPI(page)];
</del><ins>+ return [m_delegate.get() _automationSession:wrapper(session) messageOfCurrentJavaScriptDialogOnPage:toAPI(&page)];
+
</ins><span class="cx"> return String();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void AutomationSessionClient::setUserInputForCurrentJavaScriptPromptOnPage(WebAutomationSession* session, WebPageProxy* page, const String& value)
</del><ins>+void AutomationSessionClient::setUserInputForCurrentJavaScriptPromptOnPage(WebAutomationSession& session, WebPageProxy& page, const String& value)
</ins><span class="cx"> {
</span><del>- if (m_delegateMethods.setUserInputForCurrentJavaScriptPromptOnPage)
- [m_delegate.get() _automationSession:wrapper(*session) setUserInput:value forCurrentJavaScriptDialogOnPage:toAPI(page)];
</del><ins>+ if (m_delegateMethods.setUserInputForCurrentJavaScriptPromptForWebView)
+ [m_delegate.get() _automationSession:wrapper(session) setUserInput:value forCurrentJavaScriptDialogForWebView:fromWebPageProxy(page)];
+ else if (m_delegateMethods.setUserInputForCurrentJavaScriptPromptOnPage)
+ [m_delegate.get() _automationSession:wrapper(session) setUserInput:value forCurrentJavaScriptDialogOnPage:toAPI(&page)];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> } // namespace WebKit
</span></span></pre>
</div>
</div>
</body>
</html>