Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chrome-remote-interface

Package Overview
Dependencies
Maintainers
1
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chrome-remote-interface - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1

18

bin/repl.js
#!/usr/bin/env node
var repl = require('repl');
var program = require('commander');
var protocol = require('../lib/protocol.json');
var Chrome = require('../');
Chrome(function (chrome) {
program
.option('-h, --host <host>', 'Remote Debugging Protocol host', 'localhost')
.option('-p, --port <port>', 'Remote Debugging Protocol port', '9222')
.parse(process.argv);
var options = {
'host': program.host,
'port': program.port
};
Chrome(options, function (chrome) {
var chromeRepl = repl.start({
'prompt': 'chrome> '
'prompt': 'chrome> ',
'ignoreUndefined': true
});

@@ -22,2 +34,4 @@

}
}).on('error', function () {
console.error('Cannot connect to Chrome');
});

2

index.js

@@ -10,4 +10,2 @@ var events = require('events');

options = options || {};
options.host = options.host || 'localhost';
options.port = options.port || 9222;
options.chooseTab = options.chooseTab || function () { return 0; };

@@ -14,0 +12,0 @@ var notifier = new events.EventEmitter();

@@ -9,10 +9,5 @@ var protocol = require('./protocol.json');

var self = this;
self.host = options.host;
self.port = options.port;
self.chooseTab = options.chooseTab;
self.notifier = notifier;
self.callbacks = {};
self.nextCommandId = 1;
addCommandShorthands.call(self);
connectToChrome.call(self);
self.connect(options);
};

@@ -30,4 +25,6 @@

options.port = options.port || 9222;
var options = {'host': options.host, 'port': options.port, 'path': '/json'};
var request = http.get(options, function (response) {
var httpOptions = {'host': options.host,
'port': options.port,
'path': '/json'};
var request = http.get(httpOptions, function (response) {
var data = '';

@@ -47,2 +44,21 @@ response.on('data', function (chunk) {

/****************************************************************/
// TODO REUSE object for different host/port (nah?) for different tab (yes!)
/****************************************************************/
Chrome.prototype.connect = function (options, callback) {
var self = this;
self.host = options.host;
self.port = options.port;
self.chooseTab = options.chooseTab;
self.callbacks = {};
self.nextCommandId = 1;
if (callback) {
// TODO close ws
self.notifier.removeAllListeners('connect');
self.notifier.on('connect', callback);
}
connectToChrome.call(self);
};
Chrome.prototype.send = function (method, params, callback) {

@@ -49,0 +65,0 @@ var self = this;

@@ -10,3 +10,3 @@ {

"homepage": "https://github.com/cyrus-and/chrome-remote-interface",
"version": "0.4.0",
"version": "0.4.1",
"repository": {

@@ -20,3 +20,4 @@ "type": "git",

"dependencies": {
"ws": "0.4.x"
"ws": "0.4.x",
"commander": "2.1.x"
},

@@ -23,0 +24,0 @@ "bin": {

@@ -47,4 +47,5 @@ chrome-remote-interface

This module comes with a REPL interface that can be used to interactively
control Chrome. It supports command execution and event binding, see the
documentation for `chrome.Domain.method([params], [callback])` and
control Chrome (run with `--help` to display the list of available options). It
supports command execution and event binding, see the documentation for
`chrome.Domain.method([params], [callback])` and
`chrome.Domain.event(callback)`. Here's a sample session:

@@ -186,5 +187,6 @@

- `error`: a boolean value indicating the success status;
- `response`: an object containing either the response sent from Chrome or the
indication of the error.
- `error`: a boolean value indicating the success status, as reported by Chrome;
- `response`: an object containing either the response sent from Chrome
(`result` field, if `error === false`) or the indication of the error (`error`
field, if `error === true`).

@@ -221,3 +223,3 @@ Note that the field `id` mentioned in the [Remote Debugging Protocol

* [Andrey Sidorov](https://github.com/sidorares)
- [Andrey Sidorov](https://github.com/sidorares)

@@ -227,4 +229,4 @@ Resources

- [Chrome Developer Tools: Remote Debugging Protocol v1.0][1]
- [Chrome Developer Tools: Remote Debugging Protocol v1.1][1]
[1]: https://developers.google.com/chrome-developer-tools/docs/protocol/1.0/
[1]: https://developers.google.com/chrome-developer-tools/docs/protocol/1.1/
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc