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

Unified Diff: third_party/WebKit/LayoutTests/inspector/network/network-product-entry.html

Issue 2879503002: [Devtools] Added product entry tests for network
Patch Set: [Devtools] Added product entry tests for network Created 3 years, 7 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/network/network-product-entry.html
diff --git a/third_party/WebKit/LayoutTests/inspector/network/network-product-entry.html b/third_party/WebKit/LayoutTests/inspector/network/network-product-entry.html
new file mode 100644
index 0000000000000000000000000000000000000000..602200dc9234728929085237ec936d8ef22ffa39
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/inspector/network/network-product-entry.html
@@ -0,0 +1,81 @@
+<html>
+<head>
+<script src="../../http/tests/inspector/inspector-test.js"></script>
+<script src="../../http/tests/inspector/network-test.js"></script>
+<script src="../../http/tests/inspector/page-mock.js"></script>
+<script>
+
+async function test() {
+ Runtime.experiments.enableForTest('networkGroupingRequests');
+ var productRegistry = await ProductRegistry.instance();
+ ProductRegistryImpl.resetForTest();
+ addProductEntry('*.test.example.com');
+ addProductEntry('cdn-*.example.com');
+ addProductEntry('has-product-subframe.example.com');
+
+ InspectorTest.addResult('');
+
+ InspectorTest.recordNetwork();
+
+ var pageMock = new InspectorTest.PageMock('http://example.com');
+ var productFrameId = pageMock.addFrame('http://has-product-subframe.example.com');
+ var noProductFrameId = pageMock.addFrame('http://no-product-subframe.example.com');
+ var target = InspectorTest.connectToPage('mock-page-subframe-1', pageMock, true /* makeMainTarget */);
+ var resourceTreeModel = target.model(SDK.ResourceTreeModel);
+
+ await InspectorTest.waitEventListener(SDK.ResourceTreeModel.Events.CachedResourcesLoaded, resourceTreeModel);
+
+ // Main page requests.
+ var mainFrame = resourceTreeModel.mainFrame;
+ await runOnFrameAndLog(mainFrame, 'http://example.com/');
+ await runOnFrameAndLog(mainFrame, 'http://test.example.com/');
+ await runOnFrameAndLog(mainFrame, 'http://cdn-1.example.com/');
+ await runOnFrameAndLog(mainFrame, 'http://example.org/');
+
+ // Frame is associated with product.
+ var productFrame = resourceTreeModel.frameForId(productFrameId);
+ await runOnFrameAndLog(productFrame, 'http://example.com/');
+ await runOnFrameAndLog(productFrame, 'http://test.example.com/');
+ await runOnFrameAndLog(productFrame, 'http://cdn-1.example.com/');
+ await runOnFrameAndLog(productFrame, 'http://example.org/');
+
+ // Frame is not associated with product.
+ var noProductFrame = resourceTreeModel.frameForId(noProductFrameId);
+ await runOnFrameAndLog(noProductFrame, 'http://example.com/');
+ await runOnFrameAndLog(noProductFrame, 'http://test.example.com/');
+ await runOnFrameAndLog(noProductFrame, 'http://cdn-1.example.com/');
+ await runOnFrameAndLog(noProductFrame, 'http://example.org/');
+
+ InspectorTest.completeTest();
+
+ async function runOnFrameAndLog(frame, url) {
+ var requestId = await pageMock.requestWillBeSent(url, frame);
+ var networkManager = target.model(SDK.NetworkManager);
+ var request = InspectorTest.networkLog.requestForId(networkManager, requestId);
dgozman 2017/05/10 22:57:14 Use InspectorTest.findRequestsByURLPattern to make
+ await waitNodeAndLogResultForRequest(request);
+ }
+
+ async function waitNodeAndLogResultForRequest(request) {
+ var frame = SDK.ResourceTreeModel.frameForRequest(request);
+ var node = await InspectorTest.waitForNetworkLogViewNodeForRequest(request);
+ var productEntry = await node.productEntry();
+ var productName = productEntry ? productEntry.entry.name : '**No Product Entry**';
+ var matchedURL = productEntry ? productEntry.matchedURL.url : '**No Product Entry**';
+ InspectorTest.addResult("URL: " + request.url());
+ InspectorTest.addResult("Frame URL: " + frame.url);
+ InspectorTest.addResult("ProductEntry Name: " + productName);
+ InspectorTest.addResult("ProductEntry MatchedURL: " + matchedURL);
+ InspectorTest.addResult("");
+ }
+
+ function addProductEntry(domainPattern) {
+ InspectorTest.addResult("Adding product entry: " + domainPattern);
+ ProductRegistryImpl.registerEntryForTest(domainPattern, domainPattern);
+ }
+}
+</script>
+</head>
+<body onload="runTest()">
+<p>Tests to ensure product registry attributes frames and resources in network panel.</p>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698