2 function log(message
) {
3 var li
= document
.createElement("li");
4 li
.appendChild(document
.createTextNode(message
));
5 var console
= document
.getElementById("console");
6 console
.appendChild(li
);
9 function assert(func
, args
, expected
) {
10 var f
= func
+ '("' + args
+ '")';
12 if (result
!= expected
)
13 log('Failure: ' + f
+ ' was ' + result
+ ', expected: ' + expected
);
15 log('Success: ' + f
+ ' == ' + result
);
19 <input id=
"textfield" type=
"text" style=
"width: 600">
21 <div id=
"richcontent">This
<b>styled
<i>text
</i></b>, and
<a href=
"http://www.google.com"> link
</a> will be pasted into the textfield. All richness should be stripped.
</div>
22 <ol id=
"console"></ol>
24 if (window
.testRunner
)
25 window
.testRunner
.waitUntilDone();
27 var richcontent
= document
.getElementById("richcontent");
28 var s
= window
.getSelection();
29 s
.setBaseAndExtent(richcontent
, 0, richcontent
, richcontent
.childNodes
.length
);
30 assert("document.execCommand", "Copy", true);
32 var e
= document
.getElementById("textfield");
34 e
.setSelectionRange(0, 0);
36 window
.setTimeout(paste
, 500);
38 assert("document.execCommand", "Paste", true);
39 if (window
.testRunner
)
40 window
.testRunner
.notifyDone();