chrome-remote-interface
Advanced tools
Comparing version 0.6.0 to 0.6.1
#!/usr/bin/env node | ||
var repl = require('repl'); | ||
var util = require('util'); | ||
var program = require('commander'); | ||
@@ -9,4 +10,4 @@ var protocol = require('../lib/protocol.json'); | ||
program | ||
.option('-h, --host <host>', 'Remote Debugging Protocol host', 'localhost') | ||
.option('-p, --port <port>', 'Remote Debugging Protocol port', '9222') | ||
.option('-h, --host <host>', 'Remote Debugging Protocol host') | ||
.option('-p, --port <port>', 'Remote Debugging Protocol port') | ||
.parse(process.argv); | ||
@@ -22,3 +23,9 @@ | ||
'prompt': 'chrome> ', | ||
'ignoreUndefined': true | ||
'ignoreUndefined': true, | ||
'writer': function (object) { | ||
return util.inspect(object, { | ||
'colors': true, | ||
'depth': null | ||
}); | ||
} | ||
}); | ||
@@ -25,0 +32,0 @@ |
@@ -9,4 +9,2 @@ var events = require('events'); | ||
} | ||
options = options || {}; | ||
options.chooseTab = options.chooseTab || function () { return 0; }; | ||
var notifier = new events.EventEmitter(); | ||
@@ -25,2 +23,3 @@ if (typeof callback === 'function') { | ||
} | ||
// create the client passing the notifier | ||
new Chrome(options, notifier); | ||
@@ -27,0 +26,0 @@ }); |
@@ -0,1 +1,2 @@ | ||
var defaults = require('./defaults.js'); | ||
var protocol = require('./protocol.json'); | ||
@@ -7,10 +8,14 @@ var util = require('util'); | ||
var Chrome = function (options, notifier) { | ||
function Chrome(options, notifier) { | ||
var self = this; | ||
self.host = options.host; | ||
self.port = options.port; | ||
self.chooseTab = options.chooseTab; | ||
// options | ||
options = options || {}; | ||
self.host = options.host || defaults.HOST; | ||
self.port = options.port || defaults.PORT; | ||
self.chooseTab = options.chooseTab || function () { return 0; }; | ||
// locals | ||
self.notifier = notifier; | ||
self.callbacks = {}; | ||
self.nextCommandId = 1; | ||
// operations | ||
addCommandShorthands.call(self); | ||
@@ -28,4 +33,4 @@ connectToChrome.call(self); | ||
options = options || {}; | ||
options.host = options.host || 'localhost'; | ||
options.port = options.port || 9222; | ||
options.host = options.host || defaults.HOST; | ||
options.port = options.port || defaults.PORT; | ||
var httpOptions = {'host': options.host, | ||
@@ -72,11 +77,9 @@ 'port': options.port, | ||
function prepareHelp(type, object, fields) { | ||
function prepareHelp(type, object) { | ||
var help = { | ||
'type': type | ||
}; | ||
fields.forEach(function (field) { | ||
if (field in object) { | ||
help[field] = object[field]; | ||
} | ||
}); | ||
for (var field in object) { | ||
help[field] = object[field]; | ||
} | ||
return help; | ||
@@ -90,4 +93,3 @@ } | ||
}; | ||
var help = prepareHelp('command', command, ['description', 'parameters']); | ||
self[domainName][command.name].help = help; | ||
self[domainName][command.name].help = prepareHelp('command', command); | ||
} | ||
@@ -100,4 +102,3 @@ | ||
}; | ||
var help = prepareHelp('event', event, ['parameters']); | ||
self[domainName][event.name].help = help; | ||
self[domainName][event.name].help = prepareHelp('event', event); | ||
} | ||
@@ -158,3 +159,3 @@ | ||
// a WebSocket is already connected to this tab? | ||
tabError = new Error('Chosen tab does not support inspection'); | ||
tabError = new Error('Tab does not support inspection'); | ||
self.notifier.emit('error', tabError); | ||
@@ -161,0 +162,0 @@ } |
@@ -10,3 +10,3 @@ { | ||
"homepage": "https://github.com/cyrus-and/chrome-remote-interface", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"repository": { | ||
@@ -13,0 +13,0 @@ "type": "git", |
@@ -70,7 +70,14 @@ chrome-remote-interface | ||
{ type: 'command', | ||
description: 'Navigates current page to the given URL.', | ||
name: 'navigate', | ||
parameters: | ||
[ { name: 'url', | ||
type: 'string', | ||
description: 'URL to navigate the page to.' } ] } | ||
description: 'URL to navigate the page to.' } ], | ||
returns: | ||
[ { name: 'frameId', | ||
'$ref': 'FrameId', | ||
hidden: true, | ||
description: 'Frame id that will be navigated.' } ], | ||
description: 'Navigates current page to the given URL.', | ||
handlers: [ 'browser', 'renderer' ] } | ||
``` | ||
@@ -105,3 +112,3 @@ | ||
return the numeric index of a tab. Defaults to a function which returns the | ||
active one (`function (tabs) { return 0; }`). | ||
currently active tab (`function (tabs) { return 0; }`). | ||
@@ -108,0 +115,0 @@ `callback` is a listener automatically added to the `connect` event of the |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
312372
15
5322
307