| OLD | NEW |
| (Empty) | |
| 1 <html> |
| 2 <head> |
| 3 |
| 4 <style> |
| 5 #modifyRule { |
| 6 box-sizing: border-box; |
| 7 } |
| 8 |
| 9 #modifyRule { |
| 10 height: 100%; |
| 11 } |
| 12 |
| 13 #modifyRule { |
| 14 width: 100%; |
| 15 } |
| 16 </style> |
| 17 |
| 18 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto
r-protocol-test.js"></script> |
| 19 <script type="text/javascript" src="../../http/tests/inspector-protocol/css-prot
ocol-test.js"></script> |
| 20 <script type="text/javascript" src="../../http/tests/inspector-protocol/dom-prot
ocol-test.js"></script> |
| 21 <script type="text/javascript"> |
| 22 |
| 23 function test() |
| 24 { |
| 25 var documentNodeId; |
| 26 |
| 27 InspectorTest.requestDocumentNodeId(onDocumentNodeId); |
| 28 |
| 29 function onDocumentNodeId(nodeId) |
| 30 { |
| 31 documentNodeId = nodeId; |
| 32 InspectorTest.sendCommandOrDie("DOM.enable", {}); |
| 33 InspectorTest.sendCommandOrDie("CSS.enable", {}, function() { |
| 34 InspectorTest.sendCommandOrDie("CSS.startRuleUsageTracking", {}, ()
=> |
| 35 { testModifyRule(); }) |
| 36 }); |
| 37 } |
| 38 |
| 39 function testModifyRule() |
| 40 { |
| 41 InspectorTest.evaluateInPage("document.styleSheets[0].rules[0].style.set
Property('color', 'red')"); |
| 42 InspectorTest.evaluateInPage("document.styleSheets[0].rules[2].style.set
Property('color', 'blue')"); |
| 43 InspectorTest.evaluateInPage("document.styleSheets[0].rules[1].style.set
Property('color', 'green')"); |
| 44 |
| 45 InspectorTest.sendCommandOrDie("CSS.stopRuleUsageTracking", {}, ruleList
Loaded); |
| 46 function ruleListLoaded(result) { |
| 47 if(!result) { |
| 48 return; |
| 49 } |
| 50 var rules = result.ruleUsage; |
| 51 var usedLines = rules.filter(rule => rule.used); |
| 52 var unusedLines = rules.filter(rule => !rule.used); |
| 53 |
| 54 usedLines.sort(); |
| 55 unusedLines.sort(); |
| 56 InspectorTest.log("=== Size of array: " + rules.length); |
| 57 InspectorTest.log(" Number of used Rules: " + usedLines.length); |
| 58 for(var line of usedLines) |
| 59 InspectorTest.log(line.range.startLine); |
| 60 |
| 61 InspectorTest.log(" Number of unused Rules: " + unusedLines.length
); |
| 62 for(var line of unusedLines) |
| 63 InspectorTest.log(line.range.startLine); |
| 64 |
| 65 InspectorTest.completeTest(); |
| 66 } |
| 67 } |
| 68 } |
| 69 |
| 70 </script> |
| 71 </head> |
| 72 <body onload="runTest();"> |
| 73 <p>The test verifies that CSS.stopRuleUsageTracking doesn't crash when used conc
urrently with the CSSOM modifications.</p> |
| 74 <article id="modifyRule"></article> |
| 75 </body> |
| 76 </html> |
| OLD | NEW |