OLD | NEW |
(Empty) | |
| 1 <html> |
| 2 <head> |
| 3 <link rel="stylesheet" href="resources/set-style-text.css"/> |
| 4 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto
r-protocol-test.js"></script> |
| 5 <script type="text/javascript" src="../../http/tests/inspector-protocol/css-prot
ocol-test.js"></script> |
| 6 <script type="text/javascript" src="../../http/tests/inspector-protocol/dom-prot
ocol-test.js"></script> |
| 7 <script type="text/javascript"> |
| 8 |
| 9 function test() |
| 10 { |
| 11 var setStyleText; |
| 12 var verifyProtocolError; |
| 13 var dumpStyleSheet; |
| 14 var documentNodeId; |
| 15 var styleSheetId; |
| 16 var undoAndNext = InspectorTest.undoAndNext; |
| 17 |
| 18 InspectorTest.requestDocumentNodeId(onDocumentNodeId); |
| 19 |
| 20 function onDocumentNodeId(nodeId) |
| 21 { |
| 22 documentNodeId = nodeId; |
| 23 InspectorTest.eventHandler["CSS.styleSheetAdded"] = styleSheetAdded; |
| 24 InspectorTest.sendCommandOrDie("CSS.enable", {}); |
| 25 } |
| 26 |
| 27 function styleSheetAdded(result) |
| 28 { |
| 29 styleSheetId = result.params.header.styleSheetId; |
| 30 setStyleTexts = InspectorTest.setMultipleStyleTexts.bind(InspectorTest,
styleSheetId, false); |
| 31 verifyProtocolError = InspectorTest.setMultipleStyleTexts.bind(Inspector
Test, styleSheetId, true); |
| 32 dumpStyleSheet = InspectorTest.dumpStyleSheetText.bind(null, styleSheetI
d); |
| 33 InspectorTest.sendCommandOrDie("CSS.getStyleSheetText", { styleSheetId:
styleSheetId }, onInitialStyleSheetText); |
| 34 } |
| 35 |
| 36 function onInitialStyleSheetText(result) |
| 37 { |
| 38 InspectorTest.log("==== Initial style sheet text ===="); |
| 39 InspectorTest.log(result.text); |
| 40 InspectorTest.runTestSuite(testSuite); |
| 41 } |
| 42 |
| 43 var testSuite = [ |
| 44 function testMalformedArguments1(next) |
| 45 { |
| 46 verifyProtocolError({ |
| 47 styleSheetIds: [ |
| 48 styleSheetId |
| 49 ], |
| 50 ranges: [ |
| 51 { startLine: 13, startColumn: 11, endLine: 15, endColumn: 4
}, |
| 52 { startLine: 0, startColumn: 7, endLine: 2, endColumn: 0 }, |
| 53 ], |
| 54 texts: [ |
| 55 "\n content: 'EDITED';\n", |
| 56 "\n content: 'EDITED';\n", |
| 57 ], |
| 58 }, next); |
| 59 }, |
| 60 |
| 61 function testMalformedArguments2(next) |
| 62 { |
| 63 verifyProtocolError({ |
| 64 styleSheetIds: [ |
| 65 styleSheetId, |
| 66 styleSheetId, |
| 67 styleSheetId |
| 68 ], |
| 69 ranges: [ |
| 70 { startLine: 13, startColumn: 11, endLine: 15, endColumn: 4
}, |
| 71 { startLine: 0, startColumn: 7, endLine: 2, endColumn: 0 }, |
| 72 ], |
| 73 texts: [ |
| 74 "\n content: 'EDITED';\n", |
| 75 "\n content: 'EDITED';\n", |
| 76 ], |
| 77 }, next); |
| 78 }, |
| 79 |
| 80 function testMalformedArguments3(next) |
| 81 { |
| 82 verifyProtocolError({ |
| 83 styleSheetIds: [ |
| 84 styleSheetId, |
| 85 styleSheetId |
| 86 ], |
| 87 ranges: [ |
| 88 { startLine: "STRING INSTEAD OF NUMBER", startColumn: 11, en
dLine: 15, endColumn: 4 }, |
| 89 { startLine: 0, startColumn: 7, endLine: 2, endColumn: 0 }, |
| 90 ], |
| 91 texts: [ |
| 92 "\n content: 'EDITED';\n", |
| 93 "\n content: 'EDITED';\n", |
| 94 ], |
| 95 }, next); |
| 96 }, |
| 97 |
| 98 function testFirstEditDoesNotApply(next) |
| 99 { |
| 100 verifyProtocolError({ |
| 101 styleSheetIds: [ |
| 102 styleSheetId, |
| 103 styleSheetId |
| 104 ], |
| 105 ranges: [ |
| 106 { startLine: 13, startColumn: 11, endLine: 15, endColumn: 4
}, |
| 107 { startLine: 0, startColumn: 7, endLine: 2, endColumn: 0 }, |
| 108 ], |
| 109 texts: [ |
| 110 "\n content: 'EDITED2';/*\n", |
| 111 "\n content: 'EDITED2';\n", |
| 112 ], |
| 113 }, next); |
| 114 }, |
| 115 |
| 116 function testSecondEditDoesNotApply(next) |
| 117 { |
| 118 verifyProtocolError({ |
| 119 styleSheetIds: [ |
| 120 styleSheetId, |
| 121 styleSheetId |
| 122 ], |
| 123 ranges: [ |
| 124 { startLine: 13, startColumn: 11, endLine: 15, endColumn: 4
}, |
| 125 { startLine: 0, startColumn: 7, endLine: 2, endColumn: 0 }, |
| 126 ], |
| 127 texts: [ |
| 128 "\n content: 'EDITED2';\n", |
| 129 "\n content: 'EDITED2';/*\n", |
| 130 ], |
| 131 }, next); |
| 132 }, |
| 133 |
| 134 function testBasicSetStyle(next) |
| 135 { |
| 136 setStyleTexts({ |
| 137 styleSheetIds: [ styleSheetId ], |
| 138 ranges: [ |
| 139 { startLine: 0, startColumn: 7, endLine: 2, endColumn: 0 }, |
| 140 ], |
| 141 texts: [ |
| 142 "\n content: 'EDITED';\n" |
| 143 ], |
| 144 }, undoAndNext(next)); |
| 145 }, |
| 146 |
| 147 function testMultipleStyleTexts1(next) |
| 148 { |
| 149 setStyleTexts({ |
| 150 styleSheetIds: [ |
| 151 styleSheetId, |
| 152 styleSheetId |
| 153 ], |
| 154 ranges: [ |
| 155 { startLine: 13, startColumn: 11, endLine: 15, endColumn: 4
}, |
| 156 { startLine: 0, startColumn: 7, endLine: 2, endColumn: 0 }, |
| 157 ], |
| 158 texts: [ |
| 159 "\n content: 'EDITED1';\n", |
| 160 "\n content: 'EDITED2';\n", |
| 161 ], |
| 162 }, undoAndNext(next)); |
| 163 }, |
| 164 |
| 165 function testMultipleStyleTexts2(next) |
| 166 { |
| 167 setStyleTexts({ |
| 168 styleSheetIds: [ |
| 169 styleSheetId, |
| 170 styleSheetId, |
| 171 styleSheetId |
| 172 ], |
| 173 ranges: [ |
| 174 { startLine: 17, startColumn: 11, endLine: 18, endColumn: 4
}, |
| 175 { startLine: 13, startColumn: 11, endLine: 15, endColumn: 4
}, |
| 176 { startLine: 0, startColumn: 7, endLine: 2, endColumn: 0 }, |
| 177 ], |
| 178 texts: [ |
| 179 "\n content: 'EDITED5';\n", |
| 180 "\n content: 'EDITED4';\n", |
| 181 "\n content: 'EDITED3';\n", |
| 182 ], |
| 183 }, undoAndNext(next)); |
| 184 }, |
| 185 ]; |
| 186 } |
| 187 |
| 188 </script> |
| 189 </head> |
| 190 <body onload="runTest();"> |
| 191 <p>The test verifies functionality of protocol method CSS.setStyleText.</p> |
| 192 <article id="test"></article> |
| 193 </body> |
| 194 </html> |
OLD | NEW |