Commit 779983c1 authored by yosin's avatar yosin Committed by Commit bot

Convert editing/execCommand/remove-list-items.html to use w3c test harness

This patch converts "editing/execCommand/remove-list-items.html" to use w3c test
harness to simplify test script for improving code health.

BUG=n/a
TEST=n/a; no behavior changes

Review-Url: https://codereview.chromium.org/2337333003
Cr-Commit-Position: refs/heads/master@{#418521}
parent 48ec0aa3
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
This test checks to see that Insert{Un}OrderedList can remove items from a list, can remove empty list when they are emptied, and can remove content from orphaned list items.
foo
This should not be a list. 
bar
baz
This should not be in a list.
foo
This should not be in a list.
bar
This should not be in a list.
This should not be in a list.
<ol style="border: 1px solid red;"> <li>foo</li> </ol><span id="item1">This should not be a list.</span>&nbsp;<br><ol style="border: 1px solid red;"><br> bar <li>baz</li> </ol>This should not be in a list.<br><ol style="border: 1px solid red;"><li>foo</li> </ol>This should not be in a list.<br><ol style="border: 1px solid red;"> <li>bar</li> </ol> This should not be in a list.<br>This should not be in a list.
<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script> <script>
if (window.testRunner) { test(() => assert_selection(
testRunner.dumpEditingCallbacks(); [
testRunner.dumpAsText(); '<div contenteditable>',
} '<ol>',
'<li>item1</li>',
'|one<br>',
'<br>',
'one-1',
'<li>item2</li>',
'two',
'</ol>',
'</div>',
].join(''),
'InsertOrderedList',
[
'<div contenteditable>',
'<ol>',
'<li>item1</li>',
'</ol>',
'|one<br>',
'<ol>',
'<br>',
'one-1',
'<li>item2</li>',
'two',
'</ol>',
'</div>',
].join('')),
'1 insertOrderedList on text outside LI with BR');
function log(message) { test(() => assert_selection(
var console = document.getElementById("console"); [
var text = document.createTextNode(message); '<div contenteditable>',
console.appendChild(text); '<ol>',
} '<li>item2</li>',
'|two',
'</ol>',
'</div>',
].join(''),
'InsertOrderedList',
[
'<div contenteditable>',
'<ol>',
'<li>item2</li>',
'</ol>',
'|two',
'</div>',
].join('')),
'2 insertOrderedList on text outside LI');
</script> test(() => assert_selection(
<p>This test checks to see that Insert{Un}OrderedList can remove items from a list, can remove empty list when they are emptied, and can remove content from orphaned list items.</p> [
<div id="div" contenteditable="true"> '<div contenteditable>',
<ol style="border: 1px solid red;"> '<ol>',
<li>foo</li> '<li>|item1</li>',
<span id="item1">This should not be a list.</span> '</ol>',
<br><br> '</div>',
bar ].join(''),
<li>baz</li> 'InsertOrderedList',
<span id="item2">This should not be in a list.</span> '<div contenteditable>|item1</div>'),
<li>foo</li> '3 insertOrderedList on text inside LI -> remove list');
<li><span id="item3">This should not be in a list.</span></li>
<li>bar</li>
</ol>
<li><span id="item4">This should not be in a list.</span></li>
<ul><li><span id="item5">This should not be in a list.</span></li></ul>
</div>
<p id="console"></p>
<script> test(() => assert_selection(
var s = window.getSelection(); [
s.collapse(document.getElementById("item1"), 0); '<div contenteditable>',
document.execCommand("InsertOrderedList", false, ""); '<li>|item1</li>',
s.collapse(document.getElementById("item2"), 0); '</div>',
document.execCommand("InsertOrderedList", false, ""); ].join(''),
s.collapse(document.getElementById("item3"), 0); 'InsertOrderedList',
document.execCommand("InsertOrderedList", false, ""); [
s.collapse(document.getElementById("item4"), 0); '<div contenteditable>',
document.execCommand("InsertUnorderedList", false, ""); '<ol>',
s.collapse(document.getElementById("item5"), 0); '<li>|item1</li>',
document.execCommand("InsertUnorderedList", false, ""); '</ol>',
'</div>',
].join('')),
'4-1 insertOrderedList on LI outside list -> listify');
test(() => assert_selection(
[
'<div contenteditable>',
'<li>|item1</li>',
'</div>',
].join(''),
'InsertUnorderedList',
[
'<div contenteditable>',
'|item1',
'</div>',
].join('')),
'4-2 insertUnorderedList on LI outside list -> unlistify');
log(div.innerHTML); test(() => assert_selection(
[
'<div contenteditable>',
'<ul>',
'<li>|item1</li>',
'</ul>',
'</div>',
].join(''),
'InsertOrderedList',
[
'<div contenteditable>',
'<ol>',
'<li>|item1</li>',
'</ol>',
'</div>',
].join('')),
'5-1 insertOrderedList on LI in UL -> switch list type');
test(() => assert_selection(
[
'<div contenteditable>',
'<ul>',
'<li>|item1</li>',
'</ul>',
'</div>',
].join(''),
'InsertUnorderedList',
[
'<div contenteditable>',
'|item1',
'</div>',
].join('')),
'5-2 insertUnrderedList on LI in UL -> unlistify');
</script> </script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment