OLD | NEW |
| (Empty) |
1 <html> | |
2 <head> | |
3 <script src="../../../http/tests/inspector/inspector-test.js"></script> | |
4 <script src="../../../http/tests/inspector/debugger-test.js"></script> | |
5 <style> | |
6 body { | |
7 color: green; | |
8 } | |
9 | |
10 /*# sourceURL=inlineStyleSheet.css */ | |
11 </style> | |
12 <script> | |
13 function addInlineStyleSheet() | |
14 { | |
15 var styleElement = document.createElement("style"); | |
16 styleElement.textContent = "body { color: black; }\n/*# sourceURL=css/addedI
nlineStylesheet.css */"; | |
17 document.head.appendChild(styleElement); | |
18 } | |
19 | |
20 function addInlineStyleSheetDeprecated() | |
21 { | |
22 var styleElement = document.createElement("style"); | |
23 styleElement.textContent = "body { color: black; }\n/*@ sourceURL=css/addedI
nlineStylesheetDeprecated.css */"; | |
24 document.head.appendChild(styleElement); | |
25 } | |
26 | |
27 function addInlineStyleSheetNonRelative() | |
28 { | |
29 var styleElement = document.createElement("style"); | |
30 styleElement.textContent = "body { color: red; }\n/*# sourceURL=/css/nonRela
tiveInlineStylesheet.css */"; | |
31 document.head.appendChild(styleElement); | |
32 } | |
33 | |
34 function test() | |
35 { | |
36 function forEachHeaderMatchingURL(url, handler) | |
37 { | |
38 var headers = InspectorTest.cssModel.styleSheetHeaders(); | |
39 for (var i = 0; i < headers.length; ++i) { | |
40 if (headers[i].sourceURL.indexOf(url) !== -1) | |
41 handler(headers[i]); | |
42 } | |
43 } | |
44 | |
45 function checkHeaderHasSourceURL(header) | |
46 { | |
47 InspectorTest.assertTrue(header.hasSourceURL); | |
48 } | |
49 | |
50 InspectorTest.runTestSuite([ | |
51 function testSourceURLCommentInInlineScript(next) | |
52 { | |
53 InspectorTest.showScriptSource("stylesheet-source-url-comment.html",
didShowSource); | |
54 | |
55 function didShowSource(sourceFrame) | |
56 { | |
57 function checkHeaderDoesNotHaveSourceURL(header) | |
58 { | |
59 InspectorTest.assertTrue(!header.hasSourceURL, "hasSourceURL
flag is set for inline stylesheet"); | |
60 } | |
61 | |
62 forEachHeaderMatchingURL("source-url-comment.html", checkHeaderD
oesNotHaveSourceURL); | |
63 next(); | |
64 } | |
65 }, | |
66 | |
67 function testSourceURLComment(next) | |
68 { | |
69 InspectorTest.showScriptSource("css/addedInlineStylesheet.css", didS
howSource); | |
70 InspectorTest.evaluateInPage("setTimeout(addInlineStyleSheet, 0)"); | |
71 | |
72 function didShowSource(sourceFrame) | |
73 { | |
74 InspectorTest.addResult(sourceFrame.textEditor.text()); | |
75 forEachHeaderMatchingURL("addedInlineStylesheet", checkHeaderHas
SourceURL); | |
76 next(); | |
77 } | |
78 }, | |
79 | |
80 function testDeprecatedSourceURLComment(next) | |
81 { | |
82 InspectorTest.showScriptSource("css/addedInlineStylesheetDeprecated.
css", didShowSource); | |
83 InspectorTest.evaluateInPage("setTimeout(addInlineStyleSheetDeprecat
ed, 0)"); | |
84 | |
85 function didShowSource(sourceFrame) | |
86 { | |
87 InspectorTest.addResult(sourceFrame.textEditor.text()); | |
88 forEachHeaderMatchingURL("addedInlineStylesheetDeprecated", chec
kHeaderHasSourceURL); | |
89 next(); | |
90 } | |
91 }, | |
92 | |
93 function testNonRelativeURL(next) | |
94 { | |
95 InspectorTest.showScriptSource("/css/nonRelativeInlineStylesheet.css
", didShowSource); | |
96 InspectorTest.evaluateInPage("setTimeout(addInlineStyleSheetNonRelat
ive, 0)"); | |
97 | |
98 function didShowSource(sourceFrame) | |
99 { | |
100 InspectorTest.addResult(sourceFrame.textEditor.text()); | |
101 forEachHeaderMatchingURL("nonRelativeInlineStyleSheet.css", chec
kHeaderHasSourceURL); | |
102 next(); | |
103 } | |
104 } | |
105 ]); | |
106 }; | |
107 | |
108 </script> | |
109 | |
110 </head> | |
111 | |
112 <body onload="runTest()"> | |
113 <p>Tests that stylesheets with sourceURL comment are shown in the Sources panel.
</p> | |
114 </body> | |
115 </html> | |
OLD | NEW |