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>
if (window.testRunner) {
testRunner.dumpEditingCallbacks();
testRunner.dumpAsText();
}
test(() => assert_selection(
[
'<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) {
var console = document.getElementById("console");
var text = document.createTextNode(message);
console.appendChild(text);
}
test(() => assert_selection(
[
'<div contenteditable>',
'<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>
<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">
<ol style="border: 1px solid red;">
<li>foo</li>
<span id="item1">This should not be a list.</span>
<br><br>
bar
<li>baz</li>
<span id="item2">This should not be in a list.</span>
<li>foo</li>
<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>
test(() => assert_selection(
[
'<div contenteditable>',
'<ol>',
'<li>|item1</li>',
'</ol>',
'</div>',
].join(''),
'InsertOrderedList',
'<div contenteditable>|item1</div>'),
'3 insertOrderedList on text inside LI -> remove list');
<script>
var s = window.getSelection();
s.collapse(document.getElementById("item1"), 0);
document.execCommand("InsertOrderedList", false, "");
s.collapse(document.getElementById("item2"), 0);
document.execCommand("InsertOrderedList", false, "");
s.collapse(document.getElementById("item3"), 0);
document.execCommand("InsertOrderedList", false, "");
s.collapse(document.getElementById("item4"), 0);
document.execCommand("InsertUnorderedList", false, "");
s.collapse(document.getElementById("item5"), 0);
document.execCommand("InsertUnorderedList", false, "");
test(() => assert_selection(
[
'<div contenteditable>',
'<li>|item1</li>',
'</div>',
].join(''),
'InsertOrderedList',
[
'<div contenteditable>',
'<ol>',
'<li>|item1</li>',
'</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>
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