1

I'm writing Chrome devtools plugin.

devtools.js

chrome.devtools.panels.create("Override Debug",
  null,
  "panel.html",
  (panel) => {
    panel.onShown.addListener(addDebugger);
    panel.onHidden.addListener(destroyDebugger);
  }
);

So when user navigates to Override Debug tab in devtools, I'm initializing debugger. When user navigating away from my devtool, I'm discarding debugger - Which is working great

Now the issue comes, when user navigates to Override Debug and closed devtools completely, debugger still alive making page un responsive.

I tried to see events in panel object chrome.devtools objects also tried entire github to see if we have such event. No luck.

Is there any event that monitors devtools close event to discard the debugger I attached?

Update 1

Tried to attach Inspector.enable command as follows but no luck. It never got Inspector.detached message

function addDebugger() {
  chrome.tabs.getSelected(null, function(target) {
    debuggee = { tabId: target.id };

    chrome.debugger.attach(debuggee, "1.2", () => {
      chrome.debugger.sendCommand(debuggee, "Network.setRequestInterception", { patterns: [{ urlPattern: '*' }] });
      chrome.debugger.sendCommand(debuggee, "Inspector.enable");
    });



    chrome.debugger.onEvent.addListener((source, method, params) => {
      if (source.tabId === target.id) {
        if (method === "Network.requestIntercepted") {
          // Do many things
        } else if (method === "Inspector.detached") {
          destroyDebugger();
        }
      }
    })
  });
}

Pasupathi Rajamanickam
  • 1,982
  • 1
  • 24
  • 48
  • 1
    Simple method in [this answer](/a/48287643) (you need to insert that code using chrome.devtools.inspectedWindow.eval). Another solution might be to use `chrome.debugger` API and send `Inspector.enable` command then watch for `Inspector.detached` event, [more info](https://chromedevtools.github.io/devtools-protocol/tot/Inspector). – wOxxOm Feb 11 '20 at 06:23
  • @wOxxOm Where on the earth this link is hidden!!!! Thanks for sharing, but unfortunately it's not working for me. Updated my question with what I've tried. – Pasupathi Rajamanickam Feb 12 '20 at 20:24

0 Answers0