blob: 19943b72ff74b258779333f6057b052f2b8ea729 [file] [log] [blame]
<html>
<head>
<link rel="stylesheet" href="resources/styles-source-offsets.css">
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/elements-test.js"></script>
<script>
function test()
{
function dumpStyleData(ruleOrStyle)
{
var isRule = !!(ruleOrStyle.style);
var style;
var header = "";
if (isRule) {
if (ruleOrStyle.origin !== "regular")
return;
style = ruleOrStyle.style;
header = ruleOrStyle.selectorList.text + ": " + (ruleOrStyle.selectorList.range ? InspectorTest.rangeText(ruleOrStyle.selectorList.range) : "");
} else {
style = ruleOrStyle;
header = "element.style:";
}
InspectorTest.addResult(header + " " + InspectorTest.rangeText(style.range));
var allProperties = style.cssProperties;
for (var i = 0; i < allProperties.length; ++i) {
var property = allProperties[i];
if (!property.status)
continue;
InspectorTest.addResult("['" + property.name + "':'" + property.value + "'" + (property.priority ? " !important" : "") + (("parsedOk" in property) ? " non-parsed" : "") +"] @" + InspectorTest.rangeText(property.range));
}
}
InspectorTest.selectNodeWithId("mainBody", step1);
var resultStyles = {};
function inlineCallback(error, inlineStyle)
{
if (error) {
InspectorTest.addResult("error: " + error);
InspectorTest.completeTest();
return;
}
resultStyles.inlineStyle = inlineStyle;
}
function matchedCallback(error, matchedCSSRules)
{
if (error) {
InspectorTest.addResult("error: " + error);
InspectorTest.completeTest();
return;
}
resultStyles.matchedCSSRules = matchedCSSRules;
step2();
}
function step1(node)
{
CSSAgent.getInlineStylesForNode(node.id, inlineCallback);
CSSAgent.getMatchedStylesForNode(node.id, matchedCallback);
}
function step2()
{
var matchedCSSRules = resultStyles.matchedCSSRules;
for (var i = 0; i < matchedCSSRules.length; ++i)
dumpStyleData(matchedCSSRules[i].rule);
dumpStyleData(resultStyles.inlineStyle);
InspectorTest.completeTest();
}
}
</script>
<style>
body.mainpage {
text-decoration: none; /* at least one valid property is necessary for WebCore to match a rule */
badproperty: 1badvalue1;
}
</style>
</head>
<body id="mainBody" class="main1 main2 mainpage" onload="runTest()" style="font-weight: normal; width: 80%">
<p>
Tests that proper data and start/end offset positions are reported for CSS style declarations and properties.
</p>
</body>
</html>