Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/inspector-protocol/css/cssom-modify-rule-and-get-rule-list.html |
| diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/css/cssom-modify-rule-and-get-rule-list.html b/third_party/WebKit/LayoutTests/inspector-protocol/css/cssom-modify-rule-and-get-rule-list.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e5c6f9b2b6d8b6fc578ef9297f416d77f46f769c |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/inspector-protocol/css/cssom-modify-rule-and-get-rule-list.html |
| @@ -0,0 +1,94 @@ |
| +<html> |
| +<head> |
| + |
| +<style> |
| +#modifyRule { |
| + box-sizing: border-box; |
| +} |
| + |
| +#modifyRule { |
| + height: 100%; |
| +} |
| + |
| +#modifyRule { |
| + width: 100%; |
| +} |
| +</style> |
| + |
| +<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() |
| +{ |
| + var documentNodeId; |
| + |
| + InspectorTest.requestDocumentNodeId(onDocumentNodeId); |
| + |
| + function onDocumentNodeId(nodeId) |
| + { |
| + documentNodeId = nodeId; |
| + InspectorTest.sendCommandOrDie("DOM.enable", {}); |
| + InspectorTest.sendCommandOrDie("CSS.enable", {}, function() { |
| + InspectorTest.sendCommandOrDie("CSS.startRuleUsageTracking", {}, () => |
| + { InspectorTest.runTestSuite(testSuite); }) |
| + }); |
| + } |
| + |
| + var testSuite = [ |
| + function testModifyRule(next) |
| + { |
| + step1(); |
| + |
| + function step1() |
| + { |
| + InspectorTest.evaluateInPage("document.styleSheets[0].rules[0].style.setProperty('color', 'red')"); |
|
caseq
2016/11/08 01:27:48
extract a function in the page called doActions()
|
| + step2(); |
| + } |
| + |
| + function step2() |
| + { |
| + InspectorTest.evaluateInPage("document.styleSheets[0].rules[2].style.setProperty('color', 'blue')"); |
| + step3(); |
| + } |
| + |
| + function step3() |
| + { |
| + InspectorTest.evaluateInPage("document.styleSheets[0].rules[1].style.setProperty('color', 'green')"); |
| + |
| + InspectorTest.sendCommandOrDie("CSS.stopRuleUsageTracking", {}, ruleListLoaded); |
| + function ruleListLoaded(result) { |
| + if(!result) { |
| + next(); |
| + return; |
| + } |
| + var rules = result.ruleUsage; |
| + var usedLines = rules.filter(rule => rule.used); |
| + var unusedLines = rules.filter(rule => !rule.used); |
| + |
| + usedLines.sort(); |
| + unusedLines.sort(); |
| + InspectorTest.log("=== Size of array: " + rules.length); |
| + InspectorTest.log(" Number of used Rules: " + usedLines.length); |
| + for(var line of usedLines) |
| + InspectorTest.log(line.range.startLine); |
| + |
| + InspectorTest.log(" Number of unused Rules: " + unusedLines.length); |
| + for(var line of unusedLines) |
| + InspectorTest.log(line.range.startLine); |
| + |
| + next(); |
| + } |
| + } |
| + } |
| + ]; |
| +} |
| + |
| +</script> |
| +</head> |
| +<body onload="runTest();"> |
| +<p>The test verifies that CSS.stopRuleUsageTracking doesn't crash when used concurrently with the CSSOM modifications.</p> |
| +<article id="modifyRule"></article> |
| +</body> |
| +</html> |