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 setStyleTexts; |
| 12 var verifyProtocolError; |
| 13 var styleSheetId; |
| 14 var undoAndNext = InspectorTest.undoAndNext; |
| 15 |
| 16 InspectorTest.requestDocumentNodeId(onDocumentNodeId); |
| 17 |
| 18 function onDocumentNodeId(nodeId) |
| 19 { |
| 20 InspectorTest.eventHandler["CSS.styleSheetAdded"] = styleSheetAdded; |
| 21 InspectorTest.sendCommandOrDie("CSS.enable", {}); |
| 22 } |
| 23 |
| 24 function styleSheetAdded(result) |
| 25 { |
| 26 styleSheetId = result.params.header.styleSheetId; |
| 27 setStyleTexts = InspectorTest.setStyleTexts.bind(InspectorTest, styleShe
etId, false); |
| 28 verifyProtocolError = InspectorTest.setStyleTexts.bind(InspectorTest, st
yleSheetId, true); |
| 29 InspectorTest.sendCommandOrDie("CSS.getStyleSheetText", { styleSheetId:
styleSheetId }, onInitialStyleSheetText); |
| 30 } |
| 31 |
| 32 function onInitialStyleSheetText(result) |
| 33 { |
| 34 InspectorTest.log("==== Initial style sheet text ===="); |
| 35 InspectorTest.log(result.text); |
| 36 InspectorTest.runTestSuite(testSuite); |
| 37 } |
| 38 |
| 39 var testSuite = [ |
| 40 function testMalformedArguments1(next) |
| 41 { |
| 42 verifyProtocolError([ |
| 43 { |
| 44 styleSheetId: styleSheetId, |
| 45 range: { startLine: 13, startColumn: 11, endLine: 15, endCol
umn: 4 }, |
| 46 text: "\n content: 'EDITED';\n", |
| 47 }, |
| 48 { |
| 49 range: { startLine: 0, startColumn: 7, endLine: 2, endColumn
: 0 }, |
| 50 text: "\n content: 'EDITED';\n", |
| 51 }, |
| 52 ], next); |
| 53 }, |
| 54 |
| 55 function testMalformedArguments2(next) |
| 56 { |
| 57 verifyProtocolError([ |
| 58 { |
| 59 styleSheetId: styleSheetId, |
| 60 }, |
| 61 { |
| 62 styleSheetId: styleSheetId, |
| 63 range: { startLine: 13, startColumn: 11, endLine: 15, endCol
umn: 4 }, |
| 64 text: "\n content: 'EDITED';\n", |
| 65 }, |
| 66 { |
| 67 range: { startLine: 0, startColumn: 7, endLine: 2, endColumn
: 0 }, |
| 68 text: "\n content: 'EDITED';\n", |
| 69 }, |
| 70 ], next); |
| 71 }, |
| 72 |
| 73 function testMalformedArguments3(next) |
| 74 { |
| 75 verifyProtocolError([ |
| 76 { |
| 77 styleSheetId: styleSheetId, |
| 78 range: { startLine: "STRING INSTEAD OF NUMBER", startColumn:
11, endLine: 15, endColumn: 4 }, |
| 79 text: "\n content: 'EDITED';\n", |
| 80 }, |
| 81 { |
| 82 styleSheetId: styleSheetId, |
| 83 range: { startLine: 0, startColumn: 7, endLine: 2, endColumn
: 0 }, |
| 84 text: "\n content: 'EDITED';\n", |
| 85 }, |
| 86 ], next); |
| 87 }, |
| 88 |
| 89 function testFirstEditDoesNotApply(next) |
| 90 { |
| 91 verifyProtocolError([ |
| 92 { |
| 93 styleSheetId: styleSheetId, |
| 94 range: { startLine: 13, startColumn: 11, endLine: 15, endCol
umn: 4 }, |
| 95 text: "\n content: 'EDITED';/*\n", |
| 96 }, |
| 97 { |
| 98 styleSheetId: styleSheetId, |
| 99 range: { startLine: 0, startColumn: 7, endLine: 2, endColumn
: 0 }, |
| 100 text: "\n content: 'EDITED';\n", |
| 101 }, |
| 102 ], next); |
| 103 }, |
| 104 |
| 105 function testSecondEditDoesNotApply(next) |
| 106 { |
| 107 verifyProtocolError([ |
| 108 { |
| 109 styleSheetId: styleSheetId, |
| 110 range: { startLine: 13, startColumn: 11, endLine: 15, endCol
umn: 4 }, |
| 111 text: "\n content: 'EDITED';\n", |
| 112 }, |
| 113 { |
| 114 styleSheetId: styleSheetId, |
| 115 range: { startLine: 0, startColumn: 7, endLine: 2, endColumn
: 0 }, |
| 116 text: "\n content: 'EDITED';/*\n", |
| 117 }, |
| 118 ], next); |
| 119 }, |
| 120 |
| 121 function testBasicSetStyle(next) |
| 122 { |
| 123 setStyleTexts([ |
| 124 { |
| 125 styleSheetId: styleSheetId, |
| 126 range: { startLine: 0, startColumn: 7, endLine: 2, endColumn
: 0 }, |
| 127 text: "\n content: 'EDITED';\n" |
| 128 }, |
| 129 ], undoAndNext(next)); |
| 130 }, |
| 131 |
| 132 function testMultipleStyleTexts1(next) |
| 133 { |
| 134 setStyleTexts([ |
| 135 { |
| 136 styleSheetId: styleSheetId, |
| 137 range: { startLine: 13, startColumn: 11, endLine: 15, endCol
umn: 4 }, |
| 138 text: "\n content: 'EDITED1';\n", |
| 139 }, |
| 140 { |
| 141 styleSheetId: styleSheetId, |
| 142 range: { startLine: 0, startColumn: 7, endLine: 2, endColumn
: 0 }, |
| 143 text: "\n content: 'EDITED2';\n", |
| 144 }, |
| 145 ], undoAndNext(next)); |
| 146 }, |
| 147 |
| 148 function testMultipleStyleTexts2(next) |
| 149 { |
| 150 setStyleTexts([ |
| 151 { |
| 152 styleSheetId: styleSheetId, |
| 153 range: { startLine: 17, startColumn: 11, endLine: 18, endCol
umn: 4 }, |
| 154 text: "\n content: 'EDITED5';\n", |
| 155 }, |
| 156 { |
| 157 styleSheetId: styleSheetId, |
| 158 range: { startLine: 13, startColumn: 11, endLine: 15, endCol
umn: 4 }, |
| 159 text: "\n content: 'EDITED4';\n", |
| 160 }, |
| 161 { |
| 162 styleSheetId: styleSheetId, |
| 163 range: { startLine: 0, startColumn: 7, endLine: 2, endColumn
: 0 }, |
| 164 text: "\n content: 'EDITED3';\n", |
| 165 }, |
| 166 ], undoAndNext(next)); |
| 167 }, |
| 168 ]; |
| 169 } |
| 170 |
| 171 </script> |
| 172 </head> |
| 173 <body onload="runTest();"> |
| 174 <p>The test verifies functionality of protocol method CSS.setStyleTexts.</p> |
| 175 <article id="test"></article> |
| 176 </body> |
| 177 </html> |
OLD | NEW |