| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <meta http-equiv="Content-Security-Policy" content="style-src https://*:443 'uns
afe-eval'"> | 3 <meta http-equiv="Content-Security-Policy" content="style-src https://*:443 'uns
afe-eval'"> |
| 4 <script src="../../../http/tests/inspector/inspector-test.js"></script> | 4 <script src="../../../http/tests/inspector/inspector-test.js"></script> |
| 5 <script src="../../../http/tests/inspector/elements-test.js"></script> | 5 <script src="../../../http/tests/inspector/elements-test.js"></script> |
| 6 <script> | 6 <script> |
| 7 | 7 |
| 8 function test() | 8 function test() |
| 9 { | 9 { |
| 10 var nodeId; | 10 var nodeId; |
| 11 var rule; | 11 var rule; |
| 12 | 12 |
| 13 WebInspector.showPanel("elements"); | 13 WebInspector.showPanel("elements"); |
| 14 | 14 |
| 15 InspectorTest.runTestSuite([ | 15 InspectorTest.runTestSuite([ |
| 16 function testSetUp(next) { | 16 function testSetUp(next) { |
| 17 InspectorTest.selectNodeAndWaitForStyles("inspected", next); | 17 InspectorTest.selectNodeAndWaitForStyles("inspected", next); |
| 18 }, | 18 }, |
| 19 | 19 |
| 20 function testAddRule(next) | 20 function testAddRule(next) |
| 21 { | 21 { |
| 22 InspectorTest.nodeWithId("inspected", nodeCallback); | 22 InspectorTest.nodeWithId("inspected", nodeCallback); |
| 23 | 23 |
| 24 function nodeCallback(node) | 24 function nodeCallback(node) |
| 25 { | 25 { |
| 26 nodeId = node.id; | 26 nodeId = node.id; |
| 27 WebInspector.cssModel.addRule(nodeId, "#inspected", successCallb
ack, failureCallback); | 27 InspectorTest.addNewRule("#inspected", successCallback); |
| 28 } | 28 } |
| 29 | 29 |
| 30 function successCallback(newRule, doesAffectSelectedNode) | 30 function successCallback(styleRule) |
| 31 { | 31 { |
| 32 rule = newRule; | 32 rule = styleRule.rule; |
| 33 InspectorTest.addResult("=== Rule added ==="); | 33 InspectorTest.addResult("=== Rule added ==="); |
| 34 InspectorTest.addResult(rule.selectorText + " {" + rule.style.cs
sText + "}"); | 34 InspectorTest.addResult(rule.selectorText + " {" + rule.style.cs
sText + "}"); |
| 35 InspectorTest.addResult("Selectors matching the (#inspected) nod
e: " + InspectorTest.matchingSelectors(rule)); | 35 InspectorTest.addResult("Selectors matching the (#inspected) nod
e: " + InspectorTest.matchingSelectors(rule)); |
| 36 next(); | 36 next(); |
| 37 } | 37 } |
| 38 | |
| 39 function failureCallback() | |
| 40 { | |
| 41 InspectorTest.addResult("[!] Failed to add rule."); | |
| 42 InspectorTest.completeTest(); | |
| 43 } | |
| 44 }, | 38 }, |
| 45 | 39 |
| 46 function testAddProperty(next) | 40 function testAddProperty(next) |
| 47 { | 41 { |
| 48 rule.style.appendProperty("width", "100%", callback); | 42 rule.style.appendProperty("width", "100%", callback); |
| 49 | 43 |
| 50 function callback(newStyle) | 44 function callback(newStyle) |
| 51 { | 45 { |
| 52 InspectorTest.addResult("=== Added rule modified ==="); | 46 InspectorTest.addResult("=== Added rule modified ==="); |
| 53 if (!newStyle) { | 47 if (!newStyle) { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 | 112 |
| 119 <body onload="runTest()"> | 113 <body onload="runTest()"> |
| 120 <p> | 114 <p> |
| 121 Tests that adding a new rule does not crash the renderer and modifying an inline
style does not report errors when forbidden by Content-Security-Policy. | 115 Tests that adding a new rule does not crash the renderer and modifying an inline
style does not report errors when forbidden by Content-Security-Policy. |
| 122 </p> | 116 </p> |
| 123 | 117 |
| 124 <div id="inspected">Text</div> | 118 <div id="inspected">Text</div> |
| 125 | 119 |
| 126 </body> | 120 </body> |
| 127 </html> | 121 </html> |
| OLD | NEW |