4 <title>Document::nodesFromRect : basic text nodes and links test - bug
47795</title>
5 <style type=
"text/css"> @import
"resources/nodesFromRect.css"; </style>
6 <script src=
"../../../resources/js-test.js"></script>
7 <script src=
"resources/nodesFromRect.js"></script>
8 <script type=
"application/javascript">
13 // Set up shortcut access to elements
14 e['html'] = document.getElementsByTagName(
"html")[
0];
15 ['a1', 'iframe1', 'body'].forEach(function(a) {
16 e[a] = document.getElementById(a);
19 window.scrollTo(
0,
0);
21 var a1Center = getCenterFor(e.a1);
22 var iframe1Center = getCenterFor(e.iframe1);
24 // Elements inside iframe shouldn't be returned:
25 check(iframe1Center.x, iframe1Center.y,
0,
0,
0,
0, [e.iframe1]);
26 check(iframe1Center.x, iframe1Center.y,
10,
10,
10,
10, [e.iframe1]);
28 // NOTE: e.body.childNodes[
2] is a TextNode whose content is ' '.
29 check(a1Center.x, a1Center.y,
0, e.iframe1.getBoundingClientRect().left - a1Center.x,
0,
0, [e.iframe1, e.body.childNodes[
2], e.a1.firstChild, e.a1, e.body]);
31 // Testing nodesFromRect in an inner node.
32 var innerDocument = window.frames[
0].document;
33 var div = innerDocument.getElementsByTagName('div')[
0];
34 var p = innerDocument.getElementsByTagName('p')[
0];
35 var body = innerDocument.getElementsByTagName('body')[
0];
36 var divCenter = getCenterFor(div);
37 var divBottom = getBottomFor(div);
38 var pCenter = getCenterFor(p);
39 check(divCenter.x, divCenter.y,
0,
0,
0,
0, [div], innerDocument);
40 check(divCenter.x, divCenter.y,
0,
0, divBottom.y - divCenter.y,
0, [div, body], innerDocument);
41 check(divCenter.x, divCenter.y,
0,
0, pCenter.y - divCenter.y,
0, [p, div, body], innerDocument);
43 window.onload = runTest;
47 <a id=
"a1" href=
"#">A
</a>
48 <iframe id=
"iframe1" src=
"data:text/html,<div>div</div><p>p</p>"></iframe>
50 <div id=
"console"></div>