[Release] Webkit-EFL Ver. 2.0_beta_118996_0.6.22
[framework/web/webkit-efl.git] / LayoutTests / inspector / styles / styles-source-offsets.html
1 <html>
2 <head>
3
4 <link rel="stylesheet" href="resources/styles-source-offsets.css">
5
6 <script src="../../http/tests/inspector/inspector-test.js"></script>
7 <script src="../../http/tests/inspector/elements-test.js"></script>
8 <script>
9
10 function test()
11 {
12     function dumpStyleData(ruleOrStyle)
13     {
14         var isRule = !!(ruleOrStyle.style);
15         var style;
16         var header = "";
17         if (isRule) {
18             if (ruleOrStyle.origin !== "regular")
19                 return;
20             style = ruleOrStyle.style;
21             header = ruleOrStyle.selectorText + ": [" + (ruleOrStyle.selectorRange ? ruleOrStyle.selectorRange.start + "-" + ruleOrStyle.selectorRange.end : "")  + "]";
22         } else {
23             style = ruleOrStyle;
24             header = "element.style:";
25         }
26         InspectorTest.addResult(header + " " + InspectorTest.rangeText(style.range));
27         var allProperties = style.cssProperties;
28         for (var i = 0; i < allProperties.length; ++i) {
29             var property = allProperties[i];
30             if (!property.status)
31                 continue;
32             InspectorTest.addResult("['" + property.name + "':'" + property.value + "'" + (property.priority ? " !important" : "") + (("parsedOk" in property) ? " non-parsed" : "") +"] @" + InspectorTest.rangeText(property.range));
33         }
34     }
35     
36     InspectorTest.selectNodeWithId("mainBody", step1);
37
38     var resultStyles = {};
39
40     function inlineCallback(error, inlineStyle)
41     {
42         if (error) {
43              InspectorTest.addResult("error: " + error);
44              InspectorTest.completeTest();
45              return;
46         }
47
48         resultStyles.inlineStyle = inlineStyle;
49     }
50
51     function matchedCallback(error, matchedCSSRules)
52     {
53         if (error) {
54              InspectorTest.addResult("error: " + error);
55              InspectorTest.completeTest();
56              return;
57         }
58         resultStyles.matchedCSSRules = matchedCSSRules;
59         step2();
60     }
61
62     function step1(node)
63     {
64         CSSAgent.getInlineStylesForNode(node.id, inlineCallback);
65         CSSAgent.getMatchedStylesForNode(node.id, matchedCallback);
66     }
67
68     function step2()
69     {
70         var matchedCSSRules = resultStyles.matchedCSSRules;
71         for (var i = 0; i < matchedCSSRules.length; ++i)
72             dumpStyleData(matchedCSSRules[i]);
73         dumpStyleData(resultStyles.inlineStyle);
74         InspectorTest.completeTest();
75     }
76 }
77
78 </script>
79
80 <style>
81
82 body.mainpage {
83     text-decoration: none; /* at least one valid property is necessary for WebCore to match a rule */
84     badproperty: 1badvalue1;
85 }
86
87 </style>
88 </head>
89
90 <body id="mainBody" class="main1 main2 mainpage" onload="runTest()" style="font-weight: normal; width: 80%">
91 <p>
92 Tests that proper data and start/end offset positions are reported for CSS style declarations and properties.
93 </p>
94
95 </body>
96 </html>