9 testRunner
.dumpAsText();
11 // Select an element an return its value.
12 function selectElement(doc
, element
)
14 if (element
.tagName
.toLowerCase() == 'input') {
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
);
45 if (toElementNameSuffix
== "text-control") {
46 toElement
= toDocument
.createElement("input");
47 toElement
.value
= "FAIL";
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
);
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>";
76 testCopyAndPasteTexts(frames
[0].document
, "euc", document
, "utf8");
77 testCopyAndPasteTexts(document
, "utf8", frames
[0].document
, "euc");
83 <body onload=
"test()">
86 <iframe src=
"resources/copy-backslash-euc.html" width=
"600" height=
"300"></iframe>
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>