Bug 46943 - [chromium] getData('text/uri-list') should return the same thing that was passed to setData('text/uri-list')
Summary: [chromium] getData('text/uri-list') should return the same thing that was pas...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-30 17:14 PDT by Daniel Cheng
Modified: 2010-10-05 13:14 PDT (History)
2 users (show)

See Also:


Attachments
Patch (13.22 KB, patch)
2010-10-04 16:30 PDT, Daniel Cheng
tony: review-
Details | Formatted Diff | Diff
Patch (14.43 KB, patch)
2010-10-05 02:15 PDT, Daniel Cheng
tony: review-
Details | Formatted Diff | Diff
Patch (14.44 KB, patch)
2010-10-05 11:20 PDT, Daniel Cheng
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Cheng 2010-09-30 17:14:10 PDT
Right now, we strip out comments and potentially change line endings. It's probably nice to have it return the same thing that was passed in (the comments might be useful, for instance).

How do other browsers handle it?
IE8: Calling setData('URL') doesn't work. The only time you can set URLs in IE seems to be when you're dragging anchors--and it's not you setting it, it's implicitly set by the browser.
IE9: Same as IE8 as far as I can tell. I could be wrong though.
Firefox: Seems to handle URL and text/uri-list as separate types. Also allows anything to be set in the 'URL' member.
Safari: My test isn't working in Safari at the moment, but as far as I can tell, it probably returns what you set for text/uri-list (and URL as well, though that's probably a bug).

As I interpret the standard, getData('URL') should never return an invalid URL.
Comment 1 Daniel Cheng 2010-10-04 16:30:40 PDT
Created attachment 69713 [details]
Patch
Comment 2 Tony Chang 2010-10-04 16:49:04 PDT
Comment on attachment 69713 [details]
Patch

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

The code looks OK but I would like to see more tests.

> LayoutTests/editing/pasteboard/script-tests/dataTransfer-setData-getData.js:103
> +    test("text/uri-list", "# comment\r\nhttp://test.com\r\nhttp://check.com", 
> +         "URL", "http://test.com/");

Can you add some more test cases like setting URL and getting text/uri-list?  What about setting a text/uri-list with comments but no urls and getting URL?  What about setting a URL with multiple urls and getting with URL?
Comment 3 Daniel Cheng 2010-10-05 02:15:13 PDT
Created attachment 69763 [details]
Patch
Comment 4 Tony Chang 2010-10-05 09:39:52 PDT
Comment on attachment 69763 [details]
Patch

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

> LayoutTests/editing/pasteboard/script-tests/dataTransfer-setData-getData.js:119
> +    test("text/uri-list", "# comment\r\n# comment 2\r\n# comment 3", 
> +         "URL", null);

The spec says this should return an empty string, not null:
http://dev.w3.org/html5/spec/dnd.html
"If there is no data with that format, or if there is but it has no URLs, then the method must return the empty string."

> WebCore/platform/chromium/ChromiumDataObject.cpp:145
>          success = !m_url.isEmpty();
>          return m_url.string();

Maybe the fix is as simple as
  success = !m_url.isEmpty() || !m_uriList.isEmpty();
?
Comment 5 Daniel Cheng 2010-10-05 11:07:55 PDT
(In reply to comment #4)
> (From update of attachment 69763 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=69763&action=review
> 
> > LayoutTests/editing/pasteboard/script-tests/dataTransfer-setData-getData.js:119
> > +    test("text/uri-list", "# comment\r\n# comment 2\r\n# comment 3", 
> > +         "URL", null);
> 
> The spec says this should return an empty string, not null:
> http://dev.w3.org/html5/spec/dnd.html
> "If there is no data with that format, or if there is but it has no URLs, then the method must return the empty string."
> 
> > WebCore/platform/chromium/ChromiumDataObject.cpp:145
> >          success = !m_url.isEmpty();
> >          return m_url.string();
> 
> Maybe the fix is as simple as
>   success = !m_url.isEmpty() || !m_uriList.isEmpty();
> ?

It probably makes sense to address this in another patch (since getData("text") has the same problem as well then). Maybe we should just delete the empty cases from this patch before landing it and fix the undefined behavior in a separate patch and add test cases there?
Comment 6 Tony Chang 2010-10-05 11:12:44 PDT
Fixing in a follow up patch sounds fine since it sounds like this isn't a regression.  Instead of deleting the test case, keep the test case with the correct value:
test("text/uri-list", "# comment\r\n# comment 2\r\n# comment 3", 
     "URL", "");

But check in an -expected.txt file with the word FAIL in it.  When we fix the code, we can check in the new -expected.txt file.  We do this for other tests.
Comment 7 Daniel Cheng 2010-10-05 11:20:16 PDT
Created attachment 69815 [details]
Patch
Comment 8 WebKit Commit Bot 2010-10-05 13:13:55 PDT
Comment on attachment 69815 [details]
Patch

Clearing flags on attachment: 69815

Committed r69138: <http://trac.webkit.org/changeset/69138>
Comment 9 WebKit Commit Bot 2010-10-05 13:14:00 PDT
All reviewed patches have been landed.  Closing bug.