[EFL][WK1] URL printing code in DumpRenderTree doesn't match WTR or Mac DRT
authorryuan.choi@samsung.com <ryuan.choi@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Aug 2013 05:55:56 +0000 (05:55 +0000)
committerryuan.choi@samsung.com <ryuan.choi@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Aug 2013 05:55:56 +0000 (05:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=119585

Reviewed by Gyuyoung Kim.

Source/WebKit/efl:

* WebCoreSupport/DumpRenderTreeSupportEfl.cpp:
(DumpRenderTreeSupportEfl::provisionalURL):
Implemented to pass provisionalURL of main frame to DumpRenderTreeChrome.
* WebCoreSupport/DumpRenderTreeSupportEfl.h:

Tools:

* DumpRenderTree/efl/DumpRenderTreeChrome.cpp:
(pathSuitableForTestResult):
Return path string that's relative to main frame URL, or just file name if
the resource is not in the same directory subtree.
Referenced WebKitTestRunner code in r153852.
(descriptionSuitableForTestResult):
(DumpRenderTreeChrome::onFrameRedirectRequested):
(DumpRenderTreeChrome::onNewResourceRequest): Followed changes of r153903.

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

Source/WebKit/efl/ChangeLog
Source/WebKit/efl/WebCoreSupport/DumpRenderTreeSupportEfl.cpp
Source/WebKit/efl/WebCoreSupport/DumpRenderTreeSupportEfl.h
Tools/ChangeLog
Tools/DumpRenderTree/efl/DumpRenderTreeChrome.cpp

index 8042ffc..31b7317 100644 (file)
@@ -1,3 +1,15 @@
+2013-08-12  Ryuan Choi  <ryuan.choi@samsung.com>
+
+        [EFL][WK1] URL printing code in DumpRenderTree doesn't match WTR or Mac DRT
+        https://bugs.webkit.org/show_bug.cgi?id=119585
+
+        Reviewed by Gyuyoung Kim.
+
+        * WebCoreSupport/DumpRenderTreeSupportEfl.cpp:
+        (DumpRenderTreeSupportEfl::provisionalURL):
+        Implemented to pass provisionalURL of main frame to DumpRenderTreeChrome.
+        * WebCoreSupport/DumpRenderTreeSupportEfl.h:
+
 2013-08-09  Alexey Proskuryakov  <ap@apple.com>
 
         REGRESSION (r142755): window.open creates an invisible window when width and height are 0
index e153e61..d043c17 100644 (file)
@@ -223,6 +223,17 @@ String DumpRenderTreeSupportEfl::suitableDRTFrameName(const Evas_Object* ewkFram
     return String("frame (anonymous)");
 }
 
+const WebCore::KURL DumpRenderTreeSupportEfl::provisionalURL(const Evas_Object* ewkFrame)
+{
+    DRT_SUPPORT_FRAME_GET_OR_RETURN(ewkFrame, frame, WebCore::KURL());
+
+    WebCore::DocumentLoader* provisionalDocumentLoader = frame->loader()->provisionalDocumentLoader();
+    if (!provisionalDocumentLoader)
+        return WebCore::KURL();
+
+    return provisionalDocumentLoader->url();
+}
+
 void DumpRenderTreeSupportEfl::setValueForUser(JSContextRef context, JSValueRef nodeObject, const String& value)
 {
     JSC::ExecState* exec = toJS(context);
index 3bc2b4f..b974cf6 100644 (file)
@@ -22,6 +22,7 @@
 #ifndef DumpRenderTreeSupportEfl_h
 #define DumpRenderTreeSupportEfl_h
 
+#include "KURL.h"
 #include <Eina.h>
 #include <FindOptions.h>
 #include <IntRect.h>
@@ -65,6 +66,7 @@ public:
     static String responseMimeType(const Evas_Object* ewkFrame);
     static WebCore::IntRect selectionRectangle(const Evas_Object* ewkFrame);
     static String suitableDRTFrameName(const Evas_Object* ewkFrame);
+    static const WebCore::KURL provisionalURL(const Evas_Object* ewkFrame);
     static String layerTreeAsText(const Evas_Object* ewkFrame);
     static void setValueForUser(JSContextRef, JSValueRef nodeObject, const String& value);
     static void setDefersLoading(Evas_Object* ewkView, bool defers);
index 4f9471f..2e21dbc 100644 (file)
@@ -1,3 +1,19 @@
+2013-08-12  Ryuan Choi  <ryuan.choi@samsung.com>
+
+        [EFL][WK1] URL printing code in DumpRenderTree doesn't match WTR or Mac DRT
+        https://bugs.webkit.org/show_bug.cgi?id=119585
+
+        Reviewed by Gyuyoung Kim.
+
+        * DumpRenderTree/efl/DumpRenderTreeChrome.cpp:
+        (pathSuitableForTestResult):
+        Return path string that's relative to main frame URL, or just file name if
+        the resource is not in the same directory subtree.
+        Referenced WebKitTestRunner code in r153852.
+        (descriptionSuitableForTestResult):
+        (DumpRenderTreeChrome::onFrameRedirectRequested):
+        (DumpRenderTreeChrome::onNewResourceRequest): Followed changes of r153903.
+
 2013-08-12  Dan Bernstein  <mitz@apple.com>
 
         extract-localizable-strings doesn't know how to verify an existing strings file
index bc97188..586a9b3 100644 (file)
@@ -336,53 +336,38 @@ void DumpRenderTreeChrome::resetDefaultsToConsistentValues()
     policyDelegatePermissive = false;
 }
 
-// FIXME (119585): Make this match other platforms better.
-static CString pathSuitableForTestResult(const char* uriString)
-{
-    if (!uriString)
-        return CString();
+static const char divider = '/';
 
+static String pathSuitableForTestResult(const char* uriString)
+{
     KURL uri = KURL(ParsedURLString, uriString);
+    if (uri.isEmpty())
+        return "(null)";
 
     if (!uri.isLocalFile())
-        return uri.string().utf8();
+        return uri.string();
 
-    String pathString = uri.path();
-    size_t indexBaseName = pathString.reverseFind('/');
-    String baseName;
-    if (indexBaseName == notFound)
-        baseName = pathString;
-    else
-        baseName = pathString.substring(indexBaseName + 1);
+    KURL mainFrameURL = KURL(ParsedURLString, ewk_frame_uri_get(browser->mainFrame()));
+    if (mainFrameURL.isEmpty())
+        mainFrameURL = DumpRenderTreeSupportEfl::provisionalURL(browser->mainFrame());
 
-    String dirName;
-    if (indexBaseName != notFound) {
-        size_t indexDirName = pathString.reverseFind('/', indexBaseName - 1);
-        if (indexDirName != notFound)
-            dirName = pathString.substring(indexDirName + 1, indexBaseName - indexDirName - 1);
-    }
-
-    String ret = dirName + "/" + baseName;
-    return ret.utf8();
-}
+    String mainFrameUrlPathString = mainFrameURL.path();
+    String pathString = uri.path();
+    String basePath = mainFrameUrlPathString.substring(0, mainFrameUrlPathString.reverseFind(divider) + 1);
 
-static CString urlSuitableForTestResult(const char* uriString)
-{
-    KURL uri = KURL(ParsedURLString, uriString);
-    if (!uri.isLocalFile())
-        return CString(uriString);
+    if (!basePath.isEmpty() && pathString.startsWith(basePath))
+        return pathString.substring(basePath.length());
 
-    unsigned startIndex = uri.pathAfterLastSlash();
-    return uri.string().substring(startIndex).utf8();
+    return uri.lastPathComponent();
 }
 
 static CString descriptionSuitableForTestResult(Ewk_Frame_Resource_Request* request)
 {
     StringBuilder builder;
     builder.appendLiteral("<NSURLRequest URL ");
-    builder.append(pathSuitableForTestResult(request->url).data());
+    builder.append(pathSuitableForTestResult(request->url));
     builder.appendLiteral(", main document URL ");
-    builder.append(urlSuitableForTestResult(request->first_party).data());
+    builder.append(pathSuitableForTestResult(request->first_party));
     builder.appendLiteral(", http method ");
 
     if (request->http_method)
@@ -401,7 +386,7 @@ static CString descriptionSuitableForTestResult(const Ewk_Frame_Resource_Respons
 
     StringBuilder builder;
     builder.appendLiteral("<NSURLResponse ");
-    builder.append(pathSuitableForTestResult(response->url).data());
+    builder.append(pathSuitableForTestResult(response->url));
     builder.appendLiteral(", http status code ");
     builder.append(String::number(response->status_code));
     builder.append('>');
@@ -795,7 +780,7 @@ void DumpRenderTreeChrome::onFrameRedirectRequested(void*, Evas_Object* frame, v
 
     if (!done && gTestRunner->dumpFrameLoadCallbacks()) {
         const String frameName(DumpRenderTreeSupportEfl::suitableDRTFrameName(frame));
-        printf("%s - willPerformClientRedirectToURL: %s \n", frameName.utf8().data(), pathSuitableForTestResult(url).data());
+        printf("%s - willPerformClientRedirectToURL: %s \n", frameName.utf8().data(), pathSuitableForTestResult(url).utf8().data());
     }
 }
 
@@ -846,8 +831,8 @@ void DumpRenderTreeChrome::onNewResourceRequest(void*, Evas_Object*, void* event
 {
     Ewk_Frame_Resource_Request* request = static_cast<Ewk_Frame_Resource_Request*>(eventInfo);
 
-    if (!done && gTestRunner->dumpResourceLoadCallbacks())
-        m_dumpAssignedUrls.add(request->identifier, pathSuitableForTestResult(request->url));
+    if (!done)
+        m_dumpAssignedUrls.add(request->identifier, pathSuitableForTestResult(request->url).utf8());
 }
 
 void DumpRenderTreeChrome::onDownloadRequest(void*, Evas_Object*, void* eventInfo)