Changeset 69297 in webkit


Ignore:
Timestamp:
Oct 7, 2010 5:23:04 AM (14 years ago)
Author:
kbalazs@webkit.org
Message:

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

Reviewed by Kenneth Rohde Christiansen.

WebKitTestRunner should be portable
https://bugs.webkit.org/show_bug.cgi?id=45393

Use only the WebKit API for working with urls.

  • WebKitTestRunner/StringFunctions.h: (WTR::createWKURL):
  • WebKitTestRunner/TestController.cpp: (WTR::blankURL): (WTR::TestController::resetStateToConsistentValues): (WTR::TestController::didFinishLoadForFrame):

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

Reviewed by Kenneth Rohde Christiansen.

WebKitTestRunner should be portable
https://bugs.webkit.org/show_bug.cgi?id=45393

Introducing additional URL API.

  • Shared/API/c/WKURL.cpp: (WKURLCreateWithUTF8CString): (WKURLIsEqual):
  • Shared/API/c/WKURL.h:
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit2/ChangeLog

    r69245 r69297  
     12010-10-07  Balazs Kelemen  <kbalazs@webkit.org>
     2
     3        Reviewed by Kenneth Rohde Christiansen.
     4
     5        WebKitTestRunner should be portable
     6        https://bugs.webkit.org/show_bug.cgi?id=45393
     7
     8        Introducing additional URL API.
     9        * Shared/API/c/WKURL.cpp:
     10        (WKURLCreateWithUTF8CString):
     11        (WKURLIsEqual):
     12        * Shared/API/c/WKURL.h:
     13
    1142010-10-06  Balazs Kelemen  <kbalazs@webkit.org>
    215
  • trunk/WebKit2/Shared/API/c/WKURL.cpp

    r69214 r69297  
    3434    return toAPI(WebURL::APIType);
    3535}
     36
     37WKURLRef WKURLCreateWithUTF8CString(const char* string)
     38{
     39    return toAPI(WebURL::create(String::fromUTF8(string)).leakRef());
     40}
     41
     42bool WKURLIsEqual(WKURLRef a, WKURLRef b)
     43{
     44    return toImpl(a)->string() == toImpl(b)->string();
     45}
  • trunk/WebKit2/Shared/API/c/WKURL.h

    r68357 r69297  
    3535WK_EXPORT WKTypeID WKURLGetTypeID();
    3636
     37WK_EXPORT WKURLRef WKURLCreateWithUTF8CString(const char* string);
     38
     39WK_EXPORT bool WKURLIsEqual(WKURLRef a, WKURLRef b);
     40
    3741#ifdef __cplusplus
    3842}
  • trunk/WebKitTools/ChangeLog

    r69294 r69297  
     12010-10-07  Balazs Kelemen  <kbalazs@webkit.org>
     2
     3        Reviewed by Kenneth Rohde Christiansen.
     4
     5        WebKitTestRunner should be portable
     6        https://bugs.webkit.org/show_bug.cgi?id=45393
     7
     8        Use only the WebKit API for working with urls.
     9        * WebKitTestRunner/StringFunctions.h:
     10        (WTR::createWKURL):
     11        * WebKitTestRunner/TestController.cpp:
     12        (WTR::blankURL):
     13        (WTR::TestController::resetStateToConsistentValues):
     14        (WTR::TestController::didFinishLoadForFrame):
     15
    1162010-10-07  Carlos Garcia Campos  <cgarcia@igalia.com>
    217
  • trunk/WebKitTools/WebKitTestRunner/StringFunctions.h

    r69129 r69297  
    11/*
    22 * Copyright (C) 2010 Apple Inc. All rights reserved.
     3 * Copyright (C) 2010 University of Szeged. All rights reserved.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    2930#include <JavaScriptCore/JSRetainPtr.h>
    3031#include <JavaScriptCore/JavaScript.h>
     32#include <sstream>
     33#include <string>
    3134#include <WebKit2/WKRetainPtr.h>
    3235#include <WebKit2/WKString.h>
    33 #include <WebKit2/WKStringCF.h>
    3436#include <WebKit2/WKStringPrivate.h>
    3537#include <WebKit2/WKURL.h>
    36 #include <WebKit2/WKURLCF.h>
    37 #include <sstream>
    38 #include <string>
    3938#include <wtf/OwnArrayPtr.h>
    4039#include <wtf/PassOwnArrayPtr.h>
    4140#include <wtf/Platform.h>
    42 #include <wtf/RetainPtr.h>
    4341#include <wtf/Vector.h>
    4442
     
    9593}
    9694
    97 // URL Functions
     95// URL creation
    9896
    9997inline WKURLRef createWKURL(const char* pathOrURL)
    10098{
    101     RetainPtr<CFStringRef> pathOrURLCFString(AdoptCF, CFStringCreateWithCString(0, pathOrURL, kCFStringEncodingUTF8));
    102     RetainPtr<CFURLRef> cfURL;
    103     if (CFStringHasPrefix(pathOrURLCFString.get(), CFSTR("http://")) || CFStringHasPrefix(pathOrURLCFString.get(), CFSTR("https://")))
    104         cfURL.adoptCF(CFURLCreateWithString(0, pathOrURLCFString.get(), 0));
    105     else
    106 #if PLATFORM(WIN)
    107         cfURL.adoptCF(CFURLCreateWithFileSystemPath(0, pathOrURLCFString.get(), kCFURLWindowsPathStyle, false));
    108 #else
    109         cfURL.adoptCF(CFURLCreateWithFileSystemPath(0, pathOrURLCFString.get(), kCFURLPOSIXPathStyle, false));
    110 #endif
    111     return WKURLCreateWithCFURL(cfURL.get());
    112 }
     99    if (strstr(pathOrURL, "http://") || strstr(pathOrURL, "https") || strstr(pathOrURL, "file://"))
     100        return WKURLCreateWithUTF8CString(pathOrURL);
    113101
    114 inline WKStringRef copyURLString(WKURLRef url)
    115 {
    116     RetainPtr<CFURLRef> cfURL(AdoptCF, WKURLCopyCFURL(0, url));
    117     return WKStringCreateWithCFString(CFURLGetString(cfURL.get()));
     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());
    118109}
    119110
  • trunk/WebKitTools/WebKitTestRunner/TestController.cpp

    r68966 r69297  
    3535namespace WTR {
    3636
     37static WKURLRef blankURL()
     38{
     39    static staticBlankURL = WKURLCreateWithUTF8CString("about:blank");
     40    retun staticBlankURL;
     41}
     42
    3743static TestController* controller;
    3844
     
    228234    m_doneResetting = false;
    229235
    230     WKRetainPtr<WKURLRef> url(AdoptWK, createWKURL("about:blank"));
    231     WKPageLoadURL(m_mainWebView->page(), url.get());
     236    WKPageLoadURL(m_mainWebView->page(), blankURL());
    232237    TestController::runUntil(m_doneResetting);
    233238}
     
    296301
    297302    WKRetainPtr<WKURLRef> wkURL(AdoptWK, WKFrameCopyURL(frame));
    298     WKRetainPtr<WKStringRef> wkURLString(AdoptWK, copyURLString(wkURL.get()));
    299     if (!WKStringIsEqualToUTF8CString(wkURLString.get(), "about:blank"))
     303    if (!WKURLIsEqual(wkURL.get(), blankURL()))
    300304        return;
    301305
Note: See TracChangeset for help on using the changeset viewer.