Title: [136940] trunk
Revision
136940
Author
[email protected]
Date
2012-12-07 02:22:06 -0800 (Fri, 07 Dec 2012)

Log Message

[BlackBerry] DRT - Update implementation of TestRunner.setCustomPolicyDelegate()
https://bugs.webkit.org/show_bug.cgi?id=104243

RIM PR 259337

Patch by Xiaobo Wang <[email protected]> on 2012-12-07
Reviewed by Rob Buis.

Source/WebKit/blackberry:

1. Add DRT callback in dispatchDecidePolicyForResponse.
2. Pass frame pointer to DRT callback in
dispatchDecidePolicyForNavigationAction, so that it can be used to
calculate originating.
3. Fix some webkit style errors.

The patch fixed the following tests:
- http/tests/download
- fast/forms/mailto/formenctype-attribute-button-html.html
- fast/forms/mailto/formenctype-attribute-input-html.html
- fast/encoding/mailto-always-utf-8.html

* Api/DumpRenderTreeClient.h:
* WebCoreSupport/FrameLoaderClientBlackBerry.cpp:
(WebCore::FrameLoaderClientBlackBerry::dispatchDecidePolicyForResponse):
(WebCore::FrameLoaderClientBlackBerry::dispatchDecidePolicyForNavigationAction):
(WebCore::FrameLoaderClientBlackBerry::transitionToCommittedForNewPage):
(WebCore::FrameLoaderClientBlackBerry::dispatchDidFinishLoad):
(WebCore::FrameLoaderClientBlackBerry::dispatchDidFailProvisionalLoad):
(WebCore::FrameLoaderClientBlackBerry::dispatchWillSendRequest):
(WebCore::FrameLoaderClientBlackBerry::decidePolicyForExternalLoad):

Tools:

1. Implement calculation of navigation originating in
didDecidePolicyForNavigationAction().
2. Implement policy delegate for resource response.
3. Enable customPolicyDelegate if waitForPolicyDelegate() is called.
4. Minor optional updates in dump() and dumpFrameLoadCallbacks().

The patch fixed the following tests:
- http/tests/download
- fast/forms/mailto/formenctype-attribute-button-html.html
- fast/forms/mailto/formenctype-attribute-input-html.html
- fast/encoding/mailto-always-utf-8.html

* DumpRenderTree/blackberry/DumpRenderTree.cpp:
(BlackBerry::WebKit::DumpRenderTree::DumpRenderTree):
(BlackBerry::WebKit::DumpRenderTree::resetToConsistentStateBeforeTesting):
(BlackBerry::WebKit::DumpRenderTree::dump):
(BlackBerry::WebKit::DumpRenderTree::didFinishLoadForFrame):
(BlackBerry::WebKit::DumpRenderTree::didDecidePolicyForNavigationAction):
(BlackBerry::WebKit::DumpRenderTree::didDecidePolicyForResponse):
(BlackBerry::WebKit::DumpRenderTree::setCustomPolicyDelegate):
* DumpRenderTree/blackberry/DumpRenderTreeBlackBerry.h:
(DumpRenderTree):
* DumpRenderTree/blackberry/TestRunnerBlackBerry.cpp:
(TestRunner::setCustomPolicyDelegate):
(TestRunner::waitForPolicyDelegate):
(TestRunner::overridePreference):

Modified Paths

Diff

Modified: trunk/Source/WebKit/blackberry/Api/DumpRenderTreeClient.h (136939 => 136940)


--- trunk/Source/WebKit/blackberry/Api/DumpRenderTreeClient.h	2012-12-07 09:58:55 UTC (rev 136939)
+++ trunk/Source/WebKit/blackberry/Api/DumpRenderTreeClient.h	2012-12-07 10:22:06 UTC (rev 136940)
@@ -55,12 +55,13 @@
     virtual void didFinishDocumentLoadForFrame(WebCore::Frame*) = 0;
     virtual void didClearWindowObjectInWorld(WebCore::DOMWrapperWorld*, JSGlobalContextRef, JSObjectRef windowObject) = 0;
     virtual void didReceiveTitleForFrame(const String& title, WebCore::Frame*) = 0;
-    virtual void didDecidePolicyForNavigationAction(const WebCore::NavigationAction&, const WebCore::ResourceRequest&) = 0;
+    virtual void didDecidePolicyForNavigationAction(const WebCore::NavigationAction&, const WebCore::ResourceRequest&, WebCore::Frame*) = 0;
+    virtual void didDecidePolicyForResponse(const WebCore::ResourceResponse&) = 0;
     virtual void didDispatchWillPerformClientRedirect() = 0;
     virtual void didHandleOnloadEventsForFrame(WebCore::Frame*) = 0;
 
     // ChromeClient delegates
-    virtual void addMessageToConsole(const String& message, unsigned int lineNumber, const String& sourceID) = 0;
+    virtual void addMessageToConsole(const String& message, unsigned lineNumber, const String& sourceID) = 0;
     virtual void runJavaScriptAlert(const String& message) = 0;
     virtual bool runJavaScriptConfirm(const String& message) = 0;
     virtual String runJavaScriptPrompt(const String& message, const String& defaultValue) = 0;

Modified: trunk/Source/WebKit/blackberry/ChangeLog (136939 => 136940)


--- trunk/Source/WebKit/blackberry/ChangeLog	2012-12-07 09:58:55 UTC (rev 136939)
+++ trunk/Source/WebKit/blackberry/ChangeLog	2012-12-07 10:22:06 UTC (rev 136940)
@@ -1,3 +1,34 @@
+2012-12-07  Xiaobo Wang  <[email protected]>
+
+        [BlackBerry] DRT - Update implementation of TestRunner.setCustomPolicyDelegate()
+        https://bugs.webkit.org/show_bug.cgi?id=104243
+
+        RIM PR 259337
+
+        Reviewed by Rob Buis.
+
+        1. Add DRT callback in dispatchDecidePolicyForResponse.
+        2. Pass frame pointer to DRT callback in
+        dispatchDecidePolicyForNavigationAction, so that it can be used to
+        calculate originating.
+        3. Fix some webkit style errors.
+
+        The patch fixed the following tests:
+        - http/tests/download
+        - fast/forms/mailto/formenctype-attribute-button-html.html
+        - fast/forms/mailto/formenctype-attribute-input-html.html
+        - fast/encoding/mailto-always-utf-8.html
+
+        * Api/DumpRenderTreeClient.h:
+        * WebCoreSupport/FrameLoaderClientBlackBerry.cpp:
+        (WebCore::FrameLoaderClientBlackBerry::dispatchDecidePolicyForResponse):
+        (WebCore::FrameLoaderClientBlackBerry::dispatchDecidePolicyForNavigationAction):
+        (WebCore::FrameLoaderClientBlackBerry::transitionToCommittedForNewPage):
+        (WebCore::FrameLoaderClientBlackBerry::dispatchDidFinishLoad):
+        (WebCore::FrameLoaderClientBlackBerry::dispatchDidFailProvisionalLoad):
+        (WebCore::FrameLoaderClientBlackBerry::dispatchWillSendRequest):
+        (WebCore::FrameLoaderClientBlackBerry::decidePolicyForExternalLoad):
+
 2012-12-07  Mary Wu  <[email protected]>
 
         [BlackBerry] new target window would cause the url being loaded twice

Modified: trunk/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.cpp (136939 => 136940)


--- trunk/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.cpp	2012-12-07 09:58:55 UTC (rev 136939)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/FrameLoaderClientBlackBerry.cpp	2012-12-07 10:22:06 UTC (rev 136940)
@@ -200,6 +200,9 @@
     else if (ResourceRequest::TargetIsMainFrame == request.targetType() && m_webPagePrivate->m_client->downloadAllowed(request.url().string()))
         policy = PolicyDownload;
 
+    if (m_webPagePrivate->m_dumpRenderTree)
+        m_webPagePrivate->m_dumpRenderTree->didDecidePolicyForResponse(response);
+
     (m_frame->loader()->policyChecker()->*function)(policy);
 }
 
@@ -243,10 +246,10 @@
     if (decision == PolicyIgnore)
         dispatchDidCancelClientRedirect();
 
+    if (m_webPagePrivate->m_dumpRenderTree)
+        m_webPagePrivate->m_dumpRenderTree->didDecidePolicyForNavigationAction(action, request, m_frame);
+
     (m_frame->loader()->policyChecker()->*function)(decision);
-
-    if (m_webPagePrivate->m_dumpRenderTree)
-        m_webPagePrivate->m_dumpRenderTree->didDecidePolicyForNavigationAction(action, request);
 }
 
 void FrameLoaderClientBlackBerry::delayPolicyCheckUntilFragmentExists(const String& fragment, FramePolicyFunction function)
@@ -447,16 +450,16 @@
     Color backgroundColor(m_webPagePrivate->m_webSettings->backgroundColor());
 
     m_frame->createView(m_webPagePrivate->viewportSize(),      /* viewport */
-                        backgroundColor,                       /* background color */
-                        backgroundColor.hasAlpha(),            /* is transparent */
-                        m_webPagePrivate->actualVisibleSize(), /* fixed reported size */
-                        m_webPagePrivate->fixedLayoutSize(),   /* fixed layout size */
-                        IntRect(),                             /* fixed visible content rect */
-                        m_webPagePrivate->useFixedLayout(),    /* use fixed layout */
-                        ScrollbarAlwaysOff,                    /* hor mode */
-                        true,                                  /* lock the mode */
-                        ScrollbarAlwaysOff,                    /* ver mode */
-                        true);                                 /* lock the mode */
+        backgroundColor,                       /* background color */
+        backgroundColor.hasAlpha(),            /* is transparent */
+        m_webPagePrivate->actualVisibleSize(), /* fixed reported size */
+        m_webPagePrivate->fixedLayoutSize(),   /* fixed layout size */
+        IntRect(),                             /* fixed visible content rect */
+        m_webPagePrivate->useFixedLayout(),    /* use fixed layout */
+        ScrollbarAlwaysOff,                    /* hor mode */
+        true,                                  /* lock the mode */
+        ScrollbarAlwaysOff,                    /* ver mode */
+        true);                                 /* lock the mode */
 
     if (isMainFrame() && m_webPagePrivate->backingStoreClient()) {
         // FIXME: Do we really need to suspend/resume both backingstore and screen here?
@@ -601,7 +604,7 @@
 
     // Process document metadata.
     RefPtr<NodeList> nodeList = headElement->getElementsByTagName(HTMLNames::metaTag.localName());
-    unsigned int size = nodeList->length();
+    unsigned size = nodeList->length();
     ScopeArray<BlackBerry::Platform::String> headers;
 
     // This may allocate more space than needed since not all meta elements will be http-equiv.
@@ -697,7 +700,7 @@
         m_webPagePrivate->setLoadState(WebPagePrivate::Failed);
 
         if (error.domain() == ResourceError::platformErrorDomain
-                && (error.errorCode() == BlackBerry::Platform::FilterStream::StatusErrorAlreadyHandled)) {
+            && (error.errorCode() == BlackBerry::Platform::FilterStream::StatusErrorAlreadyHandled)) {
             // Error has already been displayed by client.
             return;
         }
@@ -979,7 +982,7 @@
     m_webPagePrivate->m_client->notifyFrameDetached(m_frame);
 }
 
-void FrameLoaderClientBlackBerry::dispatchWillSendRequest(DocumentLoader* docLoader, long unsigned int, ResourceRequest& request, const ResourceResponse&)
+void FrameLoaderClientBlackBerry::dispatchWillSendRequest(DocumentLoader* docLoader, long unsigned, ResourceRequest& request, const ResourceResponse&)
 {
     // If the request is being loaded by the provisional document loader, then
     // it is a new top level request which has not been commited.
@@ -1153,9 +1156,9 @@
 #endif
 
     if (m_webPagePrivate->m_webSettings->areLinksHandledExternally()
-            && isMainFrame()
-            && !request.mustHandleInternally()
-            && !isFragmentScroll) {
+        && isMainFrame()
+        && !request.mustHandleInternally()
+        && !isFragmentScroll) {
         NetworkRequest platformRequest;
         request.initializePlatformRequest(platformRequest, cookiesEnabled());
         if (platformRequest.getTargetType() == NetworkRequest::TargetIsUnknown)

Modified: trunk/Tools/ChangeLog (136939 => 136940)


--- trunk/Tools/ChangeLog	2012-12-07 09:58:55 UTC (rev 136939)
+++ trunk/Tools/ChangeLog	2012-12-07 10:22:06 UTC (rev 136940)
@@ -1,3 +1,39 @@
+2012-12-07  Xiaobo Wang  <[email protected]>
+
+        [BlackBerry] DRT - Update implementation of TestRunner.setCustomPolicyDelegate()
+        https://bugs.webkit.org/show_bug.cgi?id=104243
+
+        RIM PR 259337
+
+        Reviewed by Rob Buis.
+
+        1. Implement calculation of navigation originating in
+        didDecidePolicyForNavigationAction().
+        2. Implement policy delegate for resource response.
+        3. Enable customPolicyDelegate if waitForPolicyDelegate() is called.
+        4. Minor optional updates in dump() and dumpFrameLoadCallbacks().
+
+        The patch fixed the following tests:
+        - http/tests/download
+        - fast/forms/mailto/formenctype-attribute-button-html.html
+        - fast/forms/mailto/formenctype-attribute-input-html.html
+        - fast/encoding/mailto-always-utf-8.html
+
+        * DumpRenderTree/blackberry/DumpRenderTree.cpp:
+        (BlackBerry::WebKit::DumpRenderTree::DumpRenderTree):
+        (BlackBerry::WebKit::DumpRenderTree::resetToConsistentStateBeforeTesting):
+        (BlackBerry::WebKit::DumpRenderTree::dump):
+        (BlackBerry::WebKit::DumpRenderTree::didFinishLoadForFrame):
+        (BlackBerry::WebKit::DumpRenderTree::didDecidePolicyForNavigationAction):
+        (BlackBerry::WebKit::DumpRenderTree::didDecidePolicyForResponse):
+        (BlackBerry::WebKit::DumpRenderTree::setCustomPolicyDelegate):
+        * DumpRenderTree/blackberry/DumpRenderTreeBlackBerry.h:
+        (DumpRenderTree):
+        * DumpRenderTree/blackberry/TestRunnerBlackBerry.cpp:
+        (TestRunner::setCustomPolicyDelegate):
+        (TestRunner::waitForPolicyDelegate):
+        (TestRunner::overridePreference):
+
 2012-12-07  Gwang Yoon Hwang  <[email protected]>
 
         [Qt] Adjust library name in layout_tests/port/qt.py after Qt5-r40

Modified: trunk/Tools/DumpRenderTree/blackberry/DumpRenderTree.cpp (136939 => 136940)


--- trunk/Tools/DumpRenderTree/blackberry/DumpRenderTree.cpp	2012-12-07 09:58:55 UTC (rev 136939)
+++ trunk/Tools/DumpRenderTree/blackberry/DumpRenderTree.cpp	2012-12-07 10:22:06 UTC (rev 136940)
@@ -37,9 +37,13 @@
 #include "FrameLoaderTypes.h"
 #include "FrameTree.h"
 #include "FrameView.h"
+#include "HTTPParsers.h"
 #include "HistoryItem.h"
+#include "HitTestResult.h"
 #include "IntSize.h"
 #include "JSDOMBinding.h"
+#include "MouseEvent.h"
+#include "Node.h"
 #include "NotImplemented.h"
 #include "Page.h"
 #include "PageGroup.h"
@@ -163,6 +167,7 @@
     , m_waitToDumpWatchdogTimer(this, &DumpRenderTree::waitToDumpWatchdogTimerFired)
     , m_workTimer(this, &DumpRenderTree::processWork)
     , m_acceptsEditing(true)
+    , m_policyDelegateEnabled(false)
 {
     const char* workerNumber = getenv("WORKER_NUMBER") ? getenv("WORKER_NUMBER") : "0";
     String sdcardPath = SDCARD_PATH;
@@ -271,7 +276,8 @@
     topLoadingFrame = 0;
     m_loadFinished = false;
     s_selectTrailingWhitespaceEnabled = false;
-
+    m_policyDelegateEnabled = false;
+    waitForPolicy = false;
     testDone = false;
     WorkQueue::shared()->clear();
     WorkQueue::shared()->setFrozen(false);
@@ -523,9 +529,6 @@
     dumpToFile(result);
 
     if (!runFromCommandLine) {
-        // signal end of text block
-        fputs("#EOF\n", stdout);
-
         // There are two scenarios for dumping pixels:
         // 1. When the test case explicitly asks for it by calling dumpAsText(true) with that extra true passed as a parameter value, from _javascript_
         bool explicitPixelResults = gTestRunner->dumpAsText() && gTestRunner->generatePixelResults();
@@ -534,8 +537,11 @@
 
         // But only if m_enablePixelTests is set, to say that the user wants to run pixel tests at all.
         bool generatePixelResults = m_enablePixelTests && (explicitPixelResults || implicitPixelResults);
-        if (generatePixelResults)
+        if (generatePixelResults) {
+            // signal end of text block
+            fputs("#EOF\n", stdout);
             dumpWebViewAsPixelsAndCompareWithExpected(gTestRunner->expectedPixelHash());
+        }
 
         String crashFile = dumpFile + ".crash";
         unlink(crashFile.utf8().data());
@@ -630,9 +636,10 @@
     if (!testDone && gTestRunner->dumpFrameLoadCallbacks())
         printf("%s - didFinishLoadForFrame\n", drtFrameDescription(frame).utf8().data());
 
-    if (frame == topLoadingFrame)
+    if (frame == topLoadingFrame) {
         m_loadFinished = true;
-    locationChangeForFrame(frame);
+        locationChangeForFrame(frame);
+    }
 }
 
 void DumpRenderTree::didFinishDocumentLoadForFrame(WebCore::Frame* frame)
@@ -831,9 +838,9 @@
     return m_acceptsEditing;
 }
 
-void DumpRenderTree::didDecidePolicyForNavigationAction(const WebCore::NavigationAction& action, const WebCore::ResourceRequest& request)
+void DumpRenderTree::didDecidePolicyForNavigationAction(const WebCore::NavigationAction& action, const WebCore::ResourceRequest& request, WebCore::Frame* frame)
 {
-    if (!waitForPolicy)
+    if (testDone || !m_policyDelegateEnabled)
         return;
 
     const char* typeDescription;
@@ -860,12 +867,36 @@
         typeDescription = "illegal value";
     }
 
-    printf("Policy delegate: attempt to load %s with navigation type '%s'\n", request.url().string().utf8().data(), typeDescription);
-    // FIXME: do originating part.
+    bool shouldWaitForResponse = !request.url().string().startsWith("mailto:");
+    printf("Policy delegate: attempt to load %s with navigation type '%s'", request.url().string().utf8().data(), typeDescription);
+    // Originating part, borrowed from Chromium.
+    RefPtr<WebCore::Node> node;
+    for (const WebCore::Event* event = action.event(); event; event = event->underlyingEvent()) {
+        if (event->isMouseEvent()) {
+            const WebCore::MouseEvent* mouseEvent = static_cast<const WebCore::MouseEvent*>(event);
+            node = frame->eventHandler()->hitTestResultAtPoint(mouseEvent->absoluteLocation(), false).innerNonSharedNode();
+            break;
+        }
+    }
+    if (node.get())
+        printf(" originating from %s\n", drtDumpPath(node.get()).utf8().data());
+    else
+        printf("\n");
 
-    gTestRunner->notifyDone();
+    if (waitForPolicy && !shouldWaitForResponse)
+        gTestRunner->notifyDone();
 }
 
+void DumpRenderTree::didDecidePolicyForResponse(const WebCore::ResourceResponse& response)
+{
+    if (!testDone && m_policyDelegateEnabled) {
+        if (WebCore::contentDispositionType(response.httpHeaderField("Content-Disposition")) == WebCore::ContentDispositionAttachment)
+            printf("Policy delegate: resource is an attachment, suggested file name '%s'\n", response.suggestedFilename().utf8().data());
+        if (waitForPolicy)
+            gTestRunner->notifyDone();
+    }
+}
+
 void DumpRenderTree::didDispatchWillPerformClientRedirect()
 {
     if (!testDone && gTestRunner->dumpUserGestureInFrameLoadCallbacks())
@@ -898,8 +929,13 @@
     return true;
 }
 
+void DumpRenderTree::setCustomPolicyDelegate(bool setDelegate, bool permissive)
+{
+    m_policyDelegateEnabled = setDelegate;
+    UNUSED_PARAM(permissive);
 }
 }
+}
 
 // Static dump() function required by cross-platform DRT code.
 void dump()

Modified: trunk/Tools/DumpRenderTree/blackberry/DumpRenderTreeBlackBerry.h (136939 => 136940)


--- trunk/Tools/DumpRenderTree/blackberry/DumpRenderTreeBlackBerry.h	2012-12-07 09:58:55 UTC (rev 136939)
+++ trunk/Tools/DumpRenderTree/blackberry/DumpRenderTreeBlackBerry.h	2012-12-07 10:22:06 UTC (rev 136940)
@@ -71,7 +71,8 @@
     void didFinishDocumentLoadForFrame(WebCore::Frame*);
     void didClearWindowObjectInWorld(WebCore::DOMWrapperWorld*, JSGlobalContextRef, JSObjectRef windowObject);
     void didReceiveTitleForFrame(const String& title, WebCore::Frame*);
-    void didDecidePolicyForNavigationAction(const WebCore::NavigationAction&, const WebCore::ResourceRequest&);
+    void didDecidePolicyForNavigationAction(const WebCore::NavigationAction&, const WebCore::ResourceRequest&, WebCore::Frame*);
+    void didDecidePolicyForResponse(const WebCore::ResourceResponse&);
     void didDispatchWillPerformClientRedirect();
     void didHandleOnloadEventsForFrame(WebCore::Frame*);
     void didReceiveResponseForFrame(WebCore::Frame*, const WebCore::ResourceResponse&);
@@ -107,6 +108,7 @@
 
     // BlackBerry::Platform::BlackBerryPlatformLayoutTestClient method
     virtual void addTest(const char* testFile);
+    void setCustomPolicyDelegate(bool setDelegate, bool permissive);
 private:
     void runTest(const String& url, const String& imageHash);
     void runTests();
@@ -147,6 +149,7 @@
     bool m_acceptsEditing;
     bool m_loadFinished;
     static bool s_selectTrailingWhitespaceEnabled;
+    bool m_policyDelegateEnabled;
 };
 }
 }

Modified: trunk/Tools/DumpRenderTree/blackberry/TestRunnerBlackBerry.cpp (136939 => 136940)


--- trunk/Tools/DumpRenderTree/blackberry/TestRunnerBlackBerry.cpp	2012-12-07 09:58:55 UTC (rev 136939)
+++ trunk/Tools/DumpRenderTree/blackberry/TestRunnerBlackBerry.cpp	2012-12-07 10:22:06 UTC (rev 136940)
@@ -191,9 +191,7 @@
 
 void TestRunner::setCustomPolicyDelegate(bool setDelegate, bool permissive)
 {
-    UNUSED_PARAM(setDelegate);
-    UNUSED_PARAM(permissive);
-    notImplemented();
+    BlackBerry::WebKit::DumpRenderTree::currentInstance()->setCustomPolicyDelegate(setDelegate, permissive);
 }
 
 void TestRunner::clearApplicationCacheForOrigin(OpaqueJSString*)
@@ -302,6 +300,7 @@
 
 void TestRunner::waitForPolicyDelegate()
 {
+    setCustomPolicyDelegate(true, true);
     setWaitToDump(true);
     waitForPolicy = true;
 }
@@ -439,6 +438,8 @@
         mainFrame->page()->settings()->setHyperlinkAuditingEnabled(valueStr == "true" || valueStr == "1");
     else if (keyStr == "WebSocketsEnabled")
         BlackBerry::WebKit::DumpRenderTree::currentInstance()->page()->settings()->setWebSocketsEnabled(valueStr == "true" || valueStr == "1");
+    else if (keyStr == "WebKitDefaultTextEncodingName")
+        BlackBerry::WebKit::DumpRenderTree::currentInstance()->page()->settings()->setDefaultTextEncodingName(valueStr);
 }
 
 void TestRunner::setAlwaysAcceptCookies(bool alwaysAcceptCookies)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to