| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <style> | 3 <style> |
| 4 @import url(resources/multiple-imports-edit-crash-1.css); | 4 @import url(resources/multiple-imports-edit-crash-1.css); |
| 5 @import url(resources/multiple-imports-edit-crash-2.css); | 5 @import url(resources/multiple-imports-edit-crash-2.css); |
| 6 @import url(resources/multiple-imports-edit-crash-1.css); | 6 @import url(resources/multiple-imports-edit-crash-1.css); |
| 7 #inspected { | 7 #inspected { |
| 8 color: green; | 8 color: green; |
| 9 } | 9 } |
| 10 </style> | 10 </style> |
| 11 <script src="../../../http/tests/inspector/inspector-test.js"></script> | 11 <script src="../../../http/tests/inspector/inspector-test.js"></script> |
| 12 <script src="../../../http/tests/inspector/elements-test.js"></script> | 12 <script src="../../../http/tests/inspector/elements-test.js"></script> |
| 13 <script> | 13 <script> |
| 14 | 14 |
| 15 function test() | 15 function test() |
| 16 { | 16 { |
| 17 WebInspector.inspectorView.showPanel("elements"); | |
| 18 WebInspector.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.Sty
leSheetAdded, styleSheetAdded, this); | 17 WebInspector.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.Sty
leSheetAdded, styleSheetAdded, this); |
| 19 WebInspector.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.Sty
leSheetRemoved, styleSheetRemoved, this); | 18 WebInspector.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.Sty
leSheetRemoved, styleSheetRemoved, this); |
| 20 InspectorTest.nodeWithId("inspected", nodeFound); | 19 InspectorTest.nodeWithId("inspected", nodeFound); |
| 21 | 20 |
| 22 function nodeFound(node) | 21 function nodeFound(node) |
| 23 { | 22 { |
| 24 WebInspector.cssModel.getMatchedStylesAsync(node.id, true, false, matche
dStylesCallback); | 23 WebInspector.cssModel.getMatchedStylesAsync(node.id, true, false, matche
dStylesCallback); |
| 25 } | 24 } |
| 26 | 25 |
| 27 var styleSheetId; | 26 var styleSheetId; |
| 28 | 27 |
| 29 function matchedStylesCallback(styles) | 28 function matchedStylesCallback(styles) |
| 30 { | 29 { |
| 31 styleSheetId = styles.matchedCSSRules[1].id.styleSheetId; | 30 styleSheetId = styles.matchedCSSRules[1].id.styleSheetId; |
| 31 InspectorTest.addResult("Setting stylesheet text..."); |
| 32 CSSAgent.setStyleSheetText(styleSheetId, | 32 CSSAgent.setStyleSheetText(styleSheetId, |
| 33 "@import url(resources/multiple-imports-edit-crash-1.css);\n@import
url(resources/multiple-imports-edit-crash-2.css);\n#inspected { color: black }\n
"); | 33 "@import url(resources/multiple-imports-edit-crash-1.css);\n@import
url(resources/multiple-imports-edit-crash-2.css);\n#inspected { color: black }\n
"); |
| 34 } | 34 } |
| 35 | 35 |
| 36 function modifiedCallback() | |
| 37 { | |
| 38 WebInspector.cssModel.removeEventListener(WebInspector.CSSStyleModel.Eve
nts.StyleSheetAdded, styleSheetAdded, this); | |
| 39 WebInspector.cssModel.removeEventListener(WebInspector.CSSStyleModel.Eve
nts.StyleSheetRemoved, styleSheetRemoved, this); | |
| 40 InspectorTest.completeTest(); | |
| 41 } | |
| 42 | |
| 43 var addsExpected = 2; | 36 var addsExpected = 2; |
| 44 var removesExpected = 3; | 37 var removesExpected = 3; |
| 45 var added = []; | 38 var added = []; |
| 46 var removed = []; | 39 var removed = []; |
| 47 | 40 |
| 48 function styleSheetAdded(event) | 41 function styleSheetAdded(event) |
| 49 { | 42 { |
| 50 added.push(resourceName(event.data.sourceURL)); | 43 added.push(resourceName(event.data.sourceURL)); |
| 51 | 44 |
| 52 if (!(--addsExpected)) { | 45 if (!(--addsExpected)) { |
| 53 added.sort(); | 46 added.sort(); |
| 54 InspectorTest.addResult("Added:"); | 47 InspectorTest.addResult("Added:"); |
| 55 InspectorTest.addResult(added.join("\n")); | 48 InspectorTest.addResult(added.join("\n")); |
| 49 InspectorTest.completeTest(); |
| 56 } | 50 } |
| 57 } | 51 } |
| 58 | 52 |
| 59 function styleSheetRemoved(event) | 53 function styleSheetRemoved(event) |
| 60 { | 54 { |
| 61 removed.push(resourceName(event.data.sourceURL)); | 55 removed.push(resourceName(event.data.sourceURL)); |
| 62 | 56 |
| 63 if (!(--removesExpected)) { | 57 if (!(--removesExpected)) { |
| 64 removed.sort(); | 58 removed.sort(); |
| 65 InspectorTest.addResult("Removed:"); | 59 InspectorTest.addResult("Removed:"); |
| 66 InspectorTest.addResult(removed.join("\n")); | 60 InspectorTest.addResult(removed.join("\n")); |
| 67 InspectorTest.completeTest(); | |
| 68 } | 61 } |
| 69 } | 62 } |
| 70 | 63 |
| 71 function resourceName(url) | 64 function resourceName(url) |
| 72 { | 65 { |
| 73 return url.substring(url.lastIndexOf("/") + 1); | 66 return url.substring(url.lastIndexOf("/") + 1); |
| 74 } | 67 } |
| 75 } | 68 } |
| 76 | 69 |
| 77 </script> | 70 </script> |
| 78 </head> | 71 </head> |
| 79 | 72 |
| 80 <body onload="runTest()"> | 73 <body onload="runTest()"> |
| 81 <p> | 74 <p> |
| 82 Tests that modifying stylesheet text with multiple @import at-rules does not cra
sh. | 75 Tests that modifying stylesheet text with multiple @import at-rules does not cra
sh. |
| 83 </p> | 76 </p> |
| 84 | 77 |
| 85 <div id="inspected">Text</div> | 78 <div id="inspected">Text</div> |
| 86 </body> | 79 </body> |
| 87 </html> | 80 </html> |
| OLD | NEW |