| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 <!DOCTYPE html> | 
|  | 2 <script src="../resources/js-test.js"></script> | 
|  | 3 <script src="helper-functions.js"></script> | 
|  | 4 <div style="width:100%; height:700px;"></div> | 
|  | 5 <div id="target" style="background-color: green; width:100px; height:100px"></di
    v> | 
|  | 6 <div style="width:100%; height:700px;"></div> | 
|  | 7 | 
|  | 8 <script> | 
|  | 9   description("Simple intersection observer test with no explicit root and one d
    ocument."); | 
|  | 10   var target = document.getElementById("target"); | 
|  | 11   var entries = []; | 
|  | 12 | 
|  | 13   observer_callback = function(changes) { | 
|  | 14     for (var i in changes) | 
|  | 15       entries.push(changes[i]); | 
|  | 16   }; | 
|  | 17   var observer = new IntersectionObserver(observer_callback, {}); | 
|  | 18   observer.observe(target); | 
|  | 19 | 
|  | 20   // TODO(szager): It shouldn't be necessary to RAF after the call to observer() | 
|  | 21   // and before changing the scroll position, but it is. | 
|  | 22 | 
|  | 23   function step0() { | 
|  | 24     setTimeout(function() { | 
|  | 25       shouldBeEqualToNumber("entries.length", 0); | 
|  | 26       document.scrollingElement.scrollTop = 300; | 
|  | 27       requestAnimationFrame(step1); | 
|  | 28     }); | 
|  | 29   } | 
|  | 30 | 
|  | 31   function step1() { | 
|  | 32     setTimeout(function() { | 
|  | 33       shouldBeEqualToNumber("entries.length", 1); | 
|  | 34       shouldBeEqualToNumber("entries[0].boundingClientRect.left", 8); | 
|  | 35       shouldBeEqualToNumber("entries[0].boundingClientRect.right", 108); | 
|  | 36       shouldBeEqualToNumber("entries[0].boundingClientRect.top", 408); | 
|  | 37       shouldBeEqualToNumber("entries[0].boundingClientRect.bottom", 508); | 
|  | 38       shouldBeEqualToNumber("entries[0].intersectionRect.left", 8); | 
|  | 39       shouldBeEqualToNumber("entries[0].intersectionRect.right", 108); | 
|  | 40       shouldBeEqualToNumber("entries[0].intersectionRect.top", 408); | 
|  | 41       shouldBeEqualToNumber("entries[0].intersectionRect.bottom", 508); | 
|  | 42       shouldBeEqualToNumber("entries[0].rootBounds.left", 0); | 
|  | 43       shouldBeEqualToNumber("entries[0].rootBounds.right", 785); | 
|  | 44       shouldBeEqualToNumber("entries[0].rootBounds.top", 0); | 
|  | 45       shouldBeEqualToNumber("entries[0].rootBounds.bottom", 600); | 
|  | 46       shouldEvaluateToSameObject("entries[0].target", target); | 
|  | 47 | 
|  | 48       // ClientRect members of IntersectionObserverEntry should be stable. | 
|  | 49       shouldEvaluateToSameObject("entries[0].boundingClientRect", entries[0].bou
    ndingClientRect); | 
|  | 50       shouldEvaluateToSameObject("entries[0].intersectionRect", entries[0].inter
    sectionRect); | 
|  | 51       shouldEvaluateToSameObject("entries[0].rootBounds", entries[0].rootBounds)
    ; | 
|  | 52 | 
|  | 53       document.scrollingElement.scrollTop = 100; | 
|  | 54       requestAnimationFrame(step2); | 
|  | 55     }); | 
|  | 56   } | 
|  | 57 | 
|  | 58   function step2() { | 
|  | 59     setTimeout(function() { | 
|  | 60       shouldBeEqualToNumber("entries.length", 2); | 
|  | 61       shouldBeEqualToNumber("entries[1].boundingClientRect.left", 8); | 
|  | 62       shouldBeEqualToNumber("entries[1].boundingClientRect.right", 108); | 
|  | 63       shouldBeEqualToNumber("entries[1].boundingClientRect.top", 608); | 
|  | 64       shouldBeEqualToNumber("entries[1].boundingClientRect.bottom", 708); | 
|  | 65       shouldBeEqualToNumber("entries[1].intersectionRect.left", 0); | 
|  | 66       shouldBeEqualToNumber("entries[1].intersectionRect.right", 0); | 
|  | 67       shouldBeEqualToNumber("entries[1].intersectionRect.top", 0); | 
|  | 68       shouldBeEqualToNumber("entries[1].intersectionRect.bottom", 0); | 
|  | 69       shouldBeEqualToNumber("entries[1].rootBounds.left", 0); | 
|  | 70       shouldBeEqualToNumber("entries[1].rootBounds.right", 785); | 
|  | 71       shouldBeEqualToNumber("entries[1].rootBounds.top", 0); | 
|  | 72       shouldBeEqualToNumber("entries[1].rootBounds.bottom", 600); | 
|  | 73       shouldEvaluateToSameObject("entries[1].target", target); | 
|  | 74       finishTest(); | 
|  | 75       document.scrollingElement.scrollTop = 0; | 
|  | 76     }); | 
|  | 77   } | 
|  | 78 | 
|  | 79   requestAnimationFrame(step0); | 
|  | 80 </script> | 
| OLD | NEW | 
|---|