Title: [213304] trunk/Source/WebKit2
Revision
213304
Author
[email protected]
Date
2017-03-02 14:30:23 -0800 (Thu, 02 Mar 2017)

Log Message

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.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (213303 => 213304)


--- 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)
@@ -1,3 +1,60 @@
+2017-03-02  Brian Burg  <[email protected]>
+
+        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.
+
 2017-03-02  Alex Christensen  <[email protected]>
 
         Continue enabling WebRTC

Modified: trunk/Source/WebKit2/UIProcess/API/APIAutomationSessionClient.h (213303 => 213304)


--- 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)
@@ -40,13 +40,13 @@
     virtual ~AutomationSessionClient() { }
 
     virtual String sessionIdentifier() const { return String(); }
-    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&) { }
+    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&) { }
 };
 
 } // namespace API

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKAutomationSessionDelegate.h (213303 => 213304)


--- 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)
@@ -30,13 +30,24 @@
 #import <Foundation/Foundation.h>
 #import <WebKit/WKBase.h>
 
+@class WKWebView;
 @class _WKAutomationSession;
 
 @protocol _WKAutomationSessionDelegate <NSObject>
 @optional
-- (WKPageRef)_automationSessionDidRequestNewWindow:(_WKAutomationSession *)automationSession;
+
 - (void)_automationSessionDidDisconnectFromRemote:(_WKAutomationSession *)automationSession;
 
+- (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;
 - (BOOL)_automationSession:(_WKAutomationSession *)automationSession isShowingJavaScriptDialogOnPage:(WKPageRef)page;
 - (void)_automationSession:(_WKAutomationSession *)automationSession dismissCurrentJavaScriptDialogOnPage:(WKPageRef)page;
 - (void)_automationSession:(_WKAutomationSession *)automationSession acceptCurrentJavaScriptDialogOnPage:(WKPageRef)page;

Modified: trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp (213303 => 213304)


--- 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)
@@ -121,7 +121,7 @@
 #endif
 
     if (m_client)
-        m_client->didDisconnectFromRemote(this);
+        m_client->didDisconnectFromRemote(*this);
 }
 
 WebPageProxy* WebAutomationSession::webPageProxyForHandle(const String& handle)
@@ -252,7 +252,7 @@
     if (!m_client)
         FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InternalError, "The remote session could not request a new browsing context.");
 
-    WebPageProxy* page = m_client->didRequestNewWindow(this);
+    WebPageProxy* page = m_client->didRequestNewWindow(*this);
     if (!page)
         FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InternalError, "The remote session failed to create a new browsing context.");
 
@@ -531,7 +531,7 @@
     if (!page)
         FAIL_WITH_PREDEFINED_ERROR(WindowNotFound);
 
-    *result = m_client->isShowingJavaScriptDialogOnPage(this, page);
+    *result = m_client->isShowingJavaScriptDialogOnPage(*this, *page);
 }
 
 void WebAutomationSession::dismissCurrentJavaScriptDialog(Inspector::ErrorString& errorString, const String& browsingContextHandle)
@@ -544,10 +544,10 @@
     if (!page)
         FAIL_WITH_PREDEFINED_ERROR(WindowNotFound);
 
-    if (!m_client->isShowingJavaScriptDialogOnPage(this, page))
+    if (!m_client->isShowingJavaScriptDialogOnPage(*this, *page))
         FAIL_WITH_PREDEFINED_ERROR(NoJavaScriptDialog);
 
-    m_client->dismissCurrentJavaScriptDialogOnPage(this, page);
+    m_client->dismissCurrentJavaScriptDialogOnPage(*this, *page);
 }
 
 void WebAutomationSession::acceptCurrentJavaScriptDialog(Inspector::ErrorString& errorString, const String& browsingContextHandle)
@@ -560,10 +560,10 @@
     if (!page)
         FAIL_WITH_PREDEFINED_ERROR(WindowNotFound);
 
-    if (!m_client->isShowingJavaScriptDialogOnPage(this, page))
+    if (!m_client->isShowingJavaScriptDialogOnPage(*this, *page))
         FAIL_WITH_PREDEFINED_ERROR(NoJavaScriptDialog);
 
-    m_client->acceptCurrentJavaScriptDialogOnPage(this, page);
+    m_client->acceptCurrentJavaScriptDialogOnPage(*this, *page);
 }
 
 void WebAutomationSession::messageOfCurrentJavaScriptDialog(Inspector::ErrorString& errorString, const String& browsingContextHandle, String* text)
@@ -576,10 +576,10 @@
     if (!page)
         FAIL_WITH_PREDEFINED_ERROR(WindowNotFound);
 
-    if (!m_client->isShowingJavaScriptDialogOnPage(this, page))
+    if (!m_client->isShowingJavaScriptDialogOnPage(*this, *page))
         FAIL_WITH_PREDEFINED_ERROR(NoJavaScriptDialog);
 
-    *text = m_client->messageOfCurrentJavaScriptDialogOnPage(this, page);
+    *text = m_client->messageOfCurrentJavaScriptDialogOnPage(*this, *page);
 }
 
 void WebAutomationSession::setUserInputForCurrentJavaScriptPrompt(Inspector::ErrorString& errorString, const String& browsingContextHandle, const String& promptValue)
@@ -592,10 +592,10 @@
     if (!page)
         FAIL_WITH_PREDEFINED_ERROR(WindowNotFound);
 
-    if (!m_client->isShowingJavaScriptDialogOnPage(this, page))
+    if (!m_client->isShowingJavaScriptDialogOnPage(*this, *page))
         FAIL_WITH_PREDEFINED_ERROR(NoJavaScriptDialog);
 
-    m_client->setUserInputForCurrentJavaScriptPromptOnPage(this, page, promptValue);
+    m_client->setUserInputForCurrentJavaScriptPromptOnPage(*this, *page, promptValue);
 }
 
 void WebAutomationSession::getAllCookies(ErrorString& errorString, const String& browsingContextHandle, Ref<GetAllCookiesCallback>&& callback)

Modified: trunk/Source/WebKit2/UIProcess/Cocoa/AutomationSessionClient.h (213303 => 213304)


--- 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)
@@ -43,20 +43,29 @@
 
 private:
     // From API::AutomationSessionClient
-    WebPageProxy* didRequestNewWindow(WebAutomationSession*) override;
-    void didDisconnectFromRemote(WebAutomationSession *) override;
+    WebPageProxy* didRequestNewWindow(WebAutomationSession&) override;
+    void didDisconnectFromRemote(WebAutomationSession&) override;
 
-    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;
+    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;
 
     WeakObjCPtr<id <_WKAutomationSessionDelegate>> m_delegate;
 
     struct {
+        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.
         bool didRequestNewWindow : 1;
-        bool didDisconnectFromRemote : 1;
         bool isShowingJavaScriptDialogOnPage : 1;
         bool dismissCurrentJavaScriptDialogOnPage : 1;
         bool acceptCurrentJavaScriptDialogOnPage : 1;

Modified: trunk/Source/WebKit2/UIProcess/Cocoa/AutomationSessionClient.mm (213303 => 213304)


--- 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)
@@ -29,6 +29,7 @@
 #if WK_API_ENABLED
 
 #import "WKSharedAPICast.h"
+#import "WKWebViewInternal.h"
 #import "WebAutomationSession.h"
 #import "WebPageProxy.h"
 #import "_WKAutomationSessionDelegate.h"
@@ -39,8 +40,17 @@
 AutomationSessionClient::AutomationSessionClient(id <_WKAutomationSessionDelegate> delegate)
     : m_delegate(delegate)
 {
+    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.
     m_delegateMethods.didRequestNewWindow = [delegate respondsToSelector:@selector(_automationSessionDidRequestNewWindow:)];
-    m_delegateMethods.didDisconnectFromRemote = [delegate respondsToSelector:@selector(_automationSessionDidDisconnectFromRemote:)];
     m_delegateMethods.isShowingJavaScriptDialogOnPage = [delegate respondsToSelector:@selector(_automationSession:isShowingJavaScriptDialogOnPage:)];
     m_delegateMethods.dismissCurrentJavaScriptDialogOnPage = [delegate respondsToSelector:@selector(_automationSession:dismissCurrentJavaScriptDialogOnPage:)];
     m_delegateMethods.acceptCurrentJavaScriptDialogOnPage = [delegate respondsToSelector:@selector(_automationSession:acceptCurrentJavaScriptDialogOnPage:)];
@@ -48,49 +58,69 @@
     m_delegateMethods.setUserInputForCurrentJavaScriptPromptOnPage = [delegate respondsToSelector:@selector(_automationSession:setUserInput:forCurrentJavaScriptDialogOnPage:)];
 }
 
-WebPageProxy* AutomationSessionClient::didRequestNewWindow(WebAutomationSession* session)
+void AutomationSessionClient::didDisconnectFromRemote(WebAutomationSession& session)
 {
+    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();
+
     if (m_delegateMethods.didRequestNewWindow)
-        return toImpl([m_delegate.get() _automationSessionDidRequestNewWindow:wrapper(*session)]);
+        return toImpl([m_delegate.get() _automationSessionDidRequestNewWindow:wrapper(session)]);
+
     return nullptr;
 }
 
-void AutomationSessionClient::didDisconnectFromRemote(WebAutomationSession* session)
+bool AutomationSessionClient::isShowingJavaScriptDialogOnPage(WebAutomationSession& session, WebPageProxy& page)
 {
-    if (m_delegateMethods.didDisconnectFromRemote)
-        [m_delegate.get() _automationSessionDidDisconnectFromRemote:wrapper(*session)];
-}
+    if (m_delegateMethods.isShowingJavaScriptDialogForWebView)
+        return [m_delegate.get() _automationSession:wrapper(session) isShowingJavaScriptDialogForWebView:fromWebPageProxy(page)];
 
-bool AutomationSessionClient::isShowingJavaScriptDialogOnPage(WebAutomationSession* session, WebPageProxy* page)
-{
     if (m_delegateMethods.isShowingJavaScriptDialogOnPage)
-        return [m_delegate.get() _automationSession:wrapper(*session) isShowingJavaScriptDialogOnPage:toAPI(page)];
+        return [m_delegate.get() _automationSession:wrapper(session) isShowingJavaScriptDialogOnPage:toAPI(&page)];
+
     return false;
 }
 
-void AutomationSessionClient::dismissCurrentJavaScriptDialogOnPage(WebAutomationSession* session, WebPageProxy* page)
+void AutomationSessionClient::dismissCurrentJavaScriptDialogOnPage(WebAutomationSession& session, WebPageProxy& page)
 {
-    if (m_delegateMethods.dismissCurrentJavaScriptDialogOnPage)
-        [m_delegate.get() _automationSession:wrapper(*session) dismissCurrentJavaScriptDialogOnPage:toAPI(page)];
+    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)];
 }
 
-void AutomationSessionClient::acceptCurrentJavaScriptDialogOnPage(WebAutomationSession* session, WebPageProxy* page)
+void AutomationSessionClient::acceptCurrentJavaScriptDialogOnPage(WebAutomationSession& session, WebPageProxy& page)
 {
-    if (m_delegateMethods.acceptCurrentJavaScriptDialogOnPage)
-        [m_delegate.get() _automationSession:wrapper(*session) acceptCurrentJavaScriptDialogOnPage:toAPI(page)];
+    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)];
 }
 
-String AutomationSessionClient::messageOfCurrentJavaScriptDialogOnPage(WebAutomationSession* session, WebPageProxy* page)
+String AutomationSessionClient::messageOfCurrentJavaScriptDialogOnPage(WebAutomationSession& session, WebPageProxy& page)
 {
+    if (m_delegateMethods.messageOfCurrentJavaScriptDialogForWebView)
+        return [m_delegate.get() _automationSession:wrapper(session) messageOfCurrentJavaScriptDialogForWebView:fromWebPageProxy(page)];
+
     if (m_delegateMethods.messageOfCurrentJavaScriptDialogOnPage)
-        return [m_delegate.get() _automationSession:wrapper(*session) messageOfCurrentJavaScriptDialogOnPage:toAPI(page)];
+        return [m_delegate.get() _automationSession:wrapper(session) messageOfCurrentJavaScriptDialogOnPage:toAPI(&page)];
+
     return String();
 }
 
-void AutomationSessionClient::setUserInputForCurrentJavaScriptPromptOnPage(WebAutomationSession* session, WebPageProxy* page, const String& value)
+void AutomationSessionClient::setUserInputForCurrentJavaScriptPromptOnPage(WebAutomationSession& session, WebPageProxy& page, const String& value)
 {
-    if (m_delegateMethods.setUserInputForCurrentJavaScriptPromptOnPage)
-        [m_delegate.get() _automationSession:wrapper(*session) setUserInput:value forCurrentJavaScriptDialogOnPage:toAPI(page)];
+    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)];
 }
 
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to