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

Unified Diff: LayoutTests/fast/dom/intersection-observer.html

Issue 1330633003: Intersection Observer first draft Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix segfault on null input. Created 5 years, 3 months 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: LayoutTests/fast/dom/intersection-observer.html
diff --git a/LayoutTests/fast/dom/intersection-observer.html b/LayoutTests/fast/dom/intersection-observer.html
new file mode 100644
index 0000000000000000000000000000000000000000..23106e91a44a6f70174b4954985405291437666f
--- /dev/null
+++ b/LayoutTests/fast/dom/intersection-observer.html
@@ -0,0 +1,66 @@
+<!DOCTYPE html>
+<script src="../../resources/js-test.js"></script>
+
+<body>
ojan 2015/09/21 03:49:08 Nit: No need for the body element
MikeB 2015/09/24 19:04:03 Done.
+
+<div id="top_div" style="background-color:blue;position:absolute; top:50px; left:20px; width:600px; height:800px">
+</div>
+
+<div id="target_div" style="background-color:red;position:absolute; top:855px; left:66px; width:300px; height:250px">
ojan 2015/09/21 03:49:08 Please add test cases for the following or add app
+</div>
+
+</body>
+
+
+
+<script>
+window.jsTestIsAsync = true;
+
+var entries = [];
+var expectedEntries = [
+ {
+ time:'mark',
+ quads:[{top:855, right:366, bottom: 1000, left: 66}],
+ viewport: {top:400, right:785, bottom:1000, left:0},
+ target: document.getElementById('target_div')
+ }
+];
+
+var a = {}, b = {};
+function shouldBeClientRect(name, value1, value2)
+{
+ a[name] = value1;
+ b[name] = value2;
+ shouldBe('a.'+name+'.top', 'b.'+name+'.top');
+ shouldBe('a.'+name+'.right', 'b.'+name+'.right');
+ shouldBe('a.'+name+'.bottom', 'b.'+name+'.bottom');
+ shouldBe('a.'+name+'.left', 'b.'+name+'.left');
+}
+
+function testIntersectionObserver()
+{
+ var observer = new IntersectionObserver(intersectionCallback);
+
+ function intersectionCallback(changes)
+ {
+ entries = entries.concat(changes);
+ if (entries.length != expectedEntries.length)
+ return;
+ shouldBe('entries[0].time', '0');
+ shouldBeClientRect('quads_0', changes[0].quads[0], expectedEntries[0].quads[0]);
+ shouldBeClientRect('viewport', changes[0].viewport, expectedEntries[0].viewport);
+ shouldBe('entries[0].target', 'expectedEntries[0].target');
+ testRunner.notifyDone();
+ }
+
+ var config = { entryTypes: ['mark', 'measure'] };
ojan 2015/09/21 03:49:08 I think this is probably leftover from the test ca
MikeB 2015/09/24 19:04:03 Done.
+ var target_div = document.getElementById('target_div');
+ observer.observe(target_div, config);
+ window.setTimeout(function() { window.scrollBy(0, 400); }, 0);
ojan 2015/09/21 03:49:09 Do you need the setTimeout? I think you should be
+}
+
+description("This tests that IntersectionObserver gets called the right number of times.");
+
+testIntersectionObserver();
+testRunner.waitUntilDone();
+</script>

Powered by Google App Engine
This is Rietveld 408576698