Update JavaScript dialog delegates to include a WKSecurityOriginRef argument.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Jun 2015 16:57:30 +0000 (16:57 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Jun 2015 16:57:30 +0000 (16:57 +0000)
<rdar://problem/21269187> and https://bugs.webkit.org/show_bug.cgi?id=146249

Reviewed by Alex Christensen.

Source/WebKit2:

* UIProcess/API/C/WKPage.cpp:
(WKPageSetPageUIClient): Call the new signature if the client has it set.
  Otherwise fall back to the old signature.
* UIProcess/API/C/WKPageUIClient.h: Deprecate the old method signature, and add the new
  one to the newest V5 client structure.

Tools:

- Update WKTR to the new client structure.
- Update existing TestWebKitAPI tests to either use the new client structure or
  assign the old function signature to the updated variable name.
- Include a new test.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:

* TestWebKitAPI/Tests/WebKit2/CloseFromWithinCreatePage.cpp:
(TestWebKitAPI::runJavaScriptAlert):

* TestWebKitAPI/Tests/WebKit2/DocumentStartUserScriptAlertCrash.cpp:
(TestWebKitAPI::TEST):

* TestWebKitAPI/Tests/WebKit2/ModalAlertsSPI.cpp:
(TestWebKitAPI::analyzeDialogArguments):
(TestWebKitAPI::runJavaScriptAlert):
(TestWebKitAPI::runJavaScriptConfirm):
(TestWebKitAPI::runJavaScriptPrompt):
(TestWebKitAPI::createNewPage):
(TestWebKitAPI::TEST):

* TestWebKitAPI/Tests/mac/FullscreenZoomInitialFrame.mm:
(TestWebKitAPI::FullscreenZoomInitialFrame::initializeView):

* TestWebKitAPI/Tests/mac/PageVisibilityStateWithWindowChanges.mm:
(TestWebKitAPI::PageVisibilityStateWithWindowChanges::initializeView):

* WebKitTestRunner/TestController.cpp:
(WTR::TestController::createOtherPage):
(WTR::TestController::createWebViewWithOptions):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@185915 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/C/WKPage.cpp
Source/WebKit2/UIProcess/API/C/WKPageUIClient.h
Source/WebKit2/UIProcess/efl/PageUIClientEfl.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit2/CloseFromWithinCreatePage.cpp
Tools/TestWebKitAPI/Tests/WebKit2/DocumentStartUserScriptAlertCrash.cpp
Tools/TestWebKitAPI/Tests/WebKit2/ModalAlertsSPI.cpp [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/mac/FullscreenZoomInitialFrame.mm
Tools/TestWebKitAPI/Tests/mac/PageVisibilityStateWithWindowChanges.mm
Tools/WebKitTestRunner/TestController.cpp

index e218921..bc6d334 100644 (file)
@@ -1,3 +1,16 @@
+2015-06-24  Brady Eidson  <beidson@apple.com>
+
+        Update JavaScript dialog delegates to include a WKSecurityOriginRef argument.
+        <rdar://problem/21269187> and https://bugs.webkit.org/show_bug.cgi?id=146249
+
+        Reviewed by Alex Christensen.
+
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageSetPageUIClient): Call the new signature if the client has it set.
+          Otherwise fall back to the old signature.
+        * UIProcess/API/C/WKPageUIClient.h: Deprecate the old method signature, and add the new
+          one to the newest V5 client structure.
+
 2015-06-24  Ryuan Choi  <ryuan.choi@navercorp.com>
 
         Remove some dead code from Download
index e2b4ae8..6f98915 100644 (file)
@@ -1408,36 +1408,53 @@ void WKPageSetPageUIClient(WKPageRef pageRef, const WKPageUIClientBase* wkClient
             m_client.unfocus(toAPI(page), m_client.base.clientInfo);
         }
 
-        virtual void runJavaScriptAlert(WebPageProxy* page, const String& message, WebFrameProxy* frame, const SecurityOriginData&, std::function<void ()> completionHandler) override
+        virtual void runJavaScriptAlert(WebPageProxy* page, const String& message, WebFrameProxy* frame, const SecurityOriginData& securityOriginData, std::function<void ()> completionHandler) override
         {
-            if (!m_client.runJavaScriptAlert) {
+            if (!m_client.runJavaScriptAlert && !m_client.runJavaScriptAlert_deprecatedForUseWithV0) {
                 completionHandler();
                 return;
             }
 
-            m_client.runJavaScriptAlert(toAPI(page), toAPI(message.impl()), toAPI(frame), m_client.base.clientInfo);
+            if (m_client.runJavaScriptAlert) {
+                RefPtr<API::SecurityOrigin> securityOrigin = API::SecurityOrigin::create(securityOriginData.protocol, securityOriginData.host, securityOriginData.port);
+                m_client.runJavaScriptAlert(toAPI(page), toAPI(message.impl()), toAPI(frame), toAPI(securityOrigin.get()), m_client.base.clientInfo);
+            } else
+                m_client.runJavaScriptAlert_deprecatedForUseWithV0(toAPI(page), toAPI(message.impl()), toAPI(frame), m_client.base.clientInfo);
+
             completionHandler();
         }
 
-        virtual void runJavaScriptConfirm(WebPageProxy* page, const String& message, WebFrameProxy* frame, const SecurityOriginData&, std::function<void (bool)> completionHandler) override
+        virtual void runJavaScriptConfirm(WebPageProxy* page, const String& message, WebFrameProxy* frame, const SecurityOriginData& securityOriginData, std::function<void (bool)> completionHandler) override
         {
-            if (!m_client.runJavaScriptConfirm) {
+            if (!m_client.runJavaScriptConfirm && !m_client.runJavaScriptConfirm_deprecatedForUseWithV0) {
                 completionHandler(false);
                 return;
             }
 
-            bool result = m_client.runJavaScriptConfirm(toAPI(page), toAPI(message.impl()), toAPI(frame), m_client.base.clientInfo);
+            bool result;
+            if (m_client.runJavaScriptConfirm) {
+                RefPtr<API::SecurityOrigin> securityOrigin = API::SecurityOrigin::create(securityOriginData.protocol, securityOriginData.host, securityOriginData.port);
+                result = m_client.runJavaScriptConfirm(toAPI(page), toAPI(message.impl()), toAPI(frame), toAPI(securityOrigin.get()), m_client.base.clientInfo);
+            } else
+                result = m_client.runJavaScriptConfirm_deprecatedForUseWithV0(toAPI(page), toAPI(message.impl()), toAPI(frame), m_client.base.clientInfo);
+
             completionHandler(result);
         }
 
-        virtual void runJavaScriptPrompt(WebPageProxy* page, const String& message, const String& defaultValue, WebFrameProxy* frame, const SecurityOriginData&, std::function<void (const String&)> completionHandler) override
+        virtual void runJavaScriptPrompt(WebPageProxy* page, const String& message, const String& defaultValue, WebFrameProxy* frame, const SecurityOriginData& securityOriginData, std::function<void (const String&)> completionHandler) override
         {
-            if (!m_client.runJavaScriptPrompt) {
+            if (!m_client.runJavaScriptPrompt && !m_client.runJavaScriptPrompt_deprecatedForUseWithV0) {
                 completionHandler(String());
                 return;
             }
 
-            RefPtr<API::String> string = adoptRef(toImpl(m_client.runJavaScriptPrompt(toAPI(page), toAPI(message.impl()), toAPI(defaultValue.impl()), toAPI(frame), m_client.base.clientInfo)));
+            RefPtr<API::String> string;
+            if (m_client.runJavaScriptPrompt) {
+                RefPtr<API::SecurityOrigin> securityOrigin = API::SecurityOrigin::create(securityOriginData.protocol, securityOriginData.host, securityOriginData.port);
+                string = adoptRef(toImpl(m_client.runJavaScriptPrompt(toAPI(page), toAPI(message.impl()), toAPI(defaultValue.impl()), toAPI(frame), toAPI(securityOrigin.get()), m_client.base.clientInfo)));
+            } else
+                string = adoptRef(toImpl(m_client.runJavaScriptPrompt_deprecatedForUseWithV0(toAPI(page), toAPI(message.impl()), toAPI(defaultValue.impl()), toAPI(frame), m_client.base.clientInfo)));
+
             if (!string) {
                 completionHandler(String());
                 return;
index 9ca066d..cc90eee 100644 (file)
@@ -50,9 +50,9 @@ typedef uint32_t WKPluginUnavailabilityReason;
 
 typedef void (*WKPageUIClientCallback)(WKPageRef page, const void* clientInfo);
 typedef WKPageRef (*WKPageCreateNewPageCallback)(WKPageRef page, WKURLRequestRef urlRequest, WKDictionaryRef features, WKEventModifiers modifiers, WKEventMouseButton mouseButton, const void *clientInfo);
-typedef void (*WKPageRunJavaScriptAlertCallback)(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void *clientInfo);
-typedef bool (*WKPageRunJavaScriptConfirmCallback)(WKPageRef page, WKStringRef message, WKFrameRef frame, const void *clientInfo);
-typedef WKStringRef (*WKPageRunJavaScriptPromptCallback)(WKPageRef page, WKStringRef message, WKStringRef defaultValue, WKFrameRef frame, const void *clientInfo);
+typedef void (*WKPageRunJavaScriptAlertCallback)(WKPageRef page, WKStringRef alertText, WKFrameRef frame, WKSecurityOriginRef securityOrigin, const void *clientInfo);
+typedef bool (*WKPageRunJavaScriptConfirmCallback)(WKPageRef page, WKStringRef message, WKFrameRef frame, WKSecurityOriginRef securityOrigin, const void *clientInfo);
+typedef WKStringRef (*WKPageRunJavaScriptPromptCallback)(WKPageRef page, WKStringRef message, WKStringRef defaultValue, WKFrameRef frame, WKSecurityOriginRef securityOrigin, const void *clientInfo);
 typedef void (*WKPageTakeFocusCallback)(WKPageRef page, WKFocusDirection direction, const void *clientInfo);
 typedef void (*WKPageFocusCallback)(WKPageRef page, const void *clientInfo);
 typedef void (*WKPageUnfocusCallback)(WKPageRef page, const void *clientInfo);
@@ -97,6 +97,9 @@ typedef WKPageRef (*WKPageCreateNewPageCallback_deprecatedForUseWithV0)(WKPageRe
 typedef void      (*WKPageMouseDidMoveOverElementCallback_deprecatedForUseWithV0)(WKPageRef page, WKEventModifiers modifiers, WKTypeRef userData, const void *clientInfo);
 typedef void (*WKPageMissingPluginButtonClickedCallback_deprecatedForUseWithV0)(WKPageRef page, WKStringRef mimeType, WKStringRef url, WKStringRef pluginsPageURL, const void* clientInfo);
 typedef void (*WKPageUnavailablePluginButtonClickedCallback_deprecatedForUseWithV1)(WKPageRef page, WKPluginUnavailabilityReason pluginUnavailabilityReason, WKStringRef mimeType, WKStringRef url, WKStringRef pluginsPageURL, const void* clientInfo);
+typedef void (*WKPageRunJavaScriptAlertCallback_deprecatedForUseWithV0)(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void *clientInfo);
+typedef bool (*WKPageRunJavaScriptConfirmCallback_deprecatedForUseWithV0)(WKPageRef page, WKStringRef message, WKFrameRef frame, const void *clientInfo);
+typedef WKStringRef (*WKPageRunJavaScriptPromptCallback_deprecatedForUseWithV0)(WKPageRef page, WKStringRef message, WKStringRef defaultValue, WKFrameRef frame, const void *clientInfo);
 
 typedef struct WKPageUIClientBase {
     int                                                                 version;
@@ -113,9 +116,9 @@ typedef struct WKPageUIClientV0 {
     WKPageTakeFocusCallback                                             takeFocus;
     WKPageFocusCallback                                                 focus;
     WKPageUnfocusCallback                                               unfocus;
-    WKPageRunJavaScriptAlertCallback                                    runJavaScriptAlert;
-    WKPageRunJavaScriptConfirmCallback                                  runJavaScriptConfirm;
-    WKPageRunJavaScriptPromptCallback                                   runJavaScriptPrompt;
+    WKPageRunJavaScriptAlertCallback_deprecatedForUseWithV0             runJavaScriptAlert_deprecatedForUseWithV0;
+    WKPageRunJavaScriptConfirmCallback_deprecatedForUseWithV0           runJavaScriptConfirm_deprecatedForUseWithV0;
+    WKPageRunJavaScriptPromptCallback_deprecatedForUseWithV0            runJavaScriptPrompt_deprecatedForUseWithV0;
     WKPageSetStatusTextCallback                                         setStatusText;
     WKPageMouseDidMoveOverElementCallback_deprecatedForUseWithV0        mouseDidMoveOverElement_deprecatedForUseWithV0;
     WKPageMissingPluginButtonClickedCallback_deprecatedForUseWithV0     missingPluginButtonClicked_deprecatedForUseWithV0;
@@ -158,9 +161,9 @@ typedef struct WKPageUIClientV1 {
     WKPageTakeFocusCallback                                             takeFocus;
     WKPageFocusCallback                                                 focus;
     WKPageUnfocusCallback                                               unfocus;
-    WKPageRunJavaScriptAlertCallback                                    runJavaScriptAlert;
-    WKPageRunJavaScriptConfirmCallback                                  runJavaScriptConfirm;
-    WKPageRunJavaScriptPromptCallback                                   runJavaScriptPrompt;
+    WKPageRunJavaScriptAlertCallback_deprecatedForUseWithV0             runJavaScriptAlert_deprecatedForUseWithV0;
+    WKPageRunJavaScriptConfirmCallback_deprecatedForUseWithV0           runJavaScriptConfirm_deprecatedForUseWithV0;
+    WKPageRunJavaScriptPromptCallback_deprecatedForUseWithV0            runJavaScriptPrompt_deprecatedForUseWithV0;
     WKPageSetStatusTextCallback                                         setStatusText;
     WKPageMouseDidMoveOverElementCallback_deprecatedForUseWithV0        mouseDidMoveOverElement_deprecatedForUseWithV0;
     WKPageMissingPluginButtonClickedCallback_deprecatedForUseWithV0     missingPluginButtonClicked_deprecatedForUseWithV0;
@@ -209,9 +212,9 @@ typedef struct WKPageUIClientV2 {
     WKPageTakeFocusCallback                                             takeFocus;
     WKPageFocusCallback                                                 focus;
     WKPageUnfocusCallback                                               unfocus;
-    WKPageRunJavaScriptAlertCallback                                    runJavaScriptAlert;
-    WKPageRunJavaScriptConfirmCallback                                  runJavaScriptConfirm;
-    WKPageRunJavaScriptPromptCallback                                   runJavaScriptPrompt;
+    WKPageRunJavaScriptAlertCallback_deprecatedForUseWithV0             runJavaScriptAlert_deprecatedForUseWithV0;
+    WKPageRunJavaScriptConfirmCallback_deprecatedForUseWithV0           runJavaScriptConfirm_deprecatedForUseWithV0;
+    WKPageRunJavaScriptPromptCallback_deprecatedForUseWithV0            runJavaScriptPrompt_deprecatedForUseWithV0;
     WKPageSetStatusTextCallback                                         setStatusText;
     WKPageMouseDidMoveOverElementCallback_deprecatedForUseWithV0        mouseDidMoveOverElement_deprecatedForUseWithV0;
     WKPageMissingPluginButtonClickedCallback_deprecatedForUseWithV0     missingPluginButtonClicked_deprecatedForUseWithV0;
@@ -265,9 +268,9 @@ typedef struct WKPageUIClientV3 {
     WKPageTakeFocusCallback                                             takeFocus;
     WKPageFocusCallback                                                 focus;
     WKPageUnfocusCallback                                               unfocus;
-    WKPageRunJavaScriptAlertCallback                                    runJavaScriptAlert;
-    WKPageRunJavaScriptConfirmCallback                                  runJavaScriptConfirm;
-    WKPageRunJavaScriptPromptCallback                                   runJavaScriptPrompt;
+    WKPageRunJavaScriptAlertCallback_deprecatedForUseWithV0             runJavaScriptAlert_deprecatedForUseWithV0;
+    WKPageRunJavaScriptConfirmCallback_deprecatedForUseWithV0           runJavaScriptConfirm_deprecatedForUseWithV0;
+    WKPageRunJavaScriptPromptCallback_deprecatedForUseWithV0            runJavaScriptPrompt_deprecatedForUseWithV0;
     WKPageSetStatusTextCallback                                         setStatusText;
     WKPageMouseDidMoveOverElementCallback_deprecatedForUseWithV0        mouseDidMoveOverElement_deprecatedForUseWithV0;
     WKPageMissingPluginButtonClickedCallback_deprecatedForUseWithV0     missingPluginButtonClicked_deprecatedForUseWithV0;
@@ -324,9 +327,9 @@ typedef struct WKPageUIClientV4 {
     WKPageTakeFocusCallback                                             takeFocus;
     WKPageFocusCallback                                                 focus;
     WKPageUnfocusCallback                                               unfocus;
-    WKPageRunJavaScriptAlertCallback                                    runJavaScriptAlert;
-    WKPageRunJavaScriptConfirmCallback                                  runJavaScriptConfirm;
-    WKPageRunJavaScriptPromptCallback                                   runJavaScriptPrompt;
+    WKPageRunJavaScriptAlertCallback_deprecatedForUseWithV0             runJavaScriptAlert_deprecatedForUseWithV0;
+    WKPageRunJavaScriptConfirmCallback_deprecatedForUseWithV0           runJavaScriptConfirm_deprecatedForUseWithV0;
+    WKPageRunJavaScriptPromptCallback_deprecatedForUseWithV0            runJavaScriptPrompt_deprecatedForUseWithV0;
     WKPageSetStatusTextCallback                                         setStatusText;
     WKPageMouseDidMoveOverElementCallback_deprecatedForUseWithV0        mouseDidMoveOverElement_deprecatedForUseWithV0;
     WKPageMissingPluginButtonClickedCallback_deprecatedForUseWithV0     missingPluginButtonClicked_deprecatedForUseWithV0;
@@ -389,9 +392,9 @@ typedef struct WKPageUIClientV5 {
     WKPageTakeFocusCallback                                             takeFocus;
     WKPageFocusCallback                                                 focus;
     WKPageUnfocusCallback                                               unfocus;
-    WKPageRunJavaScriptAlertCallback                                    runJavaScriptAlert;
-    WKPageRunJavaScriptConfirmCallback                                  runJavaScriptConfirm;
-    WKPageRunJavaScriptPromptCallback                                   runJavaScriptPrompt;
+    WKPageRunJavaScriptAlertCallback_deprecatedForUseWithV0             runJavaScriptAlert_deprecatedForUseWithV0;
+    WKPageRunJavaScriptConfirmCallback_deprecatedForUseWithV0           runJavaScriptConfirm_deprecatedForUseWithV0;
+    WKPageRunJavaScriptPromptCallback_deprecatedForUseWithV0            runJavaScriptPrompt_deprecatedForUseWithV0;
     WKPageSetStatusTextCallback                                         setStatusText;
     WKPageMouseDidMoveOverElementCallback_deprecatedForUseWithV0        mouseDidMoveOverElement_deprecatedForUseWithV0;
     WKPageMissingPluginButtonClickedCallback_deprecatedForUseWithV0     missingPluginButtonClicked_deprecatedForUseWithV0;
@@ -446,6 +449,9 @@ typedef struct WKPageUIClientV5 {
     // Version 5.
     WKPageDecidePolicyForUserMediaPermissionRequestCallback             decidePolicyForUserMediaPermissionRequest;
     WKPageDidClickAutoFillButtonCallback                                didClickAutoFillButton;
+    WKPageRunJavaScriptAlertCallback                                    runJavaScriptAlert;
+    WKPageRunJavaScriptConfirmCallback                                  runJavaScriptConfirm;
+    WKPageRunJavaScriptPromptCallback                                   runJavaScriptPrompt;
 } WKPageUIClientV5;
 
 enum { kWKPageUIClientCurrentVersion WK_ENUM_DEPRECATED("Use an explicit version number instead") = 2 };
@@ -460,9 +466,9 @@ typedef struct WKPageUIClient {
     WKPageTakeFocusCallback                                             takeFocus;
     WKPageFocusCallback                                                 focus;
     WKPageUnfocusCallback                                               unfocus;
-    WKPageRunJavaScriptAlertCallback                                    runJavaScriptAlert;
-    WKPageRunJavaScriptConfirmCallback                                  runJavaScriptConfirm;
-    WKPageRunJavaScriptPromptCallback                                   runJavaScriptPrompt;
+    WKPageRunJavaScriptAlertCallback_deprecatedForUseWithV0             runJavaScriptAlert_deprecatedForUseWithV0;
+    WKPageRunJavaScriptConfirmCallback_deprecatedForUseWithV0           runJavaScriptConfirm_deprecatedForUseWithV0;
+    WKPageRunJavaScriptPromptCallback_deprecatedForUseWithV0            runJavaScriptPrompt_deprecatedForUseWithV0;
     WKPageSetStatusTextCallback                                         setStatusText;
     WKPageMouseDidMoveOverElementCallback_deprecatedForUseWithV0        mouseDidMoveOverElement_deprecatedForUseWithV0;
     WKPageMissingPluginButtonClickedCallback_deprecatedForUseWithV0     missingPluginButtonClicked_deprecatedForUseWithV0;
index c916b2b..2daf845 100644 (file)
@@ -60,9 +60,9 @@ PageUIClientEfl::PageUIClientEfl(EwkView* view)
     uiClient.takeFocus = takeFocus;
     uiClient.focus = focus;
     uiClient.unfocus = unfocus;
-    uiClient.runJavaScriptAlert = runJavaScriptAlert;
-    uiClient.runJavaScriptConfirm = runJavaScriptConfirm;
-    uiClient.runJavaScriptPrompt = runJavaScriptPrompt;
+    uiClient.runJavaScriptAlert_deprecatedForUseWithV0 = runJavaScriptAlert;
+    uiClient.runJavaScriptConfirm_deprecatedForUseWithV0 = runJavaScriptConfirm;
+    uiClient.runJavaScriptPrompt_deprecatedForUseWithV0 = runJavaScriptPrompt;
     uiClient.toolbarsAreVisible = toolbarsAreVisible;
     uiClient.setToolbarsAreVisible = setToolbarsAreVisible;
     uiClient.menuBarIsVisible = menuBarIsVisible;
index 50b06f2..e67bb4b 100644 (file)
@@ -1,3 +1,41 @@
+2015-06-24  Brady Eidson  <beidson@apple.com>
+
+        Update JavaScript dialog delegates to include a WKSecurityOriginRef argument.
+        <rdar://problem/21269187> and https://bugs.webkit.org/show_bug.cgi?id=146249
+
+        Reviewed by Alex Christensen.
+
+        - Update WKTR to the new client structure.
+        - Update existing TestWebKitAPI tests to either use the new client structure or
+          assign the old function signature to the updated variable name.
+        - Include a new test.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+
+        * TestWebKitAPI/Tests/WebKit2/CloseFromWithinCreatePage.cpp:
+        (TestWebKitAPI::runJavaScriptAlert):
+
+        * TestWebKitAPI/Tests/WebKit2/DocumentStartUserScriptAlertCrash.cpp:
+        (TestWebKitAPI::TEST):
+
+        * TestWebKitAPI/Tests/WebKit2/ModalAlertsSPI.cpp:
+        (TestWebKitAPI::analyzeDialogArguments):
+        (TestWebKitAPI::runJavaScriptAlert):
+        (TestWebKitAPI::runJavaScriptConfirm):
+        (TestWebKitAPI::runJavaScriptPrompt):
+        (TestWebKitAPI::createNewPage):
+        (TestWebKitAPI::TEST):
+
+        * TestWebKitAPI/Tests/mac/FullscreenZoomInitialFrame.mm:
+        (TestWebKitAPI::FullscreenZoomInitialFrame::initializeView):
+
+        * TestWebKitAPI/Tests/mac/PageVisibilityStateWithWindowChanges.mm:
+        (TestWebKitAPI::PageVisibilityStateWithWindowChanges::initializeView):
+
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::createOtherPage):
+        (WTR::TestController::createWebViewWithOptions):
+
 2015-06-23  Dewei Zhu  <dewei_zhu@apple.com>
 
         Refactoring benchmark runner script to follow pep8 code style.
index d96980e..4830a63 100644 (file)
@@ -51,6 +51,7 @@
                51393E221523952D005F39C5 /* DOMWindowExtensionBasic_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51393E1D1523944A005F39C5 /* DOMWindowExtensionBasic_Bundle.cpp */; };
                5142B2731517C8C800C32B19 /* ContextMenuCanCopyURL.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5142B2721517C89100C32B19 /* ContextMenuCanCopyURL.html */; };
                517E7E04151119C100D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 517E7E031511187500D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.html */; };
+               51CB4AD81B3A079C00C1B1C6 /* ModalAlertsSPI.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51CB4AD71B3A079C00C1B1C6 /* ModalAlertsSPI.cpp */; };
                51CD1C6C1B38CE4300142CA5 /* ModalAlerts.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51CD1C6A1B38CE3600142CA5 /* ModalAlerts.mm */; };
                51CD1C721B38D48400142CA5 /* modal-alerts-in-new-about-blank-window.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51CD1C711B38D48400142CA5 /* modal-alerts-in-new-about-blank-window.html */; };
                51E5C7021919C3B200D8B3E1 /* simple2.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 51E780361919AFF8001829A2 /* simple2.html */; };
                5142B2721517C89100C32B19 /* ContextMenuCanCopyURL.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = ContextMenuCanCopyURL.html; sourceTree = "<group>"; };
                517E7DFB15110EA600D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MemoryCachePruneWithinResourceLoadDelegate.mm; sourceTree = "<group>"; };
                517E7E031511187500D0B008 /* MemoryCachePruneWithinResourceLoadDelegate.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = MemoryCachePruneWithinResourceLoadDelegate.html; sourceTree = "<group>"; };
+               51CB4AD71B3A079C00C1B1C6 /* ModalAlertsSPI.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ModalAlertsSPI.cpp; sourceTree = "<group>"; };
                51CD1C6A1B38CE3600142CA5 /* ModalAlerts.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ModalAlerts.mm; sourceTree = "<group>"; };
                51CD1C711B38D48400142CA5 /* modal-alerts-in-new-about-blank-window.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "modal-alerts-in-new-about-blank-window.html"; sourceTree = "<group>"; };
                51E5C7041919EA5F00D8B3E1 /* ShouldKeepCurrentBackForwardListItemInList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShouldKeepCurrentBackForwardListItemInList.cpp; sourceTree = "<group>"; };
                                33DC8910141953A300747EF7 /* LoadCanceledNoServerRedirectCallback.cpp */,
                                33DC89131419579F00747EF7 /* LoadCanceledNoServerRedirectCallback_Bundle.cpp */,
                                8AA28C1916D2FA7B002FF4DB /* LoadPageOnCrash.cpp */,
+                               51CB4AD71B3A079C00C1B1C6 /* ModalAlertsSPI.cpp */,
                                33BE5AF4137B5A6C00705813 /* MouseMoveAfterCrash.cpp */,
                                33BE5AF8137B5AAE00705813 /* MouseMoveAfterCrash_Bundle.cpp */,
                                93F1DB3014DA20760024C362 /* NewFirstVisuallyNonEmptyLayout.cpp */,
                                2E7765CF16C4D81100BA2BB1 /* mainMac.mm in Sources */,
                                41973B5B1AF2286A006C7B36 /* FileSystem.cpp in Sources */,
                                7A5623111AD5AF3E0096B920 /* MenuTypesForMouseEvents.cpp in Sources */,
+                               51CB4AD81B3A079C00C1B1C6 /* ModalAlertsSPI.cpp in Sources */,
                                26F6E1F01ADC749B00DE696B /* DFAMinimizer.cpp in Sources */,
                                260BA5791B1D2E7B004FA07C /* DFACombiner.cpp in Sources */,
                                7A99D9941AD4A29D00373141 /* MenuTypesForMouseEvents.mm in Sources */,
index 373c571..b5e4a90 100644 (file)
@@ -35,7 +35,7 @@ namespace TestWebKitAPI {
 static bool testDone;
 static std::unique_ptr<PlatformWebView> openedWebView;
 
-static void runJavaScriptAlert(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void* clientInfo)
+static void runJavaScriptAlert(WKPageRef page, WKStringRef alertText, WKFrameRef frame, WKSecurityOriginRef, const void* clientInfo)
 {
     // FIXME: Check that the alert text matches the storage.
     testDone = true;
index 21bca74..57686e1 100644 (file)
@@ -36,7 +36,7 @@ namespace TestWebKitAPI {
 
 static bool done;
 
-static void runJavaScriptAlert(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void* clientInfo)
+static void runJavaScriptAlert_deprecatedForUseWithV0(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void* clientInfo)
 {
     ASSERT_NOT_NULL(frame);
 
@@ -57,7 +57,7 @@ TEST(WebKit2, DocumentStartUserScriptAlertCrashTest)
     memset(&uiClient, 0, sizeof(uiClient));
 
     uiClient.base.version = 0;
-    uiClient.runJavaScriptAlert = runJavaScriptAlert;
+    uiClient.runJavaScriptAlert_deprecatedForUseWithV0 = runJavaScriptAlert_deprecatedForUseWithV0;
 
     WKPageSetPageUIClient(webView.page(), &uiClient.base);
 
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/ModalAlertsSPI.cpp b/Tools/TestWebKitAPI/Tests/WebKit2/ModalAlertsSPI.cpp
new file mode 100644 (file)
index 0000000..0278f00
--- /dev/null
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if WK_HAVE_C_SPI
+
+#include "PlatformUtilities.h"
+#include "PlatformWebView.h"
+#include "Test.h"
+#include <WebKit/WKFrame.h>
+#include <WebKit/WKRetainPtr.h>
+#include <WebKit/WKSecurityOriginRef.h>
+
+namespace TestWebKitAPI {
+
+static bool done;
+static unsigned dialogsSeen;
+static const unsigned dialogsExpected = 3;
+
+static void analyzeDialogArguments(WKPageRef page, WKFrameRef frame, WKSecurityOriginRef securityOrigin)
+{
+    EXPECT_EQ(page, WKFrameGetPage(frame));
+
+    WKRetainPtr<WKURLRef> url = adoptWK(WKFrameCopyURL(frame));
+    WKRetainPtr<WKStringRef> urlString = adoptWK(WKURLCopyString(url.get()));
+    EXPECT_WK_STREQ("about:blank", urlString.get());
+
+    WKRetainPtr<WKStringRef> protocol = adoptWK(WKSecurityOriginCopyProtocol(securityOrigin));
+    EXPECT_WK_STREQ("file", protocol.get());
+
+    WKRetainPtr<WKStringRef> host = adoptWK(WKSecurityOriginCopyHost(securityOrigin));
+    EXPECT_WK_STREQ("", host.get());
+
+    EXPECT_EQ(WKSecurityOriginGetPort(securityOrigin), 0);
+
+    if (++dialogsSeen == dialogsExpected)
+        done = true;
+}
+
+static void runJavaScriptAlert(WKPageRef page, WKStringRef, WKFrameRef frame, WKSecurityOriginRef securityOrigin, const void*)
+{
+    analyzeDialogArguments(page, frame, securityOrigin);
+}
+
+static bool runJavaScriptConfirm(WKPageRef page, WKStringRef, WKFrameRef frame, WKSecurityOriginRef securityOrigin, const void*)
+{
+    analyzeDialogArguments(page, frame, securityOrigin);
+    return false;
+}
+
+static WKStringRef runJavaScriptPrompt(WKPageRef page, WKStringRef, WKStringRef, WKFrameRef frame, WKSecurityOriginRef securityOrigin, const void*)
+{
+    analyzeDialogArguments(page, frame, securityOrigin);
+    return nullptr;
+}
+
+static std::unique_ptr<PlatformWebView> openedWebView;
+
+static WKPageRef createNewPage(WKPageRef page, WKURLRequestRef urlRequest, WKDictionaryRef features, WKEventModifiers modifiers, WKEventMouseButton mouseButton, const void *clientInfo)
+{
+    EXPECT_TRUE(openedWebView == nullptr);
+
+    openedWebView = std::make_unique<PlatformWebView>(page);
+
+    WKPageUIClientV5 uiClient;
+    memset(&uiClient, 0, sizeof(uiClient));
+
+    uiClient.base.version = 5;
+    uiClient.runJavaScriptAlert = runJavaScriptAlert;
+    uiClient.runJavaScriptConfirm = runJavaScriptConfirm;
+    uiClient.runJavaScriptPrompt = runJavaScriptPrompt;
+
+    WKPageSetPageUIClient(openedWebView->page(), &uiClient.base);
+
+    WKRetain(openedWebView->page());
+    return openedWebView->page();
+}
+
+TEST(WebKit2, ModalAlertsSPI)
+{
+    WKRetainPtr<WKContextRef> context = adoptWK(WKContextCreate());
+    PlatformWebView webView(context.get());
+
+    WKPageUIClientV5 uiClient;
+    memset(&uiClient, 0, sizeof(uiClient));
+
+    uiClient.base.version = 5;
+    uiClient.createNewPage = createNewPage;
+
+    WKPageSetPageUIClient(webView.page(), &uiClient.base);
+
+    WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("modal-alerts-in-new-about-blank-window", "html"));
+    WKPageLoadURL(webView.page(), url.get());
+
+    Util::run(&done);
+}
+
+} // namespace TestWebKitAPI
+
+#endif
index 52f01f6..d71a968 100644 (file)
@@ -57,7 +57,7 @@ static bool didGetPageSignalToContinue = false;
 
 // WebKit2 WKPageUIClient
 
-static void runJavaScriptAlert(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void* clientInfo)
+static void runJavaScriptAlert_deprecatedForUseWithV0(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void* clientInfo)
 {
     EXPECT_TRUE(isWaitingForPageSignalToContinue);
     isWaitingForPageSignalToContinue = false;
@@ -112,7 +112,7 @@ void FullscreenZoomInitialFrame::initializeView(WKView *wkView)
     memset(&uiClient, 0, sizeof(uiClient));
 
     uiClient.base.version = 0;
-    uiClient.runJavaScriptAlert = runJavaScriptAlert;
+    uiClient.runJavaScriptAlert_deprecatedForUseWithV0 = runJavaScriptAlert_deprecatedForUseWithV0;
 
     WKPageSetPageUIClient(wkView.pageRef, &uiClient.base);
 
index bdccc2e..5c1a3d4 100644 (file)
@@ -52,7 +52,7 @@ static bool didGetPageSignalToContinue = false;
 
 // WebKit2 WKPageUIClient
 
-static void runJavaScriptAlert(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void* clientInfo)
+static void runJavaScriptAlert_deprecatedForUseWithV0(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void* clientInfo)
 {
     EXPECT_TRUE(isWaitingForPageSignalToContinue);
     isWaitingForPageSignalToContinue = false;
@@ -99,7 +99,7 @@ void PageVisibilityStateWithWindowChanges::initializeView(WKView *wkView)
     memset(&uiClient, 0, sizeof(uiClient));
 
     uiClient.base.version = 0;
-    uiClient.runJavaScriptAlert = runJavaScriptAlert;
+    uiClient.runJavaScriptAlert_deprecatedForUseWithV0 = runJavaScriptAlert_deprecatedForUseWithV0;
 
     WKPageSetPageUIClient(wkView.pageRef, &uiClient.base);
 }
index d03b945..57cd7e7 100644 (file)
@@ -213,9 +213,9 @@ WKPageRef TestController::createOtherPage(WKPageRef oldPage, WKURLRequestRef, WK
         0, // takeFocus
         focus,
         unfocus,
-        0, // runJavaScriptAlert
-        0, // runJavaScriptConfirm
-        0, // runJavaScriptPrompt
+        0, // runJavaScriptAlert_deprecatedForUseWithV0
+        0, // runJavaScriptAlert_deprecatedForUseWithV0
+        0, // runJavaScriptAlert_deprecatedForUseWithV0
         0, // setStatusText
         0, // mouseDidMoveOverElement_deprecatedForUseWithV0
         0, // missingPluginButtonClicked
@@ -260,6 +260,9 @@ WKPageRef TestController::createOtherPage(WKPageRef oldPage, WKURLRequestRef, WK
         0, // isPlayingAudioDidChange
         decidePolicyForUserMediaPermissionRequest,
         0, // didClickAutofillButton
+        0, // runJavaScriptAlert
+        0, // runJavaScriptConfirm
+        0, // runJavaScriptPrompt
     };
     WKPageSetPageUIClient(newPage, &otherPageUIClient.base);
     
@@ -458,9 +461,9 @@ void TestController::createWebViewWithOptions(WKDictionaryRef options)
         0, // takeFocus
         focus,
         unfocus,
-        0, // runJavaScriptAlert
-        0, // runJavaScriptConfirm
-        0, // runJavaScriptPrompt
+        0, // runJavaScriptAlert_deprecatedForUseWithV0
+        0, // runJavaScriptAlert_deprecatedForUseWithV0
+        0, // runJavaScriptAlert_deprecatedForUseWithV0
         0, // setStatusText
         0, // mouseDidMoveOverElement_deprecatedForUseWithV0
         0, // missingPluginButtonClicked
@@ -505,6 +508,9 @@ void TestController::createWebViewWithOptions(WKDictionaryRef options)
         0, // isPlayingAudioDidChange
         decidePolicyForUserMediaPermissionRequest,
         0, // didClickAutofillButton
+        0, // runJavaScriptAlert
+        0, // runJavaScriptConfirm
+        0, // runJavaScriptPrompt
     };
     WKPageSetPageUIClient(m_mainWebView->page(), &pageUIClient.base);