Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / elements / styles-2 / multiple-imports-edit-crash.html
blob2d90b024db8d6b0e6d675dbdd6675f809f60f2f5
1 <html>
2 <head>
3 <style>
4 @import url(../styles/resources/multiple-imports-edit-crash-1.css);
5 @import url(../styles/resources/multiple-imports-edit-crash-2.css);
6 @import url(../styles/resources/multiple-imports-edit-crash-1.css);
7 #inspected {
8 color: green;
10 </style>
11 <script src="../../../http/tests/inspector/inspector-test.js"></script>
12 <script src="../../../http/tests/inspector/elements-test.js"></script>
13 <script>
15 function test()
17 InspectorTest.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleSheetAdded, styleSheetAdded, this);
18 InspectorTest.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleSheetRemoved, styleSheetRemoved, this);
19 InspectorTest.nodeWithId("inspected", nodeFound);
21 function nodeFound(node)
23 InspectorTest.cssModel.matchedStylesPromise(node.id, true, false).then(matchedStylesCallback);
26 var styleSheetId;
28 function matchedStylesCallback(styles)
30 styleSheetId = styles.matchedCSSRules[1].styleSheetId;
31 InspectorTest.addResult("Setting stylesheet text...");
32 InspectorTest.CSSAgent.setStyleSheetText(styleSheetId,
33 "@import url(../styles/resources/multiple-imports-edit-crash-1.css);\n@import url(../styles/resources/multiple-imports-edit-crash-2.css);\n#inspected { color: black }\n");
36 var addsExpected = 2;
37 var removesExpected = 3;
38 var added = [];
39 var removed = [];
41 function styleSheetAdded(event)
43 added.push(resourceName(event.data.sourceURL));
45 if (!(--addsExpected)) {
46 added.sort();
47 InspectorTest.addResult("Added:");
48 InspectorTest.addResult(added.join("\n"));
49 InspectorTest.completeTest();
53 function styleSheetRemoved(event)
55 removed.push(resourceName(event.data.sourceURL));
57 if (!(--removesExpected)) {
58 removed.sort();
59 InspectorTest.addResult("Removed:");
60 InspectorTest.addResult(removed.join("\n"));
64 function resourceName(url)
66 return url.substring(url.lastIndexOf("/") + 1);
70 </script>
71 </head>
73 <body onload="runTest()">
74 <p>
75 Tests that modifying stylesheet text with multiple @import at-rules does not crash.
76 </p>
78 <div id="inspected">Text</div>
79 </body>
80 </html>