Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <p>This tests that edited whitespaces aren't all nbsps. When the region becomes non-editable, Hello and World should still be on different lines. This demonst rates a bug: the div's focus halo doesn't go away when it becomes non-editable.< /p> | 1 <!doctype html> |
| 2 <div id="div" contenteditable="true" style="border: 1px solid black; width: 60px ;"></div> | 2 <script src="../../resources/testharness.js"></script> |
| 3 <ol id="console"></ol> | 3 <script src="../../resources/testharnessreport.js"></script> |
| 4 <script src="../assert_selection.js"></script> | |
| 4 <script> | 5 <script> |
| 5 function log(str) { | 6 test(() => assert_selection( |
| 6 var li = document.createElement("li"); | 7 '<div contenteditable style="border: 1px solid black; width: 60px;">|</div>', |
|
yoichio
2017/06/14 05:57:10
Is this style needed?
yosin_UTC9
2017/06/14 06:26:49
No, this style doesn't affect test result.
Removed
| |
| 7 li.appendChild(document.createTextNode(str)); | 8 selection => { |
| 8 var console = document.getElementById("console"); | 9 selection.document.execCommand('InsertText', false, ' '); |
| 9 console.appendChild(li); | 10 selection.document.execCommand('InsertText', false, 'Hello'); |
| 10 } | 11 selection.document.execCommand('InsertText', false, ' '); |
| 11 | 12 selection.document.execCommand('InsertText', false, ' '); |
| 12 if (window.testRunner) | 13 selection.document.execCommand('InsertText', false, ' '); |
| 13 testRunner.waitUntilDone(); | 14 selection.document.execCommand('InsertText', false, ' '); |
| 14 | 15 selection.document.execCommand('InsertText', false, ' '); |
| 15 var div = document.getElementById("div"); | 16 selection.document.execCommand('InsertText', false, 'World'); |
| 16 var sel = window.getSelection(); | 17 selection.document.execCommand('InsertText', false, ' '); |
| 17 sel.collapse(div, 0); | 18 }, |
| 18 document.execCommand("InsertText", false, " "); | 19 [ |
| 19 document.execCommand("InsertText", false, "Hello"); | 20 '<div contenteditable style="border: 1px solid black; width: 60px;">', |
| 20 document.execCommand("InsertText", false, " "); | 21 '\u00A0Hello \u00A0 \u00A0 World\u00A0', |
| 21 document.execCommand("InsertText", false, " "); | 22 '|</div>', |
| 22 document.execCommand("InsertText", false, " "); | 23 ].join('')), |
| 23 document.execCommand("InsertText", false, " "); | 24 'insert " Hello World " with extra whitespaces'); |
| 24 document.execCommand("InsertText", false, " "); | |
| 25 document.execCommand("InsertText", false, "World"); | |
| 26 document.execCommand("InsertText", false, " "); | |
| 27 | |
| 28 var innerText = div.innerHTML; | |
| 29 | |
| 30 // Check the pattern produced. This might change in the future. | |
| 31 var expected = " Hello World "; | |
| 32 var nbsp = false; | |
| 33 for (var i = 0; i < innerText.length; i++) { | |
| 34 if(innerText[i] != expected[i]) | |
| 35 log("Error: Character " + i + " of the editable region was not what was e xpected."); | |
| 36 } | |
| 37 | |
| 38 div.contentEditable = "false"; | |
| 39 // When we turn content editability off, we'll see Hello and World on the same l ine if editing is using all nbsps. | |
| 40 | |
| 41 // Ensure we push a final frame to avoid flake. | |
| 42 if (window.testRunner) { | |
| 43 window.requestAnimationFrame(function() { | |
| 44 testRunner.notifyDone(); | |
| 45 }); | |
| 46 } | |
| 47 </script> | 25 </script> |
| OLD | NEW |