Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / elements / styles / dynamic-style-tag.html
1 <html>
2 <head>
3 <script src="../../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../../http/tests/inspector/elements-test.js"></script>
5 <style>
6 /* comment */.inline-style-added-by-parser {
7    color: red;
8 }
9 </style>
10 <style>
11 .inline-style-added-by-parser-with-source-url {
12    color: green;
13 }
14 /*# sourceURL=inlineStyleAddedByParser.css*/
15 </style>
16 <script>
17 document.write("<style>\n.inline-style-added-by-parser-in-document-write {\n   color: blue;\n}\n</style>");
18 document.write("<style>\n.inline-style-added-by-document-write-with-source-url {\n   color: yellow;\n}\n/*# sourceURL=inlineStyleAddedByDocumentWrite.css*/\n</style>");
19 addStyleElement(".inline-style-created-by-script {\n   color: orange;\n}");
20 addStyleElement(".inline-style-created-by-script-with-source-url {\n   color: grey;\n}\n/*# sourceURL=inlineStyleCreatedByScript.css*/");
21
22 function addStyleElement(styleContent)
23 {
24     var styleElement = document.createElement("style");
25     styleElement.textContent = styleContent;
26     document.head.appendChild(styleElement);
27 }
28
29 function test()
30 {
31     InspectorTest.selectNodeAndWaitForStyles("inspected", step1);
32
33     function step1()
34     {
35         var styleSheets = WebInspector.cssModel.allStyleSheets();
36         styleSheets.sort();
37         for (var i = 0; i < styleSheets.length; ++i)
38             CSSAgent.getStyleSheetText(styleSheets[i].id, dumpStyleSheet.bind(null, styleSheets[i], i === styleSheets.length - 1));
39     }
40
41     function dumpStyleSheet(header, isLast, error, content, callback)
42     {
43         InspectorTest.addResult("Stylesheet added:");
44         InspectorTest.addResult("  - isInline: " + header.isInline);
45         InspectorTest.addResult("  - sourceURL: " + header.sourceURL.substring(header.sourceURL.lastIndexOf("/") + 1));
46         InspectorTest.addResult("  - hasSourceURL: " + header.hasSourceURL);
47         InspectorTest.addResult("  - contents: " + content);
48         if (isLast) {
49             InspectorTest.dumpSelectedElementStyles(true, false, true);
50             InspectorTest.completeTest();
51         }
52     }
53 }
54 </script>
55 </head>
56 <body onload="runTest()">
57 <p>Tests that different types of inline styles are correctly disambiguated and their sourceURL is correct.
58 <div id="inspected" style="color:red" class="inline-style-added-by-parser inline-style-added-by-parser-with-source-url inline-style-added-by-parser-in-document-write inline-style-added-by-document-write-with-source-url inline-style-created-by-script inline-style-created-by-script-with-source-url"></div>
59 </body>
60 </html>
61