3 <script src=
"../../../http/tests/inspector/inspector-test.js"></script>
4 <script src=
"../../../http/tests/inspector/debugger-test.js"></script>
5 <script src=
"../../../http/tests/inspector/workspace-test.js"></script>
9 function dumpNavigator(sourcesNavigatorView
)
11 InspectorTest
.dumpNavigatorView(sourcesNavigatorView
, "sources", " ");
14 function createNavigatorView()
16 var navigatorView
= new WebInspector
.SourcesNavigatorView();
17 navigatorView
.setWorkspace(InspectorTest
.testWorkspace
);
18 navigatorView
.show(WebInspector
.inspectorView
.element
);
22 function createContentProvider(url
)
24 var contentProvider
= new WebInspector
.StaticContentProvider(WebInspector
.resourceTypes
.Script
, "");
25 contentProvider
.requestContent = function(callback
)
27 InspectorTest
.addResult("Source requested for " + url
);
30 return contentProvider
;
33 function createMockWorkspace()
35 InspectorTest
.createWorkspaceWithTarget(true);
36 InspectorTest
.testDebuggerProjectDelegate
= new WebInspector
.DebuggerProjectDelegate(InspectorTest
.testWorkspace
, "debugger:", WebInspector
.projectTypes
.Debugger
);
37 return InspectorTest
.testWorkspace
;
40 function addNetworkFile(workspace
, url
)
42 return InspectorTest
.testNetworkProject
.addFileForURL(url
, createContentProvider(url
));
45 function addDebuggerFile(workspace
, url
)
47 var path
= InspectorTest
.testDebuggerProjectDelegate
.addContentProvider("", url
, url
, url
, createContentProvider(url
));
48 return InspectorTest
.testWorkspace
.uiSourceCode("debugger:", path
)
51 InspectorTest
.runTestSuite([
52 function testInitialLoad(next
)
54 var workspace
= createMockWorkspace();
56 addNetworkFile(workspace
, "foobar.js");
58 var sourcesNavigatorView
= createNavigatorView();
60 addNetworkFile(workspace
, "foo.js");
61 addNetworkFile(workspace
, "bar.js");
62 var uiSourceCode
= addNetworkFile(workspace
, "baz.js");
63 sourcesNavigatorView
.revealUISourceCode(uiSourceCode
);
65 dumpNavigator(sourcesNavigatorView
);
69 function testReset(next
)
71 var workspace
= createMockWorkspace();
72 var sourcesNavigatorView
= createNavigatorView();
74 var uiSourceCode
= addNetworkFile(workspace
, "foo.js");
75 addNetworkFile(workspace
, "bar.js");
76 addNetworkFile(workspace
, "baz.js");
78 dumpNavigator(sourcesNavigatorView
);
79 InspectorTest
.addResult("Revealing in navigator.");
80 sourcesNavigatorView
.revealUISourceCode(uiSourceCode
);
81 dumpNavigator(sourcesNavigatorView
);
83 InspectorTest
.testNetworkProject
._reset();
84 dumpNavigator(sourcesNavigatorView
);
85 uiSourceCode
= addNetworkFile(workspace
, "bar.js");
86 sourcesNavigatorView
.revealUISourceCode(uiSourceCode
);
87 dumpNavigator(sourcesNavigatorView
);
92 function testDebuggerUISourceCodeAddedAndRemoved(next
)
94 var workspace
= createMockWorkspace();
95 var sourcesNavigatorView
= createNavigatorView();
97 var uiSourceCode
= addNetworkFile(workspace
, "foo.js");
98 var debuggerUISourceCode
= addDebuggerFile(workspace
, "compiled.js");
99 sourcesNavigatorView
.revealUISourceCode(uiSourceCode
);
100 sourcesNavigatorView
.revealUISourceCode(debuggerUISourceCode
);
101 dumpNavigator(sourcesNavigatorView
);
103 // Plug compiler source mapping.
104 addNetworkFile(workspace
, "source.js");
106 dumpNavigator(sourcesNavigatorView
);
113 <body onload=
"runTest()">
114 <p>Tests that scripts panel UI elements work as intended.
</p>