[ve] Annotate Network panel menus

Bug: chromium:1467464
Change-Id: I9c042a3c9182df5daf674feb0801db79c596fa75
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5319492
Reviewed-by: Wolfgang Beyer <[email protected]>
Commit-Queue: Wolfgang Beyer <[email protected]>
Auto-Submit: Danil Somsikov <[email protected]>
diff --git a/front_end/panels/network/BinaryResourceView.ts b/front_end/panels/network/BinaryResourceView.ts
index 0076782..9e26c82 100644
--- a/front_end/panels/network/BinaryResourceView.ts
+++ b/front_end/panels/network/BinaryResourceView.ts
@@ -187,21 +187,21 @@
   }
 
   addCopyToContextMenu(contextMenu: UI.ContextMenu.ContextMenu, submenuItemText: string): void {
-    const copyMenu = contextMenu.clipboardSection().appendSubMenuItem(submenuItemText);
+    const copyMenu = contextMenu.clipboardSection().appendSubMenuItem(submenuItemText, false, 'copy');
     const footerSection = copyMenu.footerSection();
 
     footerSection.appendItem(i18nString(UIStrings.copyAsBase), async () => {
       const content = await this.binaryResourceViewFactory.base64();
       Host.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(content.content);
-    });
+    }, {jslogContext: 'copy-as-base'});
     footerSection.appendItem(i18nString(UIStrings.copyAsHex), async () => {
       const content = await this.binaryResourceViewFactory.hex();
       Host.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(content.content);
-    });
+    }, {jslogContext: 'copy-as-hex'});
     footerSection.appendItem(i18nString(UIStrings.copyAsUtf), async () => {
       const content = await this.binaryResourceViewFactory.utf8();
       Host.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(content.content);
-    });
+    }, {jslogContext: 'copy-as-utf'});
   }
 }
 
diff --git a/front_end/panels/network/EventSourceMessagesView.ts b/front_end/panels/network/EventSourceMessagesView.ts
index b65bd6f..9b4a917 100644
--- a/front_end/panels/network/EventSourceMessagesView.ts
+++ b/front_end/panels/network/EventSourceMessagesView.ts
@@ -180,7 +180,8 @@
     contextMenu.clipboardSection().appendItem(
         i18nString(UIStrings.copyMessage),
         Host.InspectorFrontendHost.InspectorFrontendHostInstance.copyText.bind(
-            Host.InspectorFrontendHost.InspectorFrontendHostInstance, node.data.data));
+            Host.InspectorFrontendHost.InspectorFrontendHostInstance, node.data.data),
+        {jslogContext: 'copy'});
   }
 
   refresh(): void {
diff --git a/front_end/panels/network/NetworkLogView.ts b/front_end/panels/network/NetworkLogView.ts
index 39a3c83..3417167 100644
--- a/front_end/panels/network/NetworkLogView.ts
+++ b/front_end/panels/network/NetworkLogView.ts
@@ -1675,26 +1675,31 @@
   handleContextMenuForRequest(contextMenu: UI.ContextMenu.ContextMenu, request: SDK.NetworkRequest.NetworkRequest):
       void {
     contextMenu.appendApplicableItems(request);
-    const copyMenu = contextMenu.clipboardSection().appendSubMenuItem(i18nString(UIStrings.copy));
+    const copyMenu = contextMenu.clipboardSection().appendSubMenuItem(i18nString(UIStrings.copy), false, 'copy');
     if (request) {
       copyMenu.defaultSection().appendItem(
           i18nString(UIStrings.copyURL),
           Host.InspectorFrontendHost.InspectorFrontendHostInstance.copyText.bind(
-              Host.InspectorFrontendHost.InspectorFrontendHostInstance, request.contentURL()));
-      copyMenu.footerSection().appendItem(i18nString(UIStrings.copyAllURLs), this.copyAllURLs.bind(this));
+              Host.InspectorFrontendHost.InspectorFrontendHostInstance, request.contentURL()),
+          {jslogContext: 'copy-url'});
+      copyMenu.footerSection().appendItem(
+          i18nString(UIStrings.copyAllURLs), this.copyAllURLs.bind(this), {jslogContext: 'copy-all-urls'});
       if (request.requestHeadersText()) {
         copyMenu.saveSection().appendItem(
-            i18nString(UIStrings.copyRequestHeaders), NetworkLogView.copyRequestHeaders.bind(null, request));
+            i18nString(UIStrings.copyRequestHeaders), NetworkLogView.copyRequestHeaders.bind(null, request),
+            {jslogContext: 'copy-request-headers'});
       }
 
       if (request.responseHeadersText) {
         copyMenu.saveSection().appendItem(
-            i18nString(UIStrings.copyResponseHeaders), NetworkLogView.copyResponseHeaders.bind(null, request));
+            i18nString(UIStrings.copyResponseHeaders), NetworkLogView.copyResponseHeaders.bind(null, request),
+            {jslogContext: 'copy-response-headers'});
       }
 
       if (request.finished) {
         copyMenu.saveSection().appendItem(
-            i18nString(UIStrings.copyResponse), NetworkLogView.copyResponse.bind(null, request));
+            i18nString(UIStrings.copyResponse), NetworkLogView.copyResponse.bind(null, request),
+            {jslogContext: 'copy-response'});
       }
 
       const initiator = request.initiator();
@@ -1709,7 +1714,7 @@
           if (stackTraceText !== '') {
             copyMenu.saveSection().appendItem(i18nString(UIStrings.copyStacktrace), () => {
               Host.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(stackTraceText);
-            });
+            }, {jslogContext: 'copy-stacktrace'});
           }
         }
       }
@@ -1718,50 +1723,63 @@
       if (Host.Platform.isWin()) {
         copyMenu.defaultSection().appendItem(
             i18nString(UIStrings.copyAsCurlCmd), this.copyCurlCommand.bind(this, request, 'win'),
-            {disabled: disableIfBlob});
+            {disabled: disableIfBlob, jslogContext: 'copy-as-curl-cmd'});
         copyMenu.defaultSection().appendItem(
             i18nString(UIStrings.copyAsCurlBash), this.copyCurlCommand.bind(this, request, 'unix'),
-            {disabled: disableIfBlob});
+            {disabled: disableIfBlob, jslogContext: 'copy-as-curl-bash'});
       } else {
         copyMenu.defaultSection().appendItem(
             i18nString(UIStrings.copyAsCurl), this.copyCurlCommand.bind(this, request, 'unix'),
-            {disabled: disableIfBlob});
+            {disabled: disableIfBlob, jslogContext: 'copy-as-curl'});
       }
       copyMenu.defaultSection().appendItem(
           i18nString(UIStrings.copyAsPowershell), this.copyPowerShellCommand.bind(this, request),
-          {disabled: disableIfBlob});
+          {disabled: disableIfBlob, jslogContext: 'copy-as-powershell'});
       copyMenu.defaultSection().appendItem(
           i18nString(UIStrings.copyAsFetch), this.copyFetchCall.bind(this, request, FetchStyle.Browser),
-          {disabled: disableIfBlob});
+          {disabled: disableIfBlob, jslogContext: 'copy-as-fetch'});
       copyMenu.defaultSection().appendItem(
           i18nString(UIStrings.copyAsNodejsFetch), this.copyFetchCall.bind(this, request, FetchStyle.NodeJs),
-          {disabled: disableIfBlob});
+          {disabled: disableIfBlob, jslogContext: 'copy-as-nodejs-fetch'});
 
       if (Host.Platform.isWin()) {
         copyMenu.footerSection().appendItem(
-            i18nString(UIStrings.copyAllAsCurlCmd), this.copyAllCurlCommand.bind(this, 'win'));
+            i18nString(UIStrings.copyAllAsCurlCmd), this.copyAllCurlCommand.bind(this, 'win'),
+            {jslogContext: 'copy-all-as-curl-cmd'});
         copyMenu.footerSection().appendItem(
-            i18nString(UIStrings.copyAllAsCurlBash), this.copyAllCurlCommand.bind(this, 'unix'));
+            i18nString(UIStrings.copyAllAsCurlBash), this.copyAllCurlCommand.bind(this, 'unix'),
+            {jslogContext: 'copy-all-as-curl-bash'});
       } else {
         copyMenu.footerSection().appendItem(
-            i18nString(UIStrings.copyAllAsCurl), this.copyAllCurlCommand.bind(this, 'unix'));
+            i18nString(UIStrings.copyAllAsCurl), this.copyAllCurlCommand.bind(this, 'unix'),
+            {jslogContext: 'copy-all-as-curl'});
       }
       copyMenu.footerSection().appendItem(
-          i18nString(UIStrings.copyAllAsPowershell), this.copyAllPowerShellCommand.bind(this));
+          i18nString(UIStrings.copyAllAsPowershell), this.copyAllPowerShellCommand.bind(this),
+          {jslogContext: 'copy-all-as-powershell'});
       copyMenu.footerSection().appendItem(
-          i18nString(UIStrings.copyAllAsFetch), this.copyAllFetchCall.bind(this, FetchStyle.Browser));
+          i18nString(UIStrings.copyAllAsFetch), this.copyAllFetchCall.bind(this, FetchStyle.Browser),
+          {jslogContext: 'copy-all-as-fetch'});
       copyMenu.footerSection().appendItem(
-          i18nString(UIStrings.copyAllAsNodejsFetch), this.copyAllFetchCall.bind(this, FetchStyle.NodeJs));
+          i18nString(UIStrings.copyAllAsNodejsFetch), this.copyAllFetchCall.bind(this, FetchStyle.NodeJs),
+          {jslogContext: 'copy-all-as-nodejs-fetch'});
     }
-    copyMenu.footerSection().appendItem(i18nString(UIStrings.copyAllAsHar), this.copyAllAsHAR.bind(this));
+    copyMenu.footerSection().appendItem(
+        i18nString(UIStrings.copyAllAsHar), this.copyAllAsHAR.bind(this), {jslogContext: 'copy-all-as-har'});
 
-    contextMenu.saveSection().appendItem(i18nString(UIStrings.saveAllAsHarWithContent), this.exportAll.bind(this));
+    contextMenu.saveSection().appendItem(
+        i18nString(UIStrings.saveAllAsHarWithContent), this.exportAll.bind(this),
+        {jslogContext: 'save-all-as-har-with-content'});
     contextMenu.overrideSection().appendItem(
-        i18nString(UIStrings.overrideHeaders), this.#handleCreateResponseHeaderOverrideClick.bind(this, request));
+        i18nString(UIStrings.overrideHeaders), this.#handleCreateResponseHeaderOverrideClick.bind(this, request),
+        {jslogContext: 'override-headers'});
 
-    contextMenu.editSection().appendItem(i18nString(UIStrings.clearBrowserCache), this.clearBrowserCache.bind(this));
     contextMenu.editSection().appendItem(
-        i18nString(UIStrings.clearBrowserCookies), this.clearBrowserCookies.bind(this));
+        i18nString(UIStrings.clearBrowserCache), this.clearBrowserCache.bind(this),
+        {jslogContext: 'clear-browser-cache'});
+    contextMenu.editSection().appendItem(
+        i18nString(UIStrings.clearBrowserCookies), this.clearBrowserCookies.bind(this),
+        {jslogContext: 'clear-browser-cookies'});
 
     if (request) {
       const maxBlockedURLLength = 20;
@@ -1784,26 +1802,31 @@
       const urlWithoutScheme = request.parsedURL.urlWithoutScheme();
       if (urlWithoutScheme && !patterns.find(pattern => pattern.url === urlWithoutScheme)) {
         contextMenu.debugSection().appendItem(
-            i18nString(UIStrings.blockRequestUrl), addBlockedURL.bind(null, urlWithoutScheme));
+            i18nString(UIStrings.blockRequestUrl), addBlockedURL.bind(null, urlWithoutScheme),
+            {jslogContext: 'block-request-url'});
       } else if (urlWithoutScheme) {
         const croppedURL = Platform.StringUtilities.trimMiddle(urlWithoutScheme, maxBlockedURLLength);
         contextMenu.debugSection().appendItem(
-            i18nString(UIStrings.unblockS, {PH1: croppedURL}), removeBlockedURL.bind(null, urlWithoutScheme));
+            i18nString(UIStrings.unblockS, {PH1: croppedURL}), removeBlockedURL.bind(null, urlWithoutScheme),
+            {jslogContext: 'unblock'});
       }
 
       const domain = request.parsedURL.domain();
       if (domain && !patterns.find(pattern => pattern.url === domain)) {
         contextMenu.debugSection().appendItem(
-            i18nString(UIStrings.blockRequestDomain), addBlockedURL.bind(null, domain));
+            i18nString(UIStrings.blockRequestDomain), addBlockedURL.bind(null, domain),
+            {jslogContext: 'block-request-domain'});
       } else if (domain) {
         const croppedDomain = Platform.StringUtilities.trimMiddle(domain, maxBlockedURLLength);
         contextMenu.debugSection().appendItem(
-            i18nString(UIStrings.unblockS, {PH1: croppedDomain}), removeBlockedURL.bind(null, domain));
+            i18nString(UIStrings.unblockS, {PH1: croppedDomain}), removeBlockedURL.bind(null, domain),
+            {jslogContext: 'unblock'});
       }
 
       if (SDK.NetworkManager.NetworkManager.canReplayRequest(request)) {
         contextMenu.debugSection().appendItem(
-            i18nString(UIStrings.replayXhr), SDK.NetworkManager.NetworkManager.replayRequest.bind(null, request));
+            i18nString(UIStrings.replayXhr), SDK.NetworkManager.NetworkManager.replayRequest.bind(null, request),
+            {jslogContext: 'replay-xhr'});
       }
     }
   }
diff --git a/front_end/panels/network/NetworkLogViewColumns.ts b/front_end/panels/network/NetworkLogViewColumns.ts
index 56f98e6..2889ce9 100644
--- a/front_end/panels/network/NetworkLogViewColumns.ts
+++ b/front_end/panels/network/NetworkLogViewColumns.ts
@@ -652,7 +652,8 @@
         const title = columnConfig.title instanceof Function ? columnConfig.title() : columnConfig.title;
 
         contextMenu.headerSection().appendCheckboxItem(
-            title, this.toggleColumnVisibility.bind(this, columnConfig), {checked: columnConfig.visible, disabled});
+            title, this.toggleColumnVisibility.bind(this, columnConfig),
+            {checked: columnConfig.visible, disabled, jslogContext: columnConfig.id});
       }
 
       contextMenu.headerSection().appendSeparator();
@@ -662,37 +663,42 @@
     for (const columnConfig of nonResponseHeadersWithoutGroup) {
       const title = columnConfig.title instanceof Function ? columnConfig.title() : columnConfig.title;
       contextMenu.headerSection().appendCheckboxItem(
-          title, this.toggleColumnVisibility.bind(this, columnConfig), {checked: columnConfig.visible});
+          title, this.toggleColumnVisibility.bind(this, columnConfig),
+          {checked: columnConfig.visible, jslogContext: columnConfig.id});
     }
 
-    const responseSubMenu = contextMenu.footerSection().appendSubMenuItem(i18nString(UIStrings.responseHeaders));
+    const responseSubMenu =
+        contextMenu.footerSection().appendSubMenuItem(i18nString(UIStrings.responseHeaders), false, 'response-headers');
     const responseHeaders = columnConfigs.filter(columnConfig => columnConfig.isResponseHeader);
     for (const columnConfig of responseHeaders) {
       const title = columnConfig.title instanceof Function ? columnConfig.title() : columnConfig.title;
       responseSubMenu.defaultSection().appendCheckboxItem(
-          title, this.toggleColumnVisibility.bind(this, columnConfig), {checked: columnConfig.visible});
+          title, this.toggleColumnVisibility.bind(this, columnConfig),
+          {checked: columnConfig.visible, jslogContext: columnConfig.id});
     }
 
     responseSubMenu.footerSection().appendItem(
-        i18nString(UIStrings.manageHeaderColumns), this.manageCustomHeaderDialog.bind(this));
+        i18nString(UIStrings.manageHeaderColumns), this.manageCustomHeaderDialog.bind(this),
+        {jslogContext: 'manage-header-columns'});
 
     const waterfallSortIds = WaterfallSortIds;
-    const waterfallSubMenu = contextMenu.footerSection().appendSubMenuItem(i18nString(UIStrings.waterfall));
+    const waterfallSubMenu =
+        contextMenu.footerSection().appendSubMenuItem(i18nString(UIStrings.waterfall), false, 'waterfall');
     waterfallSubMenu.defaultSection().appendCheckboxItem(
         i18nString(UIStrings.startTime), setWaterfallMode.bind(this, waterfallSortIds.StartTime),
-        {checked: this.activeWaterfallSortId === waterfallSortIds.StartTime});
+        {checked: this.activeWaterfallSortId === waterfallSortIds.StartTime, jslogContext: 'start-time'});
     waterfallSubMenu.defaultSection().appendCheckboxItem(
         i18nString(UIStrings.responseTime), setWaterfallMode.bind(this, waterfallSortIds.ResponseTime),
-        {checked: this.activeWaterfallSortId === waterfallSortIds.ResponseTime});
+        {checked: this.activeWaterfallSortId === waterfallSortIds.ResponseTime, jslogContext: 'response-time'});
     waterfallSubMenu.defaultSection().appendCheckboxItem(
         i18nString(UIStrings.endTime), setWaterfallMode.bind(this, waterfallSortIds.EndTime),
-        {checked: this.activeWaterfallSortId === waterfallSortIds.EndTime});
+        {checked: this.activeWaterfallSortId === waterfallSortIds.EndTime, jslogContext: 'end-time'});
     waterfallSubMenu.defaultSection().appendCheckboxItem(
         i18nString(UIStrings.totalDuration), setWaterfallMode.bind(this, waterfallSortIds.Duration),
-        {checked: this.activeWaterfallSortId === waterfallSortIds.Duration});
+        {checked: this.activeWaterfallSortId === waterfallSortIds.Duration, jslogContext: 'total-duration'});
     waterfallSubMenu.defaultSection().appendCheckboxItem(
         i18nString(UIStrings.latency), setWaterfallMode.bind(this, waterfallSortIds.Latency),
-        {checked: this.activeWaterfallSortId === waterfallSortIds.Latency});
+        {checked: this.activeWaterfallSortId === waterfallSortIds.Latency, jslogContext: 'latency'});
 
     function setWaterfallMode(this: NetworkLogViewColumns, sortId: WaterfallSortIds): void {
       let calculator = this.calculatorsMap.get(CalculatorTypes.Time);
diff --git a/front_end/panels/network/NetworkPanel.ts b/front_end/panels/network/NetworkPanel.ts
index dcf5548..ea47721 100644
--- a/front_end/panels/network/NetworkPanel.ts
+++ b/front_end/panels/network/NetworkPanel.ts
@@ -720,7 +720,8 @@
           () => UI.ViewManager.ViewManager.instance()
                     .showView('network')
                     .then(this.networkLogView.resetFilter.bind(this.networkLogView))
-                    .then(this.revealAndHighlightRequest.bind(this, request)));
+                    .then(this.revealAndHighlightRequest.bind(this, request)),
+          {jslogContext: 'reveal-in-network'});
     };
 
     if ((event.target as Node).isSelfOrDescendant(this.element)) {
diff --git a/front_end/panels/network/RequestPayloadView.ts b/front_end/panels/network/RequestPayloadView.ts
index 7bedcb2..d9365de 100644
--- a/front_end/panels/network/RequestPayloadView.ts
+++ b/front_end/panels/network/RequestPayloadView.ts
@@ -168,7 +168,8 @@
         Host.userMetrics.actionTaken(Host.UserMetrics.Action.NetworkPanelCopyValue);
         Host.InspectorFrontendHost.InspectorFrontendHostInstance.copyText(decodedValue);
       };
-      contextMenu.clipboardSection().appendItem(i18nString(UIStrings.copyValue), copyDecodedValueHandler);
+      contextMenu.clipboardSection().appendItem(
+          i18nString(UIStrings.copyValue), copyDecodedValueHandler, {jslogContext: 'copy-value'});
       void contextMenu.show();
     });
   }
@@ -270,7 +271,7 @@
     function onContextMenuShowMore(event: Event): void {
       const contextMenu = new UI.ContextMenu.ContextMenu(event);
       const section = contextMenu.newSection();
-      section.appendItem(i18nString(UIStrings.showMore), showMore);
+      section.appendItem(i18nString(UIStrings.showMore), showMore, {jslogContext: 'show-more'});
       void contextMenu.show();
     }
     sourceTreeElement.listItemElement.addEventListener('contextmenu', onContextMenuShowMore);
@@ -320,7 +321,8 @@
         return;
       }
       const contextMenu = new UI.ContextMenu.ContextMenu(event);
-      contextMenu.newSection().appendItem(i18nString(UIStrings.viewParsed), viewParsed.bind(this, event));
+      contextMenu.newSection().appendItem(
+          i18nString(UIStrings.viewParsed), viewParsed.bind(this, event), {jslogContext: 'view-parsed'});
       void contextMenu.show();
     };
 
@@ -374,10 +376,11 @@
       }
       const contextMenu = new UI.ContextMenu.ContextMenu(event);
       const section = contextMenu.newSection();
-      section.appendItem(i18nString(UIStrings.viewSource), viewSource.bind(this, event));
+      section.appendItem(i18nString(UIStrings.viewSource), viewSource.bind(this, event), {jslogContext: 'view-source'});
       const viewURLEncodedText =
           this.decodeRequestParameters ? i18nString(UIStrings.viewUrlEncoded) : i18nString(UIStrings.viewDecoded);
-      section.appendItem(viewURLEncodedText, toggleURLDecoding.bind(this, event));
+      section.appendItem(
+          viewURLEncodedText, toggleURLDecoding.bind(this, event), {jslogContext: 'toggle-url-decoding'});
       void contextMenu.show();
     };
 
@@ -433,7 +436,8 @@
         return;
       }
       const contextMenu = new UI.ContextMenu.ContextMenu(event);
-      contextMenu.newSection().appendItem(i18nString(UIStrings.viewParsed), viewParsed.bind(this, event));
+      contextMenu.newSection().appendItem(
+          i18nString(UIStrings.viewParsed), viewParsed.bind(this, event), {jslogContext: 'view-parsed'});
       void contextMenu.show();
     };
 
@@ -470,7 +474,8 @@
         return;
       }
       const contextMenu = new UI.ContextMenu.ContextMenu(event);
-      contextMenu.newSection().appendItem(i18nString(UIStrings.viewSource), viewSource.bind(this, event));
+      contextMenu.newSection().appendItem(
+          i18nString(UIStrings.viewSource), viewSource.bind(this, event), {jslogContext: 'view-source'});
       void contextMenu.show();
     };
 
diff --git a/front_end/panels/network/ResourceWebSocketFrameView.ts b/front_end/panels/network/ResourceWebSocketFrameView.ts
index 583e370..d46dfe1 100644
--- a/front_end/panels/network/ResourceWebSocketFrameView.ts
+++ b/front_end/panels/network/ResourceWebSocketFrameView.ts
@@ -256,9 +256,11 @@
         contextMenu.clipboardSection().appendItem(
             i18nString(UIStrings.copyMessage),
             Host.InspectorFrontendHost.InspectorFrontendHostInstance.copyText.bind(
-                Host.InspectorFrontendHost.InspectorFrontendHostInstance, node.data.data));
+                Host.InspectorFrontendHost.InspectorFrontendHostInstance, node.data.data),
+            {jslogContext: 'copy'});
       }
-      contextMenu.footerSection().appendItem(i18nString(UIStrings.clearAllL), this.clearFrames.bind(this));
+      contextMenu.footerSection().appendItem(
+          i18nString(UIStrings.clearAllL), this.clearFrames.bind(this), {jslogContext: 'clear-all'});
     }
   }
 
diff --git a/front_end/panels/network/components/RequestHeadersView.ts b/front_end/panels/network/components/RequestHeadersView.ts
index a7d0da6..52eb7b1 100644
--- a/front_end/panels/network/components/RequestHeadersView.ts
+++ b/front_end/panels/network/components/RequestHeadersView.ts
@@ -361,7 +361,7 @@
       if (!showFull) {
         const contextMenu = new UI.ContextMenu.ContextMenu(event);
         const section = contextMenu.newSection();
-        section.appendItem(i18nString(UIStrings.showMore), showMore);
+        section.appendItem(i18nString(UIStrings.showMore), showMore, {jslogContext: 'show-more'});
         void contextMenu.show();
       }
     };