Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <title>Position value 'sticky' should be a valid value</title> | |
| 3 <link rel="help" href="https://www.w3.org/TR/css-position-3/#position-property" /> | |
| 4 <meta name="assert" content="This test checks that setting position to 'sticky' | |
| 5 should be allowed." /> | |
| 6 | |
| 7 <script src="/resources/testharness.js"></script> | |
| 8 <script src="/resources/testharnessreport.js"></script> | |
| 9 | |
| 10 <!-- We need something to create elements in. --> | |
| 11 <body></body> | |
| 12 | |
| 13 <script> | |
| 14 // Sticky is valid for all elements except table-column-group and table-column. | |
| 15 const VALID_STICKY_DISPLAY_TYPES = [ | |
| 16 'block', | |
| 17 'inline', | |
| 18 'run-in', | |
| 19 'flow', | |
| 20 'flow-root', | |
| 21 'table', | |
| 22 'flex', | |
| 23 'grid', | |
| 24 'ruby', | |
| 25 'subgrid', | |
| 26 'list-item', | |
| 27 'table-row-group', | |
| 28 'table-header-group', | |
| 29 'table-footer-group', | |
| 30 'table-row', | |
| 31 'table-cell', | |
| 32 'table-caption', | |
| 33 'ruby-base', | |
| 34 'ruby-text', | |
| 35 'ruby-base-container', | |
| 36 'ruby-text-container', | |
| 37 'contents', | |
| 38 'none', | |
| 39 ]; | |
| 40 | |
| 41 const INVALID_STICKY_DISPLAY_TYPES = [ | |
| 42 'table-column-group', | |
| 43 'table-column', | |
| 44 ]; | |
| 45 | |
| 46 test(() => { | |
| 47 for (displayValue of VALID_STICKY_DISPLAY_TYPES) { | |
| 48 // The default display value for a <div> is 'block', so even if the browser | |
| 49 // under test does not support the tested display value it should still | |
| 50 // allow sticky. | |
| 51 let div = document.createElement('div'); | |
| 52 let style = `position: sticky; display: ${displayValue};`; | |
|
flackr
2017/06/07 16:46:56
My only concern is whether any of these require a
smcgruer
2017/06/07 20:24:51
Tested, they're all good.
| |
| 53 div.setAttribute('style', style); | |
| 54 document.body.appendChild(div); | |
| 55 | |
| 56 assert_equals(getComputedStyle(div).position, 'sticky', | |
| 57 `Expected sticky to be valid for display: ${displayValue}`); | |
| 58 document.body.removeChild(div); | |
| 59 } | |
| 60 | |
| 61 for (displayValue of INVALID_STICKY_DISPLAY_TYPES) { | |
| 62 let div = document.createElement('div'); | |
| 63 let style = `position: sticky; display: ${displayValue};`; | |
| 64 div.setAttribute('style', style); | |
| 65 document.body.appendChild(div); | |
| 66 | |
| 67 assert_not_equals(getComputedStyle(div).position, 'sticky', | |
| 68 `Expected sticky to be invalid for display: ${displayValue}`); | |
| 69 document.body.removeChild(div); | |
| 70 } | |
| 71 }, 'The value of sticky for the position property should be parsed correctly'); | |
| 72 </script> | |
| 73 | |
| OLD | NEW |