|
| 1 | +<script src="../testing.js"></script> |
| 2 | +<script id=css_style_declaration> |
| 3 | + let style = document.createElement('div').style; |
| 4 | + style.cssText = 'color: red; font-size: 12px; margin: 5px !important;'; |
| 5 | + testing.expectEqual(3, style.length); |
| 6 | + |
| 7 | + testing.expectEqua;('red', style.getPropertyValue('color')); |
| 8 | + testing.expectEqua;('12px', style.getPropertyValue('font-size')); |
| 9 | + testing.expectEqua;('', style.getPropertyValue('unknown-property')); |
| 10 | + |
| 11 | + testing.expectEqual('important', style.getPropertyPriority('margin')); |
| 12 | + testing.expectEqual('', style.getPropertyPriority('color')); |
| 13 | + testing.expectEqual('', style.getPropertyPriority('unknown-property')); |
| 14 | + |
| 15 | + testing.expectEqual('color', style.item(0)); |
| 16 | + testing.expectEqual('font-size', style.item(1)); |
| 17 | + testing.expectEqual('margin', style.item(2)); |
| 18 | + testing.expectEqual('', style.item(3)); |
| 19 | + |
| 20 | + style.setProperty('background-color', 'blue'); |
| 21 | + testing.expectEqual('blue', style.getPropertyValue('background-color')); |
| 22 | + testing.expectEqual(4, style.length); |
| 23 | + |
| 24 | + style.setProperty('color', 'green'); |
| 25 | + testing.expectEqual('green', style.color); |
| 26 | + testing.expectEqual('green', style.getPropertyValue('color')); |
| 27 | + testing.expectEqual(4, style.length); |
| 28 | + |
| 29 | + style.setProperty('padding', '10px', 'important'); |
| 30 | + testing.expectEqual('10px', style.getPropertyValue('padding')); |
| 31 | + testing.expectEqual('important', style.getPropertyPriority('padding')); |
| 32 | + |
| 33 | + style.setProperty('border', '1px solid black', 'IMPORTANT'); |
| 34 | + testing.expectEqual('important', style.getPropertyPriority('border')); |
| 35 | +</script> |
| 36 | + |
| 37 | +<script id=removeProperty> |
| 38 | + testing.expectEqual('green', style.removeProperty('color')); |
| 39 | + testing.expectEqual('', style.getPropertyValue('color')); |
| 40 | + testing.expectEqual(5, style.length) |
| 41 | + |
| 42 | + testing.expectEqual('', style.removeProperty('unknown-property')); |
| 43 | +</script> |
| 44 | + |
| 45 | +<script id=includes> |
| 46 | + testing.expectEqual(false, style.cssText.includes('font-size: 10px;')); |
| 47 | + testing.expectEqual(true, style.cssText.includes('font-size: 12px;')); |
| 48 | + testing.expectEqual(true, style.cssText.includes('margin: 5px !important;')); |
| 49 | + testing.expectEqual(true, style.cssText.includes('padding: 10px !important;')); |
| 50 | + testing.expectEqual(true, style.cssText.includes('border: 1px solid black !important;')); |
| 51 | +</script> |
| 52 | + |
| 53 | +<script id=special_char"> |
| 54 | + style.cssText = 'color: purple; text-align: center;'; |
| 55 | + testing.expectEqual(2, style.length); |
| 56 | + testing.expectEqual('purple', style.getPropertyValue('color')); |
| 57 | + testing.expectEqual('center', style.getPropertyValue('text-align')); |
| 58 | + testing.expectEqual('', style.getPropertyValue('font-size')); |
| 59 | + |
| 60 | + style.setProperty('cont', 'Hello; world!'); |
| 61 | + testing.expectEqual('Hello; world!', style.getPropertyValue('cont')); |
| 62 | + |
| 63 | + style.cssText = 'content: "Hello; world!"; background-image: url("test.png");'; |
| 64 | + testing.expectEqual('"Hello; world!"', style.getPropertyValue('content')); |
| 65 | + testing.expectEqual('url("test.png")', style.getPropertyValue('background-image')); |
| 66 | +</script> |
| 67 | + |
| 68 | +<script id=cssFloat"> |
| 69 | + testing.expectEqual('', style.cssFloat); |
| 70 | + style.cssFloat = 'left'; |
| 71 | + testing.expectEqual('left', style.cssFloat); |
| 72 | + testing.expectEqual('left', style.getPropertyValue('float')); |
| 73 | + |
| 74 | + style.cssFloat = 'right'; |
| 75 | + testing.expectEqual('right', style.cssFloat); |
| 76 | + testing.expectEqual('right', style.getPropertyValue('float')); |
| 77 | + |
| 78 | + style.cssFloat = null; |
| 79 | + testing.expectEqual('', style.cssFloat); |
| 80 | + testing.expectEqual('', style.getPropertyValue('float')); |
| 81 | +</script> |
| 82 | + |
| 83 | +<script id=misc> |
| 84 | + style.setProperty('display', ''); |
| 85 | + testing.expectEqual('', style.getPropertyValue('display')); |
| 86 | + |
| 87 | + style.cssText = ' color : purple ; margin : 10px ; '; |
| 88 | + testing.expectEqual('purple', style.getPropertyValue('color')); |
| 89 | + testing.expectEqual('10px', style.getPropertyValue('margin')); |
| 90 | + |
| 91 | + style.setProperty('border-bottom-left-radius', '5px'); |
| 92 | + testing.expectEqual('5px', style.getPropertyValue('border-bottom-left-radius')); |
| 93 | + |
| 94 | + testing.expectEqual('visible', style.visibility); |
| 95 | + testing.expectEqual('visible', style.getPropertyValue('visibility')); |
| 96 | + |
| 97 | + testing.expectEqual('10px', style.margin); |
| 98 | + style.margin = 'auto'; |
| 99 | + testing.expectEqual('auto', style.margin); |
| 100 | +</script> |
| 101 | + |
0 commit comments