OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <style> |
| 3 body { margin: 0px; } |
| 4 #sandbox { |
| 5 width: 400px; |
| 6 height: 200px; |
| 7 } |
| 8 #sandbox iframe { |
| 9 display: block; |
| 10 box-sizing: border-box; |
| 11 width: 200px; |
| 12 height: 200px; |
| 13 border: none; |
| 14 } |
| 15 #sandbox { |
| 16 box-sizing: border-box; |
| 17 height: 100px; |
| 18 width: 200px; |
| 19 border: 1px solid black; |
| 20 } |
| 21 </style> |
| 22 |
| 23 <script src="../../../resources/js-test.js"></script> |
| 24 <script src="resources/nodesFromRect.js"></script> |
| 25 |
| 26 <body id="body"> |
| 27 <input id="text-input" type="text"> <br> |
| 28 <iframe id="iframe" src="resources/child-frame-scrolled.html"></iframe> |
| 29 <div id="console"></div> |
| 30 </body> |
| 31 |
| 32 <script> |
| 33 description("nodesFromRect returns correct rects when the rect is overlapping" + |
| 34 " an iframe with scrolled contents"); |
| 35 |
| 36 if (window.testRunner) { |
| 37 testRunner.dumpAsText(); |
| 38 testRunner.waitUntilDone(); |
| 39 } |
| 40 |
| 41 window.addEventListener("message", function(evt) { |
| 42 if (evt.data == "subframe-loaded") { |
| 43 var inputElement = document.getElementById('text-input'); |
| 44 var inputBoundingRect = inputElement.getBoundingClientRect(); |
| 45 var inputCenterX = inputBoundingRect.left + inputBoundingRect.width / 2; |
| 46 var inputCenterY = inputBoundingRect.top + inputBoundingRect.height / 2; |
| 47 var inputHeight = inputBoundingRect.height; |
| 48 |
| 49 var iframeElement = document.getElementById('iframe'); |
| 50 var iframeBoundingRect = iframeElement.getBoundingClientRect(); |
| 51 var iframeCenterX = iframeBoundingRect.left + iframeBoundingRect.width / 2; |
| 52 var iframeCenterY = iframeBoundingRect.top + iframeBoundingRect.height / 2; |
| 53 |
| 54 // Rect is totally within input box. |
| 55 checkRect(inputCenterX, inputCenterY, 1, 1, "DIV#inner-editor"); |
| 56 // Rect covers both input box and iframe. |
| 57 checkRect(inputCenterX, inputCenterY, inputHeight, inputHeight, |
| 58 "DIV#content, IFRAME#iframe, DIV#inner-editor, INPUT#text-input, BO
DY#body"); |
| 59 // Rect is totally within iframe. |
| 60 checkRect(iframeCenterX, iframeCenterY, 1, 1, "DIV#content"); |
| 61 |
| 62 if (window.testRunner) |
| 63 testRunner.notifyDone(); |
| 64 } |
| 65 |
| 66 }, true); |
| 67 |
| 68 </script> |
OLD | NEW |