3 <meta http-equiv="Content-Security-Policy" content="style-src https://*:443 'unsafe-eval'">
4 <script src="../../../http/tests/inspector/inspector-test.js"></script>
5 <script src="../../../http/tests/inspector/elements-test.js"></script>
14 InspectorTest.runTestSuite([
15 function testSetUp(next) {
16 InspectorTest.selectNodeAndWaitForStyles("inspected", next);
19 function testAddRule(next)
21 InspectorTest.nodeWithId("inspected", nodeCallback);
23 function nodeCallback(node)
26 InspectorTest.addNewRule("#inspected", successCallback);
29 function successCallback(section)
31 rule = section.styleRule.rule;
32 InspectorTest.addResult("=== Rule added ===");
33 InspectorTest.addResult(rule.selectorText + " {" + rule.style.cssText + "}");
34 InspectorTest.addResult("Selectors matching the (#inspected) node: " + InspectorTest.matchingSelectors(rule));
39 function testAddProperty(next)
41 rule.style.appendProperty("width", "100%", callback);
43 function callback(newStyle)
45 InspectorTest.addResult("=== Added rule modified ===");
47 InspectorTest.addResult("[!] No valid rule style received");
48 InspectorTest.completeTest();
50 dumpProperties(newStyle);
51 WebInspector.cssModel.setRuleSelector(rule, nodeId, "body", successCallback, failureCallback);
55 function successCallback(rule)
57 var doesAffectSelectedNode = rule.matchingSelectors.length > 0;
58 InspectorTest.addResult("=== Selector changed ===");
59 InspectorTest.addResult(rule.selectorText + " {" + rule.style.cssText + "}");
60 InspectorTest.addResult("Selectors matching the (#inspected) node: " + InspectorTest.matchingSelectors(rule));
65 function failureCallback()
67 InspectorTest.addResult("[!] Failed to change selector");
68 InspectorTest.completeTest();
72 function testModifyInlineStyle(next)
74 WebInspector.cssModel.getInlineStylesAsync(nodeId, stylesCallback);
76 function stylesCallback(inlineStyle)
79 InspectorTest.completeTest();
82 inlineStyle.appendProperty("font-size", "14px", appendCallback);
85 function appendCallback(newStyle)
87 InspectorTest.addResult("=== Inline style modified ===");
89 InspectorTest.addResult("No valid inline style received");
90 InspectorTest.completeTest();
94 dumpProperties(newStyle);
100 function dumpProperties(style)
104 var allProperties = style.allProperties;
105 for (var i = 0; i < allProperties.length; ++i)
106 InspectorTest.addResult(allProperties[i].text);
112 <body onload="runTest()">
114 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.
117 <div id="inspected">Text</div>