Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/editing/execCommand/script-tests/insert-list-items-inside-another-list.js |
| diff --git a/third_party/WebKit/LayoutTests/editing/execCommand/script-tests/insert-list-items-inside-another-list.js b/third_party/WebKit/LayoutTests/editing/execCommand/script-tests/insert-list-items-inside-another-list.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ea2a228417fd4d54cf4bec185e6cd03527b7ca0b |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/editing/execCommand/script-tests/insert-list-items-inside-another-list.js |
| @@ -0,0 +1,36 @@ |
| +description("Test to make sure inserting an ordered/unordered list inside another list works") |
|
yosin_UTC9
2017/03/21 05:37:20
Please use assert_selection() which is implemented
jfernandez
2017/03/24 01:57:55
Done.
|
| + |
| +var testContainer = document.createElement("div"); |
| +testContainer.contentEditable = true; |
| +document.body.appendChild(testContainer); |
| + |
| +function testList(toggleCommand, initialContents, expectedContents, id1, id2 = id1) |
| +{ |
| + testContainer.innerHTML = initialContents; |
| + window.getSelection().collapse(document.getElementById(id1), 0); |
| + window.getSelection().extend(document.getElementById(id2), 1); |
| + document.execCommand(toggleCommand, false, null); |
| + if (testContainer.innerHTML === expectedContents) { |
| + testPassed(initialContents + "\n got:" + expectedContents+"\n"); |
| + } else { |
| + testFailed(initialContents + "\n got:" + testContainer.innerHTML + "\nexp.:" + expectedContents+"\n"); |
| + } |
| +} |
| + |
| +debug('Select 1 node\n'); |
| +testList("InsertOrderedList", '<ul><li id="first">hello</li><li>world</li><li>WebKit</li></ul>', '<ol><li>hello</li></ol><ul><li>world</li><li>WebKit</li></ul>', "first"); |
| +testList("InsertOrderedList", '<ul><li>hello</li><li id="first">world</li><li>WebKit</li></ul>', '<ul><li>hello</li></ul><ol><li>world</li></ol><ul><li>WebKit</li></ul>', "first"); |
| +testList("InsertOrderedList", '<ul><li>hello</li><li>world</li><li id="first">WebKit</li></ul>', '<ul><li>hello</li><li>world</li></ul><ol><li>WebKit</li></ol>', "first"); |
| +testList("InsertUnorderedList", '<ol><li id="first">hello</li><li>world</li><li>WebKit</li></ol>', '<ul><li>hello</li></ul><ol><li>world</li><li>WebKit</li></ol>', "first"); |
| +testList("InsertUnorderedList", '<ol><li>hello</li><li id="first">world</li><li>WebKit</li></ol>', '<ol><li>hello</li></ol><ul><li>world</li></ul><ol><li>WebKit</li></ol>', "first"); |
| +testList("InsertUnorderedList", '<ol><li>hello</li><li>world</li><li id="first">WebKit</li></ol>', '<ol><li>hello</li><li>world</li></ol><ul><li>WebKit</li></ul>', "first"); |
| + |
| +debug('Select 2 nodes \n'); |
| +testList("InsertOrderedList", '<ul><li id="first">hello</li><li id="second">world</li><li>WebKit</li></ul>', '<ol><li>hello</li><li>world</li></ol><ul><li>WebKit</li></ul>', "first", "second"); |
| +testList("InsertOrderedList", '<ul><li>hello</li><li id="first">world</li><li id="second">WebKit</li></ul>', '<ul><li>hello</li></ul><ol><li>world</li><li id="second">WebKit</li></ol>', "first", "second"); |
| +testList("InsertUnorderedList", '<ol><li id="first">hello</li><li id="second">world</li><li>WebKit</li></ol>', '<ul><li>hello</li><li>world</li></ul><ol><li>WebKit</li></ol>', "first", "second"); |
| +testList("InsertUnorderedList", '<ol><li>hello</li><li id="first">world</li><li id="second">WebKit</li></ol>', '<ol><li>hello</li></ol><ul><li>world</li><li id="second">WebKit</li></ul>', "first", "second"); |
| + |
| +document.body.removeChild(testContainer); |
| + |
| +var successfullyParsed = true; |