Bug 119583 - [Win] URL printing code in DumpRenderTree doesn't match WTR or Mac DRT
Summary: [Win] URL printing code in DumpRenderTree doesn't match WTR or Mac DRT
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Brent Fulgham
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-08 11:18 PDT by Alexey Proskuryakov
Modified: 2013-08-16 11:05 PDT (History)
2 users (show)

See Also:


Attachments
Patch (1.67 KB, patch)
2013-08-16 10:01 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (2.19 KB, patch)
2013-08-16 10:04 PDT, Brent Fulgham
no flags Details | Formatted Diff | Diff
Patch (3.24 KB, patch)
2013-08-16 10:40 PDT, Brent Fulgham
ap: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexey Proskuryakov 2013-08-08 11:18:43 PDT
urlSuitableForTestResult() in DumpRenderTree/win/DumpRenderTree.cpp removes a prefix from url without checking whether the url actually has this prefix:

--------------------------
    RetainPtr<CFStringRef> basePath = adoptCF(CFURLCopyPath(baseURL.get()));
    RetainPtr<CFStringRef> path = adoptCF(CFURLCopyPath(url.get()));

    return cfStringRefToWString(substringFromIndex(path.get(), CFStringGetLength(basePath.get())).get());

--------------------------

When it doesn't match - or when base URL cannot be determined - we should print last path component.
Comment 1 Alexey Proskuryakov 2013-08-16 09:37:47 PDT
Either WebKitTestRunner code or Mac DRT could probably serve as a good model to follow.
Comment 2 Brent Fulgham 2013-08-16 10:01:43 PDT
Created attachment 208928 [details]
Patch
Comment 3 Brent Fulgham 2013-08-16 10:04:18 PDT
Created attachment 208929 [details]
Patch
Comment 4 Alexey Proskuryakov 2013-08-16 10:14:18 PDT
Comment on attachment 208929 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=208929&action=review

There are more instances of "return urlString;" above the changed code, all except the very first one should be changed to return the last path component. We never want a full file:// path!

> Tools/DumpRenderTree/win/DumpRenderTree.cpp:172
> +    if (path.get() && CFStringHasPrefix(path.get(), basePath.get()))

This null check should be for basePath, not for path.
Comment 5 Brent Fulgham 2013-08-16 10:15:16 PDT
Comment on attachment 208929 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=208929&action=review

>> Tools/DumpRenderTree/win/DumpRenderTree.cpp:172
>> +    if (path.get() && CFStringHasPrefix(path.get(), basePath.get()))
> 
> This null check should be for basePath, not for path.

Oops!
Comment 6 Brent Fulgham 2013-08-16 10:40:29 PDT
Created attachment 208931 [details]
Patch
Comment 7 Alexey Proskuryakov 2013-08-16 10:52:09 PDT
Comment on attachment 208931 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=208931&action=review

Great, thank you for tackling this!

> Tools/DumpRenderTree/win/DumpRenderTree.cpp:144
> +static wstring fallbackString(CFURLRef url)

I'd name this function after what it does - in this case, it seems more straightforward than naming it by what it is used for. What about lastPathComponent() as the name?
Comment 8 Alexey Proskuryakov 2013-08-16 10:52:49 PDT
Or something like lastPathComponentAsWString().
Comment 9 Brent Fulgham 2013-08-16 10:54:11 PDT
(In reply to comment #8)
> Or something like lastPathComponentAsWString().

That's a good idea.  I'll change it while landing.
Comment 10 Brent Fulgham 2013-08-16 11:05:01 PDT
Committed r154194: <http://trac.webkit.org/changeset/154194>