Api for using chrome remote debugging protocol. Written to provide a bridge api for AppJS v2.0
The API implements all methods detailed in the spec: https://developers.google.com/chrome-developer-tools/docs/protocol/1.0/
var rDebug = require('./index.js').rDebug;
var request = require("request");
request("http://localhost:9222/json", function(error, response, body) {
var chromeDebugOptions = JSON.parse(body);
var chromeDebugUrl = chromeDebugOptions[0].webSocketDebuggerUrl;
var rDebugApi = rDebug.openSocket(chromeDebugUrl);
rDebugApi.ws.on('close',function() {
console.log('disconnected');
});
var printErr = function(err) {
console.log("error:"+err.error.code+" "+err.error.message);
};
rDebugApi.on('*',function(event) {
console.log("Event:",event);
});
rDebugApi.ws.on('open',function() {
console.log('connected');
rDebugApi.domGetDocument().then(function(doc) {
rDebugApi.domGetOuterHTML(doc.root.nodeId)
.then(function(res) {
console.log("page html:",res.outerHTML);
rDebugApi.pageNavigate("http://appjs.com").then(function() {
setTimeout(function(){
rDebugApi.pageNavigate("about:blank")
},5000);
}).fail(function(err) {
console.log("error:"+err.error.code+" "+err.error.message);
});
}).fail(function(err) {
console.log("error:"+err.error.code+" "+err.error.message);
});
}).fail(printErr);
});
});
- pageNavigate(url)
- pageReload
- pageDisableEvents
- pageEnableEvents
- consoleClearMessages
- consoleEnable
- consoleDisable
- domGetDocument
- domGetOuterHTML
- domHideHighlight
- domHighlightNode
- domHighlightRect
- domMoveTo
- domQuerySelector
- domQuerySelectorAll
- domRemoveAttribute
- domRemoveNode
- domRequestChildNodes
- domRequestNode
- domResolveNode
- domSetAttributeValue
- domSetAttributesAsText
- domSetNodeName
- domSetNodeValue
- domSetOutputHTML
- domDebuggerRemoveDomBreakpoint
- domDebuggerRemoveEventListenerBreakpoint
- domDebuggerRemoveXHRBreakpoint
- domDebuggerSetDomBreakpoint
- domDebuggerSetEventListenerBreakpoint
- domDebuggerSetXHRBreakpoint
- runtimeCallFunctionOn
- runtimeEvaluate
- runtimeGetProperties
- runtimeReleaseObject
- runtimeReleaseObjectGroup
- timelineStart
- timelineEnd
- networkCanClearBrowserCache
- networkCanClearBrowserCookies
- networkClearBrowserCache
- networkClearBrowserCookies
- networkEnableEvents
- networkDisableEvents
- networkGetResponseBody
- networkSetCacheDisabled
- networkSetExtraHTTPHeaders
- networkSetUserAgentOverride
Register to handle a given event, use '*' to handle all events.
Event Api Example code:-
rDebugApi.on('DOM.documentUpdated',function(event) {
console.log("Event:document updated");
});
rDebugApi.on('*',function(event) {
//fired for all events.
console.log("Event:",event);
});
Methods like consoleEnable will turn on console events so you can handle them. consoleDisable and similar functions will then turn off those events.