| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 <!DOCTYPE html> | 
|  | 2 <script src="../resources/js-test.js"></script> | 
|  | 3 <script src="helper-functions.js"></script> | 
|  | 4 <style> | 
|  | 5 #root { | 
|  | 6   overflow: visible; | 
|  | 7   height: 200px; | 
|  | 8   width: 200px; | 
|  | 9   border: 7px solid black; | 
|  | 10 } | 
|  | 11 #target { | 
|  | 12   width: 100px; | 
|  | 13   height: 100px; | 
|  | 14   background-color: green; | 
|  | 15 } | 
|  | 16 </style> | 
|  | 17 <div id="root"> | 
|  | 18   <div id="target" style="transform: translateY(300px)"></div> | 
|  | 19 </div> | 
|  | 20 | 
|  | 21 <script> | 
|  | 22 description("Test that border bounding box is used to calculate intersection wit
    h a non-scrolling root."); | 
|  | 23 var target = document.getElementById("target"); | 
|  | 24 var root = document.getElementById("root"); | 
|  | 25 var entries = []; | 
|  | 26 var observer = new IntersectionObserver( | 
|  | 27     changes => { entries.push(...changes) }, | 
|  | 28     { root: document.getElementById("root") } | 
|  | 29 ); | 
|  | 30 | 
|  | 31 onload = function() { | 
|  | 32   observer.observe(target); | 
|  | 33   entries.push(...observer.takeRecords()); | 
|  | 34   shouldBeEqualToNumber("entries.length", 0); | 
|  | 35   // See README for explanation of double RAF. | 
|  | 36   requestAnimationFrame(() => { requestAnimationFrame(step0) }); | 
|  | 37 } | 
|  | 38 | 
|  | 39 function step0() { | 
|  | 40   entries.push(...observer.takeRecords()); | 
|  | 41   shouldBeEqualToNumber("entries.length", 0); | 
|  | 42   target.style.transform = "translateY(195px)"; | 
|  | 43   requestAnimationFrame(step1); | 
|  | 44 } | 
|  | 45 | 
|  | 46 function step1() { | 
|  | 47   entries.push(...observer.takeRecords()); | 
|  | 48   shouldBeEqualToNumber("entries.length", 1); | 
|  | 49   if (entries.length > 0) { | 
|  | 50     shouldBeEqualToNumber("entries[0].boundingClientRect.left", 15); | 
|  | 51     shouldBeEqualToNumber("entries[0].boundingClientRect.right", 115); | 
|  | 52     shouldBeEqualToNumber("entries[0].boundingClientRect.top", 210); | 
|  | 53     shouldBeEqualToNumber("entries[0].boundingClientRect.bottom", 310); | 
|  | 54     shouldBeEqualToNumber("entries[0].intersectionRect.left", 15); | 
|  | 55     shouldBeEqualToNumber("entries[0].intersectionRect.right", 115); | 
|  | 56     shouldBeEqualToNumber("entries[0].intersectionRect.top", 210); | 
|  | 57     shouldBeEqualToNumber("entries[0].intersectionRect.bottom", 222); | 
|  | 58     shouldBeEqualToNumber("entries[0].rootBounds.left", 8); | 
|  | 59     shouldBeEqualToNumber("entries[0].rootBounds.right", 222); | 
|  | 60     shouldBeEqualToNumber("entries[0].rootBounds.top", 8); | 
|  | 61     shouldBeEqualToNumber("entries[0].rootBounds.bottom", 222); | 
|  | 62     shouldEvaluateToSameObject("entries[0].target", target); | 
|  | 63   } | 
|  | 64 | 
|  | 65   finishJSTest(); | 
|  | 66 } | 
|  | 67 </script> | 
| OLD | NEW | 
|---|