Index: LayoutTests/inspector-protocol/css/css-create-stylesheet-and-add-rule.html |
diff --git a/LayoutTests/inspector-protocol/css/css-create-stylesheet-and-add-rule.html b/LayoutTests/inspector-protocol/css/css-create-stylesheet-and-add-rule.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a20e92a510e639b516e8d1b376d70a6b73b75952 |
--- /dev/null |
+++ b/LayoutTests/inspector-protocol/css/css-create-stylesheet-and-add-rule.html |
@@ -0,0 +1,78 @@ |
+<html> |
+<head> |
+<script type="text/javascript" src="../../http/tests/inspector-protocol/resources/protocol-test.js"></script> |
+<script type="text/javascript" src="css-protocol-test.js"></script> |
+<link rel="stylesheet" type="text/css" href="resources/stylesheet.css"></link> |
+<script type="text/javascript"> |
+function test() |
+{ |
+ var frameId; |
+ var styleSheetHeader; |
+ |
+ setTimeout(InspectorTest.completeTest.bind(InspectorTest), 2000); |
lushnikov
2014/03/03 12:43:09
1. not needed
2. bad indentation
|
+ |
+ InspectorTest.requestMainFrameId(step2); |
+ |
+ function step2(mainFrameId) |
+ { |
+ frameId = mainFrameId; |
+ InspectorTest.eventHandler["CSS.styleSheetAdded"] = styleSheetAdded; |
+ InspectorTest.sendCSSCommand("enable", {}, function() {}) |
+ } |
+ |
+ function styleSheetAdded(response) |
+ { |
+ var header = response.params.header; |
+ var urlString = header.sourceURL ? " (" + InspectorTest.displayName(header.sourceURL) + ")" : ""; |
+ InspectorTest.log("Style sheet added: " + header.origin + urlString); |
+ if (styleSheetHeader) |
+ return; |
lushnikov
2014/03/03 12:43:09
don't we want to die here?
InspectorTest.log("Err
|
+ |
+ styleSheetHeader = header; |
+ InspectorTest.loadAndDumpMatchingRules("#inspected", step3); |
+ } |
+ |
+ function step3() |
+ { |
+ InspectorTest.log("Adding a rule to the existing stylesheet."); |
lushnikov
2014/03/03 12:43:09
FYI: there's a InspectorTest.runTestSuite method w
|
+ InspectorTest.sendCSSCommand("addRule", { styleSheetId: styleSheetHeader.styleSheetId, selector: "#inspected" }, step4); |
+ } |
+ |
+ function step4() |
+ { |
+ InspectorTest.loadAndDumpMatchingRules("#inspected", step5); |
+ } |
+ |
+ function step5() |
+ { |
+ InspectorTest.log("Creating inspector stylesheet."); |
+ InspectorTest.sendCSSCommand("createStyleSheet", { frameId: frameId }, step6); |
+ } |
+ |
+ function step6(result) |
+ { |
+ InspectorTest.log("Adding a rule to the inspector stylesheet."); |
+ InspectorTest.sendCSSCommand("addRule", { styleSheetId: result.styleSheetId, selector: "#inspected" }, step7); |
+ } |
+ |
+ function step7() |
+ { |
+ InspectorTest.loadAndDumpMatchingRules("#inspected", step8); |
+ } |
+ |
+ function step8() |
+ { |
+ InspectorTest.completeTest(); |
+ } |
+}; |
+ |
+window.addEventListener("DOMContentLoaded", function () { |
+ runTest(); |
+}, false); |
+ |
+</script> |
+</head> |
+<body> |
+<div id="inspected">Inspected contents</div> |
+</body> |
+</html> |