OLD | NEW |
1 <div id="test">This test verifies that we can get text/html from the clipboard | 1 <div id="test">This test verifies that we can get text/html from the clipboard |
2 during an onpaste event. This test requires DRT.</div> | 2 during an onpaste event. This test requires DRT.</div> |
3 | 3 |
4 <div id="target" contenteditable onpaste="paste(event)"> | 4 <div id="target" contenteditable onpaste="paste(event)"> |
5 Paste content in this div. | 5 Paste content in this div. |
6 </div> | 6 </div> |
7 <div id="results">FAIL</div> | 7 <div id="results">FAIL</div> |
8 | 8 |
9 <script src="../editing.js"></script> | 9 <script src="../editing.js"></script> |
10 <script> | 10 <script> |
11 var undefined; | 11 var undefined; |
12 function removeFontName(text) | 12 function removeFontName(text) |
13 { | 13 { |
14 if (!text) | 14 if (!text) |
15 return text; | 15 return text; |
16 return text.replace(/font-family: [^;]+;\s*/g, ""); | 16 return text.replace(/font-family: .+?; /g, ""); |
17 } | 17 } |
18 | 18 |
19 function paste(ev) | 19 function paste(ev) |
20 { | 20 { |
21 console.log("text/plain: " + ev.clipboardData.getData("text/plain")); | 21 console.log("text/plain: " + ev.clipboardData.getData("text/plain")); |
22 // Remove the font name because it varies depending on the platform. | 22 // Remove the font name because it varies depending on the platform. |
23 console.log("text/html: " + removeFontName(ev.clipboardData.getData("text/ht
ml"))); | 23 console.log("text/html: " + removeFontName(ev.clipboardData.getData("text/ht
ml"))); |
24 if (ev.clipboardData.getData("text/html") != undefined) | 24 if (ev.clipboardData.getData("text/html") != undefined) |
25 document.getElementById("results").innerHTML = "PASS"; | 25 document.getElementById("results").innerHTML = "PASS"; |
26 } | 26 } |
27 | 27 |
28 function editingTest() | 28 function editingTest() |
29 { | 29 { |
30 var selection = window.getSelection(); | 30 var selection = window.getSelection(); |
31 selection.modify("extend", "forward", "sentence"); | 31 selection.modify("extend", "forward", "sentence"); |
32 copyCommand(); | 32 copyCommand(); |
33 | 33 |
34 var elem = document.getElementById("target"); | 34 var elem = document.getElementById("target"); |
35 selection.collapse(elem, 0); | 35 selection.collapse(elem, 0); |
36 selection.modify("move", "forward", "sentence"); | 36 selection.modify("move", "forward", "sentence"); |
37 pasteCommand(); | 37 pasteCommand(); |
38 } | 38 } |
39 | 39 |
40 runDumpAsTextEditingTest(false); | 40 runDumpAsTextEditingTest(false); |
41 </script> | 41 </script> |
OLD | NEW |