3 <meta http-equiv="Content-Security-Policy" content="style-src https://*:443">
4 <script src="../../http/tests/inspector/inspector-test.js"></script>
5 <script src="../../http/tests/inspector/elements-test.js"></script>
13 WebInspector.showPanel("elements");
15 InspectorTest.runTestSuite([
16 function testSetUp(next) {
17 InspectorTest.selectNodeAndWaitForStyles("inspected", next);
20 function testAddRule(next)
22 InspectorTest.nodeWithId("inspected", nodeCallback);
24 function nodeCallback(node)
27 WebInspector.cssModel.addRule(nodeId, "#inspected", successCallback, failureCallback);
30 function successCallback(newRule, doesAffectSelectedNode)
33 InspectorTest.addResult("=== Rule added ===");
34 InspectorTest.addResult(rule.selectorText + " {" + rule.style.cssText + "}");
35 InspectorTest.addResult("Selectors matching the (#inspected) node: " + InspectorTest.matchingSelectors(rule));
39 function failureCallback()
41 InspectorTest.addResult("[!] Failed to add rule.");
42 InspectorTest.completeTest();
46 function testAddProperty(next)
48 rule.style.appendProperty("width", "100%", callback);
50 function callback(newStyle)
52 InspectorTest.addResult("=== Added rule modified ===");
54 InspectorTest.addResult("[!] No valid rule style received");
55 InspectorTest.completeTest();
57 dumpProperties(newStyle);
58 WebInspector.cssModel.setRuleSelector(rule.id, nodeId, "body", successCallback, failureCallback);
62 function successCallback(rule)
64 var doesAffectSelectedNode = rule.matchingSelectors.length > 0;
65 InspectorTest.addResult("=== Selector changed ===");
66 InspectorTest.addResult(rule.selectorText + " {" + rule.style.cssText + "}");
67 InspectorTest.addResult("Selectors matching the (#inspected) node: " + InspectorTest.matchingSelectors(rule));
72 function failureCallback()
74 InspectorTest.addResult("[!] Failed to change selector");
75 InspectorTest.completeTest();
79 function testModifyInlineStyle(next)
81 WebInspector.cssModel.getInlineStylesAsync(nodeId, stylesCallback);
83 function stylesCallback(inlineStyle)
86 InspectorTest.completeTest();
89 inlineStyle.appendProperty("font-size", "14px", appendCallback);
92 function appendCallback(newStyle)
94 InspectorTest.addResult("=== Inline style modified ===");
96 InspectorTest.addResult("No valid inline style received");
97 InspectorTest.completeTest();
101 dumpProperties(newStyle);
107 function dumpProperties(style)
111 var allProperties = style.allProperties;
112 for (var i = 0; i < allProperties.length; ++i)
113 InspectorTest.addResult(allProperties[i].text);
119 <body onload="runTest()">
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.
124 <div id="inspected">Text</div>