Changeset 69657 in webkit
- Timestamp:
- Oct 13, 2010 7:07:06 AM (14 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r69656 r69657 1 2010-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 1 13 2010-10-12 Adam Roben <aroben@apple.com> 2 14 -
trunk/WebKitTools/WebKitTestRunner/StringFunctions.h
r69297 r69657 93 93 } 94 94 95 // URL creation96 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 111 95 } // namespace WTR 112 96 -
trunk/WebKitTools/WebKitTestRunner/TestInvocation.cpp
r69384 r69657 29 29 #include "StringFunctions.h" 30 30 #include "TestController.h" 31 #include <climits> 31 32 #include <cstdio> 32 33 #include <WebKit2/WKContextPrivate.h> … … 35 36 #include <wtf/PassOwnArrayPtr.h> 36 37 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 37 44 using namespace WebKit; 38 45 using namespace std; 39 46 40 47 namespace WTR { 48 49 static 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 } 41 86 42 87 TestInvocation::TestInvocation(const char* pathOrURL)
Note: See TracChangeset
for help on using the changeset viewer.