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">
8 InspectorTest
.eventHandler
["CSS.styleSheetAdded"] = styleSheetAdded
;
9 InspectorTest
.sendCommandOrDie("DOM.enable", {});
10 InspectorTest
.sendCommandOrDie("CSS.enable", {});
13 var verifyProtocolError
;
16 var firstSelectorRange
= {
22 var secondSelectorRange
= {
28 var thirdSelectorRange
= {
34 var forthSelectorRange
= {
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
);
58 function testEditSimpleSelector(next
)
61 range
: firstSelectorRange
,
62 selector
: ".EDITED-SELECTOR"
63 }, InspectorTest
.undoAndNext(next
));
66 function testEditCopmlexSelector(next
)
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
;
80 range
: thirdSelectorRange
,
81 selector
: newSelectorText
,
87 startLine
: forthSelectorRange
.startLine
,
88 startColumn
: forthSelectorRange
.startColumn
+ lengthDelta
,
89 endLine
: forthSelectorRange
.endLine
,
90 endColumn
: forthSelectorRange
.endColumn
95 }, InspectorTest
.undoAndNext(next
));
99 function testInvalidSelectorText(next
)
101 verifyProtocolError({
102 range
: firstSelectorRange
,
107 function testEmptySelector(next
)
109 verifyProtocolError({
110 range
: firstSelectorRange
,
115 function testSelectorTextWithUnclosedComment(next
)
117 verifyProtocolError({
118 range
: firstSelectorRange
,
123 function testEditSubSelector(next
)
125 verifyProtocolError({
126 range
: { startLine
: 12, startColumn
: 8, endLine
: 12, endColumn
: 14 },
131 function testInvalidParameters(next
)
133 verifyProtocolError({
134 range
: { startLine
: "three", startColumn
: 0, endLine
: 4, endColumn
: 0 },
135 selector
: "no matter what is here"
139 function testNegativeRangeParameters(next
)
141 verifyProtocolError({
142 range
: { startLine
: -1, startColumn
: -1, endLine
: 1, endColumn
: 0 },
143 selector
: "html > body > div"
147 function testStartLineOutOfBounds(next
)
149 verifyProtocolError({
150 range
: { startLine
: 100, startColumn
: 0, endLine
: 100, endColumn
: 0 },
151 selector
: "html > body > div"
155 function testEndLineOutOfBounds(next
)
157 verifyProtocolError({
158 range
: { startLine
: 0, startColumn
: 0, endLine
: 100, endColumn
: 0 },
159 selector
: "html > body > div"
163 function testStartColumnBeyondLastLineCharacter(next
)
165 verifyProtocolError({
166 range
: { startLine
: 3, startColumn
: 1000, endLine
: 3, endColumn
: 1000 },
167 selector
: "html > body > div"
171 function testEndColumnBeyondLastLineCharacter(next
)
173 verifyProtocolError({
174 range
: { startLine
: 3, startColumn
: 0, endLine
: 3, endColumn
: 1000 },
175 selector
: "html > body > div"
179 function testInsertBeyondLastCharacterOfLastLine(next
)
181 verifyProtocolError({
182 range
: { startLine
: 3, startColumn
: 2, endLine
: 3, endColumn
: 2 },
183 selector
: "html > body > div"
187 function testReversedRange(next
)
189 verifyProtocolError({
190 range
: { startLine
: 2, startColumn
: 0, endLine
: 0, endColumn
: 0 },
191 selector
: "html > body > div"
198 <link rel=
"stylesheet" href=
"resources/set-rule-selector.css"/>
200 <body onload=
"runTest();">