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 InspectorTest
.runTestSuite([
16 function testSetUp(next
) {
17 InspectorTest
.selectNodeAndWaitForStyles("inspected", selectCallback
);
19 function selectCallback()
21 var idToDOMNode
= InspectorTest
.domModel
._idToDOMNode
;
22 for (var id
in idToDOMNode
) {
23 node
= idToDOMNode
[id
];
24 if (node
.getAttribute
&& node
.getAttribute("id") === "inspected") {
25 nodeId
= parseInt(id
, 10);
31 InspectorTest
.completeTest();
35 InspectorTest
.cssModel
.matchedStylesPromise(nodeId
, false, false).then(callback
);
38 function callback(rules
)
40 if (!rules
|| !rules
.matchedCSSRules
|| !rules
.matchedCSSRules
.length
) {
41 InspectorTest
.addResult("[!] No rules found");
42 InspectorTest
.completeTest();
46 allRules
= rules
.matchedCSSRules
;
51 function testAddProperty(next
)
53 for (var i
= 0; i
< allRules
.length
; ++i
) {
54 if (allRules
[i
].isRegular()) {
59 rule
.style
.appendProperty("width", "100%", callback
);
60 function callback(success
)
62 InspectorTest
.addResult("=== Rule modified ===");
64 InspectorTest
.addResult("[!] No valid rule style received");
65 InspectorTest
.completeTest();
67 dumpProperties(rule
.style
);
68 InspectorTest
.cssModel
.setRuleSelector(rule
, nodeId
, "body", successCallback
, failureCallback
);
72 function successCallback(rule
, doesAffectSelectedNode
)
74 InspectorTest
.addResult("=== Selector changed ===");
75 InspectorTest
.addResult(rule
.selectorText() + " {" + rule
.style
.cssText
+ "}");
76 InspectorTest
.addResult("Selectors matching the (#inspected) node: " + InspectorTest
.matchingSelectors(rule
));
80 function failureCallback()
82 InspectorTest
.addResult("[!] Failed to change selector");
83 InspectorTest
.completeTest();
88 function dumpProperties(style
)
92 var allProperties
= style
.allProperties
;
93 for (var i
= 0; i
< allProperties
.length
; ++i
)
94 InspectorTest
.addResult(allProperties
[i
].text
);
100 <body onload=
"runTest()">
102 Tests that modifying a rule in a stylesheet loaded from a different domain does not crash the renderer.
105 <div id=
"inspected">Text
</div>