| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script src="../../../http/tests/inspector/inspector-test.js"></script> | 3 <script src="../../../http/tests/inspector/inspector-test.js"></script> |
| 4 <script src="../../../http/tests/inspector/debugger-test.js"></script> | 4 <script src="../../../http/tests/inspector/debugger-test.js"></script> |
| 5 <script src="../../../http/tests/inspector/workspace-test.js"></script> | |
| 6 <script> | 5 <script> |
| 7 function test() | 6 function test() |
| 8 { | 7 { |
| 9 function dumpNavigator(sourcesNavigatorView) | 8 function dumpNavigator(sourcesNavigatorView) |
| 10 { | 9 { |
| 11 InspectorTest.addResult("Navigator:"); | 10 InspectorTest.addResult("Navigator:"); |
| 12 InspectorTest.dumpNavigatorView(sourcesNavigatorView); | 11 InspectorTest.dumpNavigatorView(sourcesNavigatorView); |
| 13 } | 12 } |
| 14 | 13 |
| 15 function createNavigatorView() | 14 function createNavigatorView() |
| 16 { | 15 { |
| 17 var workspace = Workspace.workspace; | |
| 18 Workspace.workspace = InspectorTest.testWorkspace; | |
| 19 var navigatorView = new Sources.SourcesNavigatorView(); | 16 var navigatorView = new Sources.SourcesNavigatorView(); |
| 20 Workspace.workspace = workspace; | |
| 21 navigatorView.show(UI.inspectorView.element); | 17 navigatorView.show(UI.inspectorView.element); |
| 22 return navigatorView; | 18 return navigatorView; |
| 23 } | 19 } |
| 24 | 20 |
| 25 function createContentProvider(url) | 21 function createContentProvider(url) |
| 26 { | 22 { |
| 27 var contentProvider = Common.StaticContentProvider.fromString(url, Commo
n.resourceTypes.Script, ""); | 23 var contentProvider = Common.StaticContentProvider.fromString(url, Commo
n.resourceTypes.Script, ""); |
| 28 contentProvider.requestContent = function() | 24 contentProvider.requestContent = function() |
| 29 { | 25 { |
| 30 InspectorTest.addResult("Source requested for " + url); | 26 InspectorTest.addResult("Source requested for " + url); |
| 31 return Promise.resolve(""); | 27 return Promise.resolve(""); |
| 32 }; | 28 }; |
| 33 return contentProvider; | 29 return contentProvider; |
| 34 } | 30 } |
| 35 | 31 |
| 36 function createMockWorkspace() | 32 function addNetworkFile(url) |
| 37 { | 33 { |
| 38 InspectorTest.createWorkspaceWithTarget(true); | 34 var networkProject = Bindings.NetworkProject.forTarget(InspectorTest.mai
nTarget); |
| 39 InspectorTest.testDebuggerProject = new Bindings.ContentProviderBasedPro
ject(InspectorTest.testWorkspace, "", Workspace.projectTypes.Debugger, ""); | 35 return networkProject.addFile(createContentProvider(url), InspectorTest.
mainFrame()); |
| 40 return InspectorTest.testWorkspace; | |
| 41 } | |
| 42 | |
| 43 function addNetworkFile(workspace, url) | |
| 44 { | |
| 45 return InspectorTest.testNetworkProject.addFile(createContentProvider(ur
l), InspectorTest.mainFrame()); | |
| 46 } | |
| 47 | |
| 48 function addDebuggerFile(workspace, url) | |
| 49 { | |
| 50 var uiSourceCode = InspectorTest.testDebuggerProject.createUISourceCode(
url, Common.resourceTypes.Script); | |
| 51 InspectorTest.testDebuggerProject.addUISourceCodeWithProvider(uiSourceCo
de, createContentProvider(url)); | |
| 52 return uiSourceCode; | |
| 53 } | 36 } |
| 54 | 37 |
| 55 InspectorTest.runTestSuite([ | 38 InspectorTest.runTestSuite([ |
| 56 function testInitialLoad(next) | 39 function testInitialLoad(next) |
| 57 { | 40 { |
| 58 var workspace = createMockWorkspace(); | 41 Bindings.NetworkProject.forTarget(InspectorTest.mainTarget)._reset()
; |
| 59 | 42 addNetworkFile("foobar.js"); |
| 60 addNetworkFile(workspace, "foobar.js"); | |
| 61 | 43 |
| 62 var sourcesNavigatorView = createNavigatorView(); | 44 var sourcesNavigatorView = createNavigatorView(); |
| 63 | 45 |
| 64 addNetworkFile(workspace, "foo.js"); | 46 addNetworkFile("foo.js"); |
| 65 addNetworkFile(workspace, "bar.js"); | 47 addNetworkFile("bar.js"); |
| 66 var uiSourceCode = addNetworkFile(workspace, "baz.js"); | 48 var uiSourceCode = addNetworkFile("baz.js"); |
| 67 sourcesNavigatorView.revealUISourceCode(uiSourceCode); | 49 sourcesNavigatorView.revealUISourceCode(uiSourceCode); |
| 68 | 50 |
| 69 dumpNavigator(sourcesNavigatorView); | 51 dumpNavigator(sourcesNavigatorView); |
| 70 next(); | 52 next(); |
| 71 }, | 53 }, |
| 72 | 54 |
| 73 function testReset(next) | 55 function testReset(next) |
| 74 { | 56 { |
| 75 var workspace = createMockWorkspace(); | 57 Bindings.NetworkProject.forTarget(InspectorTest.mainTarget)._reset()
; |
| 76 var sourcesNavigatorView = createNavigatorView(); | 58 var sourcesNavigatorView = createNavigatorView(); |
| 77 | 59 |
| 78 var uiSourceCode = addNetworkFile(workspace, "foo.js"); | 60 var uiSourceCode = addNetworkFile("foo.js"); |
| 79 addNetworkFile(workspace, "bar.js"); | 61 addNetworkFile("bar.js"); |
| 80 addNetworkFile(workspace, "baz.js"); | 62 addNetworkFile("baz.js"); |
| 81 | 63 |
| 82 dumpNavigator(sourcesNavigatorView); | 64 dumpNavigator(sourcesNavigatorView); |
| 83 InspectorTest.addResult("Revealing in navigator."); | 65 InspectorTest.addResult("Revealing in navigator."); |
| 84 sourcesNavigatorView.revealUISourceCode(uiSourceCode); | 66 sourcesNavigatorView.revealUISourceCode(uiSourceCode); |
| 85 dumpNavigator(sourcesNavigatorView); | 67 dumpNavigator(sourcesNavigatorView); |
| 86 | 68 |
| 87 InspectorTest.testNetworkProject._reset(); | 69 Bindings.NetworkProject.forTarget(InspectorTest.mainTarget)._reset()
; |
| 88 dumpNavigator(sourcesNavigatorView); | 70 dumpNavigator(sourcesNavigatorView); |
| 89 uiSourceCode = addNetworkFile(workspace, "bar.js"); | 71 uiSourceCode = addNetworkFile("bar.js"); |
| 90 sourcesNavigatorView.revealUISourceCode(uiSourceCode); | 72 sourcesNavigatorView.revealUISourceCode(uiSourceCode); |
| 91 dumpNavigator(sourcesNavigatorView); | 73 dumpNavigator(sourcesNavigatorView); |
| 92 | 74 |
| 93 next(); | 75 next(); |
| 94 }, | 76 }, |
| 95 | 77 |
| 96 function testDebuggerUISourceCodeAddedAndRemoved(next) | 78 function testDebuggerUISourceCodeAddedAndRemoved(next) |
| 97 { | 79 { |
| 98 var workspace = createMockWorkspace(); | 80 Bindings.NetworkProject.forTarget(InspectorTest.mainTarget)._reset()
; |
| 99 var sourcesNavigatorView = createNavigatorView(); | 81 var sourcesNavigatorView = createNavigatorView(); |
| 100 | 82 |
| 101 var uiSourceCode = addNetworkFile(workspace, "foo.js"); | 83 var uiSourceCode = addNetworkFile("foo.js"); |
| 102 var debuggerUISourceCode = addDebuggerFile(workspace, "compiled.js")
; | 84 InspectorTest.waitForUISourceCode(onUISourceCode); |
| 103 sourcesNavigatorView.revealUISourceCode(uiSourceCode); | 85 InspectorTest.evaluateInPage("function foo() {}"); |
| 104 sourcesNavigatorView.revealUISourceCode(debuggerUISourceCode); | |
| 105 dumpNavigator(sourcesNavigatorView); | |
| 106 | 86 |
| 107 // Plug compiler source mapping. | 87 function onUISourceCode(debuggerUISourceCode) |
| 108 addNetworkFile(workspace, "source.js"); | 88 { |
| 89 sourcesNavigatorView.revealUISourceCode(uiSourceCode); |
| 90 sourcesNavigatorView.revealUISourceCode(debuggerUISourceCode); |
| 91 dumpNavigator(sourcesNavigatorView); |
| 109 | 92 |
| 110 dumpNavigator(sourcesNavigatorView); | 93 // Plug compiler source mapping. |
| 111 next(); | 94 addNetworkFile("source.js"); |
| 95 |
| 96 dumpNavigator(sourcesNavigatorView); |
| 97 next(); |
| 98 } |
| 112 } | 99 } |
| 113 ]); | 100 ]); |
| 114 }; | 101 }; |
| 115 </script> | 102 </script> |
| 116 </head> | 103 </head> |
| 117 <body onload="runTest()"> | 104 <body onload="runTest()"> |
| 118 <p>Tests that scripts panel UI elements work as intended.</p> | 105 <p>Tests that scripts panel UI elements work as intended.</p> |
| 119 </body> | 106 </body> |
| 120 </html> | 107 </html> |
| OLD | NEW |