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("CSS.enable", {});
12 var verifyProtocolError;
15 function styleSheetAdded(result)
17 var styleSheetId = result.params.header.styleSheetId;
18 setPropertyText = InspectorTest.setPropertyText.bind(InspectorTest, styleSheetId, false);
19 verifyProtocolError = InspectorTest.setPropertyText.bind(InspectorTest, styleSheetId, true);
20 dumpStyleSheet = InspectorTest.dumpStyleSheetText.bind(null, styleSheetId);
21 InspectorTest.sendCommandOrDie("CSS.getStyleSheetText", { styleSheetId: styleSheetId }, onInitialStyleSheetText);
24 function onInitialStyleSheetText(result)
26 InspectorTest.log("==== Initial style sheet text ====");
27 InspectorTest.log(result.text);
28 InspectorTest.runTestSuite(testSuite);
32 function testEditProperty(next)
35 range: { startLine: 7, startColumn: 4, endLine: 7, endColumn: 14 },
36 text: "content: 'EDITED PROPERTY';"
37 }, InspectorTest.undoAndNext(next));
40 function testBreakingCommentEditProperty(next)
43 range: { startLine: 8, startColumn: 4, endLine: 8, endColumn: 14 },
44 text: "/*<--OPENED COMMENT"
48 function testInsertFirstProperty(next)
51 range: { startLine: 6, startColumn: 4, endLine: 6, endColumn: 4 },
52 text: "content: 'INSERTED PROPERTY';"
53 }, InspectorTest.undoAndNext(next));
56 function testInsertLastProperty(next)
59 range: { startLine: 10, startColumn: 0, endLine: 10, endColumn: 0 },
60 text: "content: 'INSERTED PROPERTY';"
61 }, InspectorTest.undoAndNext(next));
64 function testInsertMultipleProperties(next)
67 range: { startLine: 8, startColumn: 0, endLine: 8, endColumn: 0 },
68 text: "content: 'INSERTED #1';content: 'INSERTED #2';"
69 }, InspectorTest.undoAndNext(next));
72 function testInsertPropertyInEmptyRule(next)
75 range: { startLine: 16, startColumn: 13, endLine: 16, endColumn: 13 },
76 text: "content: 'INSERTED PROPERTY';"
77 }, InspectorTest.undoAndNext(next));
80 function testInsertPropertyOutsideRule(next)
83 range: { startLine: 10, startColumn: 1, endLine: 10, endColumn: 1 },
84 text: "content: 'INSERTED PROPERTY';"
88 function testInsertBreakingPropertyInLastEmptyRule(next)
91 range: { startLine: 16, startColumn: 13, endLine: 16, endColumn: 13 },
92 text: "content: 'INSERTED PROPERTY'/*"
96 function testDisableProperty(next)
99 range: { startLine: 7, startColumn: 4, endLine: 7, endColumn: 14 },
100 text: "/* margin: 0; */"
101 }, InspectorTest.undoAndNext(next));
104 function testRedo(next)
107 range: { startLine: 10, startColumn: 0, endLine: 10, endColumn: 0 },
108 text: "align-items: center;"
109 }, InspectorTest.undoAndNext(redo));
113 InspectorTest.sendCommandOrDie("DOM.redo", null, dumpStyleSheet.bind(null, InspectorTest.undoAndNext(next)));
117 function testInvalidParameters(next)
119 verifyProtocolError({
120 range: { startLine: "three", startColumn: 0, endLine: 4, endColumn: 0 },
121 text: "no matter what is here"
125 function testNegativeRangeParameters(next)
127 verifyProtocolError({
128 range: { startLine: -1, startColumn: -1, endLine: 1, endColumn: 0 },
133 function testStartLineOutOfBounds(next)
135 verifyProtocolError({
136 range: { startLine: 100, startColumn: 0, endLine: 100, endColumn: 0 },
141 function testEndLineOutOfBounds(next)
143 verifyProtocolError({
144 range: { startLine: 0, startColumn: 0, endLine: 100, endColumn: 0 },
149 function testStartColumnBeyondLastLineCharacter(next)
151 verifyProtocolError({
152 range: { startLine: 3, startColumn: 1000, endLine: 3, endColumn: 1000 },
157 function testEndColumnBeyondLastLineCharacter(next)
159 verifyProtocolError({
160 range: { startLine: 3, startColumn: 0, endLine: 3, endColumn: 1000 },
165 function testInsertBeyondLastCharacterOfLastLine(next)
167 verifyProtocolError({
168 range: { startLine: 3, startColumn: 1, endLine: 3, endColumn: 1 },
173 function testReversedRange(next)
175 verifyProtocolError({
176 range: { startLine: 2, startColumn: 0, endLine: 0, endColumn: 0 },
184 <link rel="stylesheet" href="resources/set-property-text.css"/>
186 <body onload="runTest();">