Socket
Socket
Sign inDemoInstall

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.8.0 to 0.9.0

test/devtools.js

15

index.js

@@ -28,5 +28,12 @@ var events = require('events');

module.exports.fetchProtocol = Chrome.fetchProtocol;
module.exports.listTabs = Chrome.listTabs;
module.exports.spawnTab = Chrome.spawnTab;
module.exports.closeTab = Chrome.closeTab;
// for backward compatibility
module.exports.listTabs = Chrome.List;
module.exports.spawnTab = Chrome.New;
module.exports.closeTab = Chrome.Close;
module.exports.Protocol = Chrome.Protocol;
module.exports.List = Chrome.List;
module.exports.New = Chrome.New;
module.exports.Activate = Chrome.Activate;
module.exports.Close = Chrome.Close;
module.exports.Version = Chrome.Version;

@@ -26,3 +26,3 @@ var defaults = require('./defaults.js');

// callback(err, fromChrome, protocol)
Chrome.fetchProtocol = function (options, callback) {
Chrome.Protocol = function (options, callback) {
if (typeof options === 'function') {

@@ -36,3 +36,3 @@ callback = options;

// Chrome will reply with a 404
options.path = '/protocol/json';
options.path = '/json/protocol';
devToolsInterface(options, function (error, status, data) {

@@ -56,3 +56,3 @@ var protocol;

Chrome.listTabs = function (options, callback) {
Chrome.List = function (options, callback) {
if (typeof options === 'function') {

@@ -63,3 +63,3 @@ callback = options;

options = options || {};
options.path = '/json';
options.path = '/json/list';
devToolsInterface(options, function (error, status, data) {

@@ -79,3 +79,3 @@ if (error) {

Chrome.spawnTab = function (options, callback) {
Chrome.New = function (options, callback) {
if (typeof options === 'function') {

@@ -104,3 +104,3 @@ callback = options;

Chrome.closeTab = function (options, callback) {
Chrome.Activate = function (options, callback) {
if (typeof options === 'function') {

@@ -111,2 +111,22 @@ callback = options;

options = options || {};
options.path = '/json/activate/' + options.id;
devToolsInterface(options, function (error, status, data) {
if (error) {
callback(error);
} else {
if (status == 200) {
callback(null);
} else {
callback(new Error(data));
}
}
});
};
Chrome.Close = function (options, callback) {
if (typeof options === 'function') {
callback = options;
options = undefined;
}
options = options || {};
options.path = '/json/close/' + options.id;

@@ -126,2 +146,28 @@ devToolsInterface(options, function (error, status, data) {

Chrome.Version = function (options, callback) {
if (typeof options === 'function') {
callback = options;
options = undefined;
}
options = options || {};
options.path = '/json/version';
devToolsInterface(options, function (error, status, data) {
if (error) {
callback(error);
} else {
if (status == 200) {
var versionInfo = JSON.parse(data);
callback(null, versionInfo);
} else {
callback(new Error(data));
}
}
});
};
Chrome.prototype.inspect = function (depth, options) {
options.customInspect = false;
return util.inspect(this, options);
};
Chrome.prototype.send = function (method, params, callback) {

@@ -220,3 +266,3 @@ var self = this;

addCommandShorthands.call(self);
Chrome.listTabs(options, function (err, tabs) {
Chrome.List(options, function (err, tabs) {
if (err) {

@@ -245,3 +291,3 @@ self.notifier.emit('error', err);

if (typeof self.protocol === 'undefined') {
Chrome.fetchProtocol(options, function (err, fromChrome, protocol) {
Chrome.Protocol(options, function (err, fromChrome, protocol) {
if (err) {

@@ -248,0 +294,0 @@ self.notifier.emit('error', err);

@@ -6,3 +6,3 @@ {

"Andrey Sidorov <sidoares@yandex.ru>",
"Greg Cochard"
"Greg Cochard <greg@gregcochard.com>"
],

@@ -12,3 +12,3 @@ "description": "Chrome Remote Debugging Protocol interface",

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

@@ -15,0 +15,0 @@ "type": "git",

@@ -157,3 +157,3 @@ chrome-remote-interface

### module.fetchProtocol([options], callback)
### module.Protocol([options], callback)

@@ -180,3 +180,3 @@ Fetch the [Remote Debugging Protocol][rdb] descriptor from the remote Chrome

var Chrome = require('chrome-remote-interface');
Chrome.fetchProtocol(function (err, fromChrome, protocol) {
Chrome.Protocol(function (err, fromChrome, protocol) {
if (!err) {

@@ -188,3 +188,3 @@ console.log(JSON.stringify(protocol, null, 4));

### module.listTabs([options], callback)
### module.List([options], callback)

@@ -202,3 +202,4 @@ Request the list of the available open tabs of the remote Chrome instance.

- `err`: a `Error` object indicating the success status;
- `tabs`: the array returned by `http://host:port/json` containing the tab list.
- `tabs`: the array returned by `http://host:port/json/list` containing the tab
list.

@@ -209,3 +210,3 @@ For example:

var Chrome = require('chrome-remote-interface');
Chrome.listTabs(function (err, tabs) {
Chrome.List(function (err, tabs) {
if (!err) {

@@ -217,3 +218,3 @@ console.log(tabs);

### module.spawnTab([options], callback)
### module.New([options], callback)

@@ -238,3 +239,3 @@ Create a new tab in the remote Chrome instance.

var Chrome = require('chrome-remote-interface');
Chrome.spawnTab(function (err, tab) {
Chrome.New(function (err, tab) {
if (!err) {

@@ -246,4 +247,30 @@ console.log(tab);

### module.closeTab([options], callback)
### module.Activate([options], callback)
Activate an open tab of the remote Chrome instance.
`options` is an object with the following properties:
- `host`: [Remote Debugging Protocol][rdb] host. Defaults to `localhost`;
- `port`: [Remote Debugging Protocol][rdb] port. Defaults to `9222`.
- `id`: [Remote Debugging Protocol][rdb] id. Required, no default.
`callback` is executed when the response to the activation request is
received. It gets the following arguments:
- `err`: a `Error` object indicating the success status;
For example:
```javascript
var Chrome = require('chrome-remote-interface');
Chrome.Activate({'id': 'CC46FBFA-3BDA-493B-B2E4-2BE6EB0D97EC'}, function (err, tab) {
if (!err) {
console.log('success! tab is closing');
}
});
```
### module.Close([options], callback)
Close an open tab of the remote Chrome instance.

@@ -266,3 +293,3 @@

var Chrome = require('chrome-remote-interface');
Chrome.closeTab({'id': 'CC46FBFA-3BDA-493B-B2E4-2BE6EB0D97EC'}, function (err, tab) {
Chrome.Close({'id': 'CC46FBFA-3BDA-493B-B2E4-2BE6EB0D97EC'}, function (err, tab) {
if (!err) {

@@ -278,2 +305,29 @@ console.log('success! tab is closing');

### module.Version([options], callback)
Request version information from the remote Chrome instance.
`options` is an object with the following optional properties:
- `host`: [Remote Debugging Protocol][rdb] host. Defaults to `localhost`;
- `port`: [Remote Debugging Protocol][rdb] port. Defaults to `9222`.
`callback` is executed when the version information is correctly received, it
gets the following arguments:
- `err`: a `Error` object indicating the success status;
- `info`: a JSON object returned by `http://host:port/json/version` containing
the version information.
For example:
```javascript
var Chrome = require('chrome-remote-interface');
Chrome.Version(function (err, info) {
if (!err) {
console.log(info);
}
});
```
### Class: Chrome

@@ -280,0 +334,0 @@

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