Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / selection / anchor-focus2.html
blobf9567b81f84c9e14275a47fabd105dc50e8398cc
1 <html>
2 <head>
3 <script>
4 if (window.testRunner)
5 testRunner.dumpEditingCallbacks();
6 </script>
8 <script>
10 var x1, x2, y;
12 function log(str) {
13 var li = document.createElement("li");
14 li.appendChild(document.createTextNode(str));
15 var console = document.getElementById("console");
16 console.appendChild(li);
19 function runTest() {
20 var elem = document.getElementById("test");
21 var selection = window.getSelection();
23 var anchorNode = selection.anchorNode;
24 var anchorOffset = selection.anchorOffset;
25 var focusNode = selection.focusNode;
26 var focusOffset = selection.focusOffset;
28 var anchorString = "Anchor (" + anchorNode + ", " + anchorOffset + ")";
29 var anchorCorrect = (anchorNode == elem || anchorNode == elem.firstChild) && anchorOffset == 0;
30 if (anchorCorrect)
31 log(anchorString + " is correct.");
32 else
33 throw(anchorString + " is incorrect.");
35 var focusString = "Focus (" + focusNode + ", " + focusOffset + ")";
36 var focusCorrect = (focusNode == elem && focusOffset == 1 || focusNode == elem.firstChild && focusOffset == elem.firstChild.length);
37 if (focusCorrect)
38 log(focusString + " is correct.");
39 else
40 throw(focusString + " is incorrect.");
43 function manualTest() {
44 try {
45 runTest();
46 } catch(e) {
47 log("Test Failed. Error was: " + e);
51 function automaticTest() {
52 try {
53 if (!window.testRunner)
54 throw("This test uses the testRunner's eventSender to do mouse clicks. To run it manually, from left to right, select 'text' in the box below, then click the 'Run Test' button.");
56 window.testRunner.dumpAsText();
58 var elem = document.getElementById("test");
60 // (x1, y) to (x2, y) should select the element.
61 // selects the text from left to right.
62 x1 = elem.offsetLeft;
63 x2 = elem.offsetLeft + elem.offsetWidth;
64 y = elem.offsetTop + elem.offsetHeight / 2;
66 eventSender.mouseMoveTo(x1, y);
67 eventSender.mouseDown();
68 eventSender.mouseMoveTo(x1, y);
69 eventSender.mouseMoveTo(x2, y);
70 eventSender.mouseUp();
71 runTest();
73 } catch(e) {
74 log("Test Failed. Error was: " + e);
78 </script>
79 </head>
80 <body>
81 <p>This tests the anchorNode, anchorOffset, focusNode and focusOffset properties of the Selection object. These properties are part of Mozilla's Selection object API, and so their values should be consistent in both browsers.</p>
82 <input type="button" onclick="manualTest();" value="Run Test">
83 <div style="border: 1px solid blue;" id="test">text</div>
84 <ul id="console"></ul>
85 <script>automaticTest();</script>
87 </body>
88 </html>