OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="/js-test-resources/js-test.js"></script> |
| 3 <div style="width:100%; height:700px;"></div> |
| 4 <iframe id="target-iframe" src="http://localhost:8080/intersection-observer/reso
urces/cross-origin-subframe.html" style="height: 100px; overflow-y: scroll"></if
rame> |
| 5 <div style="width:100%; height:700px;"></div> |
| 6 |
| 7 <script> |
| 8 setPrintTestResultsLazily(); |
| 9 self.jsTestIsAsync = true; |
| 10 |
| 11 description("Simple intersection observer test with no explicit root and target
in a cross-origin iframe."); |
| 12 |
| 13 var iframe = document.getElementById("target-iframe"); |
| 14 var actual; |
| 15 |
| 16 function checkData(actualData, expected) { |
| 17 actual = actualData; |
| 18 shouldBeEqualToNumber("actual.length", expected.length); |
| 19 for (var i = 0; i < actualData.length && i < expected.length; i++) { |
| 20 actual = actualData[i]; |
| 21 shouldBeEqualToNumber("actual.boundingClientRect.left", expected[i].bounding
ClientRect.left); |
| 22 shouldBeEqualToNumber("actual.boundingClientRect.top", expected[i].boundingC
lientRect.top); |
| 23 shouldBeEqualToNumber("actual.boundingClientRect.right", expected[i].boundin
gClientRect.right); |
| 24 shouldBeEqualToNumber("actual.boundingClientRect.bottom", expected[i].boundi
ngClientRect.bottom); |
| 25 shouldBeEqualToNumber("actual.boundingClientRect.width", expected[i].boundin
gClientRect.width); |
| 26 shouldBeEqualToNumber("actual.boundingClientRect.height", expected[i].boundi
ngClientRect.height); |
| 27 shouldBeEqualToNumber("actual.intersectionRect.left", expected[i].intersecti
onRect.left); |
| 28 shouldBeEqualToNumber("actual.intersectionRect.top", expected[i].intersectio
nRect.top); |
| 29 shouldBeEqualToNumber("actual.intersectionRect.right", expected[i].intersect
ionRect.right); |
| 30 shouldBeEqualToNumber("actual.intersectionRect.bottom", expected[i].intersec
tionRect.bottom); |
| 31 shouldBeEqualToNumber("actual.intersectionRect.width", expected[i].intersect
ionRect.width); |
| 32 shouldBeEqualToNumber("actual.intersectionRect.height", expected[i].intersec
tionRect.height); |
| 33 if (expected[i].rootBounds == "null") { |
| 34 shouldBe("actual.rootBounds", "null"); |
| 35 } else if (actual.rootBounds == "null") { |
| 36 shouldNotBe("actual.rootBounds", "null"); |
| 37 } else { |
| 38 shouldBeEqualToNumber("actual.rootBounds.left", expected[i].rootBounds.lef
t); |
| 39 shouldBeEqualToNumber("actual.rootBounds.top", expected[i].rootBounds.top)
; |
| 40 shouldBeEqualToNumber("actual.rootBounds.right", expected[i].rootBounds.ri
ght); |
| 41 shouldBeEqualToNumber("actual.rootBounds.bottom", expected[i].rootBounds.b
ottom); |
| 42 shouldBeEqualToNumber("actual.rootBounds.width", expected[i].rootBounds.wi
dth); |
| 43 shouldBeEqualToNumber("actual.rootBounds.height", expected[i].rootBounds.h
eight); |
| 44 } |
| 45 shouldBeEqualToString("actual.target", expected[i].target); |
| 46 } |
| 47 } |
| 48 |
| 49 function handleMessage(event) { |
| 50 if (event.data.hasOwnProperty('scrollTo')) { |
| 51 document.scrollingElement.scrollTop = event.data.scrollTo; |
| 52 requestAnimationFrame(function () { iframe.contentWindow.postMessage("", "*"
) }); |
| 53 } else if (event.data.hasOwnProperty('actual')) { |
| 54 checkData(event.data.actual, event.data.expected); |
| 55 } else if (event.data.hasOwnProperty('DONE')) { |
| 56 finishJSTest(); |
| 57 document.scrollingElement.scrollTop = 0; |
| 58 } else { |
| 59 requestAnimationFrame(function () { iframe.contentWindow.postMessage("", "*"
) }); |
| 60 } |
| 61 } |
| 62 |
| 63 window.addEventListener("message", handleMessage); |
| 64 iframe.onload = function() { |
| 65 iframe.contentWindow.postMessage("", "*") |
| 66 }; |
| 67 </script> |
OLD | NEW |