Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/inspector-protocol/css/css-collect-class-names.html |
| diff --git a/third_party/WebKit/LayoutTests/inspector-protocol/css/css-collect-class-names.html b/third_party/WebKit/LayoutTests/inspector-protocol/css/css-collect-class-names.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..56e8ee48bbf023dadb9c95ce1345143177ba53e5 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/inspector-protocol/css/css-collect-class-names.html |
| @@ -0,0 +1,69 @@ |
| +<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() |
| +{ |
| + var documentNodeId; |
| + var addedStyleSheetCount = 0; |
| + var styleSheetClasses = []; |
| + InspectorTest.requestDocumentNodeId(onDocumentNodeId); |
| + function onDocumentNodeId(nodeId) |
| + { |
| + InspectorTest.eventHandler["CSS.styleSheetAdded"] = styleSheetAdded; |
| + InspectorTest.sendCommandOrDie("CSS.enable", {}); |
| + } |
| + |
| + function styleSheetAdded(response) |
| + { |
| + var styleSheetId = response.params.header.styleSheetId; |
| + InspectorTest.sendCommandOrDie("CSS.collectClassNamesFromStyleSheet", { styleSheetId: styleSheetId }, onClassNamesCollected); |
| + } |
| + |
| + function finalizeTest() |
| + { |
| + styleSheetClasses.sort(function (a, b) |
| + { |
| + if (a < b) |
|
lushnikov
2016/09/01 20:50:35
isn't default comparator good enough?
ahmetemirercin
2016/09/02 19:59:54
Done.
|
| + return -1 |
| + if (a > b) |
| + return 1; |
| + return 0; |
| + }); |
| + |
| + for (var i = 0; i < styleSheetClasses.length; i++) |
| + InspectorTest.log(styleSheetClasses[i]); |
| + InspectorTest.completeTest(); |
| + |
| + } |
| + |
| + function onClassNamesCollected(response) |
| + { |
| + var classNames = response.classNames; |
| + for(var i=0; i < classNames.length; i++) { |
|
lushnikov
2016/09/01 20:50:35
style: we don't put {} around one-line block
ahmetemirercin
2016/09/02 19:59:54
Done.
|
| + styleSheetClasses.push(classNames[i]); |
| + } |
| + if(++addedStyleSheetCount == 3) |
| + finalizeTest(); |
| + } |
| + |
|
lushnikov
2016/09/01 20:50:35
nit: stray line
ahmetemirercin
2016/09/02 19:59:54
Done.
|
| +}; |
| + |
| +window.addEventListener("DOMContentLoaded", function () { |
| + runTest(); |
| +}, false); |
| + |
| +</script> |
| +<link rel="stylesheet" href="resources/collect-class-names.css"/> |
| +<style> |
| +.inline1{ |
| + font-size: 12px; |
| +} |
| +</style> |
| +</head> |
| +<body> |
| +</body> |
| +</html> |