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

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

Issue 1817693002: Support edge-inclusive intersections in mapToVisibleRectInAncestorSpace (Closed) Base URL: https://chromium.googlesource.com/chromium/src@intersection-observer-idle-callback
Patch Set: compiler warning fix Created 4 years, 9 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 var observer = new IntersectionObserver(changes => { entries = entries.concat(ch anges) }, {}); 12 var observer = new IntersectionObserver(changes => { entries = entries.concat(ch anges) }, {});
13 13
14 onload = function() { 14 onload = function() {
15 observer.observe(target); 15 observer.observe(target);
16 entries = entries.concat(observer.takeRecords()); 16 entries = entries.concat(observer.takeRecords());
17 shouldBeEqualToNumber("entries.length", 0); 17 shouldBeEqualToNumber("entries.length", 0);
18 document.scrollingElement.scrollTop = 300; 18 document.scrollingElement.scrollTop = 300;
19 // See README for explanation of double RAF. 19 // See README for explanation of double RAF.
20 requestAnimationFrame(() => { requestAnimationFrame(step1) }); 20 requestAnimationFrame(() => { requestAnimationFrame(step1) });
21 }; 21 };
22 22
23 function step1() { 23 function step1() {
24 entries = entries.concat(observer.takeRecords()); 24 entries = entries.concat(observer.takeRecords());
25 shouldBeEqualToNumber("entries.length", 1); 25 shouldBeEqualToNumber("entries.length", 1);
26 if (entries.length > 0) { 26 if (entries.length > 0) {
27 shouldBeEqualToNumber("entries[0].boundingClientRect.left", 8); 27 shouldBeEqualToNumber("entries[0].boundingClientRect.left", 8);
28 shouldBeEqualToNumber("entries[0].boundingClientRect.right", 9); 28 shouldBeEqualToNumber("entries[0].boundingClientRect.right", 8);
29 shouldBeEqualToNumber("entries[0].boundingClientRect.top", 408); 29 shouldBeEqualToNumber("entries[0].boundingClientRect.top", 408);
30 shouldBeEqualToNumber("entries[0].boundingClientRect.bottom", 409); 30 shouldBeEqualToNumber("entries[0].boundingClientRect.bottom", 408);
31 shouldBeEqualToNumber("entries[0].intersectionRect.left", 8); 31 shouldBeEqualToNumber("entries[0].intersectionRect.left", 8);
32 shouldBeEqualToNumber("entries[0].intersectionRect.right", 9); 32 shouldBeEqualToNumber("entries[0].intersectionRect.right", 8);
33 shouldBeEqualToNumber("entries[0].intersectionRect.top", 408); 33 shouldBeEqualToNumber("entries[0].intersectionRect.top", 408);
34 shouldBeEqualToNumber("entries[0].intersectionRect.bottom", 409); 34 shouldBeEqualToNumber("entries[0].intersectionRect.bottom", 408);
35 shouldBeEqualToNumber("entries[0].rootBounds.left", 0); 35 shouldBeEqualToNumber("entries[0].rootBounds.left", 0);
36 shouldBeEqualToNumber("entries[0].rootBounds.right", 785); 36 shouldBeEqualToNumber("entries[0].rootBounds.right", 785);
37 shouldBeEqualToNumber("entries[0].rootBounds.top", 0); 37 shouldBeEqualToNumber("entries[0].rootBounds.top", 0);
38 shouldBeEqualToNumber("entries[0].rootBounds.bottom", 600); 38 shouldBeEqualToNumber("entries[0].rootBounds.bottom", 600);
39 shouldEvaluateToSameObject("entries[0].target", target); 39 shouldEvaluateToSameObject("entries[0].target", target);
40 40
41 // ClientRect members of IntersectionObserverEntry should be stable. 41 // ClientRect members of IntersectionObserverEntry should be stable.
42 shouldEvaluateToSameObject("entries[0].boundingClientRect", entries[0].bound ingClientRect); 42 shouldEvaluateToSameObject("entries[0].boundingClientRect", entries[0].bound ingClientRect);
43 shouldEvaluateToSameObject("entries[0].intersectionRect", entries[0].interse ctionRect); 43 shouldEvaluateToSameObject("entries[0].intersectionRect", entries[0].interse ctionRect);
44 shouldEvaluateToSameObject("entries[0].rootBounds", entries[0].rootBounds); 44 shouldEvaluateToSameObject("entries[0].rootBounds", entries[0].rootBounds);
45 } 45 }
46 document.scrollingElement.scrollTop = 100; 46 document.scrollingElement.scrollTop = 100;
47 requestAnimationFrame(step2); 47 requestAnimationFrame(step2);
48 } 48 }
49 49
50 function step2() { 50 function step2() {
51 entries = entries.concat(observer.takeRecords()); 51 entries = entries.concat(observer.takeRecords());
52 shouldBeEqualToNumber("entries.length", 2); 52 shouldBeEqualToNumber("entries.length", 2);
53 if (entries.length > 1) { 53 if (entries.length > 1) {
54 shouldBeEqualToNumber("entries[1].boundingClientRect.left", 8); 54 shouldBeEqualToNumber("entries[1].boundingClientRect.left", 8);
55 shouldBeEqualToNumber("entries[1].boundingClientRect.right", 9); 55 shouldBeEqualToNumber("entries[1].boundingClientRect.right", 8);
56 shouldBeEqualToNumber("entries[1].boundingClientRect.top", 608); 56 shouldBeEqualToNumber("entries[1].boundingClientRect.top", 608);
57 shouldBeEqualToNumber("entries[1].boundingClientRect.bottom", 609); 57 shouldBeEqualToNumber("entries[1].boundingClientRect.bottom", 608);
58 shouldBeEqualToNumber("entries[1].intersectionRect.left", 0); 58 shouldBeEqualToNumber("entries[1].intersectionRect.left", 0);
59 shouldBeEqualToNumber("entries[1].intersectionRect.right", 0); 59 shouldBeEqualToNumber("entries[1].intersectionRect.right", 0);
60 shouldBeEqualToNumber("entries[1].intersectionRect.top", 0); 60 shouldBeEqualToNumber("entries[1].intersectionRect.top", 0);
61 shouldBeEqualToNumber("entries[1].intersectionRect.bottom", 0); 61 shouldBeEqualToNumber("entries[1].intersectionRect.bottom", 0);
62 shouldBeEqualToNumber("entries[1].rootBounds.left", 0); 62 shouldBeEqualToNumber("entries[1].rootBounds.left", 0);
63 shouldBeEqualToNumber("entries[1].rootBounds.right", 785); 63 shouldBeEqualToNumber("entries[1].rootBounds.right", 785);
64 shouldBeEqualToNumber("entries[1].rootBounds.top", 0); 64 shouldBeEqualToNumber("entries[1].rootBounds.top", 0);
65 shouldBeEqualToNumber("entries[1].rootBounds.bottom", 600); 65 shouldBeEqualToNumber("entries[1].rootBounds.bottom", 600);
66 shouldEvaluateToSameObject("entries[1].target", target); 66 shouldEvaluateToSameObject("entries[1].target", target);
67 } 67 }
68 // See README for explanation of this requestIdleCallback. 68 // See README for explanation of this requestIdleCallback.
69 requestIdleCallback(finishJSTest, {timeout: 100}); 69 requestIdleCallback(finishJSTest, {timeout: 100});
70 document.scrollingElement.scrollTop = 0; 70 document.scrollingElement.scrollTop = 0;
71 } 71 }
72 </script> 72 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698