Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector-protocol / css / css-set-inline-style-text.html
blobdbbc96e7bfbcdb113171f6781d6dc3f102845911
1 <html>
2 <head>
3 <link rel="stylesheet" href="resources/set-style-text.css"/>
4 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
5 <script type="text/javascript" src="../../http/tests/inspector-protocol/css-protocol-test.js"></script>
6 <script type="text/javascript" src="../../http/tests/inspector-protocol/dom-protocol-test.js"></script>
7 <script type="text/javascript">
8 function test()
10 var styleSheetId;
11 var documentNodeId;
12 var setStyleText;
13 var verifyProtocolError;
14 var dumpStyleSheet;
16 InspectorTest.sendCommandOrDie("DOM.enable", {});
17 InspectorTest.sendCommandOrDie("CSS.enable", {}, cssWasEnabled);
19 function cssWasEnabled()
21 InspectorTest.sendCommandOrDie("DOM.getDocument", {}, onGotDocument);
24 function onGotDocument(result)
26 documentNodeId = result.root.nodeId;
27 InspectorTest.sendCommandOrDie("DOM.querySelector", { nodeId: documentNodeId, selector: "#inliner" }, onGotNode);
30 function onGotNode(node)
32 InspectorTest.sendCommandOrDie("CSS.getInlineStylesForNode", { nodeId: node.nodeId }, onGotInlineStyles);
35 function onGotInlineStyles(result)
37 styleSheetId = result.inlineStyle.styleSheetId;
38 setStyleText = InspectorTest.setStyleText.bind(InspectorTest, styleSheetId, false);
39 verifyProtocolError = InspectorTest.setStyleText.bind(InspectorTest, styleSheetId, true);
40 dumpStyleSheet = InspectorTest.dumpStyleSheetText.bind(null, styleSheetId);
41 InspectorTest.sendCommandOrDie("CSS.getStyleSheetText", { styleSheetId: styleSheetId }, onInitialStyleSheetText);
44 function dumpAndNext(next)
46 return function()
48 InspectorTest.sendCommandOrDie("CSS.getStyleSheetText", { styleSheetId: styleSheetId }, onReceiveStyleSheetText);
50 function onReceiveStyleSheetText(result)
52 InspectorTest.log("Stylesheet text: " + result.text);
53 InspectorTest.domUndo(next);
58 function onInitialStyleSheetText(result)
60 InspectorTest.log("==== Initial style sheet text ====");
61 InspectorTest.log(result.text);
62 InspectorTest.runTestSuite(testSuite);
65 var testSuite = [
66 function testBasicSetStyle(next)
68 setStyleText({
69 styleSheetId: styleSheetId,
70 range: { startLine: 0, startColumn: 0, endLine: 0, endColumn: 11 },
71 text: "content: 'EDITED'",
72 }, dumpAndNext(next));
75 function testSetStylePoorContent(next)
77 verifyProtocolError({
78 styleSheetId: styleSheetId,
79 range: { startLine: 0, startColumn: 0, endLine: 0, endColumn: 11 },
80 text: "}",
81 }, dumpAndNext(next));
84 function testDeleteStyleBody(next)
86 setStyleText({
87 styleSheetId: styleSheetId,
88 range: { startLine: 0, startColumn: 0, endLine: 0, endColumn: 11 },
89 text: "",
90 }, dumpAndNext(next));
93 function testSetStyleOpenComment(next)
95 verifyProtocolError({
96 styleSheetId: styleSheetId,
97 range: { startLine: 0, startColumn: 0, endLine: 0, endColumn: 11 },
98 text: "/*",
99 }, dumpAndNext(next));
104 </script>
105 </head>
106 <body onload="runTest();">
107 <p>The test verifies functionality of protocol method CSS.setStyleText for inline elements.</p>
108 <div id="inliner" style="color: red;">
109 </body>
110 </html>