Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <html> | |
| 2 <head> | |
| 3 <link rel="stylesheet" href="resources/add-rule.css"/> | |
| 4 <script type="text/javascript" src="../../http/tests/inspector-protocol/inspecto r-protocol-test.js"></script> | |
| 5 <script type="text/javascript" src="css-protocol-test.js"></script> | |
| 6 <script type="text/javascript"> | |
| 7 function test() | |
| 8 { | |
| 9 var addRule; | |
| 10 var verifyProtocolError; | |
| 11 var dumpStyleSheet; | |
| 12 var documentNodeId; | |
| 13 | |
| 14 InspectorTest.requestDocumentNodeId(onDocumentNodeId); | |
| 15 | |
| 16 function onDocumentNodeId(nodeId) | |
| 17 { | |
| 18 documentNodeId = nodeId; | |
| 19 InspectorTest.eventHandler["CSS.styleSheetAdded"] = styleSheetAdded; | |
| 20 InspectorTest.sendCommandOrDie("CSS.enable", {}); | |
| 21 } | |
| 22 | |
| 23 function styleSheetAdded(result) | |
| 24 { | |
| 25 var styleSheetId = result.params.header.styleSheetId; | |
| 26 addRule = InspectorTest.addRule.bind(InspectorTest, styleSheetId, false) ; | |
| 27 verifyProtocolError = InspectorTest.addRule.bind(InspectorTest, styleShe etId, true); | |
| 28 dumpStyleSheet = InspectorTest.dumpStyleSheetText.bind(null, styleSheetI d); | |
| 29 InspectorTest.sendCommandOrDie("CSS.getStyleSheetText", { styleSheetId: styleSheetId }, onInitialStyleSheetText); | |
| 30 } | |
| 31 | |
| 32 function dumpAndNext(next) | |
| 33 { | |
| 34 return InspectorTest.loadAndDumpMatchingRules.bind(InspectorTest, docume ntNodeId, "#test", InspectorTest.undoAndNext(next)); | |
| 35 } | |
| 36 | |
| 37 function onInitialStyleSheetText(result) | |
| 38 { | |
| 39 InspectorTest.log("==== Initial style sheet text ===="); | |
| 40 InspectorTest.log(result.text); | |
| 41 InspectorTest.runTestSuite(testSuite); | |
| 42 } | |
| 43 | |
| 44 var testSuite = [ | |
| 45 /* Tests that add rule into style sheet. */ | |
| 46 | |
| 47 function testAddRuleToStyleSheetBeginning(next) | |
| 48 { | |
| 49 addRule({ | |
| 50 location: { startLine: 0, startColumn: 0, endLine: 0, endColumn: 0 }, | |
| 51 ruleText: "#test { content: 'EDITED'; }", | |
|
vsevik
2014/08/12 15:53:54
Can we test a scenario where we add some '\n' symb
lushnikov
2014/08/13 09:10:48
Done.
| |
| 52 }, dumpAndNext(next)); | |
| 53 }, | |
| 54 | |
| 55 function testAddRuleToStyleSheetEnding(next) | |
| 56 { | |
| 57 addRule({ | |
| 58 location: { startLine: 20, startColumn: 0, endLine: 20, endColum n: 0 }, | |
| 59 ruleText: "#test { content: 'EDITED'; }", | |
| 60 }, dumpAndNext(next)); | |
| 61 }, | |
| 62 | |
| 63 function testAddRuleToStyleSheetCenter(next) | |
| 64 { | |
| 65 addRule({ | |
| 66 location: { startLine: 11, startColumn: 0, endLine: 11, endColum n: 0 }, | |
| 67 ruleText: "#test { content: 'EDITED'; }", | |
| 68 }, dumpAndNext(next)); | |
| 69 }, | |
| 70 | |
| 71 function testAddRuleToRuleEnding(next) | |
| 72 { | |
| 73 addRule({ | |
| 74 location: { startLine: 2, startColumn: 1, endLine: 2, endColumn: 1 }, | |
| 75 ruleText: "#test{\n content: 'EDITED';\n}", | |
| 76 }, dumpAndNext(next)); | |
| 77 }, | |
| 78 | |
| 79 /* Tests that add rule into MediaRule. */ | |
| 80 | |
| 81 function testAddRuleToMediaRuleBeginning(next) | |
| 82 { | |
| 83 addRule({ | |
| 84 location: { startLine: 12, startColumn: 25, endLine: 12, endColu mn: 25 }, | |
| 85 ruleText: "#test { content: 'EDITED'; }", | |
| 86 }, dumpAndNext(next)); | |
| 87 }, | |
| 88 | |
| 89 function testAddRuleToMediaRuleCenter(next) | |
| 90 { | |
| 91 addRule({ | |
| 92 location: { startLine: 16, startColumn: 0, endLine: 16, endColum n: 0 }, | |
| 93 ruleText: "#test { content: 'EDITED'; }", | |
| 94 }, dumpAndNext(next)); | |
| 95 }, | |
| 96 | |
| 97 function testAddRuleToMediaRuleEnd(next) | |
| 98 { | |
| 99 addRule({ | |
| 100 location: { startLine: 19, startColumn: 0, endLine: 19, endColum n: 0 }, | |
| 101 ruleText: "#test { content: 'EDITED'; }", | |
| 102 }, dumpAndNext(next)); | |
| 103 }, | |
| 104 | |
| 105 /* Tests that verify error reporting. */ | |
| 106 | |
| 107 function testInvalidRule(next) | |
| 108 { | |
| 109 verifyProtocolError({ | |
| 110 location: { startLine: 0, startColumn: 0, endLine: 0, endColumn: 0 }, | |
| 111 ruleText: "#test { content: 'EDITED';", | |
| 112 }, next); | |
| 113 }, | |
| 114 | |
| 115 function testAddingRuleInsideSelector(next) | |
| 116 { | |
| 117 verifyProtocolError({ | |
| 118 location: { startLine: 0, startColumn: 2, endLine: 0, endColumn: 2 }, | |
| 119 ruleText: "#test { content: 'EDITED'; }", | |
| 120 }, next); | |
| 121 }, | |
| 122 | |
| 123 function testAddingRuleBeforeRuleBody(next) | |
| 124 { | |
| 125 verifyProtocolError({ | |
| 126 location: { startLine: 4, startColumn: 6, endLine: 4, endColumn: 6 }, | |
| 127 ruleText: "#test { content: 'EDITED'; }", | |
| 128 }, next); | |
| 129 }, | |
| 130 | |
| 131 function testAddingRuleInsideMedia1(next) | |
| 132 { | |
| 133 verifyProtocolError({ | |
| 134 location: { startLine: 12, startColumn: 3, endLine: 12, endColum n: 3 }, | |
| 135 ruleText: "#test { content: 'EDITED'; }", | |
| 136 }, next); | |
| 137 }, | |
| 138 | |
| 139 function testAddingRuleInsideMedia2(next) | |
| 140 { | |
| 141 verifyProtocolError({ | |
| 142 location: { startLine: 12, startColumn: 15, endLine: 12, endColu mn: 15 }, | |
| 143 ruleText: "#test { content: 'EDITED'; }", | |
| 144 }, next); | |
| 145 }, | |
| 146 | |
| 147 function testAddingRuleBeforeMediaBody(next) | |
| 148 { | |
| 149 verifyProtocolError({ | |
| 150 location: { startLine: 12, startColumn: 24, endLine: 12, endColu mn: 24 }, | |
| 151 ruleText: "#test { content: 'EDITED'; }", | |
| 152 }, next); | |
| 153 }, | |
| 154 | |
| 155 function testAddingRuleInsideStyleRule(next) | |
| 156 { | |
| 157 verifyProtocolError({ | |
| 158 location: { startLine: 18, startColumn: 0, endLine: 18, endColum n: 0 }, | |
| 159 ruleText: "#test { content: 'EDITED'; }", | |
| 160 }, next); | |
| 161 }, | |
| 162 ]; | |
| 163 } | |
| 164 | |
| 165 </script> | |
| 166 </head> | |
| 167 <body onload="runTest();"> | |
| 168 <p>The test verifies functionality of protocol method CSS.addRule.</p> | |
| 169 <article id="test"></article> | |
| 170 </body> | |
| 171 </html> | |
| OLD | NEW |