OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="../resources/intersection-observer-helper-functions.js"></script> | |
3 <script src="../resources/testharness.js"></script> | 2 <script src="../resources/testharness.js"></script> |
4 <script src="../resources/testharnessreport.js"></script> | 3 <script src="../resources/testharnessreport.js"></script> |
| 4 <script src="./resources/intersection-observer-test-utils.js"></script> |
5 | 5 |
6 <title>Ensure that a hidden zero-area element is treated correctly</title> | 6 <style> |
| 7 pre, #log { |
| 8 position: absolute; |
| 9 top: 0; |
| 10 left: 200px; |
| 11 } |
| 12 #target { |
| 13 width: 0px; |
| 14 height: 0px; |
| 15 position: fixed; |
| 16 top: -1000px; |
| 17 } |
| 18 </style> |
7 | 19 |
8 <div id='target' style='width: 0px; height: 0px; position: fixed; top: -1000px'<
/div>" | 20 <div id='target'></div> |
9 | 21 |
10 <script> | 22 <script> |
11 'use strict'; | 23 var entries = []; |
12 | 24 |
13 async_test(t => { | 25 runTestCycle(function() { |
14 let target = document.getElementById('target'); | 26 assert_equals(window.innerWidth, 800, "Window must be 800 pixels wide."); |
15 let entries = []; | 27 assert_equals(window.innerHeight, 600, "Window must be 600 pixels high."); |
16 new IntersectionObserver(changes => { | 28 |
17 entries.push(...changes); | 29 var target = document.getElementById('target'); |
18 }).observe(target); | 30 assert_true(!!target, "target exists"); |
19 waitForNotification(t.step_func_done(() => { | 31 var observer = new IntersectionObserver(function(changes) { |
20 // Since the element is initially assumed to be hidden, there are no entries
. | 32 entries = entries.concat(changes) |
21 assert_equals(entries.length, 0); | 33 }); |
22 })); | 34 observer.observe(target); |
23 }); | 35 entries = entries.concat(observer.takeRecords()); |
| 36 assert_equals(entries.length, 0, "No initial notifications."); |
| 37 runTestCycle(step0, "First rAF should not generate a notification."); |
| 38 }, "No intersecting observations should be sent for a zero-area hidden target.")
; |
| 39 |
| 40 function step0() { |
| 41 assert_equals(entries.length, 0, "No notifications after first rAF."); |
| 42 } |
24 </script> | 43 </script> |
OLD | NEW |