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
.testRunner
)
19 window
.testRunner
.dumpAsText();
21 // Fully select the line in the first div.
22 d
= document
.getElementById("test1");
24 extendSelectionForwardByLineCommand();
25 createLinkCommand("http://www.google.com/");
29 // Partially select the line in the second div.
30 d
= document
.getElementById("test2");
32 moveSelectionForwardByWordCommand();
33 extendSelectionForwardByWordCommand();
34 createLinkCommand("http://www.google.com/");
38 // Partially select the link in the third div
39 var e
= document
.getElementById("starthere");
41 extendSelectionForwardByLineCommand();
42 createLinkCommand("http://www.google.com/");
46 // Select all the content in the fourth div
47 d
= document
.getElementById("test4");
50 createLinkCommand("http://www.google.com/");
58 <body style=
"font-size: 12px;">
59 <p>This is a test of execCommand(CreateLink, ...). It tests:
</p>
61 <li>Creating a link from a selection that is completely unlinked.
</li>
62 <li>Creating a link from a selection that is inside an existing link.
</li>
63 <li>Creating a link from a selection that is partially linked.
</li>
64 <li>Creating a link from a selection that contains lists, tables, styled text, and images.
</li>
67 <li><div id=
"test1" contenteditable=
"true">This paragraph starts unlinked. The entire paragraph should end up being a link to google.com.
</div></li>
68 <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>
69 <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>
70 <li><div id=
"test4" contenteditable=
"true">
71 <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>
76 <table border=
1><tr><td>1</td><td>2</td><td>3</td></tr></table>
78 This
<b>line
</b> contains
<img src=
"../resources/abe.png"> an image.
81 <p>innerHTML of editable regions after the test:
</p>
82 <ol id=
"console"></ol>