Chrome extension: (DOM) debugger API no longer works

Our chrome extension does not work correctly from version 37.0.2062.103 (it worked correctly on chrome version 36.0.1985.143).

In particular, the debugger API stops working for us when we use DOMDebugger. See Attached Code: (background.js)

chrome.tabs.onUpdated.addListener(function(tabId,changeInfo,tab){ if( changeInfo.status == "loading" && tab.active){ var debugId = {tabId:tabId}; chrome.debugger.attach(debugId, '1.0', function() { chrome.debugger.sendCommand(debugId, 'Debugger.enable', {}, function() { chrome.debugger.sendCommand(debugId, "DOMDebugger.setEventListenerBreakpoint", {'eventName':'click'}, function(result) { console.log('registering click'); }); }); }); } }); chrome.debugger.onEvent.addListener(onEvent); function onEvent(debuggeeId, method,params) { if(method=="Debugger.paused"){ console.log('DONE!'); } }; 

The extension successfully starts the debugger. we get a yellow tape debugger. We also see a “register click” message in the console. the result argument is the empty object {} (line 8). However, when you click on a button that has a click event listener, nothing happens.

It worked without problems.

+5
source share
1 answer

I think he regressed using https://codereview.chromium.org/305753005 . You need to call "DOM.enable" for it to work now. On the Chrome side, we must implicitly include the DOM domain in setEventListenerBreakpoint for backward compatibility. Unfortunately, he has already squeezed into a stable release.

+3
source

Source: https://habr.com/ru/post/1202232/


All Articles