Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / selection / move-paragraph-document-edges.html
blob872e81f10e55b2b93fcccddb3a16a09ce7c97722
1 <html>
2 <head>
3 <script>
4 function nodeAsString(node)
6 if (node && node.nodeType == Node.TEXT_NODE)
7 return "text in " + nodeAsString(node.parentNode);
8 if (node && node.nodeType == Node.ELEMENT_NODE) {
9 var id;
10 if (id = node.getAttribute("id"))
11 return id;
13 return node;
15 function selectionAsString()
17 return "(" + nodeAsString(getSelection().anchorNode)
18 + ", " + getSelection().anchorOffset
19 + "), (" + nodeAsString(getSelection().focusNode)
20 + ", " + getSelection().focusOffset + ")";
22 function checkSelection(step, expected)
24 if (selectionAsString() !== expected) {
25 document.getElementById("result").innerHTML = "FAIL: After step " + step + " selection was " + selectionAsString();
26 return true;
28 return false;
30 function runTest()
32 if (window.testRunner)
33 testRunner.dumpAsText();
34 getSelection().collapse(document.getElementById("first").firstChild, 4);
35 if (checkSelection(1, "(text in first, 4), (text in first, 4)"))
36 return;
37 getSelection().modify("extend", "backward", "line");
38 if (checkSelection(2, "(text in first, 4), (text in first, 0)"))
39 return;
40 getSelection().collapse(document.getElementById("last").firstChild, 4);
41 if (checkSelection(3, "(text in last, 4), (text in last, 4)"))
42 return;
43 getSelection().modify("extend", "forward", "line");
44 if (checkSelection(4, "(text in last, 4), (text in last, 61)"))
45 return;
46 getSelection().collapse(document.getElementById("first").firstChild, 4);
47 if (checkSelection(5, "(text in first, 4), (text in first, 4)"))
48 return;
49 getSelection().modify("extend", "backward", "paragraph");
50 if (checkSelection(6, "(text in first, 4), (text in first, 0)"))
51 return;
52 getSelection().collapse(document.getElementById("last").firstChild, 4);
53 if (checkSelection(7, "(text in last, 4), (text in last, 4)"))
54 return;
55 getSelection().modify("extend", "forward", "paragraph");
56 if (checkSelection(8, "(text in last, 4), (text in last, 61)"))
57 return;
58 document.getElementById("result").innerHTML = "SUCCESS";
60 </script>
61 </head>
62 <body onload="runTest()"><p id="first">This is the first paragraph, used for the moving-backward test.</p>
63 <p>This tests for a problem with selections at document edges.</p>
64 <p id="result">TEST HAS NOT YET RUN.</p>
65 <p id="last">This is the last paragraph, used for the moving-forward test.</p>
66 </body>
67 </html>