Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector-protocol / css / css-set-style-text.html
blobd2aefcf6bc0b0d822481013b84a2abe307a0c795
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">
9 function removeRule()
11 document.styleSheets[0].removeRule(0);
14 function test()
16 var setStyleText;
17 var verifyProtocolError;
18 var dumpStyleSheet;
19 var documentNodeId;
20 var styleSheetId;
22 InspectorTest.requestDocumentNodeId(onDocumentNodeId);
24 function onDocumentNodeId(nodeId)
26 documentNodeId = nodeId;
27 InspectorTest.eventHandler["CSS.styleSheetAdded"] = styleSheetAdded;
28 InspectorTest.sendCommandOrDie("CSS.enable", {});
31 function styleSheetAdded(result)
33 styleSheetId = result.params.header.styleSheetId;
34 setStyleText = InspectorTest.setStyleText.bind(InspectorTest, styleSheetId, false);
35 verifyProtocolError = InspectorTest.setStyleText.bind(InspectorTest, styleSheetId, true);
36 dumpStyleSheet = InspectorTest.dumpStyleSheetText.bind(null, styleSheetId);
37 InspectorTest.sendCommandOrDie("CSS.getStyleSheetText", { styleSheetId: styleSheetId }, onInitialStyleSheetText);
40 function dumpAndCall(next)
42 return InspectorTest.loadAndDumpMatchingRules.bind(InspectorTest, documentNodeId, "#test", next);
45 function dumpUndoAndNext(next)
47 return InspectorTest.loadAndDumpMatchingRules.bind(InspectorTest, documentNodeId, "#test", InspectorTest.undoAndNext(next));
50 function onInitialStyleSheetText(result)
52 InspectorTest.log("==== Initial style sheet text ====");
53 InspectorTest.log(result.text);
54 InspectorTest.runTestSuite(testSuite);
57 var testSuite = [
58 function testBasicSetStyle(next)
60 setStyleText({
61 styleSheetId: styleSheetId,
62 range: { startLine: 0, startColumn: 7, endLine: 2, endColumn: 0 },
63 text: "\n content: 'EDITED';\n",
64 }, dumpUndoAndNext(next));
67 function testSetStyleTwice(next)
69 setStyleText({
70 styleSheetId: styleSheetId,
71 range: { startLine: 0, startColumn: 7, endLine: 2, endColumn: 0 },
72 text: "\n color: green;\n padding: 0 4px;\n cursor: pointer\n",
73 }, dumpAndCall(step2));
75 function step2()
77 setStyleText({
78 styleSheetId: styleSheetId,
79 range: { startLine: 0, startColumn: 7, endLine: 4, endColumn: 0 },
80 text: "\n color: green;\n padding: 0 6px;\n cursor: pointer\n",
81 }, dumpAndCall(step3));
84 function step3()
86 setStyleText({
87 styleSheetId: styleSheetId,
88 range: { startLine: 0, startColumn: 7, endLine: 4, endColumn: 0 },
89 text: "\n color: green;\n padding: 0 8px;\n cursor: pointer\n",
90 }, dumpUndoAndNext(next));
94 function testSetStylePoorContent(next)
96 verifyProtocolError({
97 styleSheetId: styleSheetId,
98 range: { startLine: 0, startColumn: 7, endLine: 2, endColumn: 0 },
99 text: "}",
100 }, dumpUndoAndNext(next));
103 function testSetStyleInMedia(next)
105 setStyleText({
106 styleSheetId: styleSheetId,
107 range: { startLine: 13, startColumn: 11, endLine: 15, endColumn: 4 },
108 text: "\n content: 'EDITED';\n color: red;\n /** foo */\n ",
109 }, dumpUndoAndNext(next));
112 function testDeleteStyleBody(next)
114 setStyleText({
115 styleSheetId: styleSheetId,
116 range: { startLine: 13, startColumn: 11, endLine: 15, endColumn: 4 },
117 text: "",
118 }, dumpUndoAndNext(next));
121 function testSetStylePoorRange(next)
123 verifyProtocolError({
124 styleSheetId: styleSheetId,
125 range: { startLine: 11, startColumn: 11, endLine: 15, endColumn: 4 },
126 text: "\n content: 'EDITED';\n",
127 }, dumpUndoAndNext(next));
130 function testSetStyleOpenComment(next)
132 verifyProtocolError({
133 styleSheetId: styleSheetId,
134 range: { startLine: 13, startColumn: 11, endLine: 15, endColumn: 4 },
135 text: "\n content: 'EDITED'/* ;\n",
136 }, dumpUndoAndNext(next));
139 function testSetStyleOfRemovedRule(next)
141 InspectorTest.sendCommandOrDie("Runtime.evaluate", {expression: "removeRule()"}, mutateRule);
142 function mutateRule()
144 setStyleText({
145 styleSheetId: styleSheetId,
146 range: { startLine: 0, startColumn: 7, endLine: 2, endColumn: 0 },
147 text: "\n content: 'EDITED';\n",
148 }, dumpUndoAndNext(next));
154 </script>
155 </head>
156 <body onload="runTest();">
157 <p>The test verifies functionality of protocol method CSS.setStyleText.</p>
158 <article id="test"></article>
159 </body>
160 </html>