3 <script src="../../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../../http/tests/inspector/elements-test.js"></script>
6 /* comment */.inline-style-added-by-parser {
11 .inline-style-added-by-parser-with-source-url {
14 /*# sourceURL=inlineStyleAddedByParser.css*/
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*/");
22 function addStyleElement(styleContent)
24 var styleElement = document.createElement("style");
25 styleElement.textContent = styleContent;
26 document.head.appendChild(styleElement);
31 WebInspector.cssModel.addEventListener(WebInspector.CSSStyleModel.Events.StyleSheetAdded, styleSheetAdded);
32 InspectorTest.reloadPage(step1);
34 function pathToFileName(path)
36 return path.substring(path.lastIndexOf("/") + 1);
41 InspectorTest.selectNodeAndWaitForStyles("inspected", step2);
46 InspectorTest.dumpSelectedElementStyles(true, false, true);
47 InspectorTest.completeTest();
50 function dumpStyleSheetHeader(header, text)
52 InspectorTest.addResult("Stylesheet added:");
53 InspectorTest.addResult(" - isInline: " + header.isInline);
54 InspectorTest.addResult(" - sourceURL: " + pathToFileName(header.sourceURL));
55 InspectorTest.addResult(" - hasSourceURL: " + header.hasSourceURL);
56 InspectorTest.addResult(" - contents: " + text);
59 function styleSheetAdded(event)
61 var header = event.data;
62 CSSAgent.getStyleSheetText(header.id, contentLoaded.bind(this));
64 function contentLoaded(error, text)
66 dumpStyleSheetHeader(header, text);
72 <body onload="runTest()">
73 <p>Tests that different types of inline styles are correctly disambiguated and their sourceURL is correct.
74 <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>