Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / inspector / modify-cross-domain-rule.html
blob694eb029eb5f8e5947f067f1c007f298d1a5c08d
1 <html>
2 <head>
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>
6 <script>
8 function test()
10 var nodeId;
11 var allRules;
12 var rule;
13 var matchedRules;
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);
26 break;
30 if (!nodeId) {
31 InspectorTest.completeTest();
32 return;
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();
43 return;
46 allRules = rules.matchedCSSRules;
47 next();
51 function testAddProperty(next)
53 for (var i = 0; i < allRules.length; ++i) {
54 if (allRules[i].isRegular()) {
55 rule = allRules[i];
56 break;
59 rule.style.appendProperty("width", "100%", callback);
60 function callback(success)
62 InspectorTest.addResult("=== Rule modified ===");
63 if (!success) {
64 InspectorTest.addResult("[!] No valid rule style received");
65 InspectorTest.completeTest();
66 } else {
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));
77 next();
80 function failureCallback()
82 InspectorTest.addResult("[!] Failed to change selector");
83 InspectorTest.completeTest();
86 ]);
88 function dumpProperties(style)
90 if (!style)
91 return;
92 var allProperties = style.allProperties;
93 for (var i = 0; i < allProperties.length; ++i)
94 InspectorTest.addResult(allProperties[i].text);
97 </script>
98 </head>
100 <body onload="runTest()">
102 Tests that modifying a rule in a stylesheet loaded from a different domain does not crash the renderer.
103 </p>
105 <div id="inspected">Text</div>
107 </body>
108 </html>