Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / elements / styles-1 / add-new-rule-inline-style-csp.html
blob8951892185466b25d405becc69fe4074e4f819c0
1 <html>
2 <head>
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>
6 <script>
8 function test()
10 var nodeId;
11 var rule;
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)
25 nodeId = node.id;
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));
35 next();
39 function testAddProperty(next)
41 rule.style.appendProperty("width", "100%", callback);
43 function callback(success)
45 InspectorTest.addResult("=== Added rule modified ===");
46 if (!success) {
47 InspectorTest.addResult("[!] No valid rule style received");
48 InspectorTest.completeTest();
49 } else {
50 dumpProperties(rule.style);
51 InspectorTest.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));
62 next();
65 function failureCallback()
67 InspectorTest.addResult("[!] Failed to change selector");
68 InspectorTest.completeTest();
72 function testModifyInlineStyle(next)
74 var inlineStyle;
75 InspectorTest.cssModel.inlineStylesPromise(nodeId).then(stylesCallback);
77 function stylesCallback(inlineStyleResult)
79 if (!inlineStyleResult || !inlineStyleResult.inlineStyle) {
80 InspectorTest.completeTest();
81 return;
83 inlineStyle = inlineStyleResult.inlineStyle;
84 inlineStyle.appendProperty("font-size", "14px", appendCallback);
87 function appendCallback(success)
89 InspectorTest.addResult("=== Inline style modified ===");
90 if (!success) {
91 InspectorTest.addResult("No valid inline style received");
92 InspectorTest.completeTest();
93 return;
96 dumpProperties(inlineStyle);
97 next();
102 function dumpProperties(style)
104 if (!style)
105 return;
106 var allProperties = style.allProperties;
107 for (var i = 0; i < allProperties.length; ++i)
108 InspectorTest.addResult(allProperties[i].text);
111 </script>
112 </head>
114 <body onload="runTest()">
116 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 </p>
119 <div id="inspected">Text</div>
121 </body>
122 </html>