Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: LayoutTests/inspector/sources/debugger/source-url-comment.html

Issue 256543002: DevTools: do not recognize inline sourceURL, require it to end with the crlf. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: For landing Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <script src="../../../http/tests/inspector/inspector-test.js"></script> 3 <script src="../../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../../http/tests/inspector/debugger-test.js"></script> 4 <script src="../../../http/tests/inspector/debugger-test.js"></script>
5 <script> 5 <script>
6 function keepAliveInInlineScript() { } 6 function keepAliveInInlineScript() { }
7 7
8 //# sourceURL=inlineScriptURL.js 8 //# sourceURL=inlineScriptURL.js
9 </script> 9 </script>
10 <script> 10 <script>
(...skipping 17 matching lines...) Expand all
28 var scriptElement = document.createElement("script"); 28 var scriptElement = document.createElement("script");
29 scriptElement.textContent = "function keepAliveInDynamicScript() {}\n//# sou rceURL=dynamicScriptURL.js"; 29 scriptElement.textContent = "function keepAliveInDynamicScript() {}\n//# sou rceURL=dynamicScriptURL.js";
30 document.body.appendChild(scriptElement); 30 document.body.appendChild(scriptElement);
31 } 31 }
32 32
33 function doURLAndMappingURL() 33 function doURLAndMappingURL()
34 { 34 {
35 eval("function keepAlive() {}\n//# sourceMappingURL=sourceMappingURL.map\n// # sourceURL=sourceURL.js"); 35 eval("function keepAlive() {}\n//# sourceMappingURL=sourceMappingURL.map\n// # sourceURL=sourceURL.js");
36 } 36 }
37 37
38 function addScriptWithURL()
39 {
40 var script = document.createElement("script");
41 script.src = "resources/script-with-url.js";
42 document.head.appendChild(script);
43 }
44
45 function addScriptWithPoorURL()
46 {
47 var script = document.createElement("script");
48 script.src = "resources/script-with-poor-url.js";
49 document.head.appendChild(script);
50 }
51
38 function test() 52 function test()
39 53
40 { 54 {
41 function forEachScriptMatchingURL(url, handler) 55 function forEachScriptMatchingURL(url, handler)
42 { 56 {
43 var scripts = WebInspector.debuggerModel._scripts; 57 var scripts = WebInspector.debuggerModel._scripts;
44 for (var id in scripts) { 58 for (var id in scripts) {
45 if (scripts[id].sourceURL.indexOf(url) !== -1) 59 if (scripts[id].sourceURL.indexOf(url) !== -1)
46 handler(scripts[id]); 60 handler(scripts[id]);
47 } 61 }
48 } 62 }
49 63
50 InspectorTest.runDebuggerTestSuite([ 64 InspectorTest.runDebuggerTestSuite([
51 function testSourceURLCommentInInlineScript(next) 65 function testSourceURLCommentInInlineScript(next)
52 { 66 {
53 InspectorTest.showScriptSource("source-url-comment.html", didShowScr iptSource); 67 InspectorTest.showScriptSource("source-url-comment.html", didShowScr iptSource);
54 68
55 function didShowScriptSource(sourceFrame) 69 function didShowScriptSource(sourceFrame)
56 { 70 {
57 var panel = WebInspector.inspectorView.panel("sources"); 71 var panel = WebInspector.inspectorView.panel("sources");
58 var uiSourceCodes = panel._workspace.uiSourceCodes(); 72 var uiSourceCodes = panel._workspace.uiSourceCodes();
59 for (var i = 0; i < uiSourceCodes.length; ++i) 73 for (var i = 0; i < uiSourceCodes.length; ++i) {
60 InspectorTest.assertTrue(uiSourceCodes[i].originURL().indexO f("inlineScriptURL.js") === -1, "sourceURL comment in inline script was used as a script name"); 74 if (uiSourceCodes[i].originURL().indexOf("inlineScriptURL.js ") !== -1)
61 forEachScriptMatchingURL("source-url-comment.html", checkScriptS ourceURL) 75 InspectorTest.addResult("FAILED: sourceURL comment in in line script was used as a script name");
76 }
62 next(); 77 next();
63 } 78 }
64 }, 79 },
80
81 function testSourceURLCommentInScript(next)
82 {
83 InspectorTest.showScriptSource("scriptWithSourceURL.js", didShowScri ptSource);
84 InspectorTest.evaluateInPage("setTimeout(addScriptWithURL, 0)");
85
86 function didShowScriptSource(sourceFrame)
87 {
88 InspectorTest.addResult(sourceFrame.textEditor.text().trim());
89 forEachScriptMatchingURL("scriptWithSourceURL.js", checkScriptSo urceURL);
90 next();
91 }
92 },
93
94 function testPoorSourceURLCommentInScript(next)
95 {
96 InspectorTest.showScriptSource("source-url-comment.html", didShowScr iptSource);
97 InspectorTest.evaluateInPage("setTimeout(addScriptWithPoorURL, 0)");
98
99 function didShowScriptSource(sourceFrame)
100 {
101 var panel = WebInspector.inspectorView.panel("sources");
102 var uiSourceCodes = panel._workspace.uiSourceCodes();
103 for (var i = 0; i < uiSourceCodes.length; ++i) {
104 if (uiSourceCodes[i].originURL().indexOf("scriptWithPoorSour ceURL.js") !== -1)
105 InspectorTest.addResult("FAILED: poor sourceURL comment in script was used as a script name");
106 }
107 next();
108 }
109 },
65 110
66 function testSourceURLComment(next) 111 function testSourceURLComment(next)
67 { 112 {
68 InspectorTest.showScriptSource("evalURL.js", didShowScriptSource); 113 InspectorTest.showScriptSource("evalURL.js", didShowScriptSource);
69 InspectorTest.evaluateInPage("setTimeout(doEval, 0)"); 114 InspectorTest.evaluateInPage("setTimeout(doEval, 0)");
70 115
71 function didShowScriptSource(sourceFrame) 116 function didShowScriptSource(sourceFrame)
72 { 117 {
73 InspectorTest.addResult(sourceFrame.textEditor.text()); 118 InspectorTest.addResult(sourceFrame.textEditor.text());
74 forEachScriptMatchingURL("evalURL.js", checkScriptSourceURL); 119 forEachScriptMatchingURL("evalURL.js", checkScriptSourceURL);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 }; 187 };
143 188
144 </script> 189 </script>
145 190
146 </head> 191 </head>
147 192
148 <body onload="runTest()"> 193 <body onload="runTest()">
149 <p>Tests that evals with sourceURL comment are shown in scripts panel.</p> 194 <p>Tests that evals with sourceURL comment are shown in scripts panel.</p>
150 </body> 195 </body>
151 </html> 196 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698