LEFT | RIGHT |
1 <!DOCTYPE html><!-- webkit-test-runner [ enableIntersectionObserver=true ] --> | 1 <!DOCTYPE html><!-- webkit-test-runner [ enableIntersectionObserver=true ] --> |
2 <head> | 2 <head> |
3 <title>IntersectionObserverEntry interface tests.</title> | 3 <title>IntersectionObserverEntry interface tests.</title> |
4 <link rel="author" title="Simon Fraser" href="mailto:simon.fraser@apple.com"
/> | 4 <link rel="author" title="Simon Fraser" href="mailto:simon.fraser@apple.com"
/> |
5 <link rel="help" href="https://wicg.github.io/IntersectionObserver/"> | 5 <link rel="help" href="https://wicg.github.io/IntersectionObserver/"> |
6 <script src="../resources/testharness.js"></script> | 6 <script src="../resources/testharness.js"></script> |
7 <script src="../resources/testharnessreport.js"></script> | 7 <script src="../resources/testharnessreport.js"></script> |
8 </head> | 8 </head> |
9 <body> | 9 <body> |
10 <script> | 10 <script> |
11 | 11 |
12 var entryInit = { | 12 var entryInit = { |
13 time: 9999, | 13 time: 9999, |
14 rootBounds: { x: 10, y: 12.5, width: 130, height: 140 }, | 14 rootBounds: { x: 10, y: 12.5, width: 130, height: 140 }, |
15 boundingClientRect: { x: 110, y: 112.7, width: 1130, height: 1140 }, | 15 boundingClientRect: { x: 110, y: 112.7, width: 1130, height: 1140 }, |
16 intersectionRect: { x: 210, y: 212, width: 2130, height: 2140 }, | 16 intersectionRect: { x: 210, y: 212, width: 2130, height: 2140 }, |
| 17 isIntersecting: true, |
| 18 intersectionRatio: 0.35, |
17 target: document.body | 19 target: document.body |
18 }; | 20 }; |
19 | 21 |
20 test(function() { | 22 test(function() { |
21 assert_class_string(new IntersectionObserverEntry(entryInit), 'Intersect
ionObserverEntry'); | 23 assert_class_string(new IntersectionObserverEntry(entryInit), 'Intersect
ionObserverEntry'); |
22 },'Constructor0'); | 24 },'Constructor0'); |
23 test(function() { | 25 test(function() { |
24 var entry = new IntersectionObserverEntry(entryInit); | 26 var entry = new IntersectionObserverEntry(entryInit); |
25 assert_equals(entry.time, 9999); | 27 assert_equals(entry.time, 9999); |
26 },'ConstructorTime'); | 28 },'ConstructorTime'); |
27 test(function() { | 29 test(function() { |
28 var entry = new IntersectionObserverEntry(entryInit); | 30 var entry = new IntersectionObserverEntry(entryInit); |
29 assert_equals(JSON.stringify(entry.rootBounds), '{"x":10,"y":12.5,"width
":130,"height":140,"top":12.5,"right":140,"bottom":152.5,"left":10}'); | 31 assert_equals(JSON.stringify(entry.rootBounds), '{"x":10,"y":12.5,"width
":130,"height":140,"top":12.5,"right":140,"bottom":152.5,"left":10}'); |
30 assert_class_string(entry.rootBounds, 'DOMRectReadOnly'); | 32 assert_class_string(entry.rootBounds, 'DOMRectReadOnly'); |
31 },'ConstructorRootBounds'); | 33 },'ConstructorRootBounds'); |
32 test(function() { | 34 test(function() { |
33 var entry = new IntersectionObserverEntry(entryInit); | 35 var entry = new IntersectionObserverEntry(entryInit); |
34 assert_class_string(entry.boundingClientRect, 'DOMRectReadOnly'); | 36 assert_class_string(entry.boundingClientRect, 'DOMRectReadOnly'); |
35 assert_equals(JSON.stringify(entry.boundingClientRect), '{"x":110,"y":11
2.7,"width":1130,"height":1140,"top":112.7,"right":1240,"bottom":1252.7,"left":1
10}'); | 37 assert_equals(JSON.stringify(entry.boundingClientRect), '{"x":110,"y":11
2.7,"width":1130,"height":1140,"top":112.7,"right":1240,"bottom":1252.7,"left":1
10}'); |
36 },'ConstructorBoundingClientRect'); | 38 },'ConstructorBoundingClientRect'); |
37 test(function() { | 39 test(function() { |
38 var entry = new IntersectionObserverEntry(entryInit); | 40 var entry = new IntersectionObserverEntry(entryInit); |
39 assert_class_string(entry.intersectionRect, 'DOMRectReadOnly'); | 41 assert_class_string(entry.intersectionRect, 'DOMRectReadOnly'); |
40 assert_equals(JSON.stringify(entry.intersectionRect), '{"x":210,"y":212,
"width":2130,"height":2140,"top":212,"right":2340,"bottom":2352,"left":210}'); | 42 assert_equals(JSON.stringify(entry.intersectionRect), '{"x":210,"y":212,
"width":2130,"height":2140,"top":212,"right":2340,"bottom":2352,"left":210}'); |
41 },'ConstructorIntersectionRect'); | 43 },'ConstructorIntersectionRect'); |
42 test(function() { | 44 test(function() { |
43 var entry = new IntersectionObserverEntry(entryInit); | 45 var entry = new IntersectionObserverEntry(entryInit); |
| 46 assert_equals(entry.isIntersecting, true); |
| 47 },'ConstructorIsIntersecting'); |
| 48 test(function() { |
| 49 var entry = new IntersectionObserverEntry(entryInit); |
| 50 assert_equals(entry.intersectionRatio, 0.35); |
| 51 },'ConstructorIntersectionRatio'); |
| 52 test(function() { |
| 53 var entry = new IntersectionObserverEntry(entryInit); |
44 assert_equals(entry.target, document.body); | 54 assert_equals(entry.target, document.body); |
45 },'ConstructorTime'); | 55 },'ConstructorTarget'); |
46 | 56 |
47 </script> | 57 </script> |
48 </body> | 58 </body> |
49 </html> | 59 </html> |
LEFT | RIGHT |