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

Side by Side Diff: third_party/WebKit/LayoutTests/resources/intersection-observer-in-iframe.html

Issue 2560253004: IntersectionObserver: convert tests to testharness.js (Closed)
Patch Set: Address comments Created 3 years, 11 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script>
4 <script src="../resources/intersection-observer-helper-functions.js"></script>
5
6 <div style="height: 200px; width: 100px;"></div>
7 <div id="target" style="background-color: green; width:100px; height:100px"></di v>
8 <div style="height: 200px; width: 100px;"></div>
9
10 <script>
11 setup({message_events: [], output_document: window.parent.document});
12 onload = function() {
13 var entries = [];
14 var observer = new IntersectionObserver(function(changes) { entries = entries. concat(changes) }, {});
15 var target = document.getElementById("target");
16 var scroller = document.scrollingElement;
17 observer.observe(target);
18 entries = entries.concat(observer.takeRecords());
19 var t = async_test("IntersectionObserver in iframe with explicit root.");
20 test(function() { assert_equals(entries.length, 0) }, "No initial notification s.")
21 waitForNotification(t.step_func(step1));
22
23 function step1() {
24 test(function() { assert_equals(entries.length, 0) }, "No notifications afte r first rAF.");
25 scroller.scrollTop = 250;
26 waitForNotification(t.step_func(step2));
27 }
28
29 function step2() {
30 test(function() { assert_equals(entries.length, 1) }, "One notification.");
31 if (entries.length) {
32 test(function() { assert_equals(entries[0].boundingClientRect.left, 8) }, "entries[0].boundingClientRect.left");
33 test(function() { assert_equals(entries[0].boundingClientRect.right, 108) }, "entries[0].boundingClientRect.right");
34 test(function() { assert_equals(entries[0].boundingClientRect.top, -42) }, "entries[0].boundingClientRect.top");
35 test(function() { assert_equals(entries[0].boundingClientRect.bottom, 58) }, "entries[0].boundingClientRect.bottom");
36 test(function() { assert_equals(entries[0].intersectionRect.left, 8) }, "e ntries[0].intersectionRect.left");
37 test(function() { assert_equals(entries[0].intersectionRect.right, 108) }, "entries[0].intersectionRect.right");
38 test(function() { assert_equals(entries[0].intersectionRect.top, 0) }, "en tries[0].intersectionRect.top");
39 test(function() { assert_equals(entries[0].intersectionRect.bottom, 58) }, "entries[0].intersectionRect.bottom");
40 test(function() { assert_equals(entries[0].rootBounds.left, 0) }, "entries [0].rootBounds.left");
41 test(function() { assert_equals(entries[0].rootBounds.right, 800) }, "entr ies[0].rootBounds.right");
42 test(function() { assert_equals(entries[0].rootBounds.top, 0) }, "entries[ 0].rootBounds.top");
43 test(function() { assert_equals(entries[0].rootBounds.bottom, 600) }, "ent ries[0].rootBounds.bottom");
44 test(function() { assert_true(entries[0].target === target) }, "entries[0] .target object identity");
45 }
46 t.done();
47 }
48 };
49 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698