Chromium Code Reviews| Index: LayoutTests/inspector-protocol/css/css-edit-range.html |
| diff --git a/LayoutTests/inspector-protocol/css/css-edit-range.html b/LayoutTests/inspector-protocol/css/css-edit-range.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..da5e74a25beb975151a4fe4b44cbec8920a66d5b |
| --- /dev/null |
| +++ b/LayoutTests/inspector-protocol/css/css-edit-range.html |
| @@ -0,0 +1,139 @@ |
| +<html> |
| +<head> |
| +<script type="text/javascript" src="../../http/tests/inspector-protocol/resources/protocol-test.js"></script> |
| +<script type="text/javascript"> |
| +function test() |
| +{ |
| + InspectorTest.eventHandler["CSS.styleSheetAdded"] = styleSheetAdded; |
| + InspectorTest.sendCommandAndBailOnError("CSS.enable", {}); |
| + |
| + var styleSheetId; |
| + |
| + function styleSheetAdded(result) |
| + { |
| + styleSheetId = result.params.header.styleSheetId; |
| + InspectorTest.sendCommandAndBailOnError("CSS.getStyleSheetText", { styleSheetId: styleSheetId }, onInitialStyleSheetText); |
| + } |
| + |
| + function onInitialStyleSheetText(result) |
| + { |
| + InspectorTest.log("==== Initial style sheet text ===="); |
| + InspectorTest.log(result.text); |
| + InspectorTest.runTestSuite(testSuite); |
| + } |
| + |
| + var testSuite = [ |
| + function testInsertText(next) |
| + { |
| + editStyleSheetAndDump({ |
| + range: { startLine: 0, startColumn: 0, endLine: 0, endColumn: 0 }, |
| + text: "* { border: 1px }" |
| + }, next); |
| + }, |
| + |
| + function testMultiLineEdit(next) |
| + { |
| + editStyleSheetAndDump({ |
| + range: { startLine: 1, startColumn: 5, endLine: 3, endColumn: 0 }, |
| + text: "\n background-color: blue;\n font-size: 12px;\n" |
| + }, next); |
| + }, |
| + |
| + function testReplaceText(next) |
| + { |
| + editStyleSheetAndDump({ |
| + range: { startLine: 1, startColumn: 0, endLine: 1, endColumn: 3 }, |
| + text: "p, span:hover" |
| + }, next); |
| + }, |
| + |
| + function testInsertInTheEnd(next) |
| + { |
| + editStyleSheetAndDump({ |
| + range: { startLine: 4, startColumn: 1, endLine: 4, endColumn: 1 }, |
| + text: "\n* { box-sizing: border-box; }" |
| + }, next); |
| + }, |
| + |
| + function testRemoveText(next) |
| + { |
| + editStyleSheetAndDump({ |
| + range: { startLine: 3, startColumn: 0, endLine: 4, endColumn: 0 }, |
| + text: "" |
| + }, next); |
| + }, |
| + |
| + function testInvalidParameters(next) |
| + { |
| + ensureProtocolError({ |
| + range: { startLine: "three", startColumn: 0, endLine: 4, endColumn: 0 }, |
| + text: "no matter what is here" |
| + }, next); |
| + }, |
| + |
| + function testNegativeRangeParameters(next) |
| + { |
| + ensureProtocolError({ |
| + range: { startLine: -1, startColumn: -1, endLine: 1, endColumn: 2 }, |
| + text: "a:hover { color: blue }" |
| + }, next); |
| + }, |
| + |
| + function testOutOfBoundsRangeParametersNoCrash(next) |
|
apavlov
2014/02/21 14:37:55
What about the range:
- ending on the last line pa
lushnikov
2014/02/23 16:07:07
Done.
|
| + { |
| + ensureProtocolError({ |
| + range: { startLine: 0, startColumn: 0, endLine: 100, endColumn: 100 }, |
| + text: "a:hover { color: blue }" |
| + }, next); |
| + }, |
| + |
| + function testReversedRange(next) |
| + { |
| + ensureProtocolError({ |
| + range: { startLine: 2, startColumn: 0, endLine: 0, endColumn: 0 }, |
| + text: "a:hover { color: blue }" |
| + }, next); |
| + } |
| + ]; |
| + |
| + function editStyleSheetAndDump(options, callback) |
| + { |
| + options.styleSheetId = styleSheetId; |
| + InspectorTest.sendCommandAndBailOnError("CSS.editRangeInStyleSheetText", options, onEditDone); |
| + function onEditDone() |
| + { |
| + InspectorTest.sendCommandAndBailOnError("CSS.getStyleSheetText", { styleSheetId: styleSheetId }, onStyleSheetText); |
| + } |
| + function onStyleSheetText(result) |
| + { |
| + InspectorTest.log("==== Style sheet text ===="); |
| + InspectorTest.log(result.text); |
| + callback(); |
| + } |
| + } |
| + |
| + function ensureProtocolError(options, next) |
|
apavlov
2014/02/21 14:37:55
"ensure..." methods usually initialize something l
lushnikov
2014/02/23 16:07:07
Done.
|
| + { |
| + options.styleSheetId = styleSheetId; |
| + InspectorTest.sendCommand("CSS.editRangeInStyleSheetText", options, callback); |
| + |
| + function callback(message) |
| + { |
| + if (!message.error) { |
| + InspectorTest.log("ERROR: protocol method call did not raise expected error. Instead, the following message received: " + JSON.stringify(message)); |
|
apavlov
2014/02/21 14:37:55
received -> was received
lushnikov
2014/02/23 16:07:07
Done.
|
| + InspectorTest.completeTest(); |
| + return; |
| + } |
| + InspectorTest.log("Expected protocol error: " + message.error.message); |
| + next(); |
| + } |
| + } |
| + |
| +} |
| + |
| +</script> |
| +<link rel="stylesheet" href="resources/edit-range.css"/> |
| +</head> |
| +<body onload="runTest();"> |
| +</body> |
| +</html> |