chromium/third_party/blink/web_tests/fast/dom/nodesFromRect/nodesFromRect-inner-documents.html

<!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="../../../resources/js-test.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];
      ['a1', 'iframe1', 'body'].forEach(function(a) {
        e[a] = document.getElementById(a);
      });

      window.scrollTo(0, 0);

      var a1Center = getCenterFor(e.a1);
      var iframe1Center = getCenterFor(e.iframe1);

      // Elements inside iframe shouldn't be returned:
      check(iframe1Center.x, iframe1Center.y, 1, 1, [e.iframe1]);
      check(iframe1Center.x - 10, iframe1Center.y - 10, 21, 21, [e.iframe1]);

      // NOTE: e.body.childNodes[2] is a TextNode whose content is ' '.
      check(a1Center.x, a1Center.y, e.iframe1.getBoundingClientRect().left - a1Center.x + 1, 1, [e.iframe1, e.body.childNodes[2],  e.a1.firstChild, e.a1, e.body]);

      // Testing nodesFromRect in an inner node.
      var innerDocument = window.frames[0].document;
      var div = innerDocument.getElementsByTagName('div')[0];
      var p = innerDocument.getElementsByTagName('p')[0];
      var body = innerDocument.getElementsByTagName('body')[0];
      var divCenter = getCenterFor(div);
      var divBottom = getBottomFor(div);
      var pCenter = getCenterFor(p);
      check(divCenter.x, divCenter.y, 1, 1, [div], innerDocument);
      check(divCenter.x, divCenter.y, 1, divBottom.y - divCenter.y + 1, [div, body], innerDocument);
      check(divCenter.x, divCenter.y, 1, pCenter.y - divCenter.y + 1, [p, div, body], innerDocument);
    }
    window.onload = runTest;
  </script>
</head>
<body id="body">
  <a id="a1" href="#">A</a>
  <iframe id="iframe1" srcdoc="<div>div</div><p>p</p>"></iframe>
  
  <div id="console"></div>
</body>
</html>