| 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..e3fdccf02ea6e55ee16e22d7b3310cfbb20ee04b
|
| --- /dev/null
|
| +++ b/LayoutTests/inspector-protocol/css/css-edit-range.html
|
| @@ -0,0 +1,171 @@
|
| +<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 testInsertTextInTheBeginning(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)
|
| + {
|
| + checkProtocolError({
|
| + range: { startLine: "three", startColumn: 0, endLine: 4, endColumn: 0 },
|
| + text: "no matter what is here"
|
| + }, next);
|
| + },
|
| +
|
| + function testNegativeRangeParameters(next)
|
| + {
|
| + checkProtocolError({
|
| + range: { startLine: -1, startColumn: -1, endLine: 1, endColumn: 2 },
|
| + text: "a:hover { color: blue }"
|
| + }, next);
|
| + },
|
| +
|
| + function testStartLineOutOfBounds(next)
|
| + {
|
| + checkProtocolError({
|
| + range: { startLine: 7, startColumn: 0, endLine: 7, endColumn: 0 },
|
| + text: "a:hover { color: blue }"
|
| + }, next);
|
| + },
|
| +
|
| + function testEndLineOutOfBounds(next)
|
| + {
|
| + checkProtocolError({
|
| + range: { startLine: 0, startColumn: 0, endLine: 7, endColumn: 0 },
|
| + text: "a:hover { color: blue }"
|
| + }, next);
|
| + },
|
| +
|
| + function testStartColumnBeyondLastLineCharacter(next)
|
| + {
|
| + checkProtocolError({
|
| + range: { startLine: 3, startColumn: 2, endLine: 3, endColumn: 2 },
|
| + text: "a:hover { color: blue }"
|
| + }, next);
|
| + },
|
| +
|
| + function testEndColumnBeyondLastLineCharacter(next)
|
| + {
|
| + checkProtocolError({
|
| + range: { startLine: 3, startColumn: 0, endLine: 3, endColumn: 2 },
|
| + text: "a:hover { color: blue }"
|
| + }, next);
|
| + },
|
| +
|
| + function testInsertBeyondLastCharacterOfLastLine(next)
|
| + {
|
| + checkProtocolError({
|
| + range: { startLine: 4, startColumn: 30, endLine: 4, endColumn: 30 },
|
| + text: "a:hover { color: blue }"
|
| + }, next);
|
| + },
|
| +
|
| + function testReversedRange(next)
|
| + {
|
| + checkProtocolError({
|
| + 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 checkProtocolError(options, next)
|
| + {
|
| + 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 was received: " + JSON.stringify(message));
|
| + 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>
|
|
|