| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <link rel="stylesheet" href="resources/set-style-text.css"/> | 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> | 4 <script type="text/javascript" src="../../http/tests/inspector-protocol/resource
s/inspector-protocol-test.js"></script> |
| 5 <script type="text/javascript" src="../../http/tests/inspector-protocol/css-prot
ocol-test.js"></script> | 5 <script type="text/javascript" src="../resources/css-protocol-test.js"></script> |
| 6 <script type="text/javascript" src="../../http/tests/inspector-protocol/dom-prot
ocol-test.js"></script> | 6 <script type="text/javascript" src="../resources/dom-protocol-test.js"></script> |
| 7 <script type="text/javascript"> | 7 <script type="text/javascript"> |
| 8 | 8 |
| 9 function removeRule() | 9 function removeRule() |
| 10 { | 10 { |
| 11 document.styleSheets[0].removeRule(0); | 11 document.styleSheets[0].removeRule(0); |
| 12 } | 12 } |
| 13 | 13 |
| 14 function test() | 14 function test() |
| 15 { | 15 { |
| 16 var setStyleTexts; | 16 var setStyleTexts; |
| 17 var verifyProtocolError; | 17 var verifydpError; |
| 18 var documentNodeId; | 18 var documentNodeId; |
| 19 var styleSheetId; | 19 var styleSheetId; |
| 20 | 20 |
| 21 InspectorTest.requestDocumentNodeId(onDocumentNodeId); | 21 InspectorTest.requestDocumentNodeId(onDocumentNodeId); |
| 22 | 22 |
| 23 function onDocumentNodeId(nodeId) | 23 function onDocumentNodeId(nodeId) |
| 24 { | 24 { |
| 25 documentNodeId = nodeId; | 25 documentNodeId = nodeId; |
| 26 InspectorTest.eventHandler["CSS.styleSheetAdded"] = styleSheetAdded; | 26 InspectorTest.eventHandler["CSS.styleSheetAdded"] = styleSheetAdded; |
| 27 InspectorTest.sendCommandOrDie("CSS.enable", {}); | 27 InspectorTest.sendCommandOrDie("CSS.enable", {}); |
| 28 } | 28 } |
| 29 | 29 |
| 30 function styleSheetAdded(result) | 30 function styleSheetAdded(result) |
| 31 { | 31 { |
| 32 styleSheetId = result.params.header.styleSheetId; | 32 styleSheetId = result.params.header.styleSheetId; |
| 33 setStyleTexts = InspectorTest.setStyleTexts.bind(InspectorTest, styleShe
etId, false); | 33 setStyleTexts = InspectorTest.setStyleTexts.bind(InspectorTest, styleShe
etId, false); |
| 34 verifyProtocolError = InspectorTest.setStyleTexts.bind(InspectorTest, st
yleSheetId, true); | 34 verifydpError = InspectorTest.setStyleTexts.bind(InspectorTest, styleShe
etId, true); |
| 35 InspectorTest.sendCommandOrDie("CSS.getStyleSheetText", { styleSheetId:
styleSheetId }, onInitialStyleSheetText); | 35 InspectorTest.sendCommandOrDie("CSS.getStyleSheetText", { styleSheetId:
styleSheetId }, onInitialStyleSheetText); |
| 36 } | 36 } |
| 37 | 37 |
| 38 function dumpAndCall(next) | 38 function dumpAndCall(next) |
| 39 { | 39 { |
| 40 return InspectorTest.loadAndDumpMatchingRules.bind(InspectorTest, docume
ntNodeId, "#test", next); | 40 return InspectorTest.loadAndDumpMatchingRules.bind(InspectorTest, docume
ntNodeId, "#test", next); |
| 41 } | 41 } |
| 42 | 42 |
| 43 function dumpUndoAndNext(next) | 43 function dumpUndoAndNext(next) |
| 44 { | 44 { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 setStyleTexts([{ | 84 setStyleTexts([{ |
| 85 styleSheetId: styleSheetId, | 85 styleSheetId: styleSheetId, |
| 86 range: { startLine: 0, startColumn: 7, endLine: 4, endColumn
: 0 }, | 86 range: { startLine: 0, startColumn: 7, endLine: 4, endColumn
: 0 }, |
| 87 text: "\n color: green;\n padding: 0 8px;\n cursor:
pointer\n", | 87 text: "\n color: green;\n padding: 0 8px;\n cursor:
pointer\n", |
| 88 }], dumpUndoAndNext(next)); | 88 }], dumpUndoAndNext(next)); |
| 89 } | 89 } |
| 90 }, | 90 }, |
| 91 | 91 |
| 92 function testSetStylePoorContent(next) | 92 function testSetStylePoorContent(next) |
| 93 { | 93 { |
| 94 verifyProtocolError([{ | 94 verifydpError([{ |
| 95 styleSheetId: styleSheetId, | 95 styleSheetId: styleSheetId, |
| 96 range: { startLine: 0, startColumn: 7, endLine: 2, endColumn: 0
}, | 96 range: { startLine: 0, startColumn: 7, endLine: 2, endColumn: 0
}, |
| 97 text: "}", | 97 text: "}", |
| 98 }], dumpUndoAndNext(next)); | 98 }], dumpUndoAndNext(next)); |
| 99 }, | 99 }, |
| 100 | 100 |
| 101 function testSetStyleOpenBrace(next) | 101 function testSetStyleOpenBrace(next) |
| 102 { | 102 { |
| 103 verifyProtocolError([{ | 103 verifydpError([{ |
| 104 styleSheetId: styleSheetId, | 104 styleSheetId: styleSheetId, |
| 105 range: { startLine: 0, startColumn: 7, endLine: 2, endColumn: 0
}, | 105 range: { startLine: 0, startColumn: 7, endLine: 2, endColumn: 0
}, |
| 106 text: "{", | 106 text: "{", |
| 107 }], dumpUndoAndNext(next)); | 107 }], dumpUndoAndNext(next)); |
| 108 }, | 108 }, |
| 109 | 109 |
| 110 function testSetStyleComment(next) | 110 function testSetStyleComment(next) |
| 111 { | 111 { |
| 112 verifyProtocolError([{ | 112 verifydpError([{ |
| 113 styleSheetId: styleSheetId, | 113 styleSheetId: styleSheetId, |
| 114 range: { startLine: 0, startColumn: 7, endLine: 2, endColumn: 0
}, | 114 range: { startLine: 0, startColumn: 7, endLine: 2, endColumn: 0
}, |
| 115 text: "/*", | 115 text: "/*", |
| 116 }], dumpUndoAndNext(next)); | 116 }], dumpUndoAndNext(next)); |
| 117 }, | 117 }, |
| 118 | 118 |
| 119 function testSetStyleInMedia(next) | 119 function testSetStyleInMedia(next) |
| 120 { | 120 { |
| 121 setStyleTexts([{ | 121 setStyleTexts([{ |
| 122 styleSheetId: styleSheetId, | 122 styleSheetId: styleSheetId, |
| 123 range: { startLine: 13, startColumn: 11, endLine: 15, endColumn:
4 }, | 123 range: { startLine: 13, startColumn: 11, endLine: 15, endColumn:
4 }, |
| 124 text: "\n content: 'EDITED';\n color: red;\n
/** foo */\n ", | 124 text: "\n content: 'EDITED';\n color: red;\n
/** foo */\n ", |
| 125 }], dumpUndoAndNext(next)); | 125 }], dumpUndoAndNext(next)); |
| 126 }, | 126 }, |
| 127 | 127 |
| 128 function testDeleteStyleBody(next) | 128 function testDeleteStyleBody(next) |
| 129 { | 129 { |
| 130 setStyleTexts([{ | 130 setStyleTexts([{ |
| 131 styleSheetId: styleSheetId, | 131 styleSheetId: styleSheetId, |
| 132 range: { startLine: 13, startColumn: 11, endLine: 15, endColumn:
4 }, | 132 range: { startLine: 13, startColumn: 11, endLine: 15, endColumn:
4 }, |
| 133 text: "", | 133 text: "", |
| 134 }], dumpUndoAndNext(next)); | 134 }], dumpUndoAndNext(next)); |
| 135 }, | 135 }, |
| 136 | 136 |
| 137 function testSetStylePoorRange(next) | 137 function testSetStylePoorRange(next) |
| 138 { | 138 { |
| 139 verifyProtocolError([{ | 139 verifydpError([{ |
| 140 styleSheetId: styleSheetId, | 140 styleSheetId: styleSheetId, |
| 141 range: { startLine: 11, startColumn: 11, endLine: 15, endColumn:
4 }, | 141 range: { startLine: 11, startColumn: 11, endLine: 15, endColumn:
4 }, |
| 142 text: "\n content: 'EDITED';\n", | 142 text: "\n content: 'EDITED';\n", |
| 143 }], dumpUndoAndNext(next)); | 143 }], dumpUndoAndNext(next)); |
| 144 }, | 144 }, |
| 145 | 145 |
| 146 function testSetStyleOpenComment(next) | 146 function testSetStyleOpenComment(next) |
| 147 { | 147 { |
| 148 verifyProtocolError([{ | 148 verifydpError([{ |
| 149 styleSheetId: styleSheetId, | 149 styleSheetId: styleSheetId, |
| 150 range: { startLine: 13, startColumn: 11, endLine: 15, endColumn:
4 }, | 150 range: { startLine: 13, startColumn: 11, endLine: 15, endColumn:
4 }, |
| 151 text: "\n content: 'EDITED'/* ;\n", | 151 text: "\n content: 'EDITED'/* ;\n", |
| 152 }], dumpUndoAndNext(next)); | 152 }], dumpUndoAndNext(next)); |
| 153 }, | 153 }, |
| 154 | 154 |
| 155 function testSetStyleOfRemovedRule(next) | 155 function testSetStyleOfRemovedRule(next) |
| 156 { | 156 { |
| 157 InspectorTest.sendCommandOrDie("Runtime.evaluate", {expression: "rem
oveRule()"}, mutateRule); | 157 InspectorTest.sendCommandOrDie("Runtime.evaluate", {expression: "rem
oveRule()"}, mutateRule); |
| 158 function mutateRule() | 158 function mutateRule() |
| 159 { | 159 { |
| 160 setStyleTexts([{ | 160 setStyleTexts([{ |
| 161 styleSheetId: styleSheetId, | 161 styleSheetId: styleSheetId, |
| 162 range: { startLine: 0, startColumn: 7, endLine: 2, endColumn
: 0 }, | 162 range: { startLine: 0, startColumn: 7, endLine: 2, endColumn
: 0 }, |
| 163 text: "\n content: 'EDITED';\n", | 163 text: "\n content: 'EDITED';\n", |
| 164 }], dumpUndoAndNext(next)); | 164 }], dumpUndoAndNext(next)); |
| 165 } | 165 } |
| 166 } | 166 } |
| 167 ]; | 167 ]; |
| 168 } | 168 } |
| 169 | 169 |
| 170 </script> | 170 </script> |
| 171 </head> | 171 </head> |
| 172 <body onload="runTest();"> | 172 <body onload="runTest();"> |
| 173 <p>The test verifies functionality of protocol method CSS.setStyleTexts.</p> | 173 <p>The test verifies functionality of protocol method CSS.setStyleTexts.</p> |
| 174 <article id="test"></article> | 174 <article id="test"></article> |
| 175 </body> | 175 </body> |
| 176 </html> | 176 </html> |
| OLD | NEW |