Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/intersection-observer/multiple-thresholds.html | 
| diff --git a/third_party/WebKit/LayoutTests/intersection-observer/multiple-thresholds.html b/third_party/WebKit/LayoutTests/intersection-observer/multiple-thresholds.html | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..1d9cee178da5c47bfbf4e5c447972e8a3abd4ce1 | 
| --- /dev/null | 
| +++ b/third_party/WebKit/LayoutTests/intersection-observer/multiple-thresholds.html | 
| @@ -0,0 +1,155 @@ | 
| +<!DOCTYPE html> | 
| +<div style="width:100%;height:700px;"></div> | 
| +<div id="target" style="background-color: green; width:100px; height:100px"></div> | 
| +<div style="width:100%; height:700px;"></div> | 
| 
 
esprehn
2015/12/12 00:14:13
ditto for this whole test
 
szager1
2015/12/16 19:15:34
Done.
 
 | 
| + | 
| +<script src="../resources/js-test.js"></script> | 
| +<script src="helper-functions.js"></script> | 
| +<script> | 
| + description("Intersection observer test with multiple thresholds."); | 
| + var target = document.getElementById("target"); | 
| + var entries = []; | 
| + | 
| + observer_callback = function(changes) { | 
| + for (var i in changes) | 
| + entries.push(changes[i]); | 
| + }; | 
| + var observer = new IntersectionObserver(observer_callback, { | 
| + threshold: [0, 0.25, 0.5, 0.75] | 
| + }); | 
| + observer.observe(target); | 
| + | 
| + // TODO: It shouldn't be necessary to RAF after the call to observer() | 
| + // and before changing the scroll position, but it is. | 
| + | 
| + var expected0 = []; | 
| + function step0() { | 
| + setTimeout(function() { | 
| + checkResults(expected0, "entries"); | 
| + document.scrollingElement.scrollTop = 120; | 
| + requestAnimationFrame(step1); | 
| + }); | 
| + } | 
| + | 
| + var expected1 = [ | 
| + { | 
| + 'boundingClientRect': [ 8, 108, 588, 688 ], | 
| + 'intersectionRect': [ 8, 108, 588, 600 ], | 
| + 'rootBounds' : [ 0, 785, 0, 600 ], | 
| + 'target': target | 
| + }, | 
| + ]; | 
| + function step1() { | 
| + setTimeout(function() { | 
| + checkResults(expected1, "entries"); | 
| + document.scrollingElement.scrollTop = 160; | 
| + requestAnimationFrame(step2); | 
| + }); | 
| + } | 
| + | 
| + var expected2 = expected1.concat([ | 
| + { | 
| + 'boundingClientRect': [ 8, 108, 548, 648 ], | 
| + 'intersectionRect': [ 8, 108, 548, 600 ], | 
| + 'rootBounds' : [ 0, 785, 0, 600 ], | 
| + 'target': target | 
| + } | 
| + ]); | 
| + function step2() { | 
| + setTimeout(function() { | 
| + checkResults(expected2, "entries", 1); | 
| + document.scrollingElement.scrollTop = 200; | 
| + requestAnimationFrame(step3); | 
| + }); | 
| + } | 
| + | 
| + var expected3 = expected2.concat([ | 
| + { | 
| + 'boundingClientRect': [ 8, 108, 508, 608 ], | 
| + 'intersectionRect': [ 8, 108, 508, 600 ], | 
| + 'rootBounds' : [ 0, 785, 0, 600 ], | 
| + 'target': target | 
| + } | 
| + ]); | 
| + function step3() { | 
| + setTimeout(function() { | 
| + checkResults(expected3, "entries", 2); | 
| + document.scrollingElement.scrollTop = 240; | 
| + requestAnimationFrame(step4); | 
| + }); | 
| + } | 
| + | 
| + var expected4 = expected3; | 
| + function step4() { | 
| + setTimeout(function() { | 
| + checkResults(expected4, "entries", 3); | 
| + document.scrollingElement.scrollTop = 740; | 
| + requestAnimationFrame(step5); | 
| + }); | 
| + } | 
| + | 
| + var expected5 = expected4.concat([ | 
| + { | 
| + 'boundingClientRect': [ 8, 108, -32, 68 ], | 
| + 'intersectionRect': [ 8, 108, 0, 68 ], | 
| + 'rootBounds' : [ 0, 785, 0, 600 ], | 
| + 'target': target | 
| + } | 
| + ]); | 
| + function step5() { | 
| + setTimeout(function() { | 
| + checkResults(expected5, "entries", 3); | 
| + document.scrollingElement.scrollTop = 760; | 
| + requestAnimationFrame(step6); | 
| + }); | 
| + } | 
| + | 
| + var expected6 = expected5.concat([ | 
| + { | 
| + 'boundingClientRect': [ 8, 108, -52, 48 ], | 
| + 'intersectionRect': [ 8, 108, 0, 48 ], | 
| + 'rootBounds' : [ 0, 785, 0, 600 ], | 
| + 'target': target | 
| + } | 
| + ]); | 
| + function step6() { | 
| + setTimeout(function() { | 
| + checkResults(expected6, "entries", 4); | 
| + document.scrollingElement.scrollTop = 800; | 
| + requestAnimationFrame(step7); | 
| + }); | 
| + } | 
| + | 
| + var expected7 = expected6.concat([ | 
| + { | 
| + 'boundingClientRect': [ 8, 108, -92, 8 ], | 
| + 'intersectionRect': [ 8, 108, 0, 8 ], | 
| + 'rootBounds' : [ 0, 785, 0, 600 ], | 
| + 'target': target | 
| + } | 
| + ]); | 
| + function step7() { | 
| + setTimeout(function() { | 
| + checkResults(expected7, "entries", 5); | 
| + document.scrollingElement.scrollTop = 820; | 
| + requestAnimationFrame(step8); | 
| + }); | 
| + } | 
| + | 
| + var expected8 = expected7.concat([ | 
| + { | 
| + 'boundingClientRect': [ 8, 108, -112, -12 ], | 
| + 'intersectionRect': [ 0, 0, 0, 0 ], | 
| + 'rootBounds' : [ 0, 785, 0, 600 ], | 
| + 'target': target | 
| + } | 
| + ]); | 
| + function step8() { | 
| + setTimeout(function() { | 
| + checkResults(expected8, "entries", 6); | 
| + finishTest(); | 
| + document.scrollingElement.scrollTop = 0; | 
| + }); | 
| + } | 
| + requestAnimationFrame(step0); | 
| +</script> |