hit-test-unpainted-element-from-point.html (2140B)
1 <!DOCTYPE html> 2 <title>View transitions: hit test shared element at the real dom location</title> 3 <link rel="help" href="https://drafts.csswg.org/css-view-transitions-1/"> 4 <link rel="author" href="mailto:vmpstr@chromium.org"> 5 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 9 <style> 10 html { view-transition-name: none } 11 #target { 12 width: 100px; 13 height: 100px; 14 contain: paint; 15 view-transition-name: shared; 16 position: relative; 17 z-index: 1; 18 } 19 .before { 20 background: yellow; 21 left: 200px; 22 } 23 .after { 24 background: green; 25 } 26 .after:hover { 27 background: red; 28 } 29 #unrelated { 30 width: 50px; 31 height: 50px; 32 position: relative; 33 top: -50px; 34 background: blue; 35 } 36 37 html::view-transition { 38 pointer-events: none; 39 } 40 html::view-transition-group(*) { 41 pointer-events: auto; 42 } 43 44 html::view-transition-group(shared) { 45 animation-delay: 300s; 46 } 47 html::view-transition-old(shared) { 48 animation: unset; 49 opacity: 1; 50 } 51 html::view-transition-new(shared) { 52 display: none; 53 } 54 </style> 55 56 <div id=target class=before></div> 57 <div id=unrelated></div> 58 59 <script> 60 async_test(t => { 61 assert_implements(document.startViewTransition, "Missing document.startViewTransition"); 62 document.startViewTransition(() => { 63 target.classList.toggle("before"); 64 target.classList.toggle("after"); 65 requestAnimationFrame(async () => { 66 // Check the location of the element, we should get body. 67 t.step(() => assert_equals(document.elementFromPoint(20, 20), document.body)); 68 // Check the location of the pseudo element for the old snapshot, we should get documentElement, 69 // which is the originating element for the pseudo element. 70 t.step(() => assert_equals(document.elementFromPoint(220, 20), document.documentElement)); 71 // Check the spot that used to be covered by the element but now has 72 // unrelated element, which is what we expect to get. 73 t.step(() => assert_equals(document.elementFromPoint(20, 70), unrelated)); 74 t.done(); 75 }); 76 }); 77 }, "hit test should not hit unpainted element, but does hit pseudo and unrelated elements"); 78 </script>