Title: [142253] trunk/Tools
Revision
142253
Author
[email protected]
Date
2013-02-08 03:51:31 -0800 (Fri, 08 Feb 2013)

Log Message

[chromium] copy normalizeLayoutTestURL code to TestRunner library
https://bugs.webkit.org/show_bug.cgi?id=109269

Reviewed by Kent Tamura.

The method doesn't have any external dependencies, so there's no reason
it should be on the delegate. It's still required by TestShell, however,
by making a copy, we can avoid implementing this in content shell.

* DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h:
(WebTestDelegate):
* DumpRenderTree/chromium/TestRunner/src/WebPermissions.cpp:
(WebTestRunner::WebPermissions::allowImage):
(WebTestRunner::WebPermissions::allowScriptFromSource):
* DumpRenderTree/chromium/TestShell.cpp:
(TestShell::windowCount):
* DumpRenderTree/chromium/TestShell.h:
* DumpRenderTree/chromium/WebViewHost.cpp:
* DumpRenderTree/chromium/WebViewHost.h:
(WebViewHost):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (142252 => 142253)


--- trunk/Tools/ChangeLog	2013-02-08 11:45:54 UTC (rev 142252)
+++ trunk/Tools/ChangeLog	2013-02-08 11:51:31 UTC (rev 142253)
@@ -1,3 +1,26 @@
+2013-02-08  Jochen Eisinger  <[email protected]>
+
+        [chromium] copy normalizeLayoutTestURL code to TestRunner library
+        https://bugs.webkit.org/show_bug.cgi?id=109269
+
+        Reviewed by Kent Tamura.
+
+        The method doesn't have any external dependencies, so there's no reason
+        it should be on the delegate. It's still required by TestShell, however,
+        by making a copy, we can avoid implementing this in content shell.
+
+        * DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h:
+        (WebTestDelegate):
+        * DumpRenderTree/chromium/TestRunner/src/WebPermissions.cpp:
+        (WebTestRunner::WebPermissions::allowImage):
+        (WebTestRunner::WebPermissions::allowScriptFromSource):
+        * DumpRenderTree/chromium/TestShell.cpp:
+        (TestShell::windowCount):
+        * DumpRenderTree/chromium/TestShell.h:
+        * DumpRenderTree/chromium/WebViewHost.cpp:
+        * DumpRenderTree/chromium/WebViewHost.h:
+        (WebViewHost):
+
 2013-02-08  Raphael Kubo da Costa  <[email protected]>
 
         [EFL] Make the Performance bot also build WebKit.

Modified: trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h (142252 => 142253)


--- trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h	2013-02-08 11:45:54 UTC (rev 142252)
+++ trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h	2013-02-08 11:51:31 UTC (rev 142253)
@@ -54,7 +54,6 @@
 public:
     virtual void clearContextMenuData() = 0;
     virtual void clearEditCommand() = 0;
-    virtual void fillSpellingSuggestionList(const WebKit::WebString&, WebKit::WebVector<WebKit::WebString>*) { }
     virtual void setEditCommand(const std::string& name, const std::string& value) = 0;
     virtual WebKit::WebContextMenuData* lastContextMenuData() const = 0;
     virtual void setGamepadData(const WebKit::WebGamepads&) = 0;
@@ -79,7 +78,6 @@
     virtual void setCurrentWebIntentRequest(const WebKit::WebIntentRequest&) { };
     virtual WebKit::WebIntentRequest* currentWebIntentRequest() { return 0; }
     virtual std::string makeURLErrorDescription(const WebKit::WebURLError&) { return std::string(); }
-    virtual std::string normalizeLayoutTestURL(const std::string&) { return std::string(); }
     virtual void setClientWindowRect(const WebKit::WebRect&) { }
     virtual void showDevTools() { }
     virtual void closeDevTools() { }

Modified: trunk/Tools/DumpRenderTree/chromium/TestRunner/src/WebPermissions.cpp (142252 => 142253)


--- trunk/Tools/DumpRenderTree/chromium/TestRunner/src/WebPermissions.cpp	2013-02-08 11:45:54 UTC (rev 142252)
+++ trunk/Tools/DumpRenderTree/chromium/TestRunner/src/WebPermissions.cpp	2013-02-08 11:51:31 UTC (rev 142253)
@@ -35,8 +35,36 @@
 #include <public/WebCString.h>
 #include <public/WebURL.h>
 
+using namespace std;
+
 namespace WebTestRunner {
 
+namespace {
+
+const char layoutTestsPattern[] = "/LayoutTests/";
+const string::size_type layoutTestsPatternSize = sizeof(layoutTestsPattern) - 1;
+const char fileUrlPattern[] = "file:/";
+const char fileTestPrefix[] = "(file test):";
+const char dataUrlPattern[] = "data:";
+const string::size_type dataUrlPatternSize = sizeof(dataUrlPattern) - 1;
+
+string normalizeLayoutTestURL(const string& url)
+{
+    string result = url;
+    size_t pos;
+    if (!url.find(fileUrlPattern) && ((pos = url.find(layoutTestsPattern)) != string::npos)) {
+        // adjust file URLs to match upstream results.
+        result.replace(0, pos + layoutTestsPatternSize, fileTestPrefix);
+    } else if (!url.find(dataUrlPattern)) {
+        // URL-escape data URLs to match results upstream.
+        string path = url.substr(dataUrlPatternSize);
+        result.replace(dataUrlPatternSize, url.length(), path);
+    }
+    return result;
+}
+
+}
+
 WebPermissions::WebPermissions()
     : m_delegate(0)
 {
@@ -51,7 +79,7 @@
 {
     bool allowed = enabledPerSettings && m_imagesAllowed;
     if (m_dumpCallbacks && m_delegate)
-        m_delegate->printMessage(std::string("PERMISSION CLIENT: allowImage(") + m_delegate->normalizeLayoutTestURL(imageURL.spec()) + "): " + (allowed ? "true" : "false") + "\n");
+        m_delegate->printMessage(std::string("PERMISSION CLIENT: allowImage(") + normalizeLayoutTestURL(imageURL.spec()) + "): " + (allowed ? "true" : "false") + "\n");
     return allowed;
 }
 
@@ -59,7 +87,7 @@
 {
     bool allowed = enabledPerSettings && m_scriptsAllowed;
     if (m_dumpCallbacks && m_delegate)
-        m_delegate->printMessage(std::string("PERMISSION CLIENT: allowScriptFromSource(") + m_delegate->normalizeLayoutTestURL(scriptURL.spec()) + "): " + (allowed ? "true" : "false") + "\n");
+        m_delegate->printMessage(std::string("PERMISSION CLIENT: allowScriptFromSource(") + normalizeLayoutTestURL(scriptURL.spec()) + "): " + (allowed ? "true" : "false") + "\n");
     return allowed;
 }
 

Modified: trunk/Tools/DumpRenderTree/chromium/TestShell.cpp (142252 => 142253)


--- trunk/Tools/DumpRenderTree/chromium/TestShell.cpp	2013-02-08 11:45:54 UTC (rev 142252)
+++ trunk/Tools/DumpRenderTree/chromium/TestShell.cpp	2013-02-08 11:51:31 UTC (rev 142253)
@@ -825,8 +825,3 @@
 {
     return m_windowList.size();
 }
-
-string TestShell::normalizeLayoutTestURL(const string& url)
-{
-    return normalizeLayoutTestURLInternal(url);
-}

Modified: trunk/Tools/DumpRenderTree/chromium/TestShell.h (142252 => 142253)


--- trunk/Tools/DumpRenderTree/chromium/TestShell.h	2013-02-08 11:45:54 UTC (rev 142252)
+++ trunk/Tools/DumpRenderTree/chromium/TestShell.h	2013-02-08 11:51:31 UTC (rev 142253)
@@ -178,10 +178,6 @@
     typedef Vector<WebViewHost*> WindowList;
     WindowList windowList() const { return m_windowList; }
 
-    // Returns a string representation of an URL's spec that does not depend on
-    // the location of the layout test in the file system.
-    std::string normalizeLayoutTestURL(const std::string&);
-
 private:
     WebViewHost* createNewWindow(const WebKit::WebURL&, DRTDevToolsAgent*, WebTestRunner::WebTestInterfaces*);
     void createMainWindow();

Modified: trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp (142252 => 142253)


--- trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp	2013-02-08 11:45:54 UTC (rev 142252)
+++ trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp	2013-02-08 11:51:31 UTC (rev 142253)
@@ -732,11 +732,6 @@
     return webkit_support::MakeURLErrorDescription(error);
 }
 
-std::string WebViewHost::normalizeLayoutTestURL(const std::string& url)
-{
-    return m_shell->normalizeLayoutTestURL(url);
-}
-
 void WebViewHost::showDevTools()
 {
     m_shell->showDevTools();

Modified: trunk/Tools/DumpRenderTree/chromium/WebViewHost.h (142252 => 142253)


--- trunk/Tools/DumpRenderTree/chromium/WebViewHost.h	2013-02-08 11:45:54 UTC (rev 142252)
+++ trunk/Tools/DumpRenderTree/chromium/WebViewHost.h	2013-02-08 11:51:31 UTC (rev 142253)
@@ -129,7 +129,6 @@
     virtual WebKit::WebIntentRequest* currentWebIntentRequest() OVERRIDE;
 #endif
     virtual std::string makeURLErrorDescription(const WebKit::WebURLError&) OVERRIDE;
-    virtual std::string normalizeLayoutTestURL(const std::string&) OVERRIDE;
     virtual void setClientWindowRect(const WebKit::WebRect&) OVERRIDE;
     virtual void showDevTools() OVERRIDE;
     virtual void closeDevTools() OVERRIDE;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to