blob: 3325e59c1ef4ebc78e2835025d3ee4cf4cf44fa6 [file] [log] [blame]
justingf6acc032006-03-25 10:17:39 +00001<html>
2<head>
3<script src=../editing.js language="JavaScript" type="text/JavaScript"></script>
4<script>
5function log(message) {
6 var console = document.getElementById("console");
7 var li = document.createElement("li");
8 var text = document.createTextNode(message);
9 li.appendChild(text);
10 console.appendChild(li);
11}
12
13function editingTest() {
14
15 var s = window.getSelection();
16 var d;
17
rniwa@webkit.org14f6b5b2012-06-13 08:51:53 +000018 if (window.testRunner)
19 window.testRunner.dumpAsText();
justingf6acc032006-03-25 10:17:39 +000020
21 // Fully select the line in the first div.
22 d = document.getElementById("test1");
23 s.setPosition(d, 0);
24 extendSelectionForwardByLineCommand();
25 unlinkCommand();
26
27 log(d.innerHTML);
28
29 // Select the second word in the second div
30 d = document.getElementById("test2");
31 s.setPosition(d, 0);
32 moveSelectionForwardByWordCommand();
33 extendSelectionForwardByWordCommand();
34 unlinkCommand();
35
36 log(d.innerHTML);
37
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");
41 s.setPosition(e, 0);
42 extendSelectionForwardByLineCommand();
43 unlinkCommand();
44
45 log(d.innerHTML);
46
47 // Link an editable region containing lists, tables, images, etc.
48 d = document.getElementById("test4");
49 s.setPosition(d, 0);
50 selectAllCommand();
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);
55 unlinkCommand();
56
57 log(d.innerHTML);
58
59}
60</script>
61</head>
62
63<body style="font-size: 12px;">
64<p>This is a test of execCommand("Unlink"). It tests:</p>
65<ol>
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>
70</ol>
71<p>The editable regions below describe what their content should be after the test.</p>
72<ol>
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>
78<ul>
79<li>Item 1</li>
80<li>Item 2</li>
81</ul>
82<table border=1><tr><td>1</td><td>2</td><td><span id="test4end">3</span></td></tr></table>
83<br>
bdash62f43e02007-04-20 02:08:01 +000084This <b>line</b> contains <img src="../resources/abe.png"> an image.
justingf6acc032006-03-25 10:17:39 +000085</div></li>
86</ol>
87<p>The innerHTML of editable regions after the test:</p>
88<ol id="console"></ol>
89<script>
90runEditingTest();
91</script>
92</body>
93
rniwa@webkit.org14f6b5b2012-06-13 08:51:53 +000094</html>