| 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/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 async function addUISourceCode(url, isContentScript, frame) |
| 25 { | 26 { |
| 26 var contentProvider = Common.StaticContentProvider.fromString(url, Commo
n.resourceTypes.Script, ""); | 27 if (isContentScript) { |
| 27 var uiSourceCode = networkProject1.addFile(contentProvider, frame || Ins
pectorTest.mainFrame()); | 28 var uiSourceCode = await InspectorTest.addScriptUISourceCode(url, ''
, true, 42); |
| 29 uiSourceCodes.push(uiSourceCode); |
| 30 return; |
| 31 } |
| 32 InspectorTest.addScriptForFrame(url, '', frame || InspectorTest.mainFram
e()); |
| 33 var uiSourceCode = await waitForUISourceCodeAdded(url); |
| 28 uiSourceCodes.push(uiSourceCode); | 34 uiSourceCodes.push(uiSourceCode); |
| 29 } | 35 } |
| 30 | 36 |
| 31 function addUISourceCode2(url, isContentScript) | 37 async function addUISourceCode2(url, isContentScript) |
| 32 { | 38 { |
| 33 var contentProvider = Common.StaticContentProvider.fromString(url, Commo
n.resourceTypes.Script, ""); | 39 pageMock.evalScript(url, '', isContentScript); |
| 34 var uiSourceCode = networkProject2.addFile(contentProvider, SDK.Resource
TreeModel.fromTarget(target2).mainFrame); | 40 var uiSourceCode = await waitForUISourceCodeAdded(url); |
| 35 uiSourceCodes.push(uiSourceCode); | 41 uiSourceCodes.push(uiSourceCode); |
| 36 } | 42 } |
| 37 | 43 |
| 44 function waitForUISourceCodeAdded(url) { |
| 45 var fulfill; |
| 46 var promise = new Promise(x => fulfill = x); |
| 47 Workspace.workspace.addEventListener(Workspace.Workspace.Events.UISource
CodeAdded, uiSourceCodeAdded); |
| 48 return promise; |
| 49 |
| 50 function uiSourceCodeAdded(event) |
| 51 { |
| 52 if (event.data.url() !== url) |
| 53 return; |
| 54 Workspace.workspace.removeEventListener(Workspace.Workspace.Events.U
ISourceCodeAdded, uiSourceCodeAdded); |
| 55 fulfill(event.data); |
| 56 } |
| 57 } |
| 58 |
| 38 function revealUISourceCode(uiSourceCode) | 59 function revealUISourceCode(uiSourceCode) |
| 39 { | 60 { |
| 40 sourcesNavigatorView.revealUISourceCode(uiSourceCode); | 61 sourcesNavigatorView.revealUISourceCode(uiSourceCode); |
| 41 contentScriptsNavigatorView.revealUISourceCode(uiSourceCode); | 62 contentScriptsNavigatorView.revealUISourceCode(uiSourceCode); |
| 42 } | 63 } |
| 43 | 64 |
| 44 var rootURL = "http://localhost:8080/LayoutTests/inspector/debugger/"; | 65 var rootURL = "http://localhost:8080/LayoutTests/inspector/debugger/"; |
| 45 | 66 |
| 46 InspectorTest.addResult("\n\n===============================================
="); | 67 InspectorTest.addResult("\n\n===============================================
="); |
| 47 InspectorTest.addResult("Adding first resource:"); | 68 InspectorTest.addResult("Adding first resource:"); |
| 48 addUISourceCode(rootURL + "foo/bar/script.js", false); | 69 await addUISourceCode(rootURL + "foo/bar/script.js", false); |
| 49 InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView); | 70 InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView); |
| 50 | 71 |
| 51 InspectorTest.addResult("\n\n===============================================
="); | 72 InspectorTest.addResult("\n\n===============================================
="); |
| 52 InspectorTest.addResult("Adding second resource:"); | 73 InspectorTest.addResult("Adding second resource:"); |
| 53 addUISourceCode(rootURL + "foo/bar/script.js?a=2", false); | 74 await addUISourceCode(rootURL + "foo/bar/script.js?a=2", false); |
| 54 InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView); | 75 InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView); |
| 55 | 76 |
| 56 InspectorTest.addResult("\n\n===============================================
="); | 77 InspectorTest.addResult("\n\n===============================================
="); |
| 57 InspectorTest.addResult("Adding resources into another frame:"); | 78 InspectorTest.addResult("Adding resources into another frame:"); |
| 58 addUISourceCode(rootURL + "foo/bar/script.js?a=1", false, subframe); | 79 await addUISourceCode(rootURL + "foo/bar/script.js?a=1", false, subframe); |
| 59 addUISourceCode(rootURL + "foo/baz/script.js", false, subframe); | 80 |
| 81 await addUISourceCode(rootURL + "foo/baz/script.js", false, subframe); |
| 60 InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView); | 82 InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView); |
| 61 | 83 |
| 62 InspectorTest.addResult("\n\n===============================================
="); | 84 InspectorTest.addResult("\n\n===============================================
="); |
| 63 InspectorTest.addResult("Adding resources into another target:"); | 85 InspectorTest.addResult("Adding resources into another target:"); |
| 64 addUISourceCode2(rootURL + "foo/bar/script.js?a=3", false); | 86 await addUISourceCode2(rootURL + "foo/bar/script.js?a=3", false); |
| 65 addUISourceCode2(rootURL + "foo/baz/script.js", false); | 87 await addUISourceCode2(rootURL + "foo/baz/script.js", false); |
| 66 InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView); | 88 InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView); |
| 67 | 89 |
| 68 InspectorTest.addResult("\n\n===============================================
="); | 90 InspectorTest.addResult("\n\n===============================================
="); |
| 69 InspectorTest.addResult("Adding content scripts and some random resources:")
; | 91 InspectorTest.addResult("Adding content scripts and some random resources:")
; |
| 70 addUISourceCode(rootURL + "foo/bar/contentScript2.js?a=1", true); | 92 await addUISourceCode(rootURL + "foo/bar/contentScript2.js?a=1", true); |
| 71 addUISourceCode(rootURL + "foo/bar/contentScript.js?a=2", true); | 93 await addUISourceCode(rootURL + "foo/bar/contentScript.js?a=2", true); |
| 72 addUISourceCode(rootURL + "foo/bar/contentScript.js?a=1", true); | 94 await addUISourceCode(rootURL + "foo/bar/contentScript.js?a=1", true); |
| 73 addUISourceCode("http://example.com/", false); | 95 await addUISourceCode("http://example.com/", false); |
| 74 addUISourceCode("http://example.com/?a=b", false); | 96 await addUISourceCode("http://example.com/?a=b", false); |
| 75 addUISourceCode("http://example.com/the%2fdir/foo?bar=100&baz=a%20%2fb", fal
se); | 97 await addUISourceCode("http://example.com/the%2fdir/foo?bar=100&baz=a%20%2fb
", false); |
| 76 // Verify that adding invalid URL does not throw exception. | 98 // Verify that adding invalid URL does not throw exception. |
| 77 addUISourceCode("http://example.com/the%2fdir/foo?bar=100%&baz=a%20%2fb", fa
lse); | 99 await addUISourceCode("http://example.com/the%2fdir/foo?bar=100%&baz=a%20%2f
b", false); |
| 78 addUISourceCode("http://example.com/path%20with%20spaces/white%20space.html"
, false); | 100 await addUISourceCode("http://example.com/path%20with%20spaces/white%20space
.html", false); |
| 79 addUISourceCode("?a=b", false); | 101 await addUISourceCode("?a=b", false); |
| 80 addUISourceCode("very_looooooooooooooooooooooooooooooooooooooooooooooooooooo
oooooooooooooooooooooooooooooooooooooooong_url", false); | 102 await addUISourceCode("very_looooooooooooooooooooooooooooooooooooooooooooooo
oooooooooooooooooooooooooooooooooooooooooooooong_url", false); |
| 81 InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView); | 103 InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView); |
| 82 InspectorTest.dumpNavigatorViewInAllModes(contentScriptsNavigatorView); | 104 InspectorTest.dumpNavigatorViewInAllModes(contentScriptsNavigatorView); |
| 83 | 105 |
| 84 InspectorTest.addResult("\n\n===============================================
="); | 106 InspectorTest.addResult("\n\n===============================================
="); |
| 85 InspectorTest.addResult("Revealing first resource:"); | 107 InspectorTest.addResult("Revealing first resource:"); |
| 86 revealUISourceCode(uiSourceCodes[0]); | 108 revealUISourceCode(uiSourceCodes[0]); |
| 87 InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView); | 109 InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView); |
| 88 | 110 |
| 89 // Here we keep http://localhost:8080/LayoutTests/inspector/debugger2/ folde
r collapsed while adding resources into it. | 111 // Here we keep http://localhost:8080/LayoutTests/inspector/debugger2/ folde
r collapsed while adding resources into it. |
| 90 InspectorTest.addResult("\n\n===============================================
="); | 112 InspectorTest.addResult("\n\n===============================================
="); |
| 91 InspectorTest.addResult("Adding some resources to change the way debugger fo
lder looks like, first:"); | 113 InspectorTest.addResult("Adding some resources to change the way debugger fo
lder looks like, first:"); |
| 92 var rootURL2 = "http://localhost:8080/LayoutTests/inspector/debugger2/"; | 114 var rootURL2 = "http://localhost:8080/LayoutTests/inspector/debugger2/"; |
| 93 addUISourceCode(rootURL2 + "foo/bar/script.js", false); | 115 await addUISourceCode(rootURL2 + "foo/bar/script.js", false); |
| 94 InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView); | 116 InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView); |
| 95 | 117 |
| 96 InspectorTest.addResult("\n\n===============================================
="); | 118 InspectorTest.addResult("\n\n===============================================
="); |
| 97 InspectorTest.addResult("Second:"); | 119 InspectorTest.addResult("Second:"); |
| 98 addUISourceCode(rootURL2 + "foo/bar/script.js?a=2", false); | 120 await addUISourceCode(rootURL2 + "foo/bar/script.js?a=2", false); |
| 99 InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView); | 121 InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView); |
| 100 | 122 |
| 101 InspectorTest.addResult("\n\n===============================================
="); | 123 InspectorTest.addResult("\n\n===============================================
="); |
| 102 InspectorTest.addResult("Others:"); | 124 InspectorTest.addResult("Others:"); |
| 103 addUISourceCode(rootURL2 + "foo/bar/script.js?a=1", false); | 125 await addUISourceCode(rootURL2 + "foo/bar/script.js?a=1", false); |
| 104 addUISourceCode(rootURL2 + "foo/baz/script.js", false); | 126 await addUISourceCode(rootURL2 + "foo/baz/script.js", false); |
| 105 InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView); | 127 InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView); |
| 106 | 128 |
| 107 InspectorTest.addResult("\n\n===============================================
="); | 129 InspectorTest.addResult("\n\n===============================================
="); |
| 108 var rootURL3 = "http://localhost:8080/LayoutTests/inspector/debugger3/"; | 130 var rootURL3 = "http://localhost:8080/LayoutTests/inspector/debugger3/"; |
| 109 addUISourceCode(rootURL3 + "hasOwnProperty/__proto__/constructor/foo.js", fa
lse); | 131 await addUISourceCode(rootURL3 + "hasOwnProperty/__proto__/constructor/foo.j
s", false); |
| 110 addUISourceCode(rootURL3 + "hasOwnProperty/__proto__/foo.js", false); | 132 await addUISourceCode(rootURL3 + "hasOwnProperty/__proto__/foo.js", false); |
| 111 addUISourceCode(rootURL3 + "hasOwnProperty/foo.js", false); | 133 await addUISourceCode(rootURL3 + "hasOwnProperty/foo.js", false); |
| 112 InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView); | 134 InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView); |
| 113 | 135 |
| 114 InspectorTest.addResult("\n\n===============================================
="); | 136 InspectorTest.addResult("\n\n===============================================
="); |
| 115 InspectorTest.addResult("Revealing all resources:"); | 137 InspectorTest.addResult("Revealing all resources:"); |
| 116 for (var i = 0; i < uiSourceCodes.length; ++i) | 138 for (var i = 0; i < uiSourceCodes.length; ++i) |
| 117 revealUISourceCode(uiSourceCodes[i]); | 139 revealUISourceCode(uiSourceCodes[i]); |
| 118 InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView); | 140 InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView); |
| 119 InspectorTest.dumpNavigatorViewInAllModes(contentScriptsNavigatorView); | 141 InspectorTest.dumpNavigatorViewInAllModes(contentScriptsNavigatorView); |
| 120 | 142 |
| 121 InspectorTest.addResult("\n\n===============================================
="); | 143 InspectorTest.addResult("\n\n===============================================
="); |
| 122 InspectorTest.addResult("Removing all resources:"); | 144 InspectorTest.addResult("Removing all resources:"); |
| 123 networkProject2._reset(); | 145 networkProject2._reset(); |
| 124 InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView); | 146 InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView); |
| 125 InspectorTest.dumpNavigatorViewInAllModes(contentScriptsNavigatorView); | 147 InspectorTest.dumpNavigatorViewInAllModes(contentScriptsNavigatorView); |
| 126 | 148 |
| 127 InspectorTest.completeTest(); | 149 InspectorTest.completeTest(); |
| 128 } | 150 } |
| 129 </script> | 151 </script> |
| 130 | 152 |
| 131 </head> | 153 </head> |
| 132 <body> | 154 <body> |
| 133 <p> | 155 <p> |
| 134 Tests scripts panel file selectors. | 156 Tests scripts panel file selectors. |
| 135 </p> | 157 </p> |
| 136 <iframe src="resources/post-message-listener.html" name="childframe" onload="run
Test()"></iframe> | 158 <iframe src="resources/post-message-listener.html" name="childframe" onload="run
Test()"></iframe> |
| 137 </body> | 159 </body> |
| 138 | 160 |
| 139 </html> | 161 </html> |
| OLD | NEW |