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

Side by Side Diff: third_party/WebKit/LayoutTests/inspector/sources/debugger/navigator-view.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 6
6 <script> 7 <script>
7 function test() 8 async function test()
8 { 9 {
9 var networkProject1 = Bindings.NetworkProject.forTarget(InspectorTest.mainTa rget); 10 var networkProject1 = Bindings.NetworkProject.forTarget(InspectorTest.mainTa rget);
10 networkProject1._reset(); 11 networkProject1._reset();
11 var target2 = InspectorTest.createMockTarget('mock-target-100'); 12
12 SDK.ResourceTreeModel.fromTarget(target2)._cachedResourcesProcessed = true; 13 var pageMock = new InspectorTest.PageMock('mock-url.com/frame.html');
13 SDK.ResourceTreeModel.fromTarget(target2)._frameAttached('42', ''); 14 pageMock.disableDOMCapability();
14 SDK.ResourceTreeModel.fromTarget(target2)._frameNavigated({id: '42', parentI d: '', loaderId: '', name: 'mock-frame', url: 'mock-url.com/frame.html', securit yOrigin: 'mock-security-origin', mineType: 'mimeType'}); 15 var target2 = InspectorTest.connectToPage('mock-target-100', pageMock);
15 var networkProject2 = Bindings.NetworkProject.forTarget(target2); 16 var networkProject2 = Bindings.NetworkProject.forTarget(target2);
16 var subframe = InspectorTest.mainFrame().childFrames[0]; 17 var subframe = InspectorTest.mainFrame().childFrames[0];
17 18
18 var sourcesNavigatorView = new Sources.SourcesNavigatorView(); 19 var sourcesNavigatorView = new Sources.SourcesNavigatorView();
19 sourcesNavigatorView.show(UI.inspectorView.element); 20 sourcesNavigatorView.show(UI.inspectorView.element);
20 var contentScriptsNavigatorView = new Sources.ContentScriptsNavigatorView(); 21 var contentScriptsNavigatorView = new Sources.ContentScriptsNavigatorView();
21 contentScriptsNavigatorView.show(UI.inspectorView.element); 22 contentScriptsNavigatorView.show(UI.inspectorView.element);
22 23
23 var uiSourceCodes = []; 24 var uiSourceCodes = [];
24 function addUISourceCode(url, isContentScript, frame) 25 function addUISourceCode(url, isContentScript, frame)
25 { 26 {
26 var contentProvider = Common.StaticContentProvider.fromString(url, Commo n.resourceTypes.Script, ""); 27 var contentProvider = Common.StaticContentProvider.fromString(url, Commo n.resourceTypes.Script, "");
27 var uiSourceCode = networkProject1.addFile(contentProvider, frame || Ins pectorTest.mainFrame()); 28 var uiSourceCode = networkProject1.addFile(contentProvider, frame || Ins pectorTest.mainFrame());
28 uiSourceCodes.push(uiSourceCode); 29 uiSourceCodes.push(uiSourceCode);
29 } 30 }
30 31
31 function addUISourceCode2(url, isContentScript) 32 async function addUISourceCode2(url, isContentScript)
32 { 33 {
33 var contentProvider = Common.StaticContentProvider.fromString(url, Commo n.resourceTypes.Script, ""); 34 pageMock.addScript(url, '', true /* hasSourceURL */, isContentScript);
34 var uiSourceCode = networkProject2.addFile(contentProvider, SDK.Resource TreeModel.fromTarget(target2).mainFrame); 35 var uiSourceCode = await waitForUISourceCodeAdded(url);
35 uiSourceCodes.push(uiSourceCode); 36 uiSourceCodes.push(uiSourceCode);
36 } 37 }
37 38
39 function waitForUISourceCodeAdded(url) {
40 var fulfill;
41 var promise = new Promise(x => fulfill = x);
42 Workspace.workspace.addEventListener(Workspace.Workspace.Events.UISource CodeAdded, uiSourceCodeAdded);
43 return promise;
44
45 function uiSourceCodeAdded(event)
46 {
47 if (event.data.url() !== url)
48 return;
49 Workspace.workspace.removeEventListener(Workspace.Workspace.Events.U ISourceCodeAdded, uiSourceCodeAdded);
50 fulfill(event.data);
51 }
52 }
53
38 function revealUISourceCode(uiSourceCode) 54 function revealUISourceCode(uiSourceCode)
39 { 55 {
40 sourcesNavigatorView.revealUISourceCode(uiSourceCode); 56 sourcesNavigatorView.revealUISourceCode(uiSourceCode);
41 contentScriptsNavigatorView.revealUISourceCode(uiSourceCode); 57 contentScriptsNavigatorView.revealUISourceCode(uiSourceCode);
42 } 58 }
43 59
44 var rootURL = "http://localhost:8080/LayoutTests/inspector/debugger/"; 60 var rootURL = "http://localhost:8080/LayoutTests/inspector/debugger/";
45 61
46 InspectorTest.addResult("\n\n=============================================== ="); 62 InspectorTest.addResult("\n\n=============================================== =");
47 InspectorTest.addResult("Adding first resource:"); 63 InspectorTest.addResult("Adding first resource:");
48 addUISourceCode(rootURL + "foo/bar/script.js", false); 64 addUISourceCode(rootURL + "foo/bar/script.js", false);
49 InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView); 65 InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView);
50 66
51 InspectorTest.addResult("\n\n=============================================== ="); 67 InspectorTest.addResult("\n\n=============================================== =");
52 InspectorTest.addResult("Adding second resource:"); 68 InspectorTest.addResult("Adding second resource:");
53 addUISourceCode(rootURL + "foo/bar/script.js?a=2", false); 69 addUISourceCode(rootURL + "foo/bar/script.js?a=2", false);
54 InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView); 70 InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView);
55 71
56 InspectorTest.addResult("\n\n=============================================== ="); 72 InspectorTest.addResult("\n\n=============================================== =");
57 InspectorTest.addResult("Adding resources into another frame:"); 73 InspectorTest.addResult("Adding resources into another frame:");
58 addUISourceCode(rootURL + "foo/bar/script.js?a=1", false, subframe); 74 addUISourceCode(rootURL + "foo/bar/script.js?a=1", false, subframe);
59 addUISourceCode(rootURL + "foo/baz/script.js", false, subframe); 75 addUISourceCode(rootURL + "foo/baz/script.js", false, subframe);
60 InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView); 76 InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView);
61 77
62 InspectorTest.addResult("\n\n=============================================== ="); 78 InspectorTest.addResult("\n\n=============================================== =");
63 InspectorTest.addResult("Adding resources into another target:"); 79 InspectorTest.addResult("Adding resources into another target:");
64 addUISourceCode2(rootURL + "foo/bar/script.js?a=3", false); 80 await addUISourceCode2(rootURL + "foo/bar/script.js?a=3", false);
65 addUISourceCode2(rootURL + "foo/baz/script.js", false); 81 await addUISourceCode2(rootURL + "foo/baz/script.js", false);
66 InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView); 82 InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView);
67 83
68 InspectorTest.addResult("\n\n=============================================== ="); 84 InspectorTest.addResult("\n\n=============================================== =");
69 InspectorTest.addResult("Adding content scripts and some random resources:") ; 85 InspectorTest.addResult("Adding content scripts and some random resources:") ;
70 addUISourceCode(rootURL + "foo/bar/contentScript2.js?a=1", true); 86 addUISourceCode(rootURL + "foo/bar/contentScript2.js?a=1", true);
71 addUISourceCode(rootURL + "foo/bar/contentScript.js?a=2", true); 87 addUISourceCode(rootURL + "foo/bar/contentScript.js?a=2", true);
72 addUISourceCode(rootURL + "foo/bar/contentScript.js?a=1", true); 88 addUISourceCode(rootURL + "foo/bar/contentScript.js?a=1", true);
73 addUISourceCode("http://example.com/", false); 89 addUISourceCode("http://example.com/", false);
74 addUISourceCode("http://example.com/?a=b", false); 90 addUISourceCode("http://example.com/?a=b", false);
75 addUISourceCode("http://example.com/the%2fdir/foo?bar=100&baz=a%20%2fb", fal se); 91 addUISourceCode("http://example.com/the%2fdir/foo?bar=100&baz=a%20%2fb", fal se);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 146
131 </head> 147 </head>
132 <body> 148 <body>
133 <p> 149 <p>
134 Tests scripts panel file selectors. 150 Tests scripts panel file selectors.
135 </p> 151 </p>
136 <iframe src="resources/post-message-listener.html" name="childframe" onload="run Test()"></iframe> 152 <iframe src="resources/post-message-listener.html" name="childframe" onload="run Test()"></iframe>
137 </body> 153 </body>
138 154
139 </html> 155 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698