如何将调试器附加到设备?镀铬延伸 [英] how to attach debugger to device? chrome extention
问题描述
这是我的Chrome扩展程序中的代码,据我所知,它应该返回所有可以附加调试器的目标:
This is the code from my chrome extension, as far as i am aware it should return all targets that i can attach a debugger to:
chrome.browserAction.onClicked.addListener(function(tab) {
console.log('launching extention');
chrome.debugger.getTargets(function(result){
console.log('Result!');
console.log("count: "+result.length);
for (index = 0; index < result.length; index++) {
console.log(index+": "+result[index].url);
}
});
});
这是我上述扩展程序的控制台输出:
This is my console output from the above extension:
显示仅在Chrome浏览器中打开的标签,作为可调试目标返回。
This shows only tabs open in the chrome browser returned as debuggable targets.
我的设备已连接并正确设置,以便我可以调试android chrome选项卡。
I have my device connected and setup correctly so i can debug android chrome tabs.
我正在使用的方法尝试附加到设备调试器正确吗?
Is the method i am using to try to attach to the devices debugger correct?
Related Docs Links; remote-debugging, debugger, debugger-protocol, debugging-clients.
推荐答案
糟糕。看起来像这个API不允许附加到设备页面。更糟糕的是,我找不到任何功能请求来使其能够这样做。
Whoops. Seems like this API does not allow to attach to device pages. Worse, I can't find any feature requests to enable it to do so.
因此,您将需要进入低级别,并使用旧版工作流程,可以在您正在连接的手机上显示原始访问的调试器。
Therefore, you will need to go low-level, and use the "legacy workflow" to expose the debugger for raw access on the phone you're connecting.
基本上,重要的部分是运行ADB命令
Essentially, the important part is running ADB command
adb forward tcp:9222 localabstract:chrome_devtools_remote
暴露Android Chrome的调试界面本地主机:9222
,之后您可以使用XHR / WebSockets 转发原始协议消息。
that exposes the debugging interface of Android Chrome at localhost:9222
, after which you can use XHR / WebSockets to relay raw protocol messages.
恐怕这是唯一的办法如果您需要自动完成ADB步骤,则可以使用 Native Host脚本。请注意,您仍然无法绕过需要在手机上完成的配对部分。
I'm afraid that's the only way; if you need the ADB step to be done automatically, you can use a Native Host script. Note that you still can't bypass the "pairing" part that needs to be done on the phone.
这篇关于如何将调试器附加到设备?镀铬延伸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!