如何使用chrome扩展名将断点添加到javascript文件 [英] How to add breakpoint to a javascript file using a chrome extension
问题描述
我正在尝试使用chrome Extension为源JavaScript文件添加一个断点。但是它表示
I am trying to add a break-point to the source JavaScript file using a chrome Extension. But it says the
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.debugger.attach({"tabId" : tab.id }}, "1.0");
chrome.debugger.sendCommand({
"tabId": tab.id},
"Debugger.setBreakpoint",
{
"Location": {"lineNumber": 12},
},
function(response) {
chrome.extension.getBackgroundPage().console.log(JSON.stringify(response));
});
});
var version = "1.0";
它给我一个错误,表示参数位置与类型对象未找到。
It gives me a error saying the parameter 'Location' with type object not found .
推荐答案
文档说 参数名称是位置
而不是位置。
The documentation says the parameter name is location
, not Location.
在JavaScript大写的标识符通常表示类,而变量/参数使用较低的camelCase。
In javascript Capitalized identifiers denote classes commonly, while the variables/parameters use lower camelCase.
P.S。要了解实际发生的情况,嗅探调试器协议非常有用在devtools中手动执行操作。
P.S. to see what actually happens it's very useful to "sniff" the debugger protocol while doing the action manually in devtools.
这篇关于如何使用chrome扩展名将断点添加到javascript文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!