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

混江龙づ霸主 提交于 2019-12-01 02:59:57

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/25764336/chrome-extension-domdebugger-api-does-not-work-anymore

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!