| OLD | NEW |
| 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 style="white-space: nowrap;"> | 5 <div style="white-space: nowrap;"> |
| 6 <div style="display: inline-block; width: 1000px; height: 100px"></div> | 6 <div style="display: inline-block; width: 1000px; height: 100px"></div> |
| 7 <div id="target" style="display: inline-block; background-color: green; width:
100px; height:100px"></div> | 7 <div id="target" style="display: inline-block; background-color: green; width:
100px; height:100px"></div> |
| 8 <div style="display: inline-block; width: 1000px; height: 100px"></div> | 8 <div style="display: inline-block; width: 1000px; height: 100px"></div> |
| 9 </div> | 9 </div> |
| 10 <div style="width:100%; height:700px;"></div> | 10 <div style="width:100%; height:700px;"></div> |
| 11 | 11 |
| 12 <script> | 12 <script> |
| 13 description("Intersection observer test with root margin and implicit root."); | 13 description("Intersection observer test with root margin and implicit root."); |
| 14 var target = document.getElementById("target"); | 14 var target = document.getElementById("target"); |
| 15 var entries = []; | 15 var entries = []; |
| 16 | 16 |
| 17 function observer_callback(changes) { | 17 function observer_callback(changes) { |
| 18 for (var i in changes) | 18 for (var i in changes) |
| 19 entries.push(changes[i]); | 19 entries.push(changes[i]); |
| 20 } | 20 } |
| 21 | 21 |
| 22 var observer = new IntersectionObserver(observer_callback, { | 22 var observer = new IntersectionObserver(observer_callback, { |
| 23 rootMargin: "10px 20% 40% 30px" | 23 rootMargin: "10px 20% 40% 30px" |
| 24 }); | 24 }); |
| 25 observer.observe(target); | 25 observer.observe(target); |
| 26 | 26 |
| 27 function step0() { | 27 function step0() { |
| 28 setTimeout(function() { | 28 setTimeout(function() { |
| 29 shouldThrow("new IntersectionObserver(observer_callback, { rootMargin: '1'
})"); | |
| 30 shouldThrow("new IntersectionObserver(observer_callback, { rootMargin: '1e
m' })"); | |
| 31 shouldThrow("new IntersectionObserver(observer_callback, { rootMargin: 'au
to' })"); | |
| 32 shouldNotThrow("new IntersectionObserver(observer_callback, { rootMargin:
'1.4px' })"); | 29 shouldNotThrow("new IntersectionObserver(observer_callback, { rootMargin:
'1.4px' })"); |
| 33 shouldNotThrow("new IntersectionObserver(observer_callback, { rootMargin:
'1.4px 2px' })"); | 30 shouldNotThrow("new IntersectionObserver(observer_callback, { rootMargin:
'1.4px 2px' })"); |
| 34 shouldNotThrow("new IntersectionObserver(observer_callback, { rootMargin:
'1.4px 2px 3%' })"); | 31 shouldNotThrow("new IntersectionObserver(observer_callback, { rootMargin:
'1.4px 2px 3%' })"); |
| 35 shouldNotThrow("new IntersectionObserver(observer_callback, { rootMargin:
'1.4px 2px 3% 40px junk junk junk' })"); | 32 shouldNotThrow("new IntersectionObserver(observer_callback, { rootMargin:
'1.4px 2px 3% 40px junk junk junk' })"); |
| 36 shouldBeEqualToNumber("entries.length", 0); | 33 shouldBeEqualToNumber("entries.length", 0); |
| 37 document.scrollingElement.scrollLeft = 100; | 34 document.scrollingElement.scrollLeft = 100; |
| 38 requestAnimationFrame(step1); | 35 requestAnimationFrame(step1); |
| 39 }); | 36 }); |
| 40 } | 37 } |
| 41 | 38 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 shouldEvaluateToSameObject("entries[1].target", target); | 83 shouldEvaluateToSameObject("entries[1].target", target); |
| 87 | 84 |
| 88 finishJSTest(); | 85 finishJSTest(); |
| 89 document.scrollingElement.scrollLeft = 0; | 86 document.scrollingElement.scrollLeft = 0; |
| 90 document.scrollingElement.scrollTop = 0; | 87 document.scrollingElement.scrollTop = 0; |
| 91 }); | 88 }); |
| 92 } | 89 } |
| 93 | 90 |
| 94 step0(); | 91 step0(); |
| 95 </script> | 92 </script> |
| OLD | NEW |