3 <script src=
"../../../http/tests/inspector/inspector-test.js"></script>
4 <script src=
"../../../http/tests/inspector/debugger-test.js"></script>
10 /*# sourceURL=inlineStyleSheet.css */
13 function addInlineStyleSheet()
15 var styleElement
= document
.createElement("style");
16 styleElement
.textContent
= "body { color: black; }\n/*# sourceURL=css/addedInlineStylesheet.css */";
17 document
.head
.appendChild(styleElement
);
20 function addInlineStyleSheetDeprecated()
22 var styleElement
= document
.createElement("style");
23 styleElement
.textContent
= "body { color: black; }\n/*@ sourceURL=css/addedInlineStylesheetDeprecated.css */";
24 document
.head
.appendChild(styleElement
);
27 function addInlineStyleSheetNonRelative()
29 var styleElement
= document
.createElement("style");
30 styleElement
.textContent
= "body { color: red; }\n/*# sourceURL=/css/nonRelativeInlineStylesheet.css */";
31 document
.head
.appendChild(styleElement
);
36 function forEachHeaderMatchingURL(url
, handler
)
38 var headers
= InspectorTest
.cssModel
.styleSheetHeaders();
39 for (var i
= 0; i
< headers
.length
; ++i
) {
40 if (headers
[i
].sourceURL
.indexOf(url
) !== -1)
45 function checkHeaderHasSourceURL(header
)
47 InspectorTest
.assertTrue(header
.hasSourceURL
);
50 InspectorTest
.runTestSuite([
51 function testSourceURLCommentInInlineScript(next
)
53 InspectorTest
.showScriptSource("stylesheet-source-url-comment.html", didShowSource
);
55 function didShowSource(sourceFrame
)
57 function checkHeaderDoesNotHaveSourceURL(header
)
59 InspectorTest
.assertTrue(!header
.hasSourceURL
, "hasSourceURL flag is set for inline stylesheet");
62 forEachHeaderMatchingURL("source-url-comment.html", checkHeaderDoesNotHaveSourceURL
);
67 function testSourceURLComment(next
)
69 InspectorTest
.showScriptSource("css/addedInlineStylesheet.css", didShowSource
);
70 InspectorTest
.evaluateInPage("setTimeout(addInlineStyleSheet, 0)");
72 function didShowSource(sourceFrame
)
74 InspectorTest
.addResult(sourceFrame
.textEditor
.text());
75 forEachHeaderMatchingURL("addedInlineStylesheet", checkHeaderHasSourceURL
);
80 function testDeprecatedSourceURLComment(next
)
82 InspectorTest
.showScriptSource("css/addedInlineStylesheetDeprecated.css", didShowSource
);
83 InspectorTest
.evaluateInPage("setTimeout(addInlineStyleSheetDeprecated, 0)");
85 function didShowSource(sourceFrame
)
87 InspectorTest
.addResult(sourceFrame
.textEditor
.text());
88 forEachHeaderMatchingURL("addedInlineStylesheetDeprecated", checkHeaderHasSourceURL
);
93 function testNonRelativeURL(next
)
95 InspectorTest
.showScriptSource("/css/nonRelativeInlineStylesheet.css", didShowSource
);
96 InspectorTest
.evaluateInPage("setTimeout(addInlineStyleSheetNonRelative, 0)");
98 function didShowSource(sourceFrame
)
100 InspectorTest
.addResult(sourceFrame
.textEditor
.text());
101 forEachHeaderMatchingURL("nonRelativeInlineStyleSheet.css", checkHeaderHasSourceURL
);
112 <body onload=
"runTest()">
113 <p>Tests that stylesheets with sourceURL comment are shown in the Sources panel.
</p>