W3C DOM tests - styleSheet tests

This is element x. It has inline style border: 1px solid #cc0000. Element y is the test style sheet.

Test scripts

currentStyle

alert(x.currentStyle.color)

getComputedStyle

alert(window.getComputedStyle(x,null).color)

style

The color test should not give any result because the color is set by a linked style sheet, and not by inline styles.

alert(x.style.color)

The border test should get or set the element's border.

alert(x.style.border)
x.style.border = '2px dotted #00cccc'

This test should remove the border and enlarge the text. Few browsers support it.

x.style = 'font-size: 150%'

This test should access the color: #00cc00 declaration in the linked style sheet.

alert(y.cssRules[y.cssRules.length-1].style.color)
alert(y.rules[y.rules.length-1].style.color)

Same as above, but now we're trying to set the style.

y.cssRules[y.cssRules.length-1].style.color = '#000000'
y.rules[y.rules.length-1].style.color = '#000000'