This repository has been archived by the owner on Jun 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consolidate the code to normalize MIME type in DataTransfer
https://bugs.webkit.org/show_bug.cgi?id=175810 Reviewed by Wenson Hsieh. Source/WebCore: Factored out the code to convert MIME type to lowercase after stripping whitespace, and treat "text" as "text/plain" and "url" as "text/uri-list". Specifications: https://html.spec.whatwg.org/multipage/dnd.html#dom-datatransfer-getdata-2 https://html.spec.whatwg.org/multipage/dnd.html#dom-datatransfer-setdata-2 https://html.spec.whatwg.org/multipage/dnd.html#dom-datatransfer-cleardata-2 Stripping of whitespace only happens in WebKit/Blink but it's probably required for compatbility. Spec bug: whatwg/html#2946 Test: editing/pasteboard/datatransfer-getdata-plaintext.html * dom/DataTransfer.cpp: (WebCore::normalizeType): (WebCore::DataTransfer::clearData): (WebCore::DataTransfer::getData const): (WebCore::DataTransfer::setData): * platform/gtk/PasteboardGtk.cpp: (WebCore::selectionDataTypeFromHTMLClipboardType): * platform/ios/PasteboardIOS.mm: (WebCore::cocoaTypeFromHTMLClipboardType): * platform/mac/PasteboardMac.mm: (WebCore::cocoaTypeFromHTMLClipboardType): * platform/win/PasteboardWin.cpp: (WebCore::clipboardTypeFromMIMEType): LayoutTests: Added a regression test. Some test cases were failing on some platforms. * editing/pasteboard/datatransfer-getdata-plaintext-expected.txt: Added. * editing/pasteboard/datatransfer-getdata-plaintext.html: Added. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@221063 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
rniwa@webkit.org
committed
Aug 23, 2017
1 parent
c75a0c9
commit 3a241fb
Showing
9 changed files
with
133 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
LayoutTests/editing/pasteboard/datatransfer-getdata-plaintext-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
This tests peeks plain text using dataTransfer.getDAta. To manually test, click on "Copy text". | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS clipboardData.setData(" text/PLAIN ", "hello"); clipboardData.getData("text/plain") is "hello" | ||
PASS clipboardData.setData(" tEXT/pLaIN", "world"); clipboardData.getData("text/plain") is "world" | ||
PASS clipboardData.setData("text/plain; charset=utf-8", "hello"); clipboardData.getData("text/plain; charset=Shift_JIS") is "hello" | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
38 changes: 38 additions & 0 deletions
38
LayoutTests/editing/pasteboard/datatransfer-getdata-plaintext.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<script src="../../resources/js-test-pre.js"></script> | ||
<script> | ||
|
||
description('This tests peeks plain text using dataTransfer.getDAta. To manually test, click on "Copy text".'); | ||
|
||
function copyText() | ||
{ | ||
document.getElementById('source').focus(); | ||
document.execCommand('SelectAll', false, null); | ||
document.execCommand('Copy', false, null); | ||
} | ||
|
||
function copy(event) | ||
{ | ||
clipboardData = event.clipboardData; | ||
shouldBeEqualToString('clipboardData.setData(" text/PLAIN ", "hello"); clipboardData.getData("text/plain")', 'hello'); | ||
shouldBeEqualToString('clipboardData.setData(" tEXT/pLaIN", "world"); clipboardData.getData("text/plain")', 'world'); | ||
shouldBeEqualToString('clipboardData.setData("text/plain; charset=utf-8", "hello"); clipboardData.getData("text/plain; charset=Shift_JIS")', 'hello'); | ||
document.getElementById('container').style.display = 'none'; | ||
finishJSTest(); | ||
} | ||
|
||
if (window.testRunner) | ||
window.onload = copyText; | ||
jsTestIsAsync = true; | ||
successfullyParsed = true; | ||
|
||
</script> | ||
<div id="container"> | ||
<button onclick="copyText();">Copy text</button> | ||
<div id="source" oncopy="copy(event)" contenteditable="true">hello, world</div> | ||
</div> | ||
<script src="../../resources/js-test-post.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters