Changeset 142253 in webkit


Ignore:
Timestamp:
Feb 8, 2013 3:51:31 AM (11 years ago)
Author:
jochen@chromium.org
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):

Location:
trunk/Tools
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r142249 r142253  
     12013-02-08  Jochen Eisinger  <jochen@chromium.org>
     2
     3        [chromium] copy normalizeLayoutTestURL code to TestRunner library
     4        https://bugs.webkit.org/show_bug.cgi?id=109269
     5
     6        Reviewed by Kent Tamura.
     7
     8        The method doesn't have any external dependencies, so there's no reason
     9        it should be on the delegate. It's still required by TestShell, however,
     10        by making a copy, we can avoid implementing this in content shell.
     11
     12        * DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h:
     13        (WebTestDelegate):
     14        * DumpRenderTree/chromium/TestRunner/src/WebPermissions.cpp:
     15        (WebTestRunner::WebPermissions::allowImage):
     16        (WebTestRunner::WebPermissions::allowScriptFromSource):
     17        * DumpRenderTree/chromium/TestShell.cpp:
     18        (TestShell::windowCount):
     19        * DumpRenderTree/chromium/TestShell.h:
     20        * DumpRenderTree/chromium/WebViewHost.cpp:
     21        * DumpRenderTree/chromium/WebViewHost.h:
     22        (WebViewHost):
     23
    1242013-02-08  Raphael Kubo da Costa  <raphael.kubo.da.costa@intel.com>
    225
  • trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h

    r141381 r142253  
    5555    virtual void clearContextMenuData() = 0;
    5656    virtual void clearEditCommand() = 0;
    57     virtual void fillSpellingSuggestionList(const WebKit::WebString&, WebKit::WebVector<WebKit::WebString>*) { }
    5857    virtual void setEditCommand(const std::string& name, const std::string& value) = 0;
    5958    virtual WebKit::WebContextMenuData* lastContextMenuData() const = 0;
     
    8079    virtual WebKit::WebIntentRequest* currentWebIntentRequest() { return 0; }
    8180    virtual std::string makeURLErrorDescription(const WebKit::WebURLError&) { return std::string(); }
    82     virtual std::string normalizeLayoutTestURL(const std::string&) { return std::string(); }
    8381    virtual void setClientWindowRect(const WebKit::WebRect&) { }
    8482    virtual void showDevTools() { }
  • trunk/Tools/DumpRenderTree/chromium/TestRunner/src/WebPermissions.cpp

    r140565 r142253  
    3636#include <public/WebURL.h>
    3737
     38using namespace std;
     39
    3840namespace WebTestRunner {
     41
     42namespace {
     43
     44const char layoutTestsPattern[] = "/LayoutTests/";
     45const string::size_type layoutTestsPatternSize = sizeof(layoutTestsPattern) - 1;
     46const char fileUrlPattern[] = "file:/";
     47const char fileTestPrefix[] = "(file test):";
     48const char dataUrlPattern[] = "data:";
     49const string::size_type dataUrlPatternSize = sizeof(dataUrlPattern) - 1;
     50
     51string normalizeLayoutTestURL(const string& url)
     52{
     53    string result = url;
     54    size_t pos;
     55    if (!url.find(fileUrlPattern) && ((pos = url.find(layoutTestsPattern)) != string::npos)) {
     56        // adjust file URLs to match upstream results.
     57        result.replace(0, pos + layoutTestsPatternSize, fileTestPrefix);
     58    } else if (!url.find(dataUrlPattern)) {
     59        // URL-escape data URLs to match results upstream.
     60        string path = url.substr(dataUrlPatternSize);
     61        result.replace(dataUrlPatternSize, url.length(), path);
     62    }
     63    return result;
     64}
     65
     66}
    3967
    4068WebPermissions::WebPermissions()
     
    5280    bool allowed = enabledPerSettings && m_imagesAllowed;
    5381    if (m_dumpCallbacks && m_delegate)
    54         m_delegate->printMessage(std::string("PERMISSION CLIENT: allowImage(") + m_delegate->normalizeLayoutTestURL(imageURL.spec()) + "): " + (allowed ? "true" : "false") + "\n");
     82        m_delegate->printMessage(std::string("PERMISSION CLIENT: allowImage(") + normalizeLayoutTestURL(imageURL.spec()) + "): " + (allowed ? "true" : "false") + "\n");
    5583    return allowed;
    5684}
     
    6088    bool allowed = enabledPerSettings && m_scriptsAllowed;
    6189    if (m_dumpCallbacks && m_delegate)
    62         m_delegate->printMessage(std::string("PERMISSION CLIENT: allowScriptFromSource(") + m_delegate->normalizeLayoutTestURL(scriptURL.spec()) + "): " + (allowed ? "true" : "false") + "\n");
     90        m_delegate->printMessage(std::string("PERMISSION CLIENT: allowScriptFromSource(") + normalizeLayoutTestURL(scriptURL.spec()) + "): " + (allowed ? "true" : "false") + "\n");
    6391    return allowed;
    6492}
  • trunk/Tools/DumpRenderTree/chromium/TestShell.cpp

    r141926 r142253  
    826826    return m_windowList.size();
    827827}
    828 
    829 string TestShell::normalizeLayoutTestURL(const string& url)
    830 {
    831     return normalizeLayoutTestURLInternal(url);
    832 }
  • trunk/Tools/DumpRenderTree/chromium/TestShell.h

    r141926 r142253  
    179179    WindowList windowList() const { return m_windowList; }
    180180
    181     // Returns a string representation of an URL's spec that does not depend on
    182     // the location of the layout test in the file system.
    183     std::string normalizeLayoutTestURL(const std::string&);
    184 
    185181private:
    186182    WebViewHost* createNewWindow(const WebKit::WebURL&, DRTDevToolsAgent*, WebTestRunner::WebTestInterfaces*);
  • trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp

    r141823 r142253  
    733733}
    734734
    735 std::string WebViewHost::normalizeLayoutTestURL(const std::string& url)
    736 {
    737     return m_shell->normalizeLayoutTestURL(url);
    738 }
    739 
    740735void WebViewHost::showDevTools()
    741736{
  • trunk/Tools/DumpRenderTree/chromium/WebViewHost.h

    r141823 r142253  
    130130#endif
    131131    virtual std::string makeURLErrorDescription(const WebKit::WebURLError&) OVERRIDE;
    132     virtual std::string normalizeLayoutTestURL(const std::string&) OVERRIDE;
    133132    virtual void setClientWindowRect(const WebKit::WebRect&) OVERRIDE;
    134133    virtual void showDevTools() OVERRIDE;
Note: See TracChangeset for help on using the changeset viewer.