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

Side by Side Diff: third_party/WebKit/LayoutTests/intersection-observer/iframe-no-root.html

Issue 2645283008: IntersectionObserver: Always send an initial notification. (Closed)
Patch Set: Fix unit test Created 3 years, 10 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
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script> 2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script> 3 <script src="../resources/testharnessreport.js"></script>
4 <script src="./resources/intersection-observer-test-utils.js"></script> 4 <script src="./resources/intersection-observer-test-utils.js"></script>
5 5
6 <style> 6 <style>
7 pre, #log { 7 pre, #log {
8 position: absolute; 8 position: absolute;
9 top: 0; 9 top: 0;
10 left: 200px; 10 left: 200px;
(...skipping 23 matching lines...) Expand all
34 assert_equals(window.innerHeight, 600, "Window must be 600 pixels high."); 34 assert_equals(window.innerHeight, 600, "Window must be 600 pixels high.");
35 35
36 target = iframe.contentDocument.getElementById("target"); 36 target = iframe.contentDocument.getElementById("target");
37 assert_true(!!target, "Target element exists."); 37 assert_true(!!target, "Target element exists.");
38 var observer = new IntersectionObserver(function(changes) { 38 var observer = new IntersectionObserver(function(changes) {
39 entries = entries.concat(changes) 39 entries = entries.concat(changes)
40 }); 40 });
41 observer.observe(target); 41 observer.observe(target);
42 entries = entries.concat(observer.takeRecords()); 42 entries = entries.concat(observer.takeRecords());
43 assert_equals(entries.length, 0, "No initial notifications."); 43 assert_equals(entries.length, 0, "No initial notifications.");
44 runTestCycle(step0, "No notifications after first rAF."); 44 runTestCycle(step0, "First rAF.");
45 }, "Observer with the implicit root; target in a same-origin iframe."); 45 }, "Observer with the implicit root; target in a same-origin iframe.");
46 }; 46 };
47 47
48 function step0() { 48 function step0() {
49 document.scrollingElement.scrollTop = 200; 49 document.scrollingElement.scrollTop = 200;
50 runTestCycle(step1, "document.scrollingElement.scrollTop = 200"); 50 runTestCycle(step1, "document.scrollingElement.scrollTop = 200");
51 assert_equals(entries.length, 0, "entries.length == 0"); 51 checkLastEntry(entries, 0, [8, 108, 208, 308, 0, 0, 0, 0, 0, 785, 0, 600, targ et]);
52 } 52 }
53 53
54 function step1() { 54 function step1() {
55 iframe.contentDocument.scrollingElement.scrollTop = 250; 55 iframe.contentDocument.scrollingElement.scrollTop = 250;
56 runTestCycle(step2, "iframe.contentDocument.scrollingElement.scrollTop = 250") ; 56 runTestCycle(step2, "iframe.contentDocument.scrollingElement.scrollTop = 250") ;
57 assert_equals(entries.length, 0, "entries.length == 0"); 57 assert_equals(entries.length, 1, "entries.length == 1");
58 } 58 }
59 59
60 function step2() { 60 function step2() {
61 document.scrollingElement.scrollTop = 100; 61 document.scrollingElement.scrollTop = 100;
62 runTestCycle(step3, "document.scrollingElement.scrollTop = 100"); 62 runTestCycle(step3, "document.scrollingElement.scrollTop = 100");
63 checkLastEntry(entries, 0, [8, 108, -42, 58, 8, 108, 0, 58, 0, 785, 0, 600, ta rget]); 63 checkLastEntry(entries, 1, [8, 108, -42, 58, 8, 108, 0, 58, 0, 785, 0, 600, ta rget]);
64 } 64 }
65 65
66 function step3() { 66 function step3() {
67 checkLastEntry(entries, 1, [8, 108, -42, 58, 0, 0, 0, 0, 0, 785, 0, 600, targe t]); 67 checkLastEntry(entries, 2, [8, 108, -42, 58, 0, 0, 0, 0, 0, 785, 0, 600, targe t]);
68 document.scrollingElement.scrollTop = 0; 68 document.scrollingElement.scrollTop = 0;
69 } 69 }
70 </script> 70 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698