Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome extension: (DOM)Debugger API does not work anymore

Our chrome extension does not work correctly anymore since version 37.0.2062.103 (It used to work correctly on chrome version 36.0.1985.143).

Specifically, the debugger API has stopped working for us when we use the DOMDebugger. See the 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 the yellow debugger ribbon. We also see the 'registering click' msg in the console. the result argument is an empty object {} (line 8). However upon clicking on a button that has a click event listener nothing happens.

It used to work without any issues.

like image 308
Amit Levin Avatar asked Oct 20 '22 02:10

Amit Levin


1 Answers

It seems like it regressed with https://codereview.chromium.org/305753005. One needs to call "DOM.enable" for it to work now. On the Chrome side, we should implicitly enable DOM domain upon setEventListenerBreakpoint for backwards compatibility. Unfortunately it already squeezed into the stable release.

like image 142
pavel.feldman Avatar answered Nov 13 '22 05:11

pavel.feldman