Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Unified Diff: third_party/WebKit/LayoutTests/editing/execCommand/createLink.html

Issue 2013603004: Introduce assert_selection() for editing tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-05-26T19:25:56 Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/editing/execCommand/createLink.html
diff --git a/third_party/WebKit/LayoutTests/editing/execCommand/createLink.html b/third_party/WebKit/LayoutTests/editing/execCommand/createLink.html
index e19137c28015838e67468b11d82619d8838cc8a7..44e54443893774fdfa1c5ba70be6e546338af673 100644
--- a/third_party/WebKit/LayoutTests/editing/execCommand/createLink.html
+++ b/third_party/WebKit/LayoutTests/editing/execCommand/createLink.html
@@ -1,88 +1,51 @@
-<html>
-<head>
-<script src=../editing.js language="JavaScript" type="text/JavaScript"></script>
+<!doctype html>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script src="../assert_selection.js"></script>
+<div id="log"></div>
<script>
-function log(message) {
- var console = document.getElementById("console");
- var li = document.createElement("li");
- var text = document.createTextNode(message);
- li.appendChild(text);
- console.appendChild(li);
-}
+test(() => {
+ assert_selection(
+ '<div contenteditable>|0123456789</div>',
+ 'createLink abc',
+ '<div contenteditable><a href="abc">^abc|</a>0123456789</div>',
+ 'Anchor text is an URI');
-function editingTest() {
-
- var s = window.getSelection();
- var d;
-
- if (window.testRunner)
- window.testRunner.dumpAsText();
-
- // Fully select the line in the first div.
- d = document.getElementById("test1");
- s.collapse(d, 0);
- extendSelectionForwardByLineCommand();
- createLinkCommand("http://www.google.com/");
-
- log(d.innerHTML);
+ assert_selection(
+ '<div contenteditable>^0123456789|</div>',
+ 'createLink abc',
+ '<div contenteditable><a href="abc">^0123456789|</a></div>',
+ 'Fully select the line');
- // Partially select the line in the second div.
- d = document.getElementById("test2");
- s.collapse(d, 0);
- moveSelectionForwardByWordCommand();
- extendSelectionForwardByWordCommand();
- createLinkCommand("http://www.google.com/");
-
- log(d.innerHTML);
-
- // Partially select the link in the third div
- var e = document.getElementById("starthere");
- s.collapse(e, 0);
- extendSelectionForwardByLineCommand();
- createLinkCommand("http://www.google.com/");
+ assert_selection(
+ '<div contenteditable>012^345|6789</div>',
+ 'createLink abc',
+ '<div contenteditable>012<a href="abc">^345|</a>6789</div>',
+ 'Partially select the line');
- log(d.innerHTML);
-
- // Select all the content in the fourth div
- d = document.getElementById("test4");
- s.collapse(d, 0);
- selectAllCommand();
- createLinkCommand("http://www.google.com/");
-
- log(d.innerHTML);
-
-}
-</script>
-</head>
+ assert_selection(
+ '<div contenteditable><a href="abc">012^345|6789</a></div>',
+ 'createLink xyz',
+ '<div contenteditable><a href="abc">012</a><a href="xyz">^345|</a><a href="abc">6789</a></div>',
+ 'Partially select the link');
-<body style="font-size: 12px;">
-<p>This is a test of execCommand(CreateLink, ...). It tests:</p>
-<ol>
-<li>Creating a link from a selection that is completely unlinked.</li>
-<li>Creating a link from a selection that is inside an existing link.</li>
-<li>Creating a link from a selection that is partially linked.</li>
-<li>Creating a link from a selection that contains lists, tables, styled text, and images.</li>
-</ol>
-<ol>
-<li><div id="test1" contenteditable="true">This paragraph starts unlinked. The entire paragraph should end up being a link to google.com.</div></li>
-<li><div id="test2" contenteditable="true"><a href="http://www.apple.com/">This paragraph starts out as a link to apple.com. The second word in the paragraph should end up being a link to google.com.</a></div></li>
-<li><div id="test3" contenteditable="true">This line starts out with <a href="http://www.apple.com"><b>a</b><span id="starthere"> link</span></a> in the middle. The second half of this paragraph, starting after the bold 'a' should end up being a link to google.com.</div></li>
-<li><div id="test4" contenteditable="true">
-<p>This <i>editable region</i> contains lists, tables, styled text, and images. The entire region should end up being a link to google.com.</p>
-<ul>
-<li>Item 1</li>
-<li>Item 2</li>
-</ul>
-<table border=1><tr><td>1</td><td>2</td><td>3</td></tr></table>
-<br>
-This <b>line</b> contains <img src="../resources/abe.png"> an image.
-</div></li>
-</ol>
-<p>innerHTML of editable regions after the test:</p>
-<ol id="console"></ol>
-<script>
-runEditingTest();
-</script>
-</body>
+ assert_selection(
+ '<div contenteditable>^012<ul><li>item1</li><li>item2</li></ul>345|</div>',
+ 'createLink abc',
+ '<div contenteditable><a href="abc">^012</a><ul><li><a href="abc">item1</a></li><li><a href="abc">item2</a></li></ul><a href="abc">345|</a></div>',
+ 'Selection whole list');
-</html>
+ assert_selection(
+ '<div contenteditable>^foo <img src="../resources/abe.png"> bar|</div>',
+ 'createLink abc',
+ '<div contenteditable><a href="abc">^foo <img src="../resources/abe.png"> bar|</a></div>',
+ 'Line contains an image');
+
+ assert_selection(
+ '<div contenteditable>^012<table><tr><td>item1</td><td>item2</td></tr></table>345|</div>',
+ 'createLink abc',
+ '<div contenteditable><a href="abc">^012</a><table><tbody><tr><td><a href="abc">item1</a></td><td><a href="abc">item2</a></td></tr></tbody></table><a href="abc">345|</a></div>',
+ 'Selection whole table');
+
+});
+</script>

Powered by Google App Engine
This is Rietveld 408576698