b45368cb1b5a7a3ab5ceafbcb271fcce43625d1e
[WebKit-https.git] / LayoutTests / inspector / debugger / dynamic-script-tag.html
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
6 <script>
7
8 function createScriptTag()
9 {
10     var script = document.createElement("script");
11     script.innerHTML = "console.log(123)";
12     document.head.appendChild(script);
13 }
14
15 function test()
16 {
17     InspectorTest.startDebuggerTest(step1);
18
19     function step1()
20     {
21         InspectorTest.evaluateInPage("createScriptTag()");
22         WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ParsedScriptSource, step2);
23     }
24
25     function step2(event)
26     {
27         var script = event.data;
28         script.requestContent(callback);
29         function callback(content)
30         {
31             if (content !== "console.log(123)")
32                 return;
33             InspectorTest.addResult("Is anonymous:" + script.isAnonymousScript());
34             InspectorTest.addResult("Is inline script:" + script.isInlineScript());
35             InspectorTest.addResult(new WebInspector.ParsedURL(script.sourceURL).displayName);
36             // Invoke post source map install.
37             setTimeout(step3.bind(this, script), 0);
38         }
39     }
40
41     function step3(script)
42     {
43         var uiLocation = script.rawLocationToUILocation(0, 0);
44         InspectorTest.addResult("UI name: " + uiLocation.uiSourceCode.parsedURL.displayName);
45         InspectorTest.addResult("UI resource: " + uiLocation.uiSourceCode.resource());
46         uiLocation.uiSourceCode.requestContent(callback);
47         function callback(content)
48         {
49             InspectorTest.addResult("UI content: " + content);
50             InspectorTest.completeDebuggerTest();
51         }
52     }
53 }
54 </script>
55 </head>
56 <body onload="runTest()">
57 <p>
58 Tests that dynamically added script tag gets its own JavaScriptSource and is not bound to the resource.
59 <a href="https://bugs.webkit.org/show_bug.cgi?id=87119">Bug 87119</a>
60 </p>
61 </body>
62
63 </html>