Upstream version 5.34.98.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / debugger / dynamic-scripts.html
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../../http/tests/inspector/inspector-test.js"></script>
5 <script src="../../http/tests/inspector/debugger-test.js"></script>
6 <script>
7 function appendDynamicScriptElement(src, content)
8 {
9     var scriptElement = document.createElement("script");
10     if (src)
11         scriptElement.src = src;
12     else
13         scriptElement.textContent = content;
14     document.head.appendChild(scriptElement);
15 }
16
17 function loadScripts()
18 {
19     var sourceURLComment = "\n //# sourceURL=";
20     window.eval("function fooEval() {}");
21     window.eval("function fooEvalSourceURL() {}" + sourceURLComment + "evalSourceURL.js");
22     appendDynamicScriptElement("", "function fooScriptElementContent1() {}");
23     appendDynamicScriptElement("", "function fooScriptElementContent2() {}");
24     appendDynamicScriptElement("", "function fooScriptElementContentSourceURL() {}" + sourceURLComment + "scriptElementContentSourceURL.js");
25     appendDynamicScriptElement("resources/dynamic-script.js");
26 }
27
28 function scriptLoaded()
29 {
30     console.log("Done.");
31 }
32
33 function test()
34 {
35     InspectorTest.addConsoleSniffer(step1);
36     InspectorTest.evaluateInPage("loadScripts()", function() { })
37
38     function step1()
39     {
40         InspectorTest.startDebuggerTest(step2);
41     }
42
43     function step2()
44     {
45         InspectorTest.runAfterPendingDispatches(step3);
46     }
47
48     function step3()
49     {
50         var panel = WebInspector.showPanel("sources");
51         var uiSourceCodes = WebInspector.workspace.uiSourceCodesForProjectType(WebInspector.projectTypes.Network);
52         var urls = uiSourceCodes.map(function(uiSourceCode) { return uiSourceCode.name(); });
53         urls.sort();
54
55         var whiteList = ["debugger-test.js", "dynamic-script.js", "dynamic-scripts.html", "evalSourceURL.js", "inspector-test.js", "scriptElementContentSourceURL.js"];
56         function filter(url)
57         {
58             for (var i = 0; i < whiteList.length; ++i) {
59                 if (url === whiteList[i])
60                     return true;
61             }
62                 
63             return false;
64         }
65         urls = urls.filter(filter);
66
67         InspectorTest.addResult("UISourceCodes:");
68         var lastURL;
69         for (var i = 0; i < urls.length; ++i) {
70             // Hack around the problem with scripts surviving between tests.
71             if (urls[i] === lastURL && !lastURL.endsWith(".html"))
72                 continue;
73             InspectorTest.addResult("    " + urls[i]);
74             lastURL = urls[i];
75         }
76         InspectorTest.completeDebuggerTest();
77     }
78 }
79 </script>
80 </head>
81 <body onload="runTest()">
82 <p>Tests that scripts for dynamically added script elements are shown in sources panel if loaded with inspector open.</p>
83 <a href="https://bugs.webkit.org/show_bug.cgi?id=99324">Bug 99324</a>
84 </body>
85 </html>