| var element = document.getElementById("test"); |
| window.getSelection().setPosition(element.firstChild, 0); |
| window.getSelection().modify('extend', 'forward', 'word'); |
| window.getSelection().modify('extend', 'forward', 'word'); |
| window.getSelection().modify('extend', 'forward', 'word'); |
| document.execCommand("Cut"); |
| document.body.style.backgroundColor = "white"; |
| document.execCommand("Paste"); |
| document.body.innerText = document.body.innerHTML; |
| <body onLoad="runTest();" contentEditable="true" style="background-color: #bbb;"> |
| This test verifies that WebKit does not erroneously clone nodes hierarchy when copying text with background color. |
| To manually this test, select the text inside the div with the border, cut and paste it back. You should not see an additional red border. |
| <div style="border: 2px solid red"> |
| <div id="test">Select this text</div> |