Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / pasteboard / copy-backslash-with-euc.html
blobbb386caa1b883737beac10bf12971ccda0ca7ecb
1 <!DOCTYPE html>
2 <html>
4 <head>
5 <meta charset="UTF-8">
6 <script>
8 if (window.testRunner)
9 testRunner.dumpAsText();
11 // Select an element an return its value.
12 function selectElement(doc, element)
14 if (element.tagName.toLowerCase() == 'input') {
15 element.focus();
16 element.select();
17 return element.value;
18 } else {
19 doc.getSelection().selectAllChildren(element);
20 return element.innerText;
24 function testCopyAndPasteTexts(fromDocument, fromName, toDocument, toName)
26 var resultsElement = document.getElementById("results");
28 var pasteboardElement = toDocument.getElementById("pasteboard");
30 var fromElementNames = ["div", "transform", "secure", "control"];
31 for (var i = 0; i < fromElementNames.length; i++) {
32 var fromElementName = fromElementNames[i];
33 var fromElement = fromDocument.getElementById(fromElementName);
34 selectElement(fromDocument, fromElement);
35 fromDocument.execCommand("Copy");
37 var toElementNameSuffixes = ["text-control", "content-editable"];
38 for (var j = 0; j < toElementNameSuffixes.length; j++) {
39 var toElementNameSuffix = toElementNameSuffixes[j];
41 var testName = "from " + fromName.toUpperCase() + " " + fromElementName + " to " + toName.toUpperCase() + " " + toElementNameSuffix + ": ";
42 var toDescriptionText = toDocument.createTextNode(testName);
43 pasteboardElement.appendChild(toDescriptionText);
44 var toElement = null;
45 if (toElementNameSuffix == "text-control") {
46 toElement = toDocument.createElement("input");
47 toElement.value = "FAIL";
48 } else {
49 toElement = toDocument.createElement("span");
50 toElement.contentEditable = "true";
51 toElement.innerHTML = "FAIL";
53 pasteboardElement.appendChild(toElement);
54 pasteboardElement.appendChild(toDocument.createElement("br"));
56 selectElement(toDocument, toElement);
57 toDocument.execCommand("Paste");
58 var actualText = selectElement(toDocument, toElement);
60 var result = "PASS";
61 var expectedLeadingString = "\\\\ from ";
62 if (fromElementName == "secure")
63 expectedLeadingString = "•••••••";
64 else if (fromElementName == "transform")
65 expectedLeadingString = expectedLeadingString.toUpperCase();
66 if (actualText.search(expectedLeadingString) != 0)
67 result = "FAIL: the actual text was '" + actualText + "' (char code of the first character was " + actualText.charCodeAt(0) + ")";
69 resultsElement.innerHTML += testName + result + "<br>";
74 function test()
76 testCopyAndPasteTexts(frames[0].document, "euc", document, "utf8");
77 testCopyAndPasteTexts(document, "utf8", frames[0].document, "euc");
80 </script>
81 </head>
83 <body onload="test()">
85 <div>
86 <iframe src="resources/copy-backslash-euc.html" width="600" height="300"></iframe>
87 </div>
89 <h2>Original texts which will be copied</h2>
90 <div id="div">\ from UTF8 page</div>
91 <div id="transform" style="text-transform:uppercase">\ from UTF8 page (transformed)</div>
92 <div id="secure" style="-webkit-text-security:disc">\ from UTF8 page (secure)</div>
93 <input id="control" value="\ from UTF8 text control">
95 <h2>Texts in the EUC frame will be pasted here</h2>
96 <div id="pasteboard"></div>
98 <br>
100 <h2>Results</h2>
101 <p id="results">
102 </p>
104 </body>
106 </html>