3 <link rel="stylesheet" href="http://localhost:8000/inspector/elements/styles/modify-cross-domain-rule.css">
4 <script src="inspector-test.js"></script>
5 <script src="elements-test.js"></script>
15 WebInspector.showPanel("elements");
17 InspectorTest.runTestSuite([
18 function testSetUp(next) {
19 InspectorTest.selectNodeAndWaitForStyles("inspected", selectCallback);
21 function selectCallback()
23 var idToDOMNode = WebInspector.domAgent._idToDOMNode;
24 for (var id in idToDOMNode) {
25 node = idToDOMNode[id];
26 if (node.getAttribute && node.getAttribute("id") === "inspected") {
27 nodeId = parseInt(id, 10);
33 InspectorTest.completeTest();
37 WebInspector.cssModel.getMatchedStylesAsync(nodeId, false, false, callback);
40 function callback(rules)
42 if (!rules || !rules.matchedCSSRules || !rules.matchedCSSRules.length) {
43 InspectorTest.addResult("[!] No rules found");
44 InspectorTest.completeTest();
48 allRules = rules.matchedCSSRules;
53 function testAddProperty(next)
55 for (var i = 0; i < allRules.length; ++i) {
56 if (allRules[i].isRegular) {
61 rule.style.appendProperty("width", "100%", callback);
62 function callback(newStyle)
64 InspectorTest.addResult("=== Rule modified ===");
66 InspectorTest.addResult("[!] No valid rule style received");
67 InspectorTest.completeTest();
69 dumpProperties(newStyle);
70 WebInspector.cssModel.setRuleSelector(rule.id, nodeId, "body", successCallback, failureCallback);
74 function successCallback(rule, doesAffectSelectedNode)
76 InspectorTest.addResult("=== Selector changed ===");
77 InspectorTest.addResult(rule.selectorText + " {" + rule.style.cssText + "}");
78 InspectorTest.addResult("Selectors matching the (#inspected) node: " + InspectorTest.matchingSelectors(rule));
82 function failureCallback()
84 InspectorTest.addResult("[!] Failed to change selector");
85 InspectorTest.completeTest();
90 function dumpProperties(style)
94 var allProperties = style.allProperties;
95 for (var i = 0; i < allProperties.length; ++i)
96 InspectorTest.addResult(allProperties[i].text);
102 <body onload="runTest()">
104 Tests that modifying a rule in a stylesheet loaded from a different domain does not crash the renderer.
107 <div id="inspected">Text</div>