3 <script src=../editing.js language="JavaScript" type="text/JavaScript"></script>
5 function log(message) {
6 var console = document.getElementById("console");
7 var li = document.createElement("li");
8 var text = document.createTextNode(message);
10 console.appendChild(li);
13 function editingTest() {
15 var s = window.getSelection();
18 if (window.layoutTestController)
19 window.layoutTestController.dumpAsText();
21 // Fully select the line in the first div.
22 d = document.getElementById("test1");
24 extendSelectionForwardByLineCommand();
29 // Select the second word in the second div
30 d = document.getElementById("test2");
32 moveSelectionForwardByWordCommand();
33 extendSelectionForwardByWordCommand();
38 // Select part of a link (and a bit of trailing non-linked text)
39 d = document.getElementById("test3");
40 var e = document.getElementById("test3start");
42 extendSelectionForwardByLineCommand();
47 // Link an editable region containing lists, tables, images, etc.
48 d = document.getElementById("test4");
51 createLinkCommand("http://www.google.com/");
52 // Now unlink a portion of it
53 var end = document.getElementById("test4end");
54 s.setBaseAndExtent(d, 0, end, 0);
63 <body style="font-size: 12px;">
64 <p>This is a test of execCommand("Unlink"). It tests:</p>
66 <li>Completely unlinking a link.</li>
67 <li>Unlinking a single word inside of a link.</li>
68 <li>Unlinking a selection containing linked and unlinked text.</li>
69 <li>Unlinking a selection that partially selects a linked table.</li>
71 <p>The editable regions below describe what their content should be after the test.</p>
73 <li><div id="test1" contenteditable="true"><a href="http://www.apple.com/">This paragraph should should end up unlinked.</a></div></li>
74 <li><div id="test2" contenteditable="true"><a href="http://www.apple.com/">The second word in this paragraph should end up being unlinked, everything else should be a link.</a></div></li>
75 <li><div id="test3" contenteditable="true">This paragraph starts with <a href="http://www.google.com"><i>a</i><span id="test3start"> link</span></a> in the middle. Only the 'a' in the previous sentence should be linked after the test.</div></li>
76 <li><div id="test4" contenteditable="true">
77 <p>This <i>editable region</i> contains lists, tables, styled text, and images. Everything in this region that is not selected should be a link, nothing that is selected should be a link.</p>
82 <table border=1><tr><td>1</td><td>2</td><td><span id="test4end">3</span></td></tr></table>
84 This <b>line</b> contains <img src="../resources/abe.png"> an image.
87 <p>The innerHTML of editable regions after the test:</p>
88 <ol id="console"></ol>