Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Unified Diff: LayoutTests/inspector-protocol/css/css-edit-range.html

Issue 172593003: DevTools: [CSS] Add CSS.editRangeInStyleSheetText() to the protocol (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix glitch Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..6682dd82341e97da7e0c962adb0467cd89a03987
--- /dev/null
+++ b/LayoutTests/inspector-protocol/css/css-edit-range.html
@@ -0,0 +1,253 @@
+<html>
+<head>
+<script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-protocol-test.js"></script>
+<script type="text/javascript" src="css-protocol-test.js"></script>
+<script type="text/javascript" src="edit-range-utils.js"></script>
+<script type="text/javascript">
+function test()
+{
+ InspectorTest.eventHandler["CSS.styleSheetAdded"] = styleSheetAdded;
+ InspectorTest.sendCommandOrDie("CSS.enable", {});
+
+ var editStyleSheet;
+ var checkProtocolError;
+ var dumpStyleSheet;
+
+ function styleSheetAdded(result)
+ {
+ var styleSheetId = result.params.header.styleSheetId;
+ editStyleSheet = InspectorTest.editStyleSheet.bind(null, styleSheetId);
+ checkProtocolError = InspectorTest.checkProtocolError.bind(null, styleSheetId);
+ dumpStyleSheet = InspectorTest.dumpStyleSheetText.bind(null, styleSheetId);
+ InspectorTest.sendCommandOrDie("CSS.getStyleSheetText", { styleSheetId: styleSheetId }, onInitialStyleSheetText);
+ }
+
+ function onInitialStyleSheetText(result)
+ {
+ InspectorTest.log("==== Initial style sheet text ====");
+ InspectorTest.log(result.text);
+ InspectorTest.runTestSuite(testSuite);
+ }
+
+ var testSuite = [
+ function testEditSelector(next)
+ {
+ editStyleSheet({
+ range: { startLine: 0, startColumn: 0, endLine: 0, endColumn: 1 },
+ text: ".EDITED-SELECTOR"
+ }, InspectorTest.undoAndNext(next));
vsevik 2014/03/13 10:44:51 Can we make a simple InspectorTest.domUndo(callbac
+ },
+
+ function testEditSubSelector(next)
+ {
+ editStyleSheet({
+ range: { startLine: 4, startColumn: 6, endLine: 4, endColumn: 10 },
+ text: ".EDITED-SELECTOR"
+ }, InspectorTest.undoAndNext(next));
+ },
+
+ function testBreakingCommentEditSelector(next)
+ {
+ checkProtocolError({
+ range: { startLine: 12, startColumn: 12, endLine: 12, endColumn: 12 },
+ text: "/*<--OPENED COMMENT"
+ }, next);
+ },
+
+ function testInsertInSelectorStart(next)
+ {
+ editStyleSheet({
+ range: { startLine: 4, startColumn: 0, endLine: 4, endColumn: 0 },
+ text: "head, "
+ }, InspectorTest.undoAndNext(next));
+ },
+
+ function testValidEditPseudoClass(next)
+ {
+ editStyleSheet({
+ range: { startLine: 12, startColumn: 8, endLine: 12, endColumn: 14 },
+ text: "line"
+ }, InspectorTest.undoAndNext(next));
+ },
+
+ function testInvalidPseudoClass(next)
+ {
+ checkProtocolError({
+ range: { startLine: 12, startColumn: 2, endLine: 12, endColumn: 7 },
+ text: "not-sure-which"
+ }, next);
+ },
+
+ function testEditProperty(next)
+ {
+ editStyleSheet({
+ range: { startLine: 7, startColumn: 4, endLine: 7, endColumn: 14 },
+ text: "content: 'EDITED PROPERTY';"
+ }, InspectorTest.undoAndNext(next));
+ },
+
+ function testBreakingCommentEditProperty(next)
+ {
+ checkProtocolError({
+ range: { startLine: 8, startColumn: 4, endLine: 8, endColumn: 14 },
+ text: "/*<--OPENED COMMENT"
+ }, next);
+ },
+
+ function testInsertFirstProperty(next)
+ {
+ editStyleSheet({
+ range: { startLine: 6, startColumn: 4, endLine: 6, endColumn: 4 },
+ text: "content: 'INSERTED PROPERTY';"
+ }, InspectorTest.undoAndNext(next));
+ },
+
+ function testInsertLastProperty(next)
+ {
+ editStyleSheet({
+ range: { startLine: 10, startColumn: 0, endLine: 10, endColumn: 0 },
+ text: "content: 'INSERTED PROPERTY';"
+ }, InspectorTest.undoAndNext(next));
+ },
+
+ function testInsertMultipleProperties(next)
+ {
+ editStyleSheet({
+ range: { startLine: 8, startColumn: 0, endLine: 8, endColumn: 0 },
+ text: "content: 'INSERTED #1';content: 'INSERTED #2';"
+ }, InspectorTest.undoAndNext(next));
+ },
+
+ function testInsertPropertyInEmptyRule(next)
+ {
+ editStyleSheet({
+ range: { startLine: 16, startColumn: 13, endLine: 16, endColumn: 13 },
+ text: "content: 'INSERTED PROPERTY';"
+ }, InspectorTest.undoAndNext(next));
+ },
+
+ function testInsertPropertyOutsideRule(next)
+ {
+ checkProtocolError({
+ range: { startLine: 10, startColumn: 1, endLine: 10, endColumn: 1 },
+ text: "content: 'INSERTED PROPERTY';"
+ }, next);
+ },
+
+ function testInsertBreakingPropertyInLastEmptyRule(next)
+ {
+ checkProtocolError({
+ range: { startLine: 16, startColumn: 13, endLine: 16, endColumn: 13 },
+ text: "content: 'INSERTED PROPERTY'/*"
+ }, next);
+ },
+
+ function testDisableProperty(next)
+ {
+ editStyleSheet({
+ range: { startLine: 7, startColumn: 4, endLine: 7, endColumn: 14 },
+ text: "/* margin: 0; */"
+ }, InspectorTest.undoAndNext(next));
+ },
+
+ function testInsertEmptyFirstRule(next)
+ {
+ editStyleSheet({
+ range: { startLine: 0, startColumn: 0, endLine: 0, endColumn: 0 },
+ text: "div {}\n"
+ }, InspectorTest.undoAndNext(next), true);
+ },
+
+ function testInsertEmptyLastRule(next)
+ {
+ editStyleSheet({
+ range: { startLine: 17, startColumn: 1, endLine: 17, endColumn: 1 },
+ text: "div { }"
+ }, InspectorTest.undoAndNext(next), true);
+ },
+
+ function testRedo(next)
+ {
+ editStyleSheet({
+ range: { startLine: 11, startColumn: 0, endLine: 11, endColumn: 0 },
+ text: "div { content: 'INSERTED RULE'; }"
+ }, InspectorTest.undoAndNext(redo));
+
+ function redo()
+ {
+ InspectorTest.sendCommandOrDie("DOM.redo", null, dumpStyleSheet.bind(null, InspectorTest.undoAndNext(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: 0 },
+ text: "a:hover { color: blue }"
+ }, next);
+ },
+
+ function testStartLineOutOfBounds(next)
+ {
+ checkProtocolError({
+ range: { startLine: 100, startColumn: 0, endLine: 100, endColumn: 0 },
+ text: "a:hover { color: blue }"
+ }, next);
+ },
+
+ function testEndLineOutOfBounds(next)
+ {
+ checkProtocolError({
+ range: { startLine: 0, startColumn: 0, endLine: 100, endColumn: 0 },
+ text: "a:hover { color: blue }"
+ }, next);
+ },
+
+ function testStartColumnBeyondLastLineCharacter(next)
+ {
+ checkProtocolError({
+ range: { startLine: 3, startColumn: 1000, endLine: 3, endColumn: 1000 },
+ text: "a:hover { color: blue }"
+ }, next);
+ },
+
+ function testEndColumnBeyondLastLineCharacter(next)
+ {
+ checkProtocolError({
+ range: { startLine: 3, startColumn: 0, endLine: 3, endColumn: 1000 },
+ text: "a:hover { color: blue }"
+ }, next);
+ },
+
+ function testInsertBeyondLastCharacterOfLastLine(next)
+ {
+ checkProtocolError({
+ range: { startLine: 3, startColumn: 1, endLine: 3, endColumn: 1 },
+ 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);
+ },
+ ];
+}
+
+</script>
+<link rel="stylesheet" href="resources/edit-range.css"/>
+</head>
+<body onload="runTest();">
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698