130afb1c0b07dff09a132b25e851fff89edb8063
[WebKit-https.git] / LayoutTests / editing / pasteboard / select-element-1.html
1 <script>
2 function log(str) {
3     var li = document.createElement("li");
4     li.appendChild(document.createTextNode(str));
5     var console = document.getElementById("console");
6     console.appendChild(li);
7 }
8 function shouldBe(expected, actual) {
9     if (expected != actual)
10         log("Failure. Expected: " + expected + ", Actual: " + actual);
11     else
12         log("Passed");
13 }
14 </script>
15 <p>This tests copy/paste of select elements.  All the options should be included.</p>
16 <div id="copy" contenteditable="true">
17     <select id="select">
18         <option>One</option>
19         <option>Two</option>
20         <option>Three</option>
21     </select>
22 </div>
23
24 <div id="paste" contenteditable="true"></div>
25 <ul id="console"></ul>
26 <script>
27 var copy = document.getElementById("copy");
28 copy.focus();
29 document.execCommand("SelectAll");
30 document.execCommand("Cut");
31
32 shouldBe(document.getElementById("select"), null);
33
34 var paste = document.getElementById("paste");
35 paste.focus();
36 document.execCommand("Paste");
37
38 var select = document.getElementById("select");
39 shouldBe(select.options[0].value, "One");
40 shouldBe(select.options[1].value, "Two");
41 shouldBe(select.options[2].value, "Three");
42 </script>