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

Unified 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: typo 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/inspector/sources/debugger/navigator-view.html
diff --git a/third_party/WebKit/LayoutTests/inspector/sources/debugger/navigator-view.html b/third_party/WebKit/LayoutTests/inspector/sources/debugger/navigator-view.html
index 3d37ee39dc5cc8fdef229c6cf2cfa90745c95d19..e90f073a46b640de40c6eb74ccbf684caa9aa485 100644
--- a/third_party/WebKit/LayoutTests/inspector/sources/debugger/navigator-view.html
+++ b/third_party/WebKit/LayoutTests/inspector/sources/debugger/navigator-view.html
@@ -2,16 +2,17 @@
<head>
<script src="../../../http/tests/inspector/inspector-test.js"></script>
<script src="../../../http/tests/inspector/debugger-test.js"></script>
+<script src="../../../http/tests/inspector/page-mock.js"></script>
<script>
-function test()
+async function test()
{
var networkProject1 = Bindings.NetworkProject.forTarget(InspectorTest.mainTarget);
networkProject1._reset();
- var target2 = InspectorTest.createMockTarget('mock-target-100');
- SDK.ResourceTreeModel.fromTarget(target2)._cachedResourcesProcessed = true;
- SDK.ResourceTreeModel.fromTarget(target2)._frameAttached('42', '');
- SDK.ResourceTreeModel.fromTarget(target2)._frameNavigated({id: '42', parentId: '', loaderId: '', name: 'mock-frame', url: 'mock-url.com/frame.html', securityOrigin: 'mock-security-origin', mineType: 'mimeType'});
+
+ var pageMock = new InspectorTest.PageMock('mock-url.com/frame.html');
+ pageMock.disableDOMCapability();
+ var target2 = InspectorTest.connectToPage('mock-target-100', pageMock);
var networkProject2 = Bindings.NetworkProject.forTarget(target2);
var subframe = InspectorTest.mainFrame().childFrames[0];
@@ -21,20 +22,40 @@ function test()
contentScriptsNavigatorView.show(UI.inspectorView.element);
var uiSourceCodes = [];
- function addUISourceCode(url, isContentScript, frame)
+ async function addUISourceCode(url, isContentScript, frame)
{
- var contentProvider = Common.StaticContentProvider.fromString(url, Common.resourceTypes.Script, "");
- var uiSourceCode = networkProject1.addFile(contentProvider, frame || InspectorTest.mainFrame());
+ if (isContentScript) {
+ var uiSourceCode = await InspectorTest.addScriptUISourceCode(url, '', true, 42);
+ uiSourceCodes.push(uiSourceCode);
+ return;
+ }
+ InspectorTest.addScriptForFrame(url, '', frame || InspectorTest.mainFrame());
+ var uiSourceCode = await waitForUISourceCodeAdded(url);
uiSourceCodes.push(uiSourceCode);
}
- function addUISourceCode2(url, isContentScript)
+ async function addUISourceCode2(url, isContentScript)
{
- var contentProvider = Common.StaticContentProvider.fromString(url, Common.resourceTypes.Script, "");
- var uiSourceCode = networkProject2.addFile(contentProvider, SDK.ResourceTreeModel.fromTarget(target2).mainFrame);
+ pageMock.evalScript(url, '', isContentScript);
+ var uiSourceCode = await waitForUISourceCodeAdded(url);
uiSourceCodes.push(uiSourceCode);
}
+ function waitForUISourceCodeAdded(url) {
+ var fulfill;
+ var promise = new Promise(x => fulfill = x);
+ Workspace.workspace.addEventListener(Workspace.Workspace.Events.UISourceCodeAdded, uiSourceCodeAdded);
+ return promise;
+
+ function uiSourceCodeAdded(event)
+ {
+ if (event.data.url() !== url)
+ return;
+ Workspace.workspace.removeEventListener(Workspace.Workspace.Events.UISourceCodeAdded, uiSourceCodeAdded);
+ fulfill(event.data);
+ }
+ }
+
function revealUISourceCode(uiSourceCode)
{
sourcesNavigatorView.revealUISourceCode(uiSourceCode);
@@ -45,39 +66,40 @@ function test()
InspectorTest.addResult("\n\n================================================");
InspectorTest.addResult("Adding first resource:");
- addUISourceCode(rootURL + "foo/bar/script.js", false);
+ await addUISourceCode(rootURL + "foo/bar/script.js", false);
InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView);
InspectorTest.addResult("\n\n================================================");
InspectorTest.addResult("Adding second resource:");
- addUISourceCode(rootURL + "foo/bar/script.js?a=2", false);
+ await addUISourceCode(rootURL + "foo/bar/script.js?a=2", false);
InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView);
InspectorTest.addResult("\n\n================================================");
InspectorTest.addResult("Adding resources into another frame:");
- addUISourceCode(rootURL + "foo/bar/script.js?a=1", false, subframe);
- addUISourceCode(rootURL + "foo/baz/script.js", false, subframe);
+ await addUISourceCode(rootURL + "foo/bar/script.js?a=1", false, subframe);
+
+ await addUISourceCode(rootURL + "foo/baz/script.js", false, subframe);
InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView);
InspectorTest.addResult("\n\n================================================");
InspectorTest.addResult("Adding resources into another target:");
- addUISourceCode2(rootURL + "foo/bar/script.js?a=3", false);
- addUISourceCode2(rootURL + "foo/baz/script.js", false);
+ await addUISourceCode2(rootURL + "foo/bar/script.js?a=3", false);
+ await addUISourceCode2(rootURL + "foo/baz/script.js", false);
InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView);
InspectorTest.addResult("\n\n================================================");
InspectorTest.addResult("Adding content scripts and some random resources:");
- addUISourceCode(rootURL + "foo/bar/contentScript2.js?a=1", true);
- addUISourceCode(rootURL + "foo/bar/contentScript.js?a=2", true);
- addUISourceCode(rootURL + "foo/bar/contentScript.js?a=1", true);
- addUISourceCode("http://example.com/", false);
- addUISourceCode("http://example.com/?a=b", false);
- addUISourceCode("http://example.com/the%2fdir/foo?bar=100&baz=a%20%2fb", false);
+ await addUISourceCode(rootURL + "foo/bar/contentScript2.js?a=1", true);
+ await addUISourceCode(rootURL + "foo/bar/contentScript.js?a=2", true);
+ await addUISourceCode(rootURL + "foo/bar/contentScript.js?a=1", true);
+ await addUISourceCode("http://example.com/", false);
+ await addUISourceCode("http://example.com/?a=b", false);
+ await addUISourceCode("http://example.com/the%2fdir/foo?bar=100&baz=a%20%2fb", false);
// Verify that adding invalid URL does not throw exception.
- addUISourceCode("http://example.com/the%2fdir/foo?bar=100%&baz=a%20%2fb", false);
- addUISourceCode("http://example.com/path%20with%20spaces/white%20space.html", false);
- addUISourceCode("?a=b", false);
- addUISourceCode("very_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_url", false);
+ await addUISourceCode("http://example.com/the%2fdir/foo?bar=100%&baz=a%20%2fb", false);
+ await addUISourceCode("http://example.com/path%20with%20spaces/white%20space.html", false);
+ await addUISourceCode("?a=b", false);
+ await addUISourceCode("very_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_url", false);
InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView);
InspectorTest.dumpNavigatorViewInAllModes(contentScriptsNavigatorView);
@@ -90,25 +112,25 @@ function test()
InspectorTest.addResult("\n\n================================================");
InspectorTest.addResult("Adding some resources to change the way debugger folder looks like, first:");
var rootURL2 = "http://localhost:8080/LayoutTests/inspector/debugger2/";
- addUISourceCode(rootURL2 + "foo/bar/script.js", false);
+ await addUISourceCode(rootURL2 + "foo/bar/script.js", false);
InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView);
InspectorTest.addResult("\n\n================================================");
InspectorTest.addResult("Second:");
- addUISourceCode(rootURL2 + "foo/bar/script.js?a=2", false);
+ await addUISourceCode(rootURL2 + "foo/bar/script.js?a=2", false);
InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView);
InspectorTest.addResult("\n\n================================================");
InspectorTest.addResult("Others:");
- addUISourceCode(rootURL2 + "foo/bar/script.js?a=1", false);
- addUISourceCode(rootURL2 + "foo/baz/script.js", false);
+ await addUISourceCode(rootURL2 + "foo/bar/script.js?a=1", false);
+ await addUISourceCode(rootURL2 + "foo/baz/script.js", false);
InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView);
InspectorTest.addResult("\n\n================================================");
var rootURL3 = "http://localhost:8080/LayoutTests/inspector/debugger3/";
- addUISourceCode(rootURL3 + "hasOwnProperty/__proto__/constructor/foo.js", false);
- addUISourceCode(rootURL3 + "hasOwnProperty/__proto__/foo.js", false);
- addUISourceCode(rootURL3 + "hasOwnProperty/foo.js", false);
+ await addUISourceCode(rootURL3 + "hasOwnProperty/__proto__/constructor/foo.js", false);
+ await addUISourceCode(rootURL3 + "hasOwnProperty/__proto__/foo.js", false);
+ await addUISourceCode(rootURL3 + "hasOwnProperty/foo.js", false);
InspectorTest.dumpNavigatorViewInAllModes(sourcesNavigatorView);
InspectorTest.addResult("\n\n================================================");

Powered by Google App Engine
This is Rietveld 408576698