Changeset 69657 in webkit


Ignore:
Timestamp:
Oct 13, 2010 7:07:06 AM (14 years ago)
Author:
kbalazs@webkit.org
Message:

2010-10-13 Balazs Kelemen <kbalazs@webkit.org>

Reviewed by Csaba Osztrogonác.

WTR should accept relative paths
https://bugs.webkit.org/show_bug.cgi?id=47486

  • WebKitTestRunner/StringFunctions.h:
  • WebKitTestRunner/TestInvocation.cpp: (WTR::createWKURL): Moved from StringFunctions.h since it is used only here. Extend relative paths to absolute.
Location:
trunk/WebKitTools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r69656 r69657  
     12010-10-13  Balazs Kelemen  <kbalazs@webkit.org>
     2
     3        Reviewed by Csaba Osztrogonác.
     4
     5        WTR should accept relative paths
     6        https://bugs.webkit.org/show_bug.cgi?id=47486
     7
     8        * WebKitTestRunner/StringFunctions.h:
     9        * WebKitTestRunner/TestInvocation.cpp:
     10        (WTR::createWKURL): Moved from StringFunctions.h since it is
     11        used only here. Extend relative paths to absolute.
     12
    1132010-10-12  Adam Roben  <aroben@apple.com>
    214
  • trunk/WebKitTools/WebKitTestRunner/StringFunctions.h

    r69297 r69657  
    9393}
    9494
    95 // URL creation
    96 
    97 inline WKURLRef createWKURL(const char* pathOrURL)
    98 {
    99     if (strstr(pathOrURL, "http://") || strstr(pathOrURL, "https") || strstr(pathOrURL, "file://"))
    100         return WKURLCreateWithUTF8CString(pathOrURL);
    101 
    102     const char* filePrefix = "file://";
    103     static const size_t prefixLength = strlen(filePrefix);
    104     size_t length = strlen(pathOrURL);
    105     OwnArrayPtr<char> buffer = adoptArrayPtr(new char[length + prefixLength + 1]);
    106     strcpy(buffer.get(), filePrefix);
    107     strcat(buffer.get(), pathOrURL);
    108     return WKURLCreateWithUTF8CString(buffer.get());
    109 }
    110 
    11195} // namespace WTR
    11296
  • trunk/WebKitTools/WebKitTestRunner/TestInvocation.cpp

    r69384 r69657  
    2929#include "StringFunctions.h"
    3030#include "TestController.h"
     31#include <climits>
    3132#include <cstdio>
    3233#include <WebKit2/WKContextPrivate.h>
     
    3536#include <wtf/PassOwnArrayPtr.h>
    3637
     38#if OS(WINDOWS)
     39#include <direct.h> // For _getcwd.
     40#define getcwd _getcwd // MSDN says getcwd is deprecated.
     41#define PATH_MAX _MAX_PATH
     42#endif
     43
    3744using namespace WebKit;
    3845using namespace std;
    3946
    4047namespace WTR {
     48
     49static WKURLRef createWKURL(const char* pathOrURL)
     50{
     51    if (strstr(pathOrURL, "http://") || strstr(pathOrURL, "https://") || strstr(pathOrURL, "file://"))
     52        return WKURLCreateWithUTF8CString(pathOrURL);
     53
     54    // Creating from filesytem path.
     55    size_t length = strlen(pathOrURL);
     56    if (!length)
     57        return 0;
     58
     59    const char* filePrefix = "file://";
     60    static const size_t prefixLength = strlen(filePrefix);
     61#if OS(WINDOWS)
     62    const char separator = '\\';
     63    bool isAbsolutePath = length >= 3 && pathOrURL[1] == ':' && pathOrURL[2] == separator;
     64#else
     65    const char separator = '/';
     66    bool isAbsolutePath = pathOrURL[0] == separator;
     67#endif
     68
     69    OwnArrayPtr<char> buffer;
     70    if (isAbsolutePath) {
     71        buffer = adoptArrayPtr(new char[prefixLength + length + 1]);
     72        strcpy(buffer.get(), filePrefix);
     73        strcpy(buffer.get() + prefixLength, pathOrURL);
     74    } else {
     75        buffer = adoptArrayPtr(new char[prefixLength + PATH_MAX + length + 2]); // 1 for the separator
     76        strcpy(buffer.get(), filePrefix);
     77        if (!getcwd(buffer.get() + prefixLength, PATH_MAX))
     78            return 0;
     79        size_t numCharacters = strlen(buffer.get());
     80        buffer[numCharacters] = separator;
     81        strcpy(buffer.get() + numCharacters + 1, pathOrURL);
     82    }
     83
     84    return WKURLCreateWithUTF8CString(buffer.get());
     85}
    4186
    4287TestInvocation::TestInvocation(const char* pathOrURL)
Note: See TracChangeset for help on using the changeset viewer.