chrome-remote-interface
Advanced tools
Comparing version 0.31.2 to 0.31.3
@@ -32,4 +32,4 @@ 'use strict'; | ||
const defaultTarget = (targets) => { | ||
// prefer type = 'page' inspectabe targets as they represents | ||
// browser tabs (fall back to the first instectable target | ||
// prefer type = 'page' inspectable targets as they represents | ||
// browser tabs (fall back to the first inspectable target | ||
// otherwise) | ||
@@ -36,0 +36,0 @@ let backup; |
@@ -10,12 +10,11 @@ 'use strict'; | ||
// options.path must be specified; callback(err, data) | ||
function devToolsInterface(options, callback) { | ||
options.host = options.host || defaults.HOST; | ||
options.port = options.port || defaults.PORT; | ||
options.secure = !!(options.secure); | ||
options.useHostName = !!(options.useHostName); | ||
options.alterPath = options.alterPath || ((path) => path); | ||
// allow the user to alter the path | ||
const newOptions = {...options}; | ||
newOptions.path = options.alterPath(options.path); | ||
externalRequest(options.secure ? https : http, newOptions, callback); | ||
function devToolsInterface(path, options, callback) { | ||
const transport = options.secure ? https : http; | ||
const requestOptions = { | ||
host: options.host || defaults.HOST, | ||
port: options.port || defaults.PORT, | ||
useHostName: options.useHostName, | ||
path: (options.alterPath ? options.alterPath(path) : path) | ||
}; | ||
externalRequest(transport, requestOptions, callback); | ||
} | ||
@@ -58,5 +57,4 @@ | ||
} | ||
// try to fecth the protocol remotely | ||
options.path = '/json/protocol'; | ||
devToolsInterface(options, (err, descriptor) => { | ||
// try to fetch the protocol remotely | ||
devToolsInterface('/json/protocol', options, (err, descriptor) => { | ||
if (err) { | ||
@@ -71,4 +69,3 @@ callback(err); | ||
function List(options, callback) { | ||
options.path = '/json/list'; | ||
devToolsInterface(options, (err, tabs) => { | ||
devToolsInterface('/json/list', options, (err, tabs) => { | ||
if (err) { | ||
@@ -83,7 +80,7 @@ callback(err); | ||
function New(options, callback) { | ||
options.path = '/json/new'; | ||
let path = '/json/new'; | ||
if (Object.prototype.hasOwnProperty.call(options, 'url')) { | ||
options.path += `?${options.url}`; | ||
path += `?${options.url}`; | ||
} | ||
devToolsInterface(options, (err, tab) => { | ||
devToolsInterface(path, options, (err, tab) => { | ||
if (err) { | ||
@@ -98,4 +95,3 @@ callback(err); | ||
function Activate(options, callback) { | ||
options.path = '/json/activate/' + options.id; | ||
devToolsInterface(options, (err) => { | ||
devToolsInterface('/json/activate/' + options.id, options, (err) => { | ||
if (err) { | ||
@@ -110,4 +106,3 @@ callback(err); | ||
function Close(options, callback) { | ||
options.path = '/json/close/' + options.id; | ||
devToolsInterface(options, (err) => { | ||
devToolsInterface('/json/close/' + options.id, options, (err) => { | ||
if (err) { | ||
@@ -122,4 +117,3 @@ callback(err); | ||
function Version(options, callback) { | ||
options.path = '/json/version'; | ||
devToolsInterface(options, (err, versionInfo) => { | ||
devToolsInterface('/json/version', options, (err, versionInfo) => { | ||
if (err) { | ||
@@ -126,0 +120,0 @@ callback(err); |
@@ -17,3 +17,2 @@ 'use strict'; | ||
const {address} = await util.promisify(dns.lookup)(options.host); | ||
options = Object.assign({}, options); | ||
options.host = address; | ||
@@ -20,0 +19,0 @@ } catch (err) { |
@@ -18,3 +18,3 @@ { | ||
"homepage": "https://github.com/cyrus-and/chrome-remote-interface", | ||
"version": "0.31.2", | ||
"version": "0.31.3", | ||
"repository": { | ||
@@ -48,3 +48,3 @@ "type": "git", | ||
"babel-core": "^6.26.3", | ||
"babel-loader": "6.x.x", | ||
"babel-loader": "8.x.x", | ||
"babel-polyfill": "^6.26.0", | ||
@@ -51,0 +51,0 @@ "babel-preset-env": "^1.7.0", |
@@ -77,3 +77,3 @@ # chrome-remote-interface [![Build Status][]][travis] | ||
¹ Not available on [Chrome for Android][chrome-mobile-protocol]. | ||
¹ Not available on [Chrome for Android][chrome-mobile-protocol], hence a local version of the protocol must be used. | ||
@@ -139,2 +139,5 @@ [chrome-mobile-protocol]: https://bugs.chromium.org/p/chromium/issues/detail?id=824626#c4 | ||
Note that in Android, Chrome does not have its own protocol available, a local | ||
version must be used. See [here](#chrome-debugging-protocol-versions) for more information. | ||
[adb]: https://developer.chrome.com/devtools/docs/remote-debugging-legacy | ||
@@ -895,7 +898,16 @@ | ||
### Invoking `Domain.method` I obtain `Domain.method is not a function` | ||
### Invoking `Domain.methodOrEvent` I obtain `Domain.methodOrEvent is not a function` | ||
This means that the Chrome version that you are using does not support | ||
`Domain.method`. The solution is to update to a newer version. | ||
This means that you are trying to use a method or an event that are not present | ||
in the protocol descriptor that you are using. | ||
If the protocol is fetched from Chrome directly, then it means that this version | ||
of Chrome does not support that feature. The solution is to update it. | ||
If you are using a local or custom version of the protocol, then it means that | ||
the version is obsolete. The solution is to provide an up-to-date one, or if you | ||
are using the protocol embedded in chrome-remote-interface, make sure to be | ||
running the latest version of this module. In case the embedded protocol is | ||
obsolete, please [file an issue](https://github.com/cyrus-and/chrome-remote-interface/issues/new). | ||
See [here](#chrome-debugging-protocol-versions) for more information. | ||
@@ -905,3 +917,3 @@ | ||
This means that you are providing a custom protocol descriptor | ||
This means that you are providing a custom or local protocol descriptor | ||
(`CDP({protocol: customProtocol})`) which declares `Domain.method` while the | ||
@@ -908,0 +920,0 @@ Chrome version that you are using does not support it. |
Sorry, the diff of this file is too big to display
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
1832237
984
26006