--- /dev/null
+If there are NULL characters in text nodes, they should not be copied to the clipboard. This test requires DumpRenderTree.
+| "
+"
+| <div>
+| id="outerSource"
+| <p>
+| <b>
+| "bold"
+| "
+ "
+| "
+ "
+| <p>
+| style="color: green"
+| "green"
+| "
+"
+| "
+"
+| <div>
+| contenteditable="true"
+| id="destination-rich-text"
+| <p>
+| <b>
+| "bold"
+| <div>
+| contenteditable="true"
+| id="source"
+| "Copy paste me"
+| <span>
+| class="Apple-style-span"
+| style="color: rgb(0, 128, 0); "
+| "green"
+| "Copy paste me"
+| "
+"
+| <textarea>
+| id="destination-plain-text"
+| this.value="Copy paste mebold
+
+Copy paste me
+green"
+| "
+"
+| <div>
+| id="results"
+| "PASSED"
+| "
+
+"
--- /dev/null
+<head>
+<script src="../../resources/dump-as-markup.js"></script>
+<script>
+Markup.description('If there are NULL characters in text nodes, they should not be copied to the clipboard. This test requires DumpRenderTree.');
+Markup.noAutoDump();
+
+function runTest()
+{
+ var sel = window.getSelection();
+
+ var source = document.getElementById("source");
+ var textWithNull = "Copy\0 paste me";
+ source.textContent = textWithNull;
+ sel.setPosition(source, 0);
+ document.execCommand("SelectAll");
+ document.execCommand("Copy");
+
+ var destinationRichText = document.getElementById("destination-rich-text");
+ sel.setPosition(destinationRichText, 0);
+ document.execCommand("Paste");
+
+ var destinationPlainText = document.getElementById("destination-plain-text");
+ destinationPlainText.focus();
+ document.execCommand("Paste");
+
+ var results = document.getElementById("results");
+ var expectedPlainTextValue = "Copy paste me";
+ if (expectedPlainTextValue != destinationPlainText.value) {
+ results.innerText = "Plain text field has the wrong value (expected " +
+ JSON.stringify(expectedPlainTextValue) + " but found " +
+ JSON.stringify(destinationPlainText.value) + ").";
+ return;
+ }
+
+ // Run the same test but include some richly formatted text.
+ var outerSource = document.getElementById("outerSource");
+ sel.setBaseAndExtent(outerSource, 0, destinationRichText, 0);
+ document.execCommand("Copy");
+
+ // Remove the source text so we don't end up with a null character in the
+ // expected output file.
+ source.parentNode.removeChild(source);
+
+ sel.setPosition(destinationRichText, 0);
+ document.execCommand("Paste");
+
+ destinationPlainText.focus();
+ document.execCommand("Paste");
+
+ var expectedPlainTextValue2 = "Copy paste mebold\n\nCopy paste me\ngreen";
+ if (expectedPlainTextValue2 != destinationPlainText.value) {
+ results.innerText = "Plain text field has the wrong value (expected " +
+ JSON.stringify(expectedPlainTextValue2) + " but found " +
+ JSON.stringify(destinationPlainText.value) + ").";
+ return;
+ }
+
+ results.innerText = "PASSED";
+
+ Markup.dump(document.body);
+ Markup.notifyDone();
+}
+</script>
+</head>
+
+<body onload="runTest()">
+<div id="outerSource"><p><b>bold</b></p>
+ <div id="source" contentEditable="true"></div>
+ <p style="color: green">green</p>
+</div>
+<div id="destination-rich-text" contentEditable="true"></div>
+<textarea id="destination-plain-text"></textarea>
+<div id="results">FAILED</div>
+</body>
+2011-01-14 Tony Chang <tony@chromium.org>
+
+ Reviewed by Alexey Proskuryakov.
+
+ Strip NUL character when copying text on Windows
+ https://bugs.webkit.org/show_bug.cgi?id=52236
+
+ Test: editing/pasteboard/copy-null-characters.html
+
+ * editing/Editor.cpp:
+ (WebCore::Editor::selectedText):
+ * platform/mac/PasteboardMac.mm:
+ (WebCore::Pasteboard::writeSelection): Use editor()->selectedText() which matches the other platforms.
+
2011-01-14 Yuzo Fujishima <yuzo@google.com>
Reviewed by Antti Koivisto.