Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(329)

Side by Side Diff: third_party/WebKit/LayoutTests/inspector/sources/debugger-ui/scripts-panel.html

Issue 2747863007: DevTools: clean up tests to not depend on NetworkProject.addFile method (Closed)
Patch Set: remove all networkProject.addFile calls Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/page-mock.js"></script>
5 <script> 6 <script>
6 function test() 7 function test()
7 { 8 {
8 function dumpNavigator(sourcesNavigatorView) 9 function dumpNavigator(sourcesNavigatorView)
9 { 10 {
10 InspectorTest.addResult("Navigator:"); 11 InspectorTest.addResult("Navigator:");
11 InspectorTest.dumpNavigatorView(sourcesNavigatorView); 12 InspectorTest.dumpNavigatorView(sourcesNavigatorView);
12 } 13 }
13 14
14 function createNavigatorView() 15 function createNavigatorView()
15 { 16 {
16 var navigatorView = new Sources.SourcesNavigatorView(); 17 var navigatorView = new Sources.SourcesNavigatorView();
17 navigatorView.show(UI.inspectorView.element); 18 navigatorView.show(UI.inspectorView.element);
18 return navigatorView; 19 return navigatorView;
19 } 20 }
20 21
21 function createContentProvider(url) 22 InspectorTest.addSniffer(Workspace.UISourceCode.prototype, 'requestContent', onRequestContent, true);
22 { 23
23 var contentProvider = Common.StaticContentProvider.fromString(url, Commo n.resourceTypes.Script, ""); 24 function onRequestContent() {
24 contentProvider.requestContent = function() 25 InspectorTest.addResult("Source requested for " + this.url());
25 {
26 InspectorTest.addResult("Source requested for " + url);
27 return Promise.resolve("");
28 };
29 return contentProvider;
30 } 26 }
31 27
28 Bindings.NetworkProject.forTarget(InspectorTest.mainTarget)._reset();
dgozman 2017/03/16 00:17:10 Eh? Unfortunate!
lushnikov 2017/03/16 06:30:50 Right, it looks like I'll have a binding-resetters
29 var page = new InspectorTest.PageMock('http://example.com');
30 InspectorTest.connectToPage('mock-page', page);
31
32 function addNetworkFile(url) 32 function addNetworkFile(url)
33 { 33 {
34 var networkProject = Bindings.NetworkProject.forTarget(InspectorTest.mai nTarget); 34 page.addScript(url, '', true /* hasSourceURL */, false /* isContentScrip t */);
35 return networkProject.addFile(createContentProvider(url), InspectorTest. mainFrame()); 35 return InspectorTest.waitForUISourceCode(url);
36 }
37
38 function reload() {
39 page.reload();
40 return new Promise(fulfill => InspectorTest.addSniffer(SDK.ResourceTreeM odel.prototype, '_frameNavigated', fulfill));
36 } 41 }
37 42
38 InspectorTest.runTestSuite([ 43 InspectorTest.runTestSuite([
39 function testInitialLoad(next) 44 async function testInitialLoad(next)
40 { 45 {
41 Bindings.NetworkProject.forTarget(InspectorTest.mainTarget)._reset() ; 46 await reload();
42 addNetworkFile("foobar.js"); 47 await addNetworkFile("foobar.js");
43 48
44 var sourcesNavigatorView = createNavigatorView(); 49 var sourcesNavigatorView = createNavigatorView();
45 50
46 addNetworkFile("foo.js"); 51 await addNetworkFile("foo.js");
47 addNetworkFile("bar.js"); 52 await addNetworkFile("bar.js");
48 var uiSourceCode = addNetworkFile("baz.js"); 53 var uiSourceCode = await addNetworkFile("baz.js");
49 sourcesNavigatorView.revealUISourceCode(uiSourceCode); 54 sourcesNavigatorView.revealUISourceCode(uiSourceCode);
50 55
51 dumpNavigator(sourcesNavigatorView); 56 dumpNavigator(sourcesNavigatorView);
52 next(); 57 next();
53 }, 58 },
54 59
55 function testReset(next) 60 async function testReset(next)
56 { 61 {
57 Bindings.NetworkProject.forTarget(InspectorTest.mainTarget)._reset() ; 62 await reload();
58 var sourcesNavigatorView = createNavigatorView(); 63 var sourcesNavigatorView = createNavigatorView();
59 64
60 var uiSourceCode = addNetworkFile("foo.js"); 65 var uiSourceCode = await addNetworkFile("foo.js");
61 addNetworkFile("bar.js"); 66 await addNetworkFile("bar.js");
62 addNetworkFile("baz.js"); 67 await addNetworkFile("baz.js");
63 68
64 dumpNavigator(sourcesNavigatorView); 69 dumpNavigator(sourcesNavigatorView);
65 InspectorTest.addResult("Revealing in navigator."); 70 InspectorTest.addResult("Revealing in navigator.");
66 sourcesNavigatorView.revealUISourceCode(uiSourceCode); 71 sourcesNavigatorView.revealUISourceCode(uiSourceCode);
67 dumpNavigator(sourcesNavigatorView); 72 dumpNavigator(sourcesNavigatorView);
68 73
69 Bindings.NetworkProject.forTarget(InspectorTest.mainTarget)._reset() ; 74 await reload();
70 dumpNavigator(sourcesNavigatorView); 75 dumpNavigator(sourcesNavigatorView);
71 uiSourceCode = addNetworkFile("bar.js"); 76 uiSourceCode = await addNetworkFile("bar.js");
72 sourcesNavigatorView.revealUISourceCode(uiSourceCode); 77 sourcesNavigatorView.revealUISourceCode(uiSourceCode);
73 dumpNavigator(sourcesNavigatorView); 78 dumpNavigator(sourcesNavigatorView);
74 79
75 next(); 80 next();
76 }, 81 },
77 82
78 function testDebuggerUISourceCodeAddedAndRemoved(next) 83 async function testDebuggerUISourceCodeAddedAndRemoved(next)
79 { 84 {
80 Bindings.NetworkProject.forTarget(InspectorTest.mainTarget)._reset() ; 85 await reload();
81 var sourcesNavigatorView = createNavigatorView(); 86 var sourcesNavigatorView = createNavigatorView();
82 87
83 var uiSourceCode = addNetworkFile("foo.js"); 88 var uiSourceCode = await addNetworkFile("foo.js");
84 InspectorTest.waitForUISourceCode().then(onUISourceCode); 89 InspectorTest.waitForUISourceCode().then(onUISourceCode);
85 InspectorTest.evaluateInPage("function foo() {}"); 90 InspectorTest.evaluateInPage("function foo() {}");
86 91
87 function onUISourceCode(debuggerUISourceCode) 92 async function onUISourceCode(debuggerUISourceCode)
88 { 93 {
89 sourcesNavigatorView.revealUISourceCode(uiSourceCode); 94 sourcesNavigatorView.revealUISourceCode(uiSourceCode);
90 sourcesNavigatorView.revealUISourceCode(debuggerUISourceCode); 95 sourcesNavigatorView.revealUISourceCode(debuggerUISourceCode);
91 dumpNavigator(sourcesNavigatorView); 96 dumpNavigator(sourcesNavigatorView);
92 97
93 // Plug compiler source mapping. 98 // Plug compiler source mapping.
94 addNetworkFile("source.js"); 99 await addNetworkFile("source.js");
95 100
96 dumpNavigator(sourcesNavigatorView); 101 dumpNavigator(sourcesNavigatorView);
97 next(); 102 next();
98 } 103 }
99 } 104 }
100 ]); 105 ]);
101 }; 106 };
102 </script> 107 </script>
103 </head> 108 </head>
104 <body onload="runTest()"> 109 <body onload="runTest()">
105 <p>Tests that scripts panel UI elements work as intended.</p> 110 <p>Tests that scripts panel UI elements work as intended.</p>
106 </body> 111 </body>
107 </html> 112 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698