LEFT | RIGHT |
1 <!DOCTYPE html><!-- webkit-test-runner [ enableIntersectionObserver=true ] --> | 1 <!DOCTYPE html><!-- webkit-test-runner [ enableIntersectionObserver=true ] --> |
2 <head> | 2 <head> |
3 <title>IntersectionObserver interface tests.</title> | 3 <title>IntersectionObserver 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 test(function() { | 12 test(function() { |
13 assert_class_string(new IntersectionObserver(function() {}), 'Intersecti
onObserver'); | 13 assert_class_string(new IntersectionObserver(function() {}), 'Intersecti
onObserver'); |
14 },'Constructor0'); | 14 },'Constructor0'); |
15 test(function() { | 15 test(function() { |
16 var observer = new IntersectionObserver(function() {}); | 16 var observer = new IntersectionObserver(function() {}); |
17 assert_equals(observer.rootMargin, '0px'); | 17 assert_equals(observer.rootMargin, '0px 0px 0px 0px'); |
18 },'DefaultRootMargin'); | 18 },'DefaultRootMargin'); |
19 test(function() { | 19 test(function() { |
20 var observer = new IntersectionObserver(function() {}); | 20 var observer = new IntersectionObserver(function() {}); |
21 assert_equals(observer.root, null); | 21 assert_equals(observer.root, null); |
22 },'DefaultRoot'); | 22 },'DefaultRoot'); |
23 test(function() { | 23 test(function() { |
24 var observer = new IntersectionObserver(function() {}); | 24 var observer = new IntersectionObserver(function() {}); |
25 assert_array_equals(observer.thresholds, [0]); | 25 assert_array_equals(observer.thresholds, [0]); |
26 },'DefaultThresholds'); | 26 },'DefaultThresholds'); |
27 test(function() { | 27 test(function() { |
28 var observer = new IntersectionObserver(function() {}, { rootMargin: '33
em 10px -120px 3pt' }); | 28 var observer = new IntersectionObserver(function() {}, { rootMargin: '33
% 10px -120px 3%' }); |
29 assert_equals(observer.rootMargin, '33em 10px -120px 3pt'); | 29 assert_equals(observer.rootMargin, '33% 10px -120px 3%'); |
30 },'ExplicitRootMargin'); | 30 },'ExplicitRootMargin'); |
31 test(function() { | 31 test(function() { |
32 var observer = new IntersectionObserver(function() {}, { root: document.
body }); | 32 var observer = new IntersectionObserver(function() {}, { root: document.
body }); |
33 assert_equals(observer.root, document.body); | 33 assert_equals(observer.root, document.body); |
34 },'ExplicitRoot'); | 34 },'ExplicitRoot'); |
35 test(function() { | 35 test(function() { |
36 var observer = new IntersectionObserver(function() {}, { threshold: 0.4
5 }); | 36 var observer = new IntersectionObserver(function() {}, { threshold: 0.4
5 }); |
37 assert_array_equals(observer.thresholds, [0.45]); | 37 assert_array_equals(observer.thresholds, [0.45]); |
38 },'ExplicitThreshold'); | 38 },'ExplicitThreshold'); |
39 test(function() { | 39 test(function() { |
40 var observer = new IntersectionObserver(function() {}, { threshold: [0,
0.33333678, 0.5, 0.76645] }); | 40 var observer = new IntersectionObserver(function() {}, { threshold: [0,
0.33333678, 0.5, 0.76645] }); |
41 assert_array_equals(observer.thresholds, [0, 0.33333678, 0.5, 0.76645]); | 41 assert_array_equals(observer.thresholds, [0, 0.33333678, 0.5, 0.76645]); |
42 },'ExplicitThresholds'); | 42 },'ExplicitThresholds'); |
43 </script> | 43 </script> |
44 </body> | 44 </body> |
45 </html> | 45 </html> |
LEFT | RIGHT |