Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/intersection-observer/iframe-no-root.html | 
| diff --git a/third_party/WebKit/LayoutTests/intersection-observer/iframe-no-root.html b/third_party/WebKit/LayoutTests/intersection-observer/iframe-no-root.html | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..97fd1464af7299c485ec620fdeeb39e3684c94ff | 
| --- /dev/null | 
| +++ b/third_party/WebKit/LayoutTests/intersection-observer/iframe-no-root.html | 
| @@ -0,0 +1,79 @@ | 
| +<!DOCTYPE html> | 
| +<div style="width:100%;height:700px;"></div> | 
| 
 
esprehn
2015/12/12 00:14:12
space after ; to be consistent?
 
szager1
2015/12/16 19:15:33
Done.
 
 | 
| +<iframe id="target-iframe" src="../resources/intersection-observer-subframe.html" style="height: 100px; overflow-y: scroll" onload="runtests()"></iframe> | 
| 
 
esprehn
2015/12/12 00:14:12
runTests(), but just wait for onload, doesn't that
 
szager1
2015/12/16 19:15:33
Done.
 
 | 
| +<div style="width:100%; height:700px;"></div> | 
| + | 
| +<script src="../resources/js-test.js"></script> | 
| +<script src="helper-functions.js"></script> | 
| 
 
esprehn
2015/12/12 00:14:12
these should always be first, before the test stuf
 
szager1
2015/12/16 19:15:33
Done.
 
 | 
| +<script> | 
| +description("Simple intersection observer test with no explicit root and target in an iframe."); | 
| +var entries = []; | 
| + | 
| +function runtests() { | 
| 
 
esprehn
2015/12/12 00:14:12
onload = function() {
 
szager1
2015/12/16 19:15:33
Done.
 
 | 
| + var targetIframe = document.getElementById("target-iframe"); | 
| + var target = targetIframe.contentDocument.getElementById("target"); | 
| + var iframeScroller = targetIframe.contentDocument.scrollingElement; | 
| + | 
| + observer_callback = function(changes) { | 
| + for (var i in changes) | 
| + entries.push(changes[i]); | 
| + }; | 
| + var observer = new IntersectionObserver(observer_callback, {}); | 
| + 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 = 200; | 
| + requestAnimationFrame(step1); | 
| + }); | 
| + } | 
| + | 
| + var expected1 = []; | 
| + function step1() { | 
| + setTimeout(function() { | 
| + checkResults(expected1, "entries"); | 
| + iframeScroller.scrollTop = 250; | 
| + requestAnimationFrame(step2); | 
| + }); | 
| + } | 
| + | 
| + var expected2 = [ | 
| + { | 
| + 'boundingClientRect': [ 18, 118, 468, 568 ], | 
| 
 
esprehn
2015/12/12 00:14:12
no quotes needed
 
szager1
2015/12/16 19:15:33
I removed all of the 'expected' variables, here an
 
 | 
| + 'intersectionRect': [ 18, 118, 510, 568], | 
| + 'rootBounds' : [ 0, 785, 0, 600 ], | 
| + 'target': target | 
| + } | 
| + ]; | 
| + function step2() { | 
| + setTimeout(function() { | 
| + checkResults(expected2, "entries"); | 
| + document.scrollingElement.scrollTop = 100; | 
| + requestAnimationFrame(step3); | 
| + }); | 
| + } | 
| + | 
| + var expected3 = expected2.concat([ | 
| + { | 
| + 'boundingClientRect': [ 18, 118, 568, 668 ], | 
| + 'intersectionRect': [ 0, 0, 0, 0 ], | 
| 
 
esprehn
2015/12/12 00:14:12
remove quotes
 
szager1
2015/12/16 19:15:33
Same.
 
 | 
| + 'rootBounds' : [ 0, 785, 0, 600 ], | 
| + 'target': target | 
| + } | 
| + ]); | 
| + function step3() { | 
| + setTimeout(function() { | 
| + checkResults(expected3, "entries", 1); | 
| 
 
esprehn
2015/12/12 00:14:12
these tests are super hard to debug since the asse
 
szager1
2015/12/16 19:15:33
Inlined all asserts.
 
 | 
| + finishTest(); | 
| + document.scrollingElement.scrollTop = 0; | 
| + }); | 
| + } | 
| + | 
| + requestAnimationFrame(step0); | 
| +} | 
| +</script> |