Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / Document / CaretRangeFromPoint / caretRangeFromPoint-in-zoom-and-scroll.html
blob8cd6fad93eda28d374931d86fe9400554e87f2e3
1 <div id="first" style="width: 4000px; height: 1000px">A long text to test document caretRangeFromPoint. Test scroll, zoom, zoomAndScroll .................................... The End </div>
2 <ul id="console"></ul>
4 <script src="../../../../resources/js-test.js"></script>
5 <script>
6 function sendClick(x, y)
8 eventSender.mouseMoveTo(x, y);
9 eventSender.mouseDown();
10 eventSender.mouseUp();
13 // 29 is the character offset in the div text "A long text to test document caretRangeFromPoint".
14 var expectedOffset = 29;
15 var succeed = true;
17 function checkNodeAndOffsetFromCaretRangeFromPoint(message, event)
19 var range = document.caretRangeFromPoint(event.clientX, event.clientY);
20 var offset = 0;
21 if (range)
22 offset = range.startOffset;
23 else {
24 alert("range is null");
25 return;
28 var node = document.getElementById("first").firstChild;
29 if (range.startContainer != node) {
30 testFailed(message + " node should be div's child text node");
31 succeed = false;
33 if (offset != expectedOffset) {
34 testFailed(message + " offset actual: " + offset + "; expected: " + expectedOffset);
35 succeed = false;
39 function checkBase(event)
41 checkNodeAndOffsetFromCaretRangeFromPoint("check base", event);
44 function checkScroll(event)
46 checkNodeAndOffsetFromCaretRangeFromPoint("check scroll", event);
49 function checkZoom(event)
51 checkNodeAndOffsetFromCaretRangeFromPoint("check zoom", event);
54 function checkZoomScroll(event)
56 checkNodeAndOffsetFromCaretRangeFromPoint("check zoom and scroll", event);
59 function scrollPage(x, y)
61 window.scrollTo(x, y);
64 onload = function()
66 if (!window.testRunner)
67 return;
69 testRunner.dumpAsText();
71 var range = document.createRange();
72 var node = document.getElementById("first");
73 // Set range in the middle of word "document".
74 range.setStart(node.firstChild, expectedOffset);
75 range.setEnd(node.firstChild, expectedOffset + 1);
77 // Base test.
78 window.addEventListener("click", checkBase, false);
79 rects = range.getClientRects();
80 var x = rects[0].left;
81 var y = rects[0].top + rects[0].width / 2;
82 sendClick(x, y);
83 window.removeEventListener("click", checkBase, false);
85 // Test scroll.
86 window.addEventListener("click", checkScroll, false);
87 scrollPage(x / 2, 0);
88 sendClick(x / 2, y);
89 scrollPage(0, 0);
90 window.removeEventListener("click", checkScroll, false);
92 // Test zoom.
93 window.addEventListener("click", checkZoom, false);
94 node.style.zoom = 2.0;
95 rects = range.getClientRects();
96 var x = rects[0].left;
97 var y = rects[0].top + rects[0].width / 2;
98 sendClick(x * 2, y);
99 window.removeEventListener("click", checkZoom, false);
101 // Test scroll and Zoom.
102 window.addEventListener("click", checkZoomScroll, false);
103 scrollPage(x, 0);
104 sendClick(x, y);
105 scrollPage(0, 0);
106 node.style.zoom = 1.0;
107 window.removeEventListener("click", checkZoomScroll, false);
109 if (succeed == true)
110 testPassed("Test completed successfully");
112 </script>