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(success
)
45 InspectorTest
.addResult("=== Added rule modified ===");
47 InspectorTest
.addResult("[!] No valid rule style received");
48 InspectorTest
.completeTest();
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
));
65 function failureCallback()
67 InspectorTest
.addResult("[!] Failed to change selector");
68 InspectorTest
.completeTest();
72 function testModifyInlineStyle(next
)
75 InspectorTest
.cssModel
.inlineStylesPromise(nodeId
).then(stylesCallback
);
77 function stylesCallback(inlineStyleResult
)
79 if (!inlineStyleResult
|| !inlineStyleResult
.inlineStyle
) {
80 InspectorTest
.completeTest();
83 inlineStyle
= inlineStyleResult
.inlineStyle
;
84 inlineStyle
.appendProperty("font-size", "14px", appendCallback
);
87 function appendCallback(success
)
89 InspectorTest
.addResult("=== Inline style modified ===");
91 InspectorTest
.addResult("No valid inline style received");
92 InspectorTest
.completeTest();
96 dumpProperties(inlineStyle
);
102 function dumpProperties(style
)
106 var allProperties
= style
.allProperties
;
107 for (var i
= 0; i
< allProperties
.length
; ++i
)
108 InspectorTest
.addResult(allProperties
[i
].text
);
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.
119 <div id=
"inspected">Text
</div>