Repository: microsoft/vscode-edge-devtools
Pull request #215 (2020-10-09 20:37:08)

Remove DOM Breakpoint tab and context menu option
DOM Breakpoints operate on the sources pane which is not included in the extension.  This PR removes the DOM Breakpoints tab in the Elements side panel and the "Break on" context menu option


Patch:
diff --git a/postBuildStep.ts b/postBuildStep.ts
index 6592949..ff9b7ab 100644
--- a/postBuildStep.ts
+++ b/postBuildStep.ts
@@ -18,6 +18,7 @@ import {
     applyInspectorCommonNetworkPatch,
     applyMainViewPatch,
     applyPersistRequestBlockingTab,
+    applyRemoveBreakOnContextMenuItem,
     applySetTabIconPatch,
     applyShowElementsTab,
     applyShowRequestBlockingTab,
@@ -128,6 +129,9 @@ async function patchFilesForWebView(toolsOutDir: string) {
     await patchFileForWebViewWrapper("ui/ui.js", toolsOutDir, [
         applyHandleActionPatch,
     ]);
+    await patchFileForWebViewWrapper("browser_debugger/browser_debugger.js", toolsOutDir, [
+        applyRemoveBreakOnContextMenuItem,
+    ])
 }
 
 // This function wraps the patchFileForWebView function to catch any errors thrown, log them
diff --git a/src/host/polyfills/simpleView.ts b/src/host/polyfills/simpleView.ts
index f47990f..24e45d4 100644
--- a/src/host/polyfills/simpleView.ts
+++ b/src/host/polyfills/simpleView.ts
@@ -87,7 +87,16 @@ export function applyShowElementsTab(content: string) {
     if (content.match(pattern)) {
         return content.replace(pattern, "this._defaultTab = 'elements';");
     } else {
-    return null;
+        return null;
+    }
+}
+
+export function applyRemoveBreakOnContextMenuItem(content: string) {
+    const pattern = /const breakpointsMenu=.+hasDOMBreakpoint\(.*\);}/;
+    if (content.match(pattern)) {
+        return content.replace(pattern, "");
+    } else {
+        return null;
     }
 }
 
@@ -134,7 +143,6 @@ export function applyAppendTabPatch(content: string) {
         "Computed",
         "accessibility.view",
         "elements.domProperties",
-        "elements.domBreakpoints",
         "elements.eventListeners",
     ];
 


Test patch:
diff --git a/src/host/polyfills/simpleView.test.ts b/src/host/polyfills/simpleView.test.ts
index 7e7ee00..edeae13 100644
--- a/src/host/polyfills/simpleView.test.ts
+++ b/src/host/polyfills/simpleView.test.ts
@@ -147,6 +147,21 @@ describe("simpleView", () => {
         }
     });
 
+    it("applyRemoveBreakOnContextMenuItem correctly changes text", async () => {
+        const filePath = "browser_debugger/browser_debugger.js";
+        const fileContents = getTextFromFile(filePath);
+        if (!fileContents) {
+            throw new Error(`Could not find file: ${filePath}`);
+        }
+
+        const apply = await import("./simpleView");
+        const result = apply.applyRemoveBreakOnContextMenuItem(fileContents);
+        expect(result).not.toEqual(null);
+        if (result) {
+            expect(result).not.toEqual(expect.stringContaining("const breakpointsMenu"));
+        }
+    });
+
     it("applyShowRequestBlockingTab correctly changes text", async () => {
         const filePath = "ui/ui.js";
         const fileContents = getTextFromFile(filePath);