From fb849a149c5c55fe5dbef97e6215d2d64f7d5dfb Mon Sep 17 00:00:00 2001 From: "eric@webkit.org" Date: Thu, 26 Jan 2012 00:27:03 +0000 Subject: [PATCH] "text" and "URL" legacy clipboard types should not be case sensitive https://bugs.webkit.org/show_bug.cgi?id=76947 Reviewed by Adam Barth. Source/WebCore: This matches the HTML5 spec which says the first thing to do is to lowercase the type before comparing. I also removed the stripping of whitespace since that is not part of the modern spec (and no tests failed as a result of removal). Turns out we already had a test for case sensitivity, but it was disabled on Mac so I just re-enabled it and have added failing expectations for the parts of the test we still fail. * platform/mac/ClipboardMac.mm: (WebCore::cocoaTypeFromHTMLClipboardType): (WebCore::ClipboardMac::getData): LayoutTests: This test has been disabled on Mac since it was added 2 years ago. But we actually need to fix at least one of the bugs covered by this test, so I'm unskipping it and adding failing expectations for the parts Mac doens't yet pass. * platform/mac/Skipped: * platform/mac/editing/pasteboard/dataTransfer-setData-getData-expected.txt: Added. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105941 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- LayoutTests/ChangeLog | 15 +++++++ .../dataTransfer-setData-getData-expected.txt | 43 ++++++++++-------- .../dataTransfer-setData-getData-expected.txt | 51 ++++++++++++++++++++++ LayoutTests/platform/mac/Skipped | 3 -- Source/WebCore/ChangeLog | 18 ++++++++ Source/WebCore/platform/mac/ClipboardMac.mm | 18 ++++---- 6 files changed, 117 insertions(+), 31 deletions(-) create mode 100644 LayoutTests/platform/chromium/editing/pasteboard/dataTransfer-setData-getData-expected.txt diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 2f6debd..d8175bc 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,5 +1,20 @@ 2012-01-25 Eric Seidel + "text" and "URL" legacy clipboard types should not be case sensitive + https://bugs.webkit.org/show_bug.cgi?id=76947 + + Reviewed by Adam Barth. + + This test has been disabled on Mac since it was added 2 years ago. + But we actually need to fix at least one of the bugs covered by this + test, so I'm unskipping it and adding failing expectations for the + parts Mac doens't yet pass. + + * platform/mac/Skipped: + * platform/mac/editing/pasteboard/dataTransfer-setData-getData-expected.txt: Added. + +2012-01-25 Eric Seidel + HTMLEmbedObject should match HTMLObjectElement by stopping any load when it is removed from beforeload https://bugs.webkit.org/show_bug.cgi?id=74360 diff --git a/LayoutTests/editing/pasteboard/dataTransfer-setData-getData-expected.txt b/LayoutTests/editing/pasteboard/dataTransfer-setData-getData-expected.txt index 6d7f172..81395ac 100644 --- a/LayoutTests/editing/pasteboard/dataTransfer-setData-getData-expected.txt +++ b/LayoutTests/editing/pasteboard/dataTransfer-setData-getData-expected.txt @@ -5,34 +5,39 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE --- Test set/get 'URL': PASS getDataResultType is "string" -PASS getDataResult is "http://test.com/" +FAIL getDataResult should be http://test.com/. Was http://test.com. --- Test set/get 'URL' with multiple URLs: -PASS getDataResultType is "string" -PASS getDataResult is "http://test.com/" +FAIL getDataResultType should be string. Was undefined. +FAIL getDataResult should be http://test.com/ (of type string). Was undefined (of type undefined). --- Test set/get 'text/uri-list': -PASS getDataResultType is "string" -PASS getDataResult is "http://test.com\r\nhttp://check.com" +FAIL getDataResultType should be string. Was undefined. +FAIL getDataResult should be http://test.com +http://check.com (of type string). Was undefined (of type undefined). --- Test set/get 'text/uri-list' using '\n': -PASS getDataResultType is "string" -PASS getDataResult is "http://test.com\nhttp://check.com" +FAIL getDataResultType should be string. Was undefined. +FAIL getDataResult should be http://test.com +http://check.com (of type string). Was undefined (of type undefined). --- Test set 'text/uri-list', get 'URL': -PASS getDataResultType is "string" -PASS getDataResult is "http://test.com/" +FAIL getDataResultType should be string. Was undefined. +FAIL getDataResult should be http://test.com/ (of type string). Was undefined (of type undefined). --- Test set 'URL', get 'text/uri-list': -PASS getDataResultType is "string" -PASS getDataResult is "http://test.com\r\nhttp://check.com" +FAIL getDataResultType should be string. Was undefined. +FAIL getDataResult should be http://test.com +http://check.com (of type string). Was undefined (of type undefined). --- Test set 'text/uri-list', get 'URL', using only '\n': -PASS getDataResultType is "string" -PASS getDataResult is "http://test.com/" +FAIL getDataResultType should be string. Was undefined. +FAIL getDataResult should be http://test.com/ (of type string). Was undefined (of type undefined). --- Test set/get 'text/uri-list' with comments: -PASS getDataResultType is "string" -PASS getDataResult is "# comment\r\nhttp://test.com\r\nhttp://check.com" +FAIL getDataResultType should be string. Was undefined. +FAIL getDataResult should be # comment +http://test.com +http://check.com (of type string). Was undefined (of type undefined). --- Test set 'text/uri-list', get 'URL' with comments: -PASS getDataResultType is "string" -PASS getDataResult is "http://test.com/" +FAIL getDataResultType should be string. Was undefined. +FAIL getDataResult should be http://test.com/ (of type string). Was undefined (of type undefined). --- Test set 'text/uri-list', get 'URL' with only comments: -PASS getDataResultType is "string" -PASS getDataResult is "" +FAIL getDataResultType should be string. Was undefined. +FAIL getDataResult should be (of type string). Was undefined (of type undefined). --- Test set/get 'text/plain': PASS getDataResultType is "string" PASS getDataResult is "Lorem ipsum dolor sit amet." diff --git a/LayoutTests/platform/chromium/editing/pasteboard/dataTransfer-setData-getData-expected.txt b/LayoutTests/platform/chromium/editing/pasteboard/dataTransfer-setData-getData-expected.txt new file mode 100644 index 0000000..6d7f172 --- /dev/null +++ b/LayoutTests/platform/chromium/editing/pasteboard/dataTransfer-setData-getData-expected.txt @@ -0,0 +1,51 @@ +Tests correct behavior of event.dataTransfer.setData/getData for 'URL', 'text/uri-list' and 'text/plain' + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +--- Test set/get 'URL': +PASS getDataResultType is "string" +PASS getDataResult is "http://test.com/" +--- Test set/get 'URL' with multiple URLs: +PASS getDataResultType is "string" +PASS getDataResult is "http://test.com/" +--- Test set/get 'text/uri-list': +PASS getDataResultType is "string" +PASS getDataResult is "http://test.com\r\nhttp://check.com" +--- Test set/get 'text/uri-list' using '\n': +PASS getDataResultType is "string" +PASS getDataResult is "http://test.com\nhttp://check.com" +--- Test set 'text/uri-list', get 'URL': +PASS getDataResultType is "string" +PASS getDataResult is "http://test.com/" +--- Test set 'URL', get 'text/uri-list': +PASS getDataResultType is "string" +PASS getDataResult is "http://test.com\r\nhttp://check.com" +--- Test set 'text/uri-list', get 'URL', using only '\n': +PASS getDataResultType is "string" +PASS getDataResult is "http://test.com/" +--- Test set/get 'text/uri-list' with comments: +PASS getDataResultType is "string" +PASS getDataResult is "# comment\r\nhttp://test.com\r\nhttp://check.com" +--- Test set 'text/uri-list', get 'URL' with comments: +PASS getDataResultType is "string" +PASS getDataResult is "http://test.com/" +--- Test set 'text/uri-list', get 'URL' with only comments: +PASS getDataResultType is "string" +PASS getDataResult is "" +--- Test set/get 'text/plain': +PASS getDataResultType is "string" +PASS getDataResult is "Lorem ipsum dolor sit amet." +--- Test set 'text/plain', get 'text': +PASS getDataResultType is "string" +PASS getDataResult is "Lorem ipsum dolor sit amet." +--- Test set 'text', get 'text/plain': +PASS getDataResultType is "string" +PASS getDataResult is "Lorem ipsum dolor sit amet." +--- Test set/get 'text': +PASS getDataResultType is "string" +PASS getDataResult is "Lorem ipsum dolor sit amet." +PASS successfullyParsed is true + +TEST COMPLETE + diff --git a/LayoutTests/platform/mac/Skipped b/LayoutTests/platform/mac/Skipped index 9e6dd66..7833ea9 100644 --- a/LayoutTests/platform/mac/Skipped +++ b/LayoutTests/platform/mac/Skipped @@ -114,9 +114,6 @@ fast/forms/multiple-form-submission-protection-mouse.html # The animation causes the result of this test to depend on the speed of executing it, and that will cause it to be flaky fast/dom/HTMLProgressElement/progress-element.html -# event.dataTransfer.setData('text/uri-list') not correctly implemented on Mac -editing/pasteboard/dataTransfer-setData-getData.html - # eventSender needs to propagate the event to the calling window, not the main frame always. http/tests/plugins/plugin-document-has-focus.html diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 8cb3919..7384350 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,5 +1,23 @@ 2012-01-25 Eric Seidel + "text" and "URL" legacy clipboard types should not be case sensitive + https://bugs.webkit.org/show_bug.cgi?id=76947 + + Reviewed by Adam Barth. + + This matches the HTML5 spec which says the first thing to do is to lowercase + the type before comparing. + I also removed the stripping of whitespace since that is not part of the modern spec (and no tests failed as a result of removal). + Turns out we already had a test for case sensitivity, but it was disabled on Mac + so I just re-enabled it and have added failing expectations for the parts + of the test we still fail. + + * platform/mac/ClipboardMac.mm: + (WebCore::cocoaTypeFromHTMLClipboardType): + (WebCore::ClipboardMac::getData): + +2012-01-25 Eric Seidel + HTMLIsIndexElement should not expose HTMLInputElement properties https://bugs.webkit.org/show_bug.cgi?id=76095 diff --git a/Source/WebCore/platform/mac/ClipboardMac.mm b/Source/WebCore/platform/mac/ClipboardMac.mm index ef759fb..48dc3e0 100644 --- a/Source/WebCore/platform/mac/ClipboardMac.mm +++ b/Source/WebCore/platform/mac/ClipboardMac.mm @@ -68,13 +68,13 @@ bool ClipboardMac::hasData() static RetainPtr cocoaTypeFromHTMLClipboardType(const String& type) { - String qType = type.stripWhiteSpace(); + // http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#dom-datatransfer-setdata + String qType = type.lower(); - // two special cases for IE compatibility - if (qType == "Text") - return NSStringPboardType; - if (qType == "URL") - return NSURLPboardType; + if (qType == "text") + qType = "text/plain"; + if (qType == "url") + qType = "text/uri-list"; // Ignore any trailing charset - JS strings are Unicode, which encapsulates the charset issue if (qType == "text/plain" || qType.startsWith("text/plain;")) @@ -82,7 +82,7 @@ static RetainPtr cocoaTypeFromHTMLClipboardType(const String& type) if (qType == "text/uri-list") // special case because UTI doesn't work with Cocoa's URL type return NSURLPboardType; // note special case in getData to read NSFilenamesType - + // Try UTI now NSString *mimeType = qType; RetainPtr utiType(AdoptCF, UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, (CFStringRef)mimeType, NULL)); @@ -218,8 +218,8 @@ String ClipboardMac::getData(const String& type, bool& success) const // Grab the value off the pasteboard corresponding to the cocoaType if ([cocoaType.get() isEqualToString:NSURLPboardType]) { - // "URL" and "text/url-list" both map to NSURLPboardType in cocoaTypeFromHTMLClipboardType(), "URL" only wants the first URL - bool onlyFirstURL = (type == "URL"); + // "url" and "text/url-list" both map to NSURLPboardType in cocoaTypeFromHTMLClipboardType(), "url" only wants the first URL + bool onlyFirstURL = (equalIgnoringCase(type, "url")); NSArray *absoluteURLs = absoluteURLsFromPasteboard(m_pasteboard.get(), onlyFirstURL); cocoaValue = [absoluteURLs componentsJoinedByString:@"\n"]; } else if ([cocoaType.get() isEqualToString:NSStringPboardType]) { -- 2.7.4