Title: [185072] trunk
Revision
185072
Author
beid...@apple.com
Date
2015-06-01 12:57:16 -0700 (Mon, 01 Jun 2015)

Log Message

Add WKTR support for "should open external URLs".
https://bugs.webkit.org/show_bug.cgi?id=145505

Reviewed by Darin Adler.

Source/WebKit2:

Expose C-spi to allow WKTR to set this bit on new loads:
* UIProcess/API/C/WKPage.cpp:
(WKPageLoadURLWithShouldOpenExternalURLsPolicy):
* UIProcess/API/C/WKPagePrivate.h:

Expose the bit on NavigationAction for the policy delegate:
* WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.cpp:
(WKBundleNavigationActionGetShouldOpenExternalURLs):
* WebProcess/InjectedBundle/API/c/WKBundleNavigationActionPrivate.h: Copied from Tools/WebKitTestRunner/WorkQueueManager.h.

* WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp:
(WebKit::InjectedBundleNavigationAction::InjectedBundleNavigationAction):
* WebProcess/InjectedBundle/InjectedBundleNavigationAction.h:
(WebKit::InjectedBundleNavigationAction::shouldOpenExternalURLs):

* WebKit2.xcodeproj/project.pbxproj:

Tools:

- Add a new option to "queueLoad" to allow _javascript_ to queue a load that has the
  "should open external URLs" bit set.

- Add a new "dumpPolicyDelegateCallbacks" call to dump the NavigationAction in
  the policy delegate, including whether or not the bit was set.

* WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::queueLoad):
* WebKitTestRunner/InjectedBundle/TestRunner.h:
(WTR::TestRunner::dumpPolicyDelegateCallbacks):
(WTR::TestRunner::shouldDumpPolicyCallbacks):

* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::queueLoad):
* WebKitTestRunner/InjectedBundle/InjectedBundle.h:

* WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
(WTR::InjectedBundlePage::decidePolicyForNavigationAction):

* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveMessageFromInjectedBundle):

* WebKitTestRunner/WorkQueueManager.cpp:
(WTR::WorkQueueManager::queueLoad):
* WebKitTestRunner/WorkQueueManager.h:

LayoutTests:

* loader/navigation-policy/resources/notify-done.html: Added.
* loader/navigation-policy/should-load-external-urls-set-by-api-basic-expected.txt: Added.
* loader/navigation-policy/should-load-external-urls-set-by-api-basic.html: Added.
* loader/navigation-policy/should-not-load-external-urls-set-by-api-basic-expected.txt: Added.
* loader/navigation-policy/should-not-load-external-urls-set-by-api-basic.html: Added.

* platform/ios-simulator-wk1/TestExpectations:
* platform/mac-wk1/TestExpectations:
* platform/win/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (185071 => 185072)


--- trunk/LayoutTests/ChangeLog	2015-06-01 19:42:43 UTC (rev 185071)
+++ trunk/LayoutTests/ChangeLog	2015-06-01 19:57:16 UTC (rev 185072)
@@ -1,3 +1,20 @@
+2015-06-01  Brady Eidson  <beid...@apple.com>
+
+        Add WKTR support for "should open external URLs".
+        https://bugs.webkit.org/show_bug.cgi?id=145505
+
+        Reviewed by Darin Adler.
+
+        * loader/navigation-policy/resources/notify-done.html: Added.
+        * loader/navigation-policy/should-load-external-urls-set-by-api-basic-expected.txt: Added.
+        * loader/navigation-policy/should-load-external-urls-set-by-api-basic.html: Added.
+        * loader/navigation-policy/should-not-load-external-urls-set-by-api-basic-expected.txt: Added.
+        * loader/navigation-policy/should-not-load-external-urls-set-by-api-basic.html: Added.
+
+        * platform/ios-simulator-wk1/TestExpectations:
+        * platform/mac-wk1/TestExpectations:
+        * platform/win/TestExpectations:
+
 2015-06-01  Chris Dumez  <cdu...@apple.com>
 
         ASSERT(revalidatingResource.inCache()) in MemoryCache when reloading tumblr.com

Added: trunk/LayoutTests/loader/navigation-policy/should-open-external-urls/api-does-not-set-flag-basic-expected.txt (0 => 185072)


--- trunk/LayoutTests/loader/navigation-policy/should-open-external-urls/api-does-not-set-flag-basic-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/loader/navigation-policy/should-open-external-urls/api-does-not-set-flag-basic-expected.txt	2015-06-01 19:57:16 UTC (rev 185072)
@@ -0,0 +1,3 @@
+ - decidePolicyForNavigationAction 
+<NSURLRequest URL resources/notify-done.html, main document URL resources/notify-done.html, http method GET> is main frame - yes should open URLs externally - no
+

Added: trunk/LayoutTests/loader/navigation-policy/should-open-external-urls/api-does-not-set-flag-basic.html (0 => 185072)


--- trunk/LayoutTests/loader/navigation-policy/should-open-external-urls/api-does-not-set-flag-basic.html	                        (rev 0)
+++ trunk/LayoutTests/loader/navigation-policy/should-open-external-urls/api-does-not-set-flag-basic.html	2015-06-01 19:57:16 UTC (rev 185072)
@@ -0,0 +1,9 @@
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.dumpPolicyDelegateCallbacks();
+    testRunner.queueLoad("resources/notify-done.html");
+}
+</script>
+This test dumps the NavigationPolicy passed to the decidePolicyForNavigationAction delegate call.<br>
+It only makes sense to run this in WebKitTestRunner.

Added: trunk/LayoutTests/loader/navigation-policy/should-open-external-urls/api-sets-flag-basic-expected.txt (0 => 185072)


--- trunk/LayoutTests/loader/navigation-policy/should-open-external-urls/api-sets-flag-basic-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/loader/navigation-policy/should-open-external-urls/api-sets-flag-basic-expected.txt	2015-06-01 19:57:16 UTC (rev 185072)
@@ -0,0 +1,3 @@
+ - decidePolicyForNavigationAction 
+<NSURLRequest URL resources/notify-done.html, main document URL resources/notify-done.html, http method GET> is main frame - yes should open URLs externally - yes
+

Added: trunk/LayoutTests/loader/navigation-policy/should-open-external-urls/api-sets-flag-basic.html (0 => 185072)


--- trunk/LayoutTests/loader/navigation-policy/should-open-external-urls/api-sets-flag-basic.html	                        (rev 0)
+++ trunk/LayoutTests/loader/navigation-policy/should-open-external-urls/api-sets-flag-basic.html	2015-06-01 19:57:16 UTC (rev 185072)
@@ -0,0 +1,9 @@
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.dumpPolicyDelegateCallbacks();
+    testRunner.queueLoad("resources/notify-done.html", "", true);
+}
+</script>
+This test dumps the NavigationPolicy passed to the decidePolicyForNavigationAction delegate call.<br>
+It only makes sense to run this in WebKitTestRunner.

Added: trunk/LayoutTests/loader/navigation-policy/should-open-external-urls/resources/notify-done.html (0 => 185072)


--- trunk/LayoutTests/loader/navigation-policy/should-open-external-urls/resources/notify-done.html	                        (rev 0)
+++ trunk/LayoutTests/loader/navigation-policy/should-open-external-urls/resources/notify-done.html	2015-06-01 19:57:16 UTC (rev 185072)
@@ -0,0 +1,4 @@
+<script>
+if (window.testRunner)
+    testRunner.notifyDone();
+</script>

Modified: trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations (185071 => 185072)


--- trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations	2015-06-01 19:42:43 UTC (rev 185071)
+++ trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations	2015-06-01 19:57:16 UTC (rev 185072)
@@ -1446,3 +1446,6 @@
 crypto/subtle/rsa-indexeddb.html
 fast/history/page-cache-indexed-closed-db.html
 fast/history/page-cache-indexed-opened-db.html
+
+# ShouldOpenExternalURLs not yet supported in WK1
+loader/navigation-policy [ Skip ]

Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (185071 => 185072)


--- trunk/LayoutTests/platform/mac-wk1/TestExpectations	2015-06-01 19:42:43 UTC (rev 185071)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations	2015-06-01 19:57:16 UTC (rev 185072)
@@ -102,5 +102,8 @@
 
 [ Yosemite+ ] platform/mac/fast/ruby/ruby-expansion-cjk-2.html [ ImageOnlyFailure ]
 
+# ShouldOpenExternalURLs not yet supported in WK1
+loader/navigation-policy [ Skip ]
+
 ### END OF (2) Failures without bug reports
 ########################################

Modified: trunk/LayoutTests/platform/win/TestExpectations (185071 => 185072)


--- trunk/LayoutTests/platform/win/TestExpectations	2015-06-01 19:42:43 UTC (rev 185071)
+++ trunk/LayoutTests/platform/win/TestExpectations	2015-06-01 19:57:16 UTC (rev 185072)
@@ -3101,3 +3101,6 @@
 
 # Seems to be font metrics dependent.
 fast/text/simple-line-layout-text-stroke-width.html [ Failure ]
+
+# ShouldOpenExternalURLs not yet supported in WK1
+loader/navigation-policy [ Skip ]

Modified: trunk/Source/WebKit2/ChangeLog (185071 => 185072)


--- trunk/Source/WebKit2/ChangeLog	2015-06-01 19:42:43 UTC (rev 185071)
+++ trunk/Source/WebKit2/ChangeLog	2015-06-01 19:57:16 UTC (rev 185072)
@@ -1,3 +1,27 @@
+2015-06-01  Brady Eidson  <beid...@apple.com>
+
+        Add WKTR support for "should open external URLs".
+        https://bugs.webkit.org/show_bug.cgi?id=145505
+
+        Reviewed by Darin Adler.
+
+        Expose C-spi to allow WKTR to set this bit on new loads:
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageLoadURLWithShouldOpenExternalURLsPolicy):
+        * UIProcess/API/C/WKPagePrivate.h:
+        
+        Expose the bit on NavigationAction for the policy delegate:        
+        * WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.cpp:
+        (WKBundleNavigationActionGetShouldOpenExternalURLs):
+        * WebProcess/InjectedBundle/API/c/WKBundleNavigationActionPrivate.h: Copied from Tools/WebKitTestRunner/WorkQueueManager.h.
+
+        * WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp:
+        (WebKit::InjectedBundleNavigationAction::InjectedBundleNavigationAction):
+        * WebProcess/InjectedBundle/InjectedBundleNavigationAction.h:
+        (WebKit::InjectedBundleNavigationAction::shouldOpenExternalURLs):
+    
+        * WebKit2.xcodeproj/project.pbxproj:
+
 2015-06-01  Gavin Barraclough  <barraclo...@apple.com>
 
         PDFs always think they're visible on iOS.

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp (185071 => 185072)


--- trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp	2015-06-01 19:42:43 UTC (rev 185071)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp	2015-06-01 19:57:16 UTC (rev 185072)
@@ -126,6 +126,12 @@
     toImpl(pageRef)->loadRequest(URL(URL(), toWTFString(URLRef)));
 }
 
+void WKPageLoadURLWithShouldOpenExternalURLsPolicy(WKPageRef pageRef, WKURLRef URLRef, bool shouldOpenExternalURLs)
+{
+    ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicy = shouldOpenExternalURLs ? ShouldOpenExternalURLsPolicy::ShouldAllow : ShouldOpenExternalURLsPolicy::ShouldNotAllow;
+    toImpl(pageRef)->loadRequest(URL(URL(), toWTFString(URLRef)), shouldOpenExternalURLsPolicy);
+}
+
 void WKPageLoadURLWithUserData(WKPageRef pageRef, WKURLRef URLRef, WKTypeRef userDataRef)
 {
     toImpl(pageRef)->loadRequest(URL(URL(), toWTFString(URLRef)), ShouldOpenExternalURLsPolicy::ShouldNotAllow, toImpl(userDataRef));

Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h (185071 => 185072)


--- trunk/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h	2015-06-01 19:42:43 UTC (rev 185071)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h	2015-06-01 19:57:16 UTC (rev 185072)
@@ -111,6 +111,8 @@
 WK_EXPORT bool WKPageIsPlayingAudio(WKPageRef page);
 WK_EXPORT void WKPageSetMuted(WKPageRef page, bool muted);
 
+WK_EXPORT void WKPageLoadURLWithShouldOpenExternalURLsPolicy(WKPageRef page, WKURLRef url, bool shouldOpenExternalURLs);
+
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (185071 => 185072)


--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2015-06-01 19:42:43 UTC (rev 185071)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2015-06-01 19:57:16 UTC (rev 185072)
@@ -1001,6 +1001,7 @@
 		51A555F6128C6C47009ABCEC /* WKContextMenuItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 51A555F4128C6C47009ABCEC /* WKContextMenuItem.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		51A55601128C6D92009ABCEC /* WKContextMenuItemTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 51A55600128C6D92009ABCEC /* WKContextMenuItemTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		51A60B2A180CCEB500F3BF50 /* DatabaseProcess.app in Copy Files */ = {isa = PBXBuildFile; fileRef = 51FA1E28180CCADE00C44BE9 /* DatabaseProcess.app */; };
+		51A728DE1B1BAD3800102EEE /* WKBundleNavigationActionPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 51A728DC1B1BAD2D00102EEE /* WKBundleNavigationActionPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		51A7F2F3125BF820008AEB1D /* Logging.h in Headers */ = {isa = PBXBuildFile; fileRef = 51A7F2F2125BF820008AEB1D /* Logging.h */; };
 		51A7F2F5125BF8D4008AEB1D /* Logging.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51A7F2F4125BF8D4008AEB1D /* Logging.cpp */; };
 		51A84CE3127F386B00CA6EA4 /* WebContextMenuProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51A84CE2127F386B00CA6EA4 /* WebContextMenuProxy.cpp */; };
@@ -3199,6 +3200,7 @@
 		51A60B27180CCD9000F3BF50 /* DatabaseProcess.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = DatabaseProcess.xcconfig; sourceTree = "<group>"; };
 		51A60B28180CCD9000F3BF50 /* DatabaseService.Development.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = DatabaseService.Development.xcconfig; sourceTree = "<group>"; };
 		51A60B29180CCD9000F3BF50 /* DatabaseService.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = DatabaseService.xcconfig; sourceTree = "<group>"; };
+		51A728DC1B1BAD2D00102EEE /* WKBundleNavigationActionPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBundleNavigationActionPrivate.h; sourceTree = "<group>"; };
 		51A7F2F2125BF820008AEB1D /* Logging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Logging.h; sourceTree = "<group>"; };
 		51A7F2F4125BF8D4008AEB1D /* Logging.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Logging.cpp; sourceTree = "<group>"; };
 		51A84CE2127F386B00CA6EA4 /* WebContextMenuProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebContextMenuProxy.cpp; sourceTree = "<group>"; };
@@ -6706,6 +6708,7 @@
 				65B86F1812F11D7B00B7DD8A /* WKBundleInspector.h */,
 				BC7043CB12F75EE0006472B9 /* WKBundleNavigationAction.cpp */,
 				BC7043CA12F75EE0006472B9 /* WKBundleNavigationAction.h */,
+				51A728DC1B1BAD2D00102EEE /* WKBundleNavigationActionPrivate.h */,
 				BC4BEFE0120A1A4C00FBA0C7 /* WKBundleNodeHandle.cpp */,
 				BC4BEFDF120A1A4C00FBA0C7 /* WKBundleNodeHandle.h */,
 				BC57450B1263B155006F0F12 /* WKBundleNodeHandlePrivate.h */,
@@ -7907,6 +7910,7 @@
 				1A2BB6D114117B4D000F35D4 /* PluginProcessConnectionMessages.h in Headers */,
 				1A2D90D21281C966001EB962 /* PluginProcessCreationParameters.h in Headers */,
 				1A0EC603124A9F2C007EF4A5 /* PluginProcessManager.h in Headers */,
+				51A728DE1B1BAD3800102EEE /* WKBundleNavigationActionPrivate.h in Headers */,
 				1A0EC6C0124BBD9B007EF4A5 /* PluginProcessMessages.h in Headers */,
 				1A0EC75E124BC7B2007EF4A5 /* PluginProcessProxy.h in Headers */,
 				1A043B5E124D5E9D00FFBFB5 /* PluginProcessProxyMessages.h in Headers */,

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.cpp (185071 => 185072)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.cpp	2015-06-01 19:42:43 UTC (rev 185071)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.cpp	2015-06-01 19:57:16 UTC (rev 185072)
@@ -25,6 +25,7 @@
 
 #include "config.h"
 #include "WKBundleNavigationAction.h"
+#include "WKBundleNavigationActionPrivate.h"
 
 #include "InjectedBundleHitTestResult.h"
 #include "InjectedBundleNavigationAction.h"
@@ -65,3 +66,8 @@
     RefPtr<InjectedBundleNodeHandle> formElement = toImpl(navigationActionRef)->formElement();
     return toAPI(formElement.release().leakRef());
 }
+
+bool WKBundleNavigationActionGetShouldOpenExternalURLs(WKBundleNavigationActionRef navigationActionRef)
+{
+    return toImpl(navigationActionRef)->shouldOpenExternalURLs();
+}

Copied: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationActionPrivate.h (from rev 185071, trunk/Tools/WebKitTestRunner/WorkQueueManager.h) (0 => 185072)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationActionPrivate.h	                        (rev 0)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationActionPrivate.h	2015-06-01 19:57:16 UTC (rev 185072)
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+
+#ifndef WKBundleNavigationActionPrivate_h
+#define WKBundleNavigationActionPrivate_h
+
+#include <WebKit/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT bool WKBundleNavigationActionGetShouldOpenExternalURLs(WKBundleNavigationActionRef);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // WKBundleNavigationActionPrivate_h

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp (185071 => 185072)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp	2015-06-01 19:42:43 UTC (rev 185071)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp	2015-06-01 19:57:16 UTC (rev 185072)
@@ -90,6 +90,7 @@
     : m_navigationType(navigationAction.type())
     , m_modifiers(modifiersForNavigationAction(navigationAction))
     , m_mouseButton(WebMouseEvent::NoButton)
+    , m_shouldOpenExternalURLs(navigationAction.shouldOpenExternalURLsPolicy() == ShouldOpenExternalURLsPolicy::ShouldAllow)
 {
     if (const MouseEvent* mouseEvent = mouseEventForNavigationAction(navigationAction)) {
         m_hitTestResult = InjectedBundleHitTestResult::create(frame->coreFrame()->eventHandler().hitTestResultAtPoint(mouseEvent->absoluteLocation()));

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.h (185071 => 185072)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.h	2015-06-01 19:42:43 UTC (rev 185071)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.h	2015-06-01 19:57:16 UTC (rev 185072)
@@ -56,6 +56,8 @@
     InjectedBundleHitTestResult* hitTestResult() const { return m_hitTestResult.get(); }
     InjectedBundleNodeHandle* formElement() const { return m_formElement.get(); }
 
+    bool shouldOpenExternalURLs() const { return m_shouldOpenExternalURLs; }
+
 private:
     InjectedBundleNavigationAction(WebFrame*, const WebCore::NavigationAction&, PassRefPtr<WebCore::FormState>);
 
@@ -64,6 +66,7 @@
     WebMouseEvent::Button m_mouseButton;
     RefPtr<InjectedBundleHitTestResult> m_hitTestResult;
     RefPtr<InjectedBundleNodeHandle> m_formElement;
+    bool m_shouldOpenExternalURLs;
 };
 
 } // namespace WebKit

Modified: trunk/Tools/ChangeLog (185071 => 185072)


--- trunk/Tools/ChangeLog	2015-06-01 19:42:43 UTC (rev 185071)
+++ trunk/Tools/ChangeLog	2015-06-01 19:57:16 UTC (rev 185072)
@@ -1,3 +1,37 @@
+2015-06-01  Brady Eidson  <beid...@apple.com>
+
+        Add WKTR support for "should open external URLs".
+        https://bugs.webkit.org/show_bug.cgi?id=145505
+
+        Reviewed by Darin Adler.
+
+        - Add a new option to "queueLoad" to allow _javascript_ to queue a load that has the
+          "should open external URLs" bit set.
+        
+        - Add a new "dumpPolicyDelegateCallbacks" call to dump the NavigationAction in
+          the policy delegate, including whether or not the bit was set.
+        
+        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
+        (WTR::TestRunner::queueLoad):
+        * WebKitTestRunner/InjectedBundle/TestRunner.h:
+        (WTR::TestRunner::dumpPolicyDelegateCallbacks):
+        (WTR::TestRunner::shouldDumpPolicyCallbacks):
+        
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+        (WTR::InjectedBundle::queueLoad):
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.h:
+
+        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
+        (WTR::InjectedBundlePage::decidePolicyForNavigationAction):
+
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
+
+        * WebKitTestRunner/WorkQueueManager.cpp:
+        (WTR::WorkQueueManager::queueLoad):
+        * WebKitTestRunner/WorkQueueManager.h:
+
 2015-06-01  Mark Lam  <mark....@apple.com>
 
         build-jsc's --cloop option is broken.

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (185071 => 185072)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl	2015-06-01 19:42:43 UTC (rev 185071)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl	2015-06-01 19:57:16 UTC (rev 185072)
@@ -48,6 +48,7 @@
     void dumpApplicationCacheDelegateCallbacks();
     void dumpDatabaseCallbacks();
     void dumpDOMAsWebArchive();
+    void dumpPolicyDelegateCallbacks();
 
     // Special options.
     void keepWebHistory();
@@ -180,7 +181,7 @@
     // Work queue.
     void queueBackNavigation(unsigned long howFarBackward);
     void queueForwardNavigation(unsigned long howFarForward);
-    void queueLoad(DOMString url, DOMString target);
+    void queueLoad(DOMString url, DOMString target, optional boolean shouldOpenExternalURLs);
     void queueLoadHTMLString(DOMString content, optional DOMString baseURL, optional DOMString unreachableURL);
     void queueReload();
     void queueLoadingScript(DOMString script);

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp (185071 => 185072)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp	2015-06-01 19:42:43 UTC (rev 185071)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp	2015-06-01 19:57:16 UTC (rev 185072)
@@ -544,7 +544,7 @@
     WKBundlePagePostMessage(page()->page(), messageName.get(), messageBody.get());
 }
 
-void InjectedBundle::queueLoad(WKStringRef url, WKStringRef target)
+void InjectedBundle::queueLoad(WKStringRef url, WKStringRef target, bool shouldOpenExternalURLs)
 {
     m_useWorkQueue = true;
 
@@ -558,6 +558,10 @@
     WKRetainPtr<WKStringRef> targetKey(AdoptWK, WKStringCreateWithUTF8CString("target"));
     WKDictionarySetItem(loadData.get(), targetKey.get(), target);
 
+    WKRetainPtr<WKStringRef> shouldOpenExternalURLsKey(AdoptWK, WKStringCreateWithUTF8CString("shouldOpenExternalURLs"));
+    WKRetainPtr<WKBooleanRef> shouldOpenExternalURLsValue(AdoptWK, WKBooleanCreate(shouldOpenExternalURLs));
+    WKDictionarySetItem(loadData.get(), shouldOpenExternalURLsKey.get(), shouldOpenExternalURLsValue.get());
+
     WKBundlePagePostMessage(page()->page(), messageName.get(), loadData.get());
 }
 

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h (185071 => 185072)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h	2015-06-01 19:42:43 UTC (rev 185071)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h	2015-06-01 19:57:16 UTC (rev 185072)
@@ -109,7 +109,7 @@
     void processWorkQueue();
     void queueBackNavigation(unsigned howFarBackward);
     void queueForwardNavigation(unsigned howFarForward);
-    void queueLoad(WKStringRef url, WKStringRef target);
+    void queueLoad(WKStringRef url, WKStringRef target, bool shouldOpenExternalURLs = false);
     void queueLoadHTMLString(WKStringRef content, WKStringRef baseURL = 0, WKStringRef unreachableURL = 0);
     void queueReload();
     void queueLoadingScript(WKStringRef script);

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp (185071 => 185072)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp	2015-06-01 19:42:43 UTC (rev 185071)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp	2015-06-01 19:57:16 UTC (rev 185072)
@@ -39,6 +39,7 @@
 #include <WebKit/WKBundleFramePrivate.h>
 #include <WebKit/WKBundleHitTestResult.h>
 #include <WebKit/WKBundleNavigationAction.h>
+#include <WebKit/WKBundleNavigationActionPrivate.h>
 #include <WebKit/WKBundleNodeHandlePrivate.h>
 #include <WebKit/WKBundlePagePrivate.h>
 #include <WebKit/WKBundlePrivate.h>
@@ -1262,6 +1263,18 @@
     if (!injectedBundle.isTestRunning())
         return WKBundlePagePolicyActionUse;
 
+    if (injectedBundle.testRunner()->shouldDumpPolicyCallbacks()) {
+        StringBuilder stringBuilder;
+        stringBuilder.appendLiteral(" - decidePolicyForNavigationAction \n");
+        dumpRequestDescriptionSuitableForTestResult(request, stringBuilder);
+        stringBuilder.appendLiteral(" is main frame - ");
+        stringBuilder.append(WKBundleFrameIsMainFrame(frame) ? "yes" : "no");
+        stringBuilder.appendLiteral(" should open URLs externally - ");
+        stringBuilder.append(WKBundleNavigationActionGetShouldOpenExternalURLs(navigationAction) ? "yes" : "no");
+        stringBuilder.append('\n');
+        injectedBundle.outputText(stringBuilder.toString());
+    }
+
     if (!injectedBundle.testRunner()->isPolicyDelegateEnabled())
         return WKBundlePagePolicyActionUse;
 

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp (185071 => 185072)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2015-06-01 19:42:43 UTC (rev 185071)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp	2015-06-01 19:57:16 UTC (rev 185072)
@@ -764,14 +764,14 @@
     InjectedBundle::singleton().queueForwardNavigation(howFarForward);
 }
 
-void TestRunner::queueLoad(JSStringRef url, JSStringRef target)
+void TestRunner::queueLoad(JSStringRef url, JSStringRef target, bool shouldOpenExternalURLs)
 {
     auto& injectedBundle = InjectedBundle::singleton();
     WKRetainPtr<WKURLRef> baseURLWK(AdoptWK, WKBundleFrameCopyURL(WKBundlePageGetMainFrame(injectedBundle.page()->page())));
     WKRetainPtr<WKURLRef> urlWK(AdoptWK, WKURLCreateWithBaseURL(baseURLWK.get(), toWTFString(toWK(url)).utf8().data()));
     WKRetainPtr<WKStringRef> urlStringWK(AdoptWK, WKURLCopyString(urlWK.get()));
 
-    injectedBundle.queueLoad(urlStringWK.get(), toWK(target).get());
+    injectedBundle.queueLoad(urlStringWK.get(), toWK(target).get(), shouldOpenExternalURLs);
 }
 
 void TestRunner::queueLoadHTMLString(JSStringRef content, JSStringRef baseURL, JSStringRef unreachableURL)

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (185071 => 185072)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2015-06-01 19:42:43 UTC (rev 185071)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2015-06-01 19:57:16 UTC (rev 185072)
@@ -82,6 +82,7 @@
     void dumpApplicationCacheDelegateCallbacks() { m_dumpApplicationCacheDelegateCallbacks = true; }
     void dumpDatabaseCallbacks() { m_dumpDatabaseCallbacks = true; }
     void dumpDOMAsWebArchive() { m_whatToDump = DOMAsWebArchive; }
+    void dumpPolicyDelegateCallbacks() { m_dumpPolicyCallbacks = true; }
 
     void setShouldDumpFrameLoadCallbacks(bool value) { m_dumpFrameLoadCallbacks = value; }
     void setShouldDumpProgressFinishedCallback(bool value) { m_dumpProgressFinishedCallback = value; }
@@ -179,6 +180,7 @@
     bool shouldDumpApplicationCacheDelegateCallbacks() const { return m_dumpApplicationCacheDelegateCallbacks; }
     bool shouldDumpDatabaseCallbacks() const { return m_dumpDatabaseCallbacks; }
     bool shouldDumpSelectionRect() const { return m_dumpSelectionRect; }
+    bool shouldDumpPolicyCallbacks() const { return m_dumpPolicyCallbacks; }
 
     bool isPolicyDelegateEnabled() const { return m_policyDelegateEnabled; }
     bool isPolicyDelegatePermissive() const { return m_policyDelegatePermissive; }
@@ -268,7 +270,7 @@
     // Work queue.
     void queueBackNavigation(unsigned howFarBackward);
     void queueForwardNavigation(unsigned howFarForward);
-    void queueLoad(JSStringRef url, JSStringRef target);
+    void queueLoad(JSStringRef url, JSStringRef target, bool shouldOpenExternalURLs);
     void queueLoadHTMLString(JSStringRef content, JSStringRef baseURL, JSStringRef unreachableURL);
     void queueReload();
     void queueLoadingScript(JSStringRef script);
@@ -307,6 +309,7 @@
     bool m_dumpWillCacheResponse;
     bool m_dumpApplicationCacheDelegateCallbacks;
     bool m_dumpDatabaseCallbacks;
+    bool m_dumpPolicyCallbacks { false };
     bool m_disallowIncreaseForApplicationCacheQuota;
     bool m_waitToDump; // True if waitUntilDone() has been called, but notifyDone() has not yet been called.
     bool m_testRepaint;

Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (185071 => 185072)


--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2015-06-01 19:42:43 UTC (rev 185071)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2015-06-01 19:57:16 UTC (rev 185072)
@@ -557,7 +557,10 @@
         WKRetainPtr<WKStringRef> targetKey(AdoptWK, WKStringCreateWithUTF8CString("target"));
         WKStringRef targetWK = static_cast<WKStringRef>(WKDictionaryGetItemForKey(loadDataDictionary, targetKey.get()));
 
-        TestController::singleton().workQueueManager().queueLoad(toWTFString(urlWK), toWTFString(targetWK));
+        WKRetainPtr<WKStringRef> shouldOpenExternalURLsKey(AdoptWK, WKStringCreateWithUTF8CString("shouldOpenExternalURLs"));
+        WKBooleanRef shouldOpenExternalURLsValueWK = static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(loadDataDictionary, shouldOpenExternalURLsKey.get()));
+
+        TestController::singleton().workQueueManager().queueLoad(toWTFString(urlWK), toWTFString(targetWK), WKBooleanGetValue(shouldOpenExternalURLsValueWK));
         return;
     }
 

Modified: trunk/Tools/WebKitTestRunner/WorkQueueManager.cpp (185071 => 185072)


--- trunk/Tools/WebKitTestRunner/WorkQueueManager.cpp	2015-06-01 19:42:43 UTC (rev 185071)
+++ trunk/Tools/WebKitTestRunner/WorkQueueManager.cpp	2015-06-01 19:57:16 UTC (rev 185072)
@@ -29,6 +29,7 @@
 #include "PlatformWebView.h"
 #include "TestController.h"
 #include <WebKit/WKPage.h>
+#include <WebKit/WKPagePrivate.h>
 #include <WebKit/WKRetainPtr.h>
 #include <stdio.h>
 #include <wtf/text/CString.h>
@@ -125,13 +126,14 @@
     return !m_processing;
 }
 
-void WorkQueueManager::queueLoad(const String& url, const String& target)
+void WorkQueueManager::queueLoad(const String& url, const String& target, bool shouldOpenExternalURLs)
 {
     class LoadItem : public WorkQueueItem {
     public:
-        LoadItem(const String& url, const String& target)
+        LoadItem(const String& url, const String& target, bool shouldOpenExternalURLs)
             : m_url(AdoptWK, WKURLCreateWithUTF8CString(url.utf8().data()))
             , m_target(target)
+            , m_shouldOpenExternalURLs(shouldOpenExternalURLs)
         {
         }
 
@@ -142,15 +144,16 @@
                 fprintf(stderr, "queueLoad for a specific target is not implemented.\n");
                 return WorkQueueItem::NonLoading;
             }
-            WKPageLoadURL(mainPage(), m_url.get());
+            WKPageLoadURLWithShouldOpenExternalURLsPolicy(mainPage(), m_url.get(), m_shouldOpenExternalURLs);
             return WorkQueueItem::Loading;
         }
 
         WKRetainPtr<WKURLRef> m_url;
         String m_target;
+        bool m_shouldOpenExternalURLs;
     };
 
-    enqueue(new LoadItem(url, target));
+    enqueue(new LoadItem(url, target, shouldOpenExternalURLs));
 }
 
 void WorkQueueManager::queueLoadHTMLString(const String& content, const String& baseURL, const String& unreachableURL)

Modified: trunk/Tools/WebKitTestRunner/WorkQueueManager.h (185071 => 185072)


--- trunk/Tools/WebKitTestRunner/WorkQueueManager.h	2015-06-01 19:42:43 UTC (rev 185071)
+++ trunk/Tools/WebKitTestRunner/WorkQueueManager.h	2015-06-01 19:57:16 UTC (rev 185072)
@@ -41,7 +41,7 @@
     void clearWorkQueue();
     bool processWorkQueue(); // Returns 'true' if queue is processed (no new loading is started), returns 'false' otherwise.
 
-    void queueLoad(const String& url, const String& target);
+    void queueLoad(const String& url, const String& target, bool shouldOpenExternalURLs);
     void queueLoadHTMLString(const String& content, const String& baseURL, const String& unreachableURL);
     void queueBackNavigation(unsigned howFarBackward);
     void queueForwardNavigation(unsigned howFarForward);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to