Web Inspector: Create JavaScriptSources based on network resources.
[WebKit-https.git] / LayoutTests / inspector / debugger / scripts-panel.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 <script>
6 function test()
7 {
8     // Always use indentation in scripts drop box
9     WebInspector._isMac = false;
10     WebInspector.showPanel("scripts");
11
12     var persistentBreakpoints = [];
13     var breakpointStorage = {
14         get: function() { return persistentBreakpoints; },
15         set: function(breakpoints) { persistentBreakpoints = breakpoints; }
16     };
17
18     var contentProvider = {
19         contentType: function()
20         {
21             return WebInspector.resourceTypes.Script;
22         }
23     }
24     
25     function createUISouceCode(url)
26     {
27         var uiSourceCode = new WebInspector.JavaScriptSource(url, null, contentProvider, false);
28         uiSourceCode.requestContent = function(callback)
29         {
30             InspectorTest.addResult("Source requested for " + url);
31             callback("");
32         };
33         return uiSourceCode;
34     }
35
36     InspectorTest.runTestSuite([
37         function testInitialLoad(next)
38         {
39             var workspace = new WebInspector.Workspace();
40             
41             var uiSourceCode = createUISouceCode("foobar.js");
42             var uiSourceCodeFoo = createUISouceCode("foo.js");
43             var uiSourceCodeBar = createUISouceCode("bar.js");
44             var uiSourceCodeBaz = createUISouceCode("baz.js");
45
46             workspace.project().addUISourceCode(uiSourceCode);
47
48             var panel = new WebInspector.ScriptsPanel(workspace);
49             panel.show();
50
51             workspace.project().addUISourceCode(uiSourceCodeFoo);
52             workspace.project().addUISourceCode(uiSourceCodeBar);
53             workspace.project().addUISourceCode(uiSourceCodeBaz);
54
55             InspectorTest.dumpScriptsNavigator(panel._navigator);
56
57             // Select "baz.js".
58             panel._showFile(uiSourceCodeBaz);
59             panel.detach();
60
61             next();
62         },
63
64         function testReset(next)
65         {
66             var workspace = new WebInspector.Workspace();
67             var panel = new WebInspector.ScriptsPanel(workspace);
68             panel.show();
69
70             var uiSourceCodeFoo = createUISouceCode("foo.js");
71             var uiSourceCodeBar = createUISouceCode("bar.js");
72             var uiSourceCodeBaz = createUISouceCode("baz.js");
73
74             workspace.project().addUISourceCode(uiSourceCodeFoo);
75             workspace.project().addUISourceCode(uiSourceCodeBar);
76             workspace.project().addUISourceCode(uiSourceCodeBaz);
77
78             InspectorTest.dumpScriptsNavigator(panel._navigator);
79
80             workspace.project().reset();
81             workspace.project().addUISourceCode(uiSourceCodeBar);
82             InspectorTest.dumpScriptsNavigator(panel._navigator);
83
84             panel.detach();
85             next();
86         },
87
88         function testSourceReplaced(next)
89         {
90             var workspace = new WebInspector.Workspace();
91             var panel = new WebInspector.ScriptsPanel(workspace);
92             panel.show();
93
94             var uiSourceCodeFoo = createUISouceCode("foo.js");
95             workspace.project().addUISourceCode(uiSourceCodeFoo);
96             var compiledSourceCode = createUISouceCode("compiled.js");
97             workspace.project().addUISourceCode(compiledSourceCode);
98
99             InspectorTest.dumpScriptsNavigator(panel._navigator);
100
101             // Plug compiler source mapping.
102             var sourceSourceCode = createUISouceCode("source.js");
103             workspace.project().replaceUISourceCode(compiledSourceCode, sourceSourceCode);
104
105             InspectorTest.dumpScriptsNavigator(panel._navigator);
106             next();
107         }
108     ]);
109 };
110 </script>
111 </head>
112 <body onload="runTest()">
113 <p>Tests that scripts panel UI elements work as intended.</p>
114 </body>
115 </html>