3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../http/tests/inspector/debugger-test.js"></script>
6 function keepAliveInInlineScript() { }
8 //# sourceURL=inlineScriptURL.js
13 eval("function keepAlive() {}\n//# sourceURL=evalURL.js");
16 function doDeprecatedEval()
18 eval("function keepAlive() {}\n//@ sourceURL=deprecatedEvalURL.js");
21 function doEvalWithNonRelativeURL()
23 eval("function relativeURLScript() {}\n//# sourceURL=/js/nonRelativeURL.js");
26 function doDynamicScript()
28 var scriptElement = document.createElement("script");
29 scriptElement.textContent = "function keepAliveInDynamicScript() {}\n//# sourceURL=dynamicScriptURL.js";
30 document.body.appendChild(scriptElement);
36 function forEachScriptMatchingURL(url, handler)
38 var scripts = WebInspector.debuggerModel.scripts;
39 for (var i = 0; i < scripts.length; ++i) {
40 if (scripts[i].sourceURL.indexOf(url) !== -1)
45 InspectorTest.runDebuggerTestSuite([
46 function testSourceURLCommentInInlineScript(next)
48 InspectorTest.showScriptSource("source-url-comment.html", didShowScriptSource);
50 function didShowScriptSource(sourceFrame)
52 function checkScriptDoesNotHaveSourceURL(script)
54 InspectorTest.assertTrue(!script.hasSourceURL, "hasSourceURL flag is set for inline script");
57 var panel = WebInspector.panel("sources");
58 var uiSourceCodes = panel._workspace.uiSourceCodes();
59 for (var i = 0; i < uiSourceCodes.length; ++i)
60 InspectorTest.assertTrue(uiSourceCodes[i].originURL().indexOf("inlineScriptURL.js") === -1, "sourceURL comment in inline script was used as a script name");
61 forEachScriptMatchingURL("source-url-comment.html", checkScriptDoesNotHaveSourceURL)
66 function testSourceURLComment(next)
68 InspectorTest.showScriptSource("evalURL.js", didShowScriptSource);
69 InspectorTest.evaluateInPage("setTimeout(doEval, 0)");
71 function didShowScriptSource(sourceFrame)
73 function checkScriptHasSourceURL(script)
75 InspectorTest.assertTrue(script.hasSourceURL, "hasSourceURL flag is not set for eval with sourceURL comment");
78 InspectorTest.addResult(sourceFrame.textEditor.text());
79 forEachScriptMatchingURL("evalURL.js", checkScriptHasSourceURL);
84 function testDeprecatedSourceURLComment(next)
86 InspectorTest.showScriptSource("deprecatedEvalURL.js", didShowScriptSource);
87 InspectorTest.evaluateInPage("setTimeout(doDeprecatedEval, 0)");
89 function didShowScriptSource(sourceFrame)
91 function checkScriptHasSourceURL(script)
93 InspectorTest.assertTrue(script.hasSourceURL, "hasSourceURL flag is not set for eval with sourceURL comment");
96 InspectorTest.addResult(sourceFrame.textEditor.text());
97 forEachScriptMatchingURL("deprecatedEvalURL.js", checkScriptHasSourceURL);
102 function testSourceURLCommentInDynamicScript(next)
104 InspectorTest.showScriptSource("dynamicScriptURL.js", didShowScriptSource);
105 InspectorTest.evaluateInPage("setTimeout(doDynamicScript, 0)");
107 function didShowScriptSource(sourceFrame)
109 function checkScriptHasSourceURL(script)
111 InspectorTest.assertTrue(script.hasSourceURL, "hasSourceURL flag is not set for dynamic script with sourceURL comment");
114 InspectorTest.addResult(sourceFrame.textEditor.text());
115 forEachScriptMatchingURL("dynamicScriptURL.js", checkScriptHasSourceURL);
120 function testNonRelativeURL(next)
122 InspectorTest.showScriptSource("/js/nonRelativeURL.js", didShowScriptSource);
123 InspectorTest.evaluateInPage("setTimeout(doEvalWithNonRelativeURL, 0)");
125 function didShowScriptSource(sourceFrame)
127 function checkScriptHasSourceURL(script)
129 InspectorTest.assertTrue(script.hasSourceURL, "hasSourceURL flag is not set for eval with a non-relative URL in a sourceURL comment");
132 InspectorTest.addResult(sourceFrame.textEditor.text());
133 forEachScriptMatchingURL("nonRelativeURL.js", checkScriptHasSourceURL);
144 <body onload="runTest()">
145 <p>Tests that evals with sourceURL comment are shown in scripts panel.</p>