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

Side by Side Diff: LayoutTests/inspector-protocol/css/css-set-property-text.html

Issue 211193006: DevTools: [CSS] use setStyleText as undo action for setPropertyText (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add testcase 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <html>
2 <head>
3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto r-protocol-test.js"></script>
4 <script type="text/javascript" src="css-protocol-test.js"></script>
5 <script type="text/javascript">
6 function test()
7 {
8 setTimeout(InspectorTest.completeTest.bind(InspectorTest), 2000);
9 InspectorTest.eventHandler["CSS.styleSheetAdded"] = styleSheetAdded;
10 InspectorTest.sendCommandOrDie("CSS.enable", {});
11
12 var setPropertyText;
13 var verifyProtocolError;
14 var dumpStyleSheet;
15
16 function styleSheetAdded(result)
17 {
18 var styleSheetId = result.params.header.styleSheetId;
19 setPropertyText = InspectorTest.setPropertyText.bind(InspectorTest, styl eSheetId, false);
20 verifyProtocolError = InspectorTest.setPropertyText.bind(InspectorTest, styleSheetId, true);
21 dumpStyleSheet = InspectorTest.dumpStyleSheetText.bind(null, styleSheetI d);
22 InspectorTest.sendCommandOrDie("CSS.getStyleSheetText", { styleSheetId: styleSheetId }, onInitialStyleSheetText);
23 }
24
25 function onInitialStyleSheetText(result)
26 {
27 InspectorTest.log("==== Initial style sheet text ====");
28 InspectorTest.log(result.text);
29 InspectorTest.runTestSuite(testSuite);
30 }
31
32 var testSuite = [
33 function testEditProperty(next)
34 {
35 setPropertyText({
36 styleIndex: 1,
37 propertyIndex: 1,
38 overwrite: true,
39 text: "content: 'EDITED PROPERTY';"
40 }, InspectorTest.undoAndNext(next));
41 },
42
43 function testBreakingCommentEditProperty(next)
44 {
45 verifyProtocolError({
46 styleIndex: 1,
47 propertyIndex: 2,
48 overwrite: true,
49 text: "/*<--OPENED COMMENT"
50 }, next);
51 },
52
53 function testInsertFirstProperty(next)
54 {
55 setPropertyText({
56 styleIndex: 1,
57 propertyIndex: 0,
58 overwrite: false,
59 text: "content: 'INSERTED PROPERTY';"
60 }, InspectorTest.undoAndNext(next));
61 },
62
63 function testInsertLastProperty(next)
64 {
65 setPropertyText({
66 styleIndex: 1,
67 propertyIndex: 4,
68 overwrite: false,
69 text: "content: 'INSERTED PROPERTY';"
70 }, InspectorTest.undoAndNext(next));
71 },
72
73 function testInsertMultipleProperties(next)
74 {
75 setPropertyText({
76 styleIndex: 1,
77 propertyIndex: 2,
78 overwrite: false,
79 text: "content: 'INSERTED #1';content: 'INSERTED #2';"
80 }, InspectorTest.undoAndNext(next));
81 },
82
83 function testInsertPropertyInEmptyRule(next)
84 {
85 setPropertyText({
86 styleIndex: 3,
87 propertyIndex: 0,
88 overwrite: false,
89 text: "content: 'INSERTED PROPERTY';"
90 }, InspectorTest.undoAndNext(next));
91 },
92
93 function testInsertBreakingPropertyInLastEmptyRule(next)
94 {
95 verifyProtocolError({
96 styleIndex: 3,
97 propertyIndex: 0,
98 overwrite: false,
99 text: "content: 'INSERTED PROPERTY'/*"
100 }, next);
101 },
102
103 function testDisableProperty(next)
104 {
105 setPropertyText({
106 styleIndex: 1,
107 propertyIndex: 1,
108 overwrite: true,
109 text: "/* margin: 0; */"
110 }, InspectorTest.undoAndNext(next));
111 },
112
113 function testRedo(next)
114 {
115 setPropertyText({
116 styleIndex: 1,
117 propertyIndex: 4,
118 overwrite: false,
119 text: "align-items: center;"
120 }, InspectorTest.undoAndNext(redo));
121
122 function redo()
123 {
124 InspectorTest.sendCommandOrDie("DOM.redo", null, dumpStyleSheet. bind(null, InspectorTest.undoAndNext(next)));
125 }
126 },
127
128 function testInvalidParameters(next)
129 {
130 verifyProtocolError({
131 styleIndex: "one",
132 propertyIndex: 4,
133 overwrite: false,
134 text: "no matter what is here"
135 }, next);
136 },
137 ];
138 }
139
140 </script>
141 <link rel="stylesheet" href="resources/set-property-text.css"/>
142 </head>
143 <body onload="runTest();">
144 </body>
145 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698