Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector-protocol / css / css-set-property-text.html
1 <html>
2 <head>
3 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspector-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     InspectorTest.eventHandler["CSS.styleSheetAdded"] = styleSheetAdded;
9     InspectorTest.sendCommandOrDie("DOM.enable", {});
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, styleSheetId, false);
20         verifyProtocolError = InspectorTest.setPropertyText.bind(InspectorTest, styleSheetId, true);
21         dumpStyleSheet = InspectorTest.dumpStyleSheetText.bind(null, styleSheetId);
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                 range: { startLine: 7, startColumn: 4, endLine: 7, endColumn: 14 },
37                 text: "content: 'EDITED PROPERTY';"
38             }, InspectorTest.undoAndNext(next));
39         },
40
41         function testBreakingCommentEditProperty(next)
42         {
43             verifyProtocolError({
44                 range: { startLine: 8, startColumn: 4, endLine: 8, endColumn: 14 },
45                 text: "/*<--OPENED COMMENT"
46             }, next);
47         },
48
49         function testInsertFirstProperty(next)
50         {
51             setPropertyText({
52                 range: { startLine: 6, startColumn: 4, endLine: 6, endColumn: 4 },
53                 text: "content: 'INSERTED PROPERTY';"
54             }, InspectorTest.undoAndNext(next));
55         },
56
57         function testInsertLastProperty(next)
58         {
59             setPropertyText({
60                 range: { startLine: 10, startColumn: 0, endLine: 10, endColumn: 0 },
61                 text: "content: 'INSERTED PROPERTY';"
62             }, InspectorTest.undoAndNext(next));
63         },
64
65         function testInsertMultipleProperties(next)
66         {
67             setPropertyText({
68                 range: { startLine: 8, startColumn: 0, endLine: 8, endColumn: 0 },
69                 text: "content: 'INSERTED #1';content: 'INSERTED #2';"
70             }, InspectorTest.undoAndNext(next));
71         },
72
73         function testInsertPropertyInEmptyRule(next)
74         {
75             setPropertyText({
76                 range: { startLine: 16, startColumn: 13, endLine: 16, endColumn: 13 },
77                 text: "content: 'INSERTED PROPERTY';"
78             }, InspectorTest.undoAndNext(next));
79         },
80
81         function testInsertPropertyOutsideRule(next)
82         {
83             verifyProtocolError({
84                 range: { startLine: 10, startColumn: 1, endLine: 10, endColumn: 1 },
85                 text: "content: 'INSERTED PROPERTY';"
86             }, next);
87         },
88
89         function testInsertBreakingPropertyInLastEmptyRule(next)
90         {
91             verifyProtocolError({
92                 range: { startLine: 16, startColumn: 13, endLine: 16, endColumn: 13 },
93                 text: "content: 'INSERTED PROPERTY'/*"
94             }, next);
95         },
96
97         function testDisableProperty(next)
98         {
99             setPropertyText({
100                 range: { startLine: 7, startColumn: 4, endLine: 7, endColumn: 14 },
101                 text: "/* margin: 0; */"
102             }, InspectorTest.undoAndNext(next));
103         },
104
105         function testRedo(next)
106         {
107             setPropertyText({
108                 range: { startLine: 10, startColumn: 0, endLine: 10, endColumn: 0 },
109                 text: "align-items: center;"
110             }, InspectorTest.undoAndNext(redo));
111
112             function redo()
113             {
114                 InspectorTest.sendCommandOrDie("DOM.redo", null, dumpStyleSheet.bind(null, InspectorTest.undoAndNext(next)));
115             }
116         },
117
118         function testInvalidParameters(next)
119         {
120             verifyProtocolError({
121                 range: { startLine: "three", startColumn: 0, endLine: 4, endColumn: 0 },
122                 text: "no matter what is here"
123             }, next);
124         },
125
126         function testNegativeRangeParameters(next)
127         {
128             verifyProtocolError({
129                 range: { startLine: -1, startColumn: -1, endLine: 1, endColumn: 0 },
130                 text: "color: blue;"
131             }, next);
132         },
133
134         function testStartLineOutOfBounds(next)
135         {
136             verifyProtocolError({
137                 range: { startLine: 100, startColumn: 0, endLine: 100, endColumn: 0 },
138                 text: "color: blue;"
139             }, next);
140         },
141
142         function testEndLineOutOfBounds(next)
143         {
144             verifyProtocolError({
145                 range: { startLine: 0, startColumn: 0, endLine: 100, endColumn: 0 },
146                 text: "color: blue;"
147             }, next);
148         },
149
150         function testStartColumnBeyondLastLineCharacter(next)
151         {
152             verifyProtocolError({
153                 range: { startLine: 3, startColumn: 1000, endLine: 3, endColumn: 1000 },
154                 text: "color: blue;"
155             }, next);
156         },
157
158         function testEndColumnBeyondLastLineCharacter(next)
159         {
160             verifyProtocolError({
161                 range: { startLine: 3, startColumn: 0, endLine: 3, endColumn: 1000 },
162                 text: "color: blue;"
163             }, next);
164         },
165
166         function testInsertBeyondLastCharacterOfLastLine(next)
167         {
168             verifyProtocolError({
169                 range: { startLine: 3, startColumn: 1, endLine: 3, endColumn: 1 },
170                 text: "color: blue;"
171             }, next);
172         },
173
174         function testReversedRange(next)
175         {
176             verifyProtocolError({
177                 range: { startLine: 2, startColumn: 0, endLine: 0, endColumn: 0 },
178                 text: "color: blue;"
179             }, next);
180         },
181    ];
182 }
183
184 </script>
185 <link rel="stylesheet" href="resources/set-property-text.css"/>
186 </head>
187 <body onload="runTest();">
188 </body>
189 </html>