summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/dom/css-dom-read.html
blob: 99b192faf82f72d2eed31e713532e41ffa8dedd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<html>
<head>
<style>.one { display: block; }
.two { display: inline; }
.three { display: list-item; list-style-type: square; margin-left: 3em; }
.four { display: none; color: red; }
I { display: block; }
</style>
<script>
function test() {
    if (window.testRunner)
        testRunner.dumpAsText();

    t = document.createTextNode(document.getElementsByTagName('style').item(0).firstChild.nodeValue);
    document.getElementById('docStyle').appendChild(t);

    styleSheet = document.styleSheets.item(0)
    
    s = ""
    for (i = 0; i < styleSheet.cssRules.length; i++) {
        rule = styleSheet.cssRules.item(i);
        switch (rule.type) {
        case CSSRule.STYLE_RULE:		
            s += rule.selectorText + ' { ';
            style = rule.style;
            for (j = 0; j < style.length; j++) {
                    s += style.item(j) + ': ' + style.getPropertyValue(style.item(j))+ '; ';
            }
            s += '}\n';
        }
    }
    
    document.getElementById('serializedStyle').appendChild(document.createTextNode(s));
}
</script>
</head>
<body onload="test();">
<div>Style as specified in the style element:</div>
<pre id="docStyle"></pre>
<div>Serialized style, using CSS DOM:</div>
<pre id="serializedStyle"></pre>
</body>
</html>