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

Side by Side Diff: third_party/WebKit/LayoutTests/intersection-observer/same-document-zero-size-target.html

Issue 1826323002: IntersectionObserver: use edge-inclusive geometry for intersections. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@intersection-observer-inclusive-geometry
Patch Set: refactor Created 4 years, 8 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/js-test.js"></script> 2 <script src="../resources/js-test.js"></script>
3 <script src="helper-functions.js"></script> 3 <script src="helper-functions.js"></script>
4 <div style="width:100%; height:700px;"></div> 4 <div style="width:100%; height:700px;"></div>
5 <div id="target" style="background-color: green; width:0px; height:0px"></div> 5 <div id="target" style="background-color: green; width:0px; height:0px"></div>
6 <div style="width:100%; height:700px;"></div> 6 <div style="width:100%; height:700px;"></div>
7 7
8 <script> 8 <script>
9 description("Iintersection observer test with zero-size target element."); 9 description("Iintersection observer test with zero-size target element.");
10 var target = document.getElementById("target"); 10 var target = document.getElementById("target");
11 var entries = []; 11 var entries = [];
12 observer_callback = function(changes) { 12 observer_callback = function(changes) {
13 for (var i in changes) 13 for (var i in changes)
14 entries.push(changes[i]); 14 entries.push(changes[i]);
15 }; 15 };
16 var observer = new IntersectionObserver(observer_callback, {}); 16 var observer = new IntersectionObserver(observer_callback, {});
17 observer.observe(target); 17 observer.observe(target);
18 18
19 onload = function() { 19 onload = function() {
20 shouldBeEqualToNumber("entries.length", 0); 20 shouldBeEqualToNumber("entries.length", 0);
21 document.scrollingElement.scrollTop = 300; 21 document.scrollingElement.scrollTop = 300;
22 requestAnimationFrame(step1); 22 requestAnimationFrame(step1);
23 }; 23 };
24 24
25 function step1() { 25 function step1() {
26 setTimeout(function() { 26 setTimeout(function() {
27 shouldBeEqualToNumber("entries.length", 1); 27 shouldBeEqualToNumber("entries.length", 1);
28 shouldBeEqualToNumber("entries[0].boundingClientRect.left", 8); 28 shouldBeEqualToNumber("entries[0].boundingClientRect.left", 8);
29 shouldBeEqualToNumber("entries[0].boundingClientRect.right", 9); 29 shouldBeEqualToNumber("entries[0].boundingClientRect.right", 8);
30 shouldBeEqualToNumber("entries[0].boundingClientRect.top", 408); 30 shouldBeEqualToNumber("entries[0].boundingClientRect.top", 408);
31 shouldBeEqualToNumber("entries[0].boundingClientRect.bottom", 409); 31 shouldBeEqualToNumber("entries[0].boundingClientRect.bottom", 408);
32 shouldBeEqualToNumber("entries[0].intersectionRect.left", 8); 32 shouldBeEqualToNumber("entries[0].intersectionRect.left", 8);
33 shouldBeEqualToNumber("entries[0].intersectionRect.right", 9); 33 shouldBeEqualToNumber("entries[0].intersectionRect.right", 8);
34 shouldBeEqualToNumber("entries[0].intersectionRect.top", 408); 34 shouldBeEqualToNumber("entries[0].intersectionRect.top", 408);
35 shouldBeEqualToNumber("entries[0].intersectionRect.bottom", 409); 35 shouldBeEqualToNumber("entries[0].intersectionRect.bottom", 408);
36 shouldBeEqualToNumber("entries[0].rootBounds.left", 0); 36 shouldBeEqualToNumber("entries[0].rootBounds.left", 0);
37 shouldBeEqualToNumber("entries[0].rootBounds.right", 785); 37 shouldBeEqualToNumber("entries[0].rootBounds.right", 785);
38 shouldBeEqualToNumber("entries[0].rootBounds.top", 0); 38 shouldBeEqualToNumber("entries[0].rootBounds.top", 0);
39 shouldBeEqualToNumber("entries[0].rootBounds.bottom", 600); 39 shouldBeEqualToNumber("entries[0].rootBounds.bottom", 600);
40 shouldEvaluateToSameObject("entries[0].target", target); 40 shouldEvaluateToSameObject("entries[0].target", target);
41 41
42 // ClientRect members of IntersectionObserverEntry should be stable. 42 // ClientRect members of IntersectionObserverEntry should be stable.
43 shouldEvaluateToSameObject("entries[0].boundingClientRect", entries[0].bou ndingClientRect); 43 shouldEvaluateToSameObject("entries[0].boundingClientRect", entries[0].bou ndingClientRect);
44 shouldEvaluateToSameObject("entries[0].intersectionRect", entries[0].inter sectionRect); 44 shouldEvaluateToSameObject("entries[0].intersectionRect", entries[0].inter sectionRect);
45 shouldEvaluateToSameObject("entries[0].rootBounds", entries[0].rootBounds) ; 45 shouldEvaluateToSameObject("entries[0].rootBounds", entries[0].rootBounds) ;
46 46
47 document.scrollingElement.scrollTop = 100; 47 document.scrollingElement.scrollTop = 100;
48 requestAnimationFrame(step2); 48 requestAnimationFrame(step2);
49 }); 49 });
50 } 50 }
51 51
52 function step2() { 52 function step2() {
53 setTimeout(function() { 53 setTimeout(function() {
54 shouldBeEqualToNumber("entries.length", 2); 54 shouldBeEqualToNumber("entries.length", 2);
55 shouldBeEqualToNumber("entries[1].boundingClientRect.left", 8); 55 shouldBeEqualToNumber("entries[1].boundingClientRect.left", 8);
56 shouldBeEqualToNumber("entries[1].boundingClientRect.right", 9); 56 shouldBeEqualToNumber("entries[1].boundingClientRect.right", 8);
57 shouldBeEqualToNumber("entries[1].boundingClientRect.top", 608); 57 shouldBeEqualToNumber("entries[1].boundingClientRect.top", 608);
58 shouldBeEqualToNumber("entries[1].boundingClientRect.bottom", 609); 58 shouldBeEqualToNumber("entries[1].boundingClientRect.bottom", 608);
59 shouldBeEqualToNumber("entries[1].intersectionRect.left", 0); 59 shouldBeEqualToNumber("entries[1].intersectionRect.left", 0);
60 shouldBeEqualToNumber("entries[1].intersectionRect.right", 0); 60 shouldBeEqualToNumber("entries[1].intersectionRect.right", 0);
61 shouldBeEqualToNumber("entries[1].intersectionRect.top", 0); 61 shouldBeEqualToNumber("entries[1].intersectionRect.top", 0);
62 shouldBeEqualToNumber("entries[1].intersectionRect.bottom", 0); 62 shouldBeEqualToNumber("entries[1].intersectionRect.bottom", 0);
63 shouldBeEqualToNumber("entries[1].rootBounds.left", 0); 63 shouldBeEqualToNumber("entries[1].rootBounds.left", 0);
64 shouldBeEqualToNumber("entries[1].rootBounds.right", 785); 64 shouldBeEqualToNumber("entries[1].rootBounds.right", 785);
65 shouldBeEqualToNumber("entries[1].rootBounds.top", 0); 65 shouldBeEqualToNumber("entries[1].rootBounds.top", 0);
66 shouldBeEqualToNumber("entries[1].rootBounds.bottom", 600); 66 shouldBeEqualToNumber("entries[1].rootBounds.bottom", 600);
67 shouldEvaluateToSameObject("entries[1].target", target); 67 shouldEvaluateToSameObject("entries[1].target", target);
68 finishJSTest(); 68 finishJSTest();
69 document.scrollingElement.scrollTop = 0; 69 document.scrollingElement.scrollTop = 0;
70 }); 70 });
71 } 71 }
72 72
73 </script> 73 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698