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