summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/dom/nodesFromRect/nodesFromRect-links-and-text.html
blob: e1f1ef2d951d1ce92107494f84f9c98118a4b842 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<!DOCTYPE html>
<html>
<head>
  <title>Document::nodesFromRect : basic text nodes and links test - bug 47795</title>
  <style type="text/css"> @import "resources/nodesFromRect.css"; </style>
  <script src="../../js/resources/js-test-pre.js"></script>
  <script src="resources/nodesFromRect.js"></script>
  <script type="application/javascript">
    function runTest()
    {
      var e = {};

      // Set up shortcut access to elements
      e['html'] = document.getElementsByTagName("html")[0];
      ['p1', 'a1', 'a2', 'a3', 'body'].forEach(function(a) {
        e[a] = document.getElementById(a);
      });

      window.scrollTo(0, 0);

      // Area with links and text nodes:
      var centerA1 = getCenterFor(e.a1);
      var centerA2 = getCenterFor(e.a2);
      var centerA3 = getCenterFor(e.a3);
      var topP1 = getTopFor(e.p1);
      var topA1 = getTopFor(e.a1);
      var centerText = { x : (centerA2.x + centerA1.x) / 2, y : centerA1.y }; //text node between a1 and a2

      check(centerA1.x, centerA1.y, 0, 0, 0, 0, [e.a1.firstChild]);
      check(centerA1.x, centerA1.y, topA1.y - topP1.y, 0, 0, 0, [e.a1.firstChild, e.a1, e.p1]);

      check(centerA1.x, centerA1.y, 0, 0, centerA3.y - centerA1.y, 0, [e.a3.firstChild, e.a3, e.p1, e.a1.firstChild, e.a1]);
      check(centerA1.x, centerA1.y, 0, centerText.x - centerA1.x, 0, 0, [e.p1.childNodes[2], e.a1.firstChild, e.a1, e.p1]);
      check(centerA1.x, centerA1.y, 0, centerA2.x - centerA1.x, 0, 0, [e.a2.firstChild, e.a2, e.p1.childNodes[2], e.a1.firstChild, e.a1, e.p1]);
      check(centerA1.x, centerA1.y, 0, centerA2.x - centerA1.x, centerA3.y - centerA1.y, 0, [e.a3.firstChild, e.a3, e.p1, e.a2.firstChild, e.a2, e.p1.childNodes[2], e.a1.firstChild, e.a1]);

    }
    window.onload = runTest;
  </script>
</head>
<body id="body">
  <p id="p1">
    <a href="#" id="a1">A</a> / <a href="#" id="a2">B</a><br/><a href="#" id="a3">C</a>
  </p>

  <span id="console"></span>
</body>
</html>