Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector-protocol / css / css-set-rule-selector.html
blobda5de24b082f011729f25e7612867c297c9eec51
1 <html>
2 <head>
3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
4 <script type="text/javascript" src="../../http/tests/inspector-protocol/css-protocol-test.js"></script>
5 <script type="text/javascript">
6 function test()
8 InspectorTest.eventHandler["CSS.styleSheetAdded"] = styleSheetAdded;
9 InspectorTest.sendCommandOrDie("DOM.enable", {});
10 InspectorTest.sendCommandOrDie("CSS.enable", {});
12 var setRuleSelector;
13 var verifyProtocolError;
14 var dumpStyleSheet;
16 var firstSelectorRange = {
17 startLine: 0,
18 startColumn: 0,
19 endLine: 0,
20 endColumn: 1
22 var secondSelectorRange = {
23 startLine: 4,
24 startColumn: 0,
25 endLine: 4,
26 endColumn: 18
28 var thirdSelectorRange = {
29 startLine: 12,
30 startColumn: 0,
31 endLine: 12,
32 endColumn: 14
34 var forthSelectorRange = {
35 startLine: 12,
36 startColumn: 36,
37 endLine: 13,
38 endColumn: 4
41 function styleSheetAdded(result)
43 var styleSheetId = result.params.header.styleSheetId;
44 setRuleSelector = InspectorTest.setRuleSelector.bind(InspectorTest, styleSheetId, false);
45 verifyProtocolError = InspectorTest.setRuleSelector.bind(InspectorTest, styleSheetId, true);
46 dumpStyleSheet = InspectorTest.dumpStyleSheetText.bind(null, styleSheetId);
47 InspectorTest.sendCommandOrDie("CSS.getStyleSheetText", { styleSheetId: styleSheetId }, onInitialStyleSheetText);
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 testEditSimpleSelector(next)
60 setRuleSelector({
61 range: firstSelectorRange,
62 selector: ".EDITED-SELECTOR"
63 }, InspectorTest.undoAndNext(next));
66 function testEditCopmlexSelector(next)
68 setRuleSelector({
69 range: secondSelectorRange,
70 selector: ".EDITED-SELECTOR:first-line"
71 }, InspectorTest.undoAndNext(next));
74 function testEditSequentially(next)
76 var newSelectorText = ".EDITED";
77 var oldSelectorLength = thirdSelectorRange.endColumn - thirdSelectorRange.startColumn;
78 var lengthDelta = newSelectorText.length - oldSelectorLength;
79 setRuleSelector({
80 range: thirdSelectorRange,
81 selector: newSelectorText,
82 }, step2);
84 function step2()
86 var range = {
87 startLine: forthSelectorRange.startLine,
88 startColumn: forthSelectorRange.startColumn + lengthDelta,
89 endLine: forthSelectorRange.endLine,
90 endColumn: forthSelectorRange.endColumn
92 setRuleSelector({
93 range: range,
94 selector: ".EDITED-2"
95 }, InspectorTest.undoAndNext(next));
99 function testInvalidSelectorText(next)
101 verifyProtocolError({
102 range: firstSelectorRange,
103 selector: "123"
104 }, next);
107 function testEmptySelector(next)
109 verifyProtocolError({
110 range: firstSelectorRange,
111 selector: ""
112 }, next);
115 function testSelectorTextWithUnclosedComment(next)
117 verifyProtocolError({
118 range: firstSelectorRange,
119 selector: "body /*"
120 }, next);
123 function testEditSubSelector(next)
125 verifyProtocolError({
126 range: { startLine: 12, startColumn: 8, endLine: 12, endColumn: 14 },
127 selector: "line"
128 }, next);
131 function testInvalidParameters(next)
133 verifyProtocolError({
134 range: { startLine: "three", startColumn: 0, endLine: 4, endColumn: 0 },
135 selector: "no matter what is here"
136 }, next);
139 function testNegativeRangeParameters(next)
141 verifyProtocolError({
142 range: { startLine: -1, startColumn: -1, endLine: 1, endColumn: 0 },
143 selector: "html > body > div"
144 }, next);
147 function testStartLineOutOfBounds(next)
149 verifyProtocolError({
150 range: { startLine: 100, startColumn: 0, endLine: 100, endColumn: 0 },
151 selector: "html > body > div"
152 }, next);
155 function testEndLineOutOfBounds(next)
157 verifyProtocolError({
158 range: { startLine: 0, startColumn: 0, endLine: 100, endColumn: 0 },
159 selector: "html > body > div"
160 }, next);
163 function testStartColumnBeyondLastLineCharacter(next)
165 verifyProtocolError({
166 range: { startLine: 3, startColumn: 1000, endLine: 3, endColumn: 1000 },
167 selector: "html > body > div"
168 }, next);
171 function testEndColumnBeyondLastLineCharacter(next)
173 verifyProtocolError({
174 range: { startLine: 3, startColumn: 0, endLine: 3, endColumn: 1000 },
175 selector: "html > body > div"
176 }, next);
179 function testInsertBeyondLastCharacterOfLastLine(next)
181 verifyProtocolError({
182 range: { startLine: 3, startColumn: 2, endLine: 3, endColumn: 2 },
183 selector: "html > body > div"
184 }, next);
187 function testReversedRange(next)
189 verifyProtocolError({
190 range: { startLine: 2, startColumn: 0, endLine: 0, endColumn: 0 },
191 selector: "html > body > div"
192 }, next);
197 </script>
198 <link rel="stylesheet" href="resources/set-rule-selector.css"/>
199 </head>
200 <body onload="runTest();">
201 </body>
202 </html>