Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / style / style-text-node-without-editable-parent.html
blobd2f4b5af6ccbc41a3893f35719e4566c61dc069c
1 <script src="../../resources/dump-as-markup.js"></script>
2 <body>
3 <div id="test"></div>
4 <script>
6 function appendNewSpan(title)
8 var div = document.getElementById('test');
9 if (div.innerHTML.length)
10 div.innerHTML += '<br>';
11 div.innerHTML += title + ' : <span contenteditable>hello, world WebKit</span>';
12 return div.lastChild;
15 function setSelection(text, start, end)
17 var range = document.createRange();
18 var selection = window.getSelection();
20 range.setStart(text, start);
21 range.setEnd(text, end);
22 selection.removeAllRanges();
23 selection.addRange(range);
26 function dumpLastSpan(description) {
27 Markup.dump(document.getElementById('test').lastChild, description)
30 function applyInlineStyleToTextNode(command, value)
32 setSelection(appendNewSpan(command).firstChild, 0, 7);
33 document.execCommand(command, false, value);
34 dumpLastSpan(command + ' first');
36 setSelection(appendNewSpan(command).firstChild, 7, 12);
37 document.execCommand(command, false, value);
38 dumpLastSpan(command + ' middle');
40 setSelection(appendNewSpan(command).firstChild, 12, 19);
41 document.execCommand(command, false, value);
42 dumpLastSpan(command + ' last');
44 setSelection(appendNewSpan(command).firstChild, 0, 19);
45 document.execCommand(command, false, value);
46 dumpLastSpan(command + ' all');
49 Markup.description("This tests applying inline style to a text node, which is a child of the editable root. Style should be applied properly and the test should not crash. (See the bug 39989).")
50 applyInlineStyleToTextNode('bold');
51 applyInlineStyleToTextNode('italic');
52 applyInlineStyleToTextNode('underline');
53 applyInlineStyleToTextNode('strikeThrough');
54 applyInlineStyleToTextNode('foreColor', 'blue');
55 applyInlineStyleToTextNode('hiliteColor', 'blue');
56 applyInlineStyleToTextNode('subscript');
57 applyInlineStyleToTextNode('superscript');
58 applyInlineStyleToTextNode('createLink', 'http://webkit.org/');
60 </script>
61 </body>