Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/inspector-protocol/css/css-get-rule-list.html |
| diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/css/css-get-rule-list.html b/third_party/WebKit/LayoutTests/inspector-protocol/css/css-get-rule-list.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0e19f0678e65ea0bc3637e28a5b4ea72c091abcb |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/inspector-protocol/css/css-get-rule-list.html |
| @@ -0,0 +1,59 @@ |
| +<html> |
| +<head> |
| +<script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script> |
| +<script type="text/javascript" src="../../http/tests/inspector-protocol/css-protocol-test.js"></script> |
| +<script type="text/javascript" src="../../http/tests/inspector-protocol/dom-protocol-test.js"></script> |
| +<script type="text/javascript"> |
| +function test() |
| +{ |
| + InspectorTest.sendCommandOrDie("DOM.enable", {}); |
| + InspectorTest.sendCommandOrDie("CSS.enable", {}, () => InspectorTest.runTestSuite(testSuite)); |
| + |
| + var testSuite = [ |
| + function testGetRuleListAfterStartingRecording(next) |
| + { |
| + InspectorTest.sendCommandOrDie("CSS.setSelectorRecording", { enable: true }, () => |
| + { InspectorTest.sendCommandOrDie("CSS.getRuleList", {}, ruleListLoaded); }); |
| + |
| + function ruleListLoaded(result) |
| + { |
| + if(!result) { |
| + next(); |
| + return; |
| + } |
| + var rules = result.CSSRules, usedLines = [], unusedLines = []; |
|
caseq
2016/10/31 19:06:05
nit:
var usedLines = rules.filter(rule => rule.us
|
| + |
| + for (var i = 0; i < rules.length; ++i) |
| + { |
| + if(rules[i].status) |
| + usedLines.push(rules[i].range.startLine); |
| + else |
| + unusedLines.push(rules[i].range.startLine); |
| + } |
| + usedLines.sort(); |
| + unusedLines.sort(); |
| + InspectorTest.log("=== Size of array: " + rules.length); |
| + InspectorTest.log(" Number of used Rules: " + usedLines.length); |
| + for(var i = 0; i < usedLines.length; ++i) |
| + InspectorTest.log(usedLines[i]); |
| + |
| + InspectorTest.log(" Number of unused Rules: " + unusedLines.length); |
| + for(var i = 0; i < unusedLines.length; ++i) |
| + InspectorTest.log(unusedLines[i]); |
| + |
| + next(); |
| + } |
| + } |
| + ]; |
| +} |
| + |
| +</script> |
| +<link rel="stylesheet" href="resources/get-rule-list.css"> |
| +</head> |
| +<body onload="runTest();"> |
| +<h1 class="class">Class Selector</h1> |
| +<p id="id">ID Selector</p> |
| +<div></div> |
| + |
| +</body> |
| +</html> |