| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <link rel="stylesheet" href="http://localhost:8000/inspector/elements/styles/mod
ify-cross-domain-rule.css"> | 3 <link rel="stylesheet" href="http://localhost:8000/inspector/elements/styles/mod
ify-cross-domain-rule.css"> |
| 4 <script src="inspector-test.js"></script> | 4 <script src="inspector-test.js"></script> |
| 5 <script src="elements-test.js"></script> | 5 <script src="elements-test.js"></script> |
| 6 <script> | 6 <script> |
| 7 | 7 |
| 8 function test() | 8 function test() |
| 9 { | 9 { |
| 10 var nodeId; | 10 var nodeId; |
| 11 var allRules; | 11 var allRules; |
| 12 var rule; | 12 var rule; |
| 13 var matchedRules; | 13 var matchedRules; |
| 14 | 14 |
| 15 InspectorTest.runTestSuite([ | 15 InspectorTest.runTestSuite([ |
| 16 function testSetUp(next) { | 16 function testSetUp(next) { |
| 17 InspectorTest.selectNodeAndWaitForStyles("inspected", selectCallback
); | 17 InspectorTest.selectNodeAndWaitForStyles("inspected", selectCallback
); |
| 18 | 18 |
| 19 function selectCallback() | 19 function selectCallback() |
| 20 { | 20 { |
| 21 var idToDOMNode = WebInspector.domModel._idToDOMNode; | 21 var idToDOMNode = InspectorTest.domModel._idToDOMNode; |
| 22 for (var id in idToDOMNode) { | 22 for (var id in idToDOMNode) { |
| 23 node = idToDOMNode[id]; | 23 node = idToDOMNode[id]; |
| 24 if (node.getAttribute && node.getAttribute("id") === "inspec
ted") { | 24 if (node.getAttribute && node.getAttribute("id") === "inspec
ted") { |
| 25 nodeId = parseInt(id, 10); | 25 nodeId = parseInt(id, 10); |
| 26 break; | 26 break; |
| 27 } | 27 } |
| 28 } | 28 } |
| 29 | 29 |
| 30 if (!nodeId) { | 30 if (!nodeId) { |
| 31 InspectorTest.completeTest(); | 31 InspectorTest.completeTest(); |
| 32 return; | 32 return; |
| 33 } | 33 } |
| 34 | 34 |
| 35 WebInspector.cssModel.getMatchedStylesAsync(nodeId, false, false
, callback); | 35 InspectorTest.cssModel.getMatchedStylesAsync(nodeId, false, fals
e, callback); |
| 36 } | 36 } |
| 37 | 37 |
| 38 function callback(rules) | 38 function callback(rules) |
| 39 { | 39 { |
| 40 if (!rules || !rules.matchedCSSRules || !rules.matchedCSSRules.l
ength) { | 40 if (!rules || !rules.matchedCSSRules || !rules.matchedCSSRules.l
ength) { |
| 41 InspectorTest.addResult("[!] No rules found"); | 41 InspectorTest.addResult("[!] No rules found"); |
| 42 InspectorTest.completeTest(); | 42 InspectorTest.completeTest(); |
| 43 return; | 43 return; |
| 44 } | 44 } |
| 45 | 45 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 58 } | 58 } |
| 59 rule.style.appendProperty("width", "100%", callback); | 59 rule.style.appendProperty("width", "100%", callback); |
| 60 function callback(newStyle) | 60 function callback(newStyle) |
| 61 { | 61 { |
| 62 InspectorTest.addResult("=== Rule modified ==="); | 62 InspectorTest.addResult("=== Rule modified ==="); |
| 63 if (!newStyle) { | 63 if (!newStyle) { |
| 64 InspectorTest.addResult("[!] No valid rule style received"); | 64 InspectorTest.addResult("[!] No valid rule style received"); |
| 65 InspectorTest.completeTest(); | 65 InspectorTest.completeTest(); |
| 66 } else { | 66 } else { |
| 67 dumpProperties(newStyle); | 67 dumpProperties(newStyle); |
| 68 WebInspector.cssModel.setRuleSelector(rule, nodeId, "body",
successCallback, failureCallback); | 68 InspectorTest.cssModel.setRuleSelector(rule, nodeId, "body",
successCallback, failureCallback); |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 | 71 |
| 72 function successCallback(rule, doesAffectSelectedNode) | 72 function successCallback(rule, doesAffectSelectedNode) |
| 73 { | 73 { |
| 74 InspectorTest.addResult("=== Selector changed ==="); | 74 InspectorTest.addResult("=== Selector changed ==="); |
| 75 InspectorTest.addResult(rule.selectorText + " {" + rule.style.cs
sText + "}"); | 75 InspectorTest.addResult(rule.selectorText + " {" + rule.style.cs
sText + "}"); |
| 76 InspectorTest.addResult("Selectors matching the (#inspected) nod
e: " + InspectorTest.matchingSelectors(rule)); | 76 InspectorTest.addResult("Selectors matching the (#inspected) nod
e: " + InspectorTest.matchingSelectors(rule)); |
| 77 next(); | 77 next(); |
| 78 } | 78 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 99 | 99 |
| 100 <body onload="runTest()"> | 100 <body onload="runTest()"> |
| 101 <p> | 101 <p> |
| 102 Tests that modifying a rule in a stylesheet loaded from a different domain does
not crash the renderer. | 102 Tests that modifying a rule in a stylesheet loaded from a different domain does
not crash the renderer. |
| 103 </p> | 103 </p> |
| 104 | 104 |
| 105 <div id="inspected">Text</div> | 105 <div id="inspected">Text</div> |
| 106 | 106 |
| 107 </body> | 107 </body> |
| 108 </html> | 108 </html> |
| OLD | NEW |