3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
4 <script type="text/javascript" src="css-protocol-test.js"></script>
5 <script type="text/javascript">
8 InspectorTest.eventHandler["CSS.styleSheetAdded"] = styleSheetAdded;
9 InspectorTest.sendCommandOrDie("DOM.enable", {});
10 InspectorTest.sendCommandOrDie("CSS.enable", {});
13 var verifyProtocolError;
16 function styleSheetAdded(result)
18 var styleSheetId = result.params.header.styleSheetId;
19 setPropertyText = InspectorTest.setPropertyText.bind(InspectorTest, styleSheetId, false);
20 verifyProtocolError = InspectorTest.setPropertyText.bind(InspectorTest, styleSheetId, true);
21 dumpStyleSheet = InspectorTest.dumpStyleSheetText.bind(null, styleSheetId);
22 InspectorTest.sendCommandOrDie("CSS.getStyleSheetText", { styleSheetId: styleSheetId }, onInitialStyleSheetText);
25 function onInitialStyleSheetText(result)
27 InspectorTest.log("==== Initial style sheet text ====");
28 InspectorTest.log(result.text);
29 InspectorTest.runTestSuite(testSuite);
33 function testEditProperty(next)
36 range: { startLine: 7, startColumn: 4, endLine: 7, endColumn: 14 },
37 text: "content: 'EDITED PROPERTY';"
38 }, InspectorTest.undoAndNext(next));
41 function testBreakingCommentEditProperty(next)
44 range: { startLine: 8, startColumn: 4, endLine: 8, endColumn: 14 },
45 text: "/*<--OPENED COMMENT"
49 function testInsertFirstProperty(next)
52 range: { startLine: 6, startColumn: 4, endLine: 6, endColumn: 4 },
53 text: "content: 'INSERTED PROPERTY';"
54 }, InspectorTest.undoAndNext(next));
57 function testInsertLastProperty(next)
60 range: { startLine: 10, startColumn: 0, endLine: 10, endColumn: 0 },
61 text: "content: 'INSERTED PROPERTY';"
62 }, InspectorTest.undoAndNext(next));
65 function testInsertMultipleProperties(next)
68 range: { startLine: 8, startColumn: 0, endLine: 8, endColumn: 0 },
69 text: "content: 'INSERTED #1';content: 'INSERTED #2';"
70 }, InspectorTest.undoAndNext(next));
73 function testInsertPropertyInEmptyRule(next)
76 range: { startLine: 16, startColumn: 13, endLine: 16, endColumn: 13 },
77 text: "content: 'INSERTED PROPERTY';"
78 }, InspectorTest.undoAndNext(next));
81 function testInsertPropertyOutsideRule(next)
84 range: { startLine: 10, startColumn: 1, endLine: 10, endColumn: 1 },
85 text: "content: 'INSERTED PROPERTY';"
89 function testInsertBreakingPropertyInLastEmptyRule(next)
92 range: { startLine: 16, startColumn: 13, endLine: 16, endColumn: 13 },
93 text: "content: 'INSERTED PROPERTY'/*"
97 function testDisableProperty(next)
100 range: { startLine: 7, startColumn: 4, endLine: 7, endColumn: 14 },
101 text: "/* margin: 0; */"
102 }, InspectorTest.undoAndNext(next));
105 function testRedo(next)
108 range: { startLine: 10, startColumn: 0, endLine: 10, endColumn: 0 },
109 text: "align-items: center;"
110 }, InspectorTest.undoAndNext(redo));
114 InspectorTest.sendCommandOrDie("DOM.redo", null, dumpStyleSheet.bind(null, InspectorTest.undoAndNext(next)));
118 function testInvalidParameters(next)
120 verifyProtocolError({
121 range: { startLine: "three", startColumn: 0, endLine: 4, endColumn: 0 },
122 text: "no matter what is here"
126 function testNegativeRangeParameters(next)
128 verifyProtocolError({
129 range: { startLine: -1, startColumn: -1, endLine: 1, endColumn: 0 },
134 function testStartLineOutOfBounds(next)
136 verifyProtocolError({
137 range: { startLine: 100, startColumn: 0, endLine: 100, endColumn: 0 },
142 function testEndLineOutOfBounds(next)
144 verifyProtocolError({
145 range: { startLine: 0, startColumn: 0, endLine: 100, endColumn: 0 },
150 function testStartColumnBeyondLastLineCharacter(next)
152 verifyProtocolError({
153 range: { startLine: 3, startColumn: 1000, endLine: 3, endColumn: 1000 },
158 function testEndColumnBeyondLastLineCharacter(next)
160 verifyProtocolError({
161 range: { startLine: 3, startColumn: 0, endLine: 3, endColumn: 1000 },
166 function testInsertBeyondLastCharacterOfLastLine(next)
168 verifyProtocolError({
169 range: { startLine: 3, startColumn: 1, endLine: 3, endColumn: 1 },
174 function testReversedRange(next)
176 verifyProtocolError({
177 range: { startLine: 2, startColumn: 0, endLine: 0, endColumn: 0 },
185 <link rel="stylesheet" href="resources/set-property-text.css"/>
187 <body onload="runTest();">