canvas-as-container-006.html (1127B)
1 <!doctype html> 2 <title>CSS Container Queries Test: Absolute positioned canvas as dynamic size container for focusable child with display</title> 3 <link rel="help" href="https://drafts.csswg.org/css-conditional-5/#size-container"> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script src="support/cq-testcommon.js"></script> 7 <style> 8 canvas { 9 display: block; 10 position: absolute; 11 width: 100px; 12 height: 100px; 13 container-type: size; 14 } 15 #target { display: none; } 16 @container (width = 200px) { 17 #target { display: block; } 18 } 19 </style> 20 <p>Test passes if there is a filled green square.</p> 21 <canvas id="canvas"> 22 <div id="target" tabIndex="1"></div> 23 </canvas> 24 <script> 25 setup(() => assert_implements_size_container_queries()); 26 27 test(() => { 28 target.focus(); 29 assert_not_equals(document.activeElement, target); 30 }, "Initially display:none, not focusable"); 31 32 test(() => { 33 canvas.style.width = "200px"; 34 target.focus(); 35 assert_equals(document.activeElement, target); 36 }, "Focusable after container size change"); 37 </script>