Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Unified Diff: third_party/WebKit/LayoutTests/intersection-observer/root-margin.html

Issue 1449623002: IntersectionObserver: second cut. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Implemented root margin Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/intersection-observer/root-margin.html
diff --git a/third_party/WebKit/LayoutTests/intersection-observer/root-margin.html b/third_party/WebKit/LayoutTests/intersection-observer/root-margin.html
new file mode 100644
index 0000000000000000000000000000000000000000..77f4d5ccba7a64b5937a933331e6d8fa7e0e2d8e
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/intersection-observer/root-margin.html
@@ -0,0 +1,82 @@
+<!DOCTYPE html>
+<div style="width:100%;height:700px;"></div>
+<div style="white-space: nowrap;">
+ <div style="display: inline-block; width: 1000px; height: 100px"></div>
+ <div id="target" style="display: inline-block; background-color: green; width:100px; height:100px"></div>
+ <div style="display: inline-block; width: 1000px; height: 100px"></div>
+</div>
+<div style="width:100%; height:700px;"></div>
+
+<script src="../resources/js-test.js"></script>
+<script src="helper-functions.js"></script>
+<script>
+ description("Intersection observer test with root margin and implicit root.");
+ var target = document.getElementById("target");
+ var entries = [];
+
+ observer_callback = function(changes) {
+ for (var i in changes) {
+ console.log(entryToString(changes[i]));
+ entries.push(changes[i]);
+ }
+ };
+ var observer = new IntersectionObserver(observer_callback, {
+ rootMargin: "10px 20% 40% 30px"
+ });
+ 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");
esprehn 2015/12/12 00:14:13 every time you call checkResults you pass "entries
szager1 2015/12/16 19:15:34 checkResults is gone now.
+ document.scrollingElement.scrollLeft = 100;
+ requestAnimationFrame(step1);
+ });
+ }
+
+ var expected1 = [
+ {
+ 'boundingClientRect': [ 912, 1012, 708, 808 ],
+ 'intersectionRect': [ 912, 942, 708, 808 ],
+ 'rootBounds' : [ -30, 942, -10, 819 ],
+ 'target': target
+ },
+ ];
+ function step1() {
+ setTimeout(function() {
+ checkResults(expected1, "entries");
+ document.scrollingElement.scrollTop = 800;
+ requestAnimationFrame(step2);
+ });
+ }
+
+ var expected2 = expected1;
+ function step2() {
+ setTimeout(function() {
+ checkResults(expected2, "entries", 1);
+ document.scrollingElement.scrollTop = 900;
+ requestAnimationFrame(step3);
+ });
+ }
+
+ var expected3 = expected1.concat([
+ {
+ 'boundingClientRect': [ 912, 1012, -192, -92 ],
+ 'intersectionRect': [ 0, 0, 0, 0 ],
+ 'rootBounds' : [ -30, 942, -10, 819 ],
+ 'target': target
+ }
+ ]);
+ function step3() {
+ setTimeout(function() {
+ checkResults(expected3, "entries", 1);
+ finishTest();
+ document.scrollingElement.scrollLeft = 0;
+ document.scrollingElement.scrollTop = 0;
+ });
+ }
+ requestAnimationFrame(step0);
+</script>

Powered by Google App Engine
This is Rietveld 408576698