Title: [92839] trunk
Revision
92839
Author
[email protected]
Date
2011-08-11 05:40:57 -0700 (Thu, 11 Aug 2011)

Log Message

[WK2] Implement waitForPolicyDelegate
https://bugs.webkit.org/show_bug.cgi?id=42330

Patch by Zsolt Fehér <[email protected]> on 2011-08-11
Reviewed by Csaba Osztrogonác.

Tools:

* WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl:
* WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
(WTR::navigationTypeToString):
(WTR::InjectedBundlePage::decidePolicyForNavigationAction):
* WebKitTestRunner/InjectedBundle/LayoutTestController.cpp:
(WTR::LayoutTestController::LayoutTestController):
(WTR::LayoutTestController::setCustomPolicyDelegate):
(WTR::LayoutTestController::waitForPolicyDelegate):
* WebKitTestRunner/InjectedBundle/LayoutTestController.h:
(WTR::LayoutTestController::isPolicyDelegateEnabled):
(WTR::LayoutTestController::isPolicyDelegatePermissive):

LayoutTests:

Unskip passing tests.

* platform/qt-wk2/Skipped:
* platform/wk2/Skipped:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (92838 => 92839)


--- trunk/LayoutTests/ChangeLog	2011-08-11 12:20:59 UTC (rev 92838)
+++ trunk/LayoutTests/ChangeLog	2011-08-11 12:40:57 UTC (rev 92839)
@@ -1,3 +1,15 @@
+2011-08-11  Zsolt Fehér  <[email protected]>
+
+        [WK2] Implement waitForPolicyDelegate
+        https://bugs.webkit.org/show_bug.cgi?id=42330
+
+        Reviewed by Csaba Osztrogonác.
+
+        Unskip passing tests.
+
+        * platform/qt-wk2/Skipped:
+        * platform/wk2/Skipped:
+
 2011-08-11  Pavel Podivilov  <[email protected]>
 
         Web Inspector: use source-file-replaced instead of source-file-changed event.

Modified: trunk/LayoutTests/platform/qt-wk2/Skipped (92838 => 92839)


--- trunk/LayoutTests/platform/qt-wk2/Skipped	2011-08-11 12:20:59 UTC (rev 92838)
+++ trunk/LayoutTests/platform/qt-wk2/Skipped	2011-08-11 12:40:57 UTC (rev 92839)
@@ -76,6 +76,7 @@
 editing/selection/hit-test-anonymous.html
 editing/selection/mixed-editability-1.html
 fast/block/float/float-in-float-hit-testing.html
+fast/encoding/mailto-always-utf-8.html
 fast/events/updateLayoutForHitTest.html
 fast/files
 fast/forms/input-number-events.html

Modified: trunk/LayoutTests/platform/wk2/Skipped (92838 => 92839)


--- trunk/LayoutTests/platform/wk2/Skipped	2011-08-11 12:20:59 UTC (rev 92838)
+++ trunk/LayoutTests/platform/wk2/Skipped	2011-08-11 12:40:57 UTC (rev 92839)
@@ -1092,29 +1092,6 @@
 fast/profiler
 inspector/profiler/cpu-profiler-profiling-without-inspector.html
 
-# WebKitTestRunner needs layoutTestController.waitForPolicyDelegate
-# <https://bugs.webkit.org/show_bug.cgi?id=42330>
-fast/encoding/mailto-always-utf-8.html
-fast/forms/mailto/advanced-get.html
-fast/forms/mailto/advanced-put.html
-fast/forms/mailto/formenctype-attribute-button-html.html
-fast/forms/mailto/formenctype-attribute-input-html.html
-fast/forms/mailto/get-multiple-items-text-plain.html
-fast/forms/mailto/get-multiple-items-x-www-form-urlencoded.html
-fast/forms/mailto/get-multiple-items.html
-fast/forms/mailto/get-non-ascii-always-utf-8.html
-fast/forms/mailto/get-non-ascii-text-plain-latin-1.html
-fast/forms/mailto/get-non-ascii-text-plain.html
-fast/forms/mailto/get-non-ascii.html
-fast/forms/mailto/get-overwrite-query.html
-fast/forms/mailto/post-append-query.html
-fast/forms/mailto/post-multiple-items-multipart-form-data.html
-fast/forms/mailto/post-multiple-items-text-plain.html
-fast/forms/mailto/post-multiple-items-x-www-form-urlencoded.html
-fast/forms/mailto/post-multiple-items.html
-fast/forms/mailto/post-text-plain-with-accept-charset.html
-fast/forms/mailto/post-text-plain.html
-
 # WebKitTestRunner needs layoutTestController.dumpFrameLoadCallbacks
 # <https://bugs.webkit.org/show_bug.cgi?id=42331>
 fast/loader/recursive-before-unload-crash.html

Modified: trunk/Tools/ChangeLog (92838 => 92839)


--- trunk/Tools/ChangeLog	2011-08-11 12:20:59 UTC (rev 92838)
+++ trunk/Tools/ChangeLog	2011-08-11 12:40:57 UTC (rev 92839)
@@ -1,3 +1,22 @@
+2011-08-11  Zsolt Fehér  <[email protected]>
+
+        [WK2] Implement waitForPolicyDelegate
+        https://bugs.webkit.org/show_bug.cgi?id=42330
+
+        Reviewed by Csaba Osztrogonác.
+
+        * WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl:
+        * WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
+        (WTR::navigationTypeToString):
+        (WTR::InjectedBundlePage::decidePolicyForNavigationAction):
+        * WebKitTestRunner/InjectedBundle/LayoutTestController.cpp:
+        (WTR::LayoutTestController::LayoutTestController):
+        (WTR::LayoutTestController::setCustomPolicyDelegate):
+        (WTR::LayoutTestController::waitForPolicyDelegate):
+        * WebKitTestRunner/InjectedBundle/LayoutTestController.h:
+        (WTR::LayoutTestController::isPolicyDelegateEnabled):
+        (WTR::LayoutTestController::isPolicyDelegatePermissive):
+
 2011-08-11  Adam Barth  <[email protected]>
 
         rebaseline-expectations should use the release bots, not the debug

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl (92838 => 92839)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl	2011-08-11 12:20:59 UTC (rev 92838)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/LayoutTestController.idl	2011-08-11 12:40:57 UTC (rev 92839)
@@ -29,6 +29,7 @@
         // The basics.
         void dumpAsText(in boolean dumpPixels);
         void dumpChildFramesAsText();
+        void waitForPolicyDelegate();
         void waitUntilDone();
         void notifyDone();
 

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp (92838 => 92839)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp	2011-08-11 12:20:59 UTC (rev 92838)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp	2011-08-11 12:40:57 UTC (rev 92839)
@@ -37,6 +37,9 @@
 #include <WebKit2/WKBundleBackForwardListItem.h>
 #include <WebKit2/WKBundleFrame.h>
 #include <WebKit2/WKBundleFramePrivate.h>
+#include <WebKit2/WKBundleHitTestResult.h>
+#include <WebKit2/WKBundleNavigationAction.h>
+#include <WebKit2/WKBundleNodeHandlePrivate.h>
 #include <WebKit2/WKBundlePagePrivate.h>
 #include <WebKit2/WKURLRequest.h>
 
@@ -136,6 +139,25 @@
     return out.str();
 }
 
+static WKRetainPtr<WKStringRef> navigationTypeToString(WKFrameNavigationType type)
+{
+    switch (type) {
+    case kWKFrameNavigationTypeLinkClicked:
+        return adoptWK(WKStringCreateWithUTF8CString("link clicked"));
+    case kWKFrameNavigationTypeFormSubmitted:
+        return adoptWK(WKStringCreateWithUTF8CString("form submitted"));
+    case kWKFrameNavigationTypeBackForward:
+        return adoptWK(WKStringCreateWithUTF8CString("back/forward"));
+    case kWKFrameNavigationTypeReload:
+        return adoptWK(WKStringCreateWithUTF8CString("reload"));
+    case kWKFrameNavigationTypeFormResubmitted:
+        return adoptWK(WKStringCreateWithUTF8CString("form resubmitted"));
+    case kWKFrameNavigationTypeOther:
+        return adoptWK(WKStringCreateWithUTF8CString("other"));
+    }
+    return adoptWK(WKStringCreateWithUTF8CString("illegal value"));
+}
+
 static ostream& operator<<(ostream& out, WKBundleCSSStyleDeclarationRef style)
 {
     // DumpRenderTree calls -[DOMCSSStyleDeclaration description], which just dumps class name and object address.
@@ -720,9 +742,27 @@
     static_cast<InjectedBundlePage*>(const_cast<void*>(clientInfo))->unableToImplementPolicy(page, frame, error, userData);
 }
 
-WKBundlePagePolicyAction InjectedBundlePage::decidePolicyForNavigationAction(WKBundlePageRef, WKBundleFrameRef, WKBundleNavigationActionRef, WKURLRequestRef request, WKTypeRef*)
+WKBundlePagePolicyAction InjectedBundlePage::decidePolicyForNavigationAction(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleNavigationActionRef navigationAction, WKURLRequestRef request, WKTypeRef* userData)
 {
-    return WKBundlePagePolicyActionUse;
+    if (!InjectedBundle::shared().isTestRunning())
+        return WKBundlePagePolicyActionUse;
+
+    if (!InjectedBundle::shared().layoutTestController()->isPolicyDelegateEnabled())
+        return WKBundlePagePolicyActionUse;
+
+    if (InjectedBundle::shared().layoutTestController()->waitToDump()) {
+        InjectedBundle::shared().os() << "Policy delegate: attempt to load " << adoptWK(WKURLRequestCopyURL(request)) << " with navigation type \'" << navigationTypeToString(WKBundleNavigationActionGetNavigationType(navigationAction)) << "\'";
+        WKBundleHitTestResultRef hitTestResultRef = WKBundleNavigationActionCopyHitTestResult(navigationAction);
+        if (hitTestResultRef)
+            InjectedBundle::shared().os() << " originating from " << dumpPath(m_page, m_world.get(), WKBundleHitTestResultCopyNodeHandle(hitTestResultRef));
+
+        InjectedBundle::shared().os() << "\n";
+        InjectedBundle::shared().layoutTestController()->notifyDone();
+    }
+
+    if (InjectedBundle::shared().layoutTestController()->isPolicyDelegatePermissive())
+        return WKBundlePagePolicyActionUse;
+    return WKBundlePagePolicyActionPassThrough;
 }
 
 WKBundlePagePolicyAction InjectedBundlePage::decidePolicyForNewWindowAction(WKBundlePageRef, WKBundleFrameRef, WKBundleNavigationActionRef, WKURLRequestRef, WKStringRef, WKTypeRef*)

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp (92838 => 92839)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp	2011-08-11 12:20:59 UTC (rev 92838)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.cpp	2011-08-11 12:40:57 UTC (rev 92839)
@@ -104,6 +104,8 @@
     , m_testRepaint(false)
     , m_testRepaintSweepHorizontally(false)
     , m_willSendRequestReturnsNull(false)
+    , m_policyDelegateEnabled(false)
+    , m_policyDelegatePermissive(false)
 {
     platformInitialize();
 }
@@ -127,7 +129,20 @@
     m_whatToDump = MainFrameText;
     m_dumpPixels = dumpPixels;
 }
-    
+
+// FIXME: Needs a full implementation see https://bugs.webkit.org/show_bug.cgi?id=42546
+void LayoutTestController::setCustomPolicyDelegate(bool enabled, bool permissive)
+{
+    m_policyDelegateEnabled = enabled;
+    m_policyDelegatePermissive = permissive;
+}
+
+void LayoutTestController::waitForPolicyDelegate()
+{
+    setCustomPolicyDelegate(true);
+    waitUntilDone();
+}
+
 void LayoutTestController::waitUntilDone()
 {
     m_waitToDump = true;

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h (92838 => 92839)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h	2011-08-11 12:20:59 UTC (rev 92838)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/LayoutTestController.h	2011-08-11 12:40:57 UTC (rev 92839)
@@ -59,6 +59,7 @@
 
     // The basics.
     void dumpAsText(bool dumpPixels);
+    void waitForPolicyDelegate();
     void dumpChildFramesAsText() { m_whatToDump = AllFramesText; }
     void waitUntilDone();
     void notifyDone();
@@ -84,6 +85,7 @@
     void setJavaScriptCanAccessClipboard(bool);
     void setPrivateBrowsingEnabled(bool);
     void setAuthorAndUserStylesEnabled(bool);
+    void setCustomPolicyDelegate(bool enabled, bool permissive = false);
     void addOriginAccessWhitelistEntry(JSStringRef sourceOrigin, JSStringRef destinationProtocol, JSStringRef destinationHost, bool allowDestinationSubdomains);
     void removeOriginAccessWhitelistEntry(JSStringRef sourceOrigin, JSStringRef destinationProtocol, JSStringRef destinationHost, bool allowDestinationSubdomains);
 
@@ -140,6 +142,8 @@
     bool shouldDumpTitleChanges() const { return m_dumpTitleChanges; }
     bool shouldDumpPixels() const { return m_dumpPixels; }
     bool shouldDumpFullScreenCallbacks() const { return m_dumpFullScreenCallbacks; }
+    bool isPolicyDelegateEnabled() const { return m_policyDelegateEnabled; }
+    bool isPolicyDelegatePermissive() const { return m_policyDelegatePermissive; }
 
     bool waitToDump() const { return m_waitToDump; }
     void waitToDumpWatchdogTimerFired();
@@ -190,6 +194,9 @@
 
     bool m_willSendRequestReturnsNull;
 
+    bool m_policyDelegateEnabled;
+    bool m_policyDelegatePermissive;
+
     PlatformTimerRef m_waitToDumpWatchdogTimer;
 };
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to