是否可以从Chrome浏览器内部连接到Remote Debugging Protoco l? - 没有为此目的安装和创建扩展。
目的是使用ACE编辑器或类似方法测试在HTML页面内创建的JavaScript代码,以允许用户在页面中运行代码片段,然后将结果返回到调用页面。例如,代码可能在IFRAME中运行。
至少http://brackets.io/据说“Brackets是一个基于网络的IDE,它使用Chrome调试协议来启用调试和实时HTML / CSS开发。” - 这让我想知道,浏览器是否有客户端JS API将WebSockets连接到接口,还是你必须自己编写该接口?
所以,客户端似乎有几种选择,但浏览器本身呢?
编辑:假设此处浏览器已启动--remote-debugging-port = ...设置为有意义的值。
答案 0 :(得分:1)
Not directly. As far as I can tell, the remote debugging interface is only available if it has explicitly been enabled at startup using the ListView buttonPanel = new ListView(this);
buttonPanel.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
selectedGameMenu.setVisibility(View.VISIBLE);
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
ArrayList<Button> btnList = new ArrayList<>();
try
{
//... your code
while(line != null)
{
GameItem tempGameItem = new GameItem();
tempGameItem.setGameName(line);
btnList.add(tempGameItem);
line = buff.readLine();
}
//Closing all streams that were opened. May have been the reason for frame loss
buff.close();
input.close();
ListAdapter btnAdp = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1 ,btnList);
buttonPanel.setAdapter(btnAdp);
}
//... your code
command-line flag. There doesn't appear to be any way to activate it at runtime; even if it were, you wouldn't be able to access it from a web page.
Keep in mind that Brackets is a standalone application based on Chrome; it doesn't run as a web site. As such, it can do some things that aren't possible in a browser.
Now, that all being said, there may be a way to make some error reporting and debugging features available if you're careful. In particular, if you can inject code into your iframe, you could attach an event handler to the global onerror
event to catch exceptions. You may need to use some special tricks to pass events from the frame to the parent page — Window.postMessage
may be helpful here — but that should at least get you started.