legend-display-ruby.html (1775B)
1 <!doctype html> 2 <title>rendered legend and CSS display (ruby)</title> 3 <script src=/resources/testharness.js></script> 4 <script src=/resources/testharnessreport.js></script> 5 <style> 6 legend { width:initial; } 7 </style> 8 <fieldset><legend id="ref">x</legend></fieldset> 9 <fieldset><legend id="test">x</legend></fieldset> 10 <script> 11 const refElm = document.querySelector('#ref'); 12 const refStyle = getComputedStyle(refElm); 13 const testElm = document.querySelector('#test'); 14 // Note that we're not testing "display:run-in" here; it's mentioned in 15 // several CSS specs, but no browser engines appear likely to support it. 16 const values = ['block ruby', 'ruby', 'ruby-base', 'ruby-text', 'ruby-base-container', 'ruby-text-container']; 17 const extraStyle = ['', 'overflow:hidden', 'columns:1', 'overflow:hidden;columns:1']; 18 19 for (const style of extraStyle) { 20 for (const val of values) { 21 test(() => { 22 testElm.style.removeProperty('display'); 23 testElm.style = style; 24 testElm.style.display = val; 25 const computed = getComputedStyle(testElm); 26 // Note that computed value is different from the used value. 27 // E.g., if ruby is not supported, the following assertion will 28 // fail as the computed value of display will be block. 29 // If ruby is supported, computed.display will return "ruby", 30 // but the used value is supposed to be "block ruby". 31 let expected = val; 32 assert_equals(computed.display, expected, `display: ${val} is not supported`); 33 assert_equals(computed.width, refStyle.width, 'width'); 34 assert_equals(testElm.offsetLeft, refElm.offsetLeft, 'offsetLeft'); 35 }, `rendered legend with display: ${val}` + (style == '' ? '' : "; " + style)); 36 } 37 } 38 </script>