2 This is the paragraph before.
5 This paragraph contains an <ruby id="ruby">annotated <rt id="rt">annotation</rt></ruby> word.
8 This is the paragraph after.
13 if (window.testRunner)
14 testRunner.dumpAsText();
18 document.getElementById("console").appendChild(document.createTextNode(message + "\n"));
21 function positionAsString(node, offset)
23 if (node.nodeType === Node.TEXT_NODE)
24 return "\"" + node.data.trim() + "\"[" + offset + "]";
25 return node.tagName + "[" + offset + "]";
28 function testMovementToEndOfParagraph(node, offset)
30 var selection = getSelection();
32 selection.collapse(node, offset);
33 selection.modify("move", "forward", "paragraphBoundary");
34 if (selection.baseNode === paragraph.lastChild && selection.baseOffset === 6)
35 log("PASS: Reached the end of the paragraph starting from " + positionAsString(node, offset) + ".");
37 log("FAIL: Reached " + positionAsString(selection.baseNode, selection.baseOffset) + " instead "
38 + "of the end of the paragraph starting from " + positionAsString(node, offset) + ".");
41 function testMovementToStartOfParagraph(node, offset)
43 var selection = getSelection();
45 selection.collapse(node, offset);
46 selection.modify("move", "backward", "paragraphBoundary");
47 if (selection.baseNode === paragraph.firstChild && selection.baseOffset === 5)
48 log("PASS: Reached the start of the paragraph starting from " + positionAsString(node, offset) + ".");
50 log("FAIL: Reached " + positionAsString(selection.baseNode, selection.baseOffset) + " instead "
51 + "of the start of the paragraph starting from " + positionAsString(node, offset) + ".");
54 var paragraph = document.getElementById("paragraph");
55 var ruby = document.getElementById("ruby");
56 var rt = document.getElementById("rt");
58 testMovementToEndOfParagraph(paragraph, 0);
59 testMovementToEndOfParagraph(ruby, 0);
60 testMovementToEndOfParagraph(rt, 0);
62 testMovementToStartOfParagraph(paragraph, 2);
63 testMovementToStartOfParagraph(ruby, 2);
64 testMovementToStartOfParagraph(rt, 1);