Comparing version 6.0.0-alpha.1 to 6.0.0-beta.0
@@ -16,6 +16,11 @@ "use strict"; | ||
const puppeteerFirefoxPath = require.resolve('puppeteer-firefox'); | ||
let puppeteerFirefoxPath; | ||
let puppeteerFirefoxPkg; | ||
const puppeteerFirefoxPkg = require(`${_path.default.dirname(puppeteerFirefoxPath)}/package.json`); | ||
try { | ||
puppeteerFirefoxPath = require.resolve('puppeteer-firefox'); | ||
} catch (error) {} | ||
puppeteerFirefoxPkg = puppeteerFirefoxPath ? require(`${_path.default.dirname(puppeteerFirefoxPath)}/package.json`) : {}; | ||
async function status() { | ||
@@ -22,0 +27,0 @@ return { |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.ERROR_MESSAGES = exports.SERIALIZE_FLAG = exports.SERIALIZE_PROPERTY = exports.SUPPORTED_SELECTOR_STRATEGIES = exports.DEFAULT_SCRIPT_TIMEOUT = exports.DEFAULT_PAGELOAD_TIMEOUT = exports.DEFAULT_IMPLICIT_TIMEOUT = exports.DEFAULTS = exports.EDGE_NAMES = exports.FIREFOX_NAMES = exports.CHROME_NAMES = exports.DEFAULT_FLAGS = exports.ELEMENT_KEY = exports.DEFAULT_Y_POSITION = exports.DEFAULT_X_POSITION = exports.DEFAULT_HEIGHT = exports.DEFAULT_WIDTH = void 0; | ||
exports.ERROR_MESSAGES = exports.SERIALIZE_FLAG = exports.SERIALIZE_PROPERTY = exports.SUPPORTED_SELECTOR_STRATEGIES = exports.DEFAULT_SCRIPT_TIMEOUT = exports.DEFAULT_PAGELOAD_TIMEOUT = exports.DEFAULT_IMPLICIT_TIMEOUT = exports.DEFAULTS = exports.SUPPORTED_BROWSER = exports.EDGE_NAMES = exports.FIREFOX_NAMES = exports.CHROME_NAMES = exports.DEFAULT_FLAGS = exports.ELEMENT_KEY = exports.DEFAULT_Y_POSITION = exports.DEFAULT_X_POSITION = exports.DEFAULT_HEIGHT = exports.DEFAULT_WIDTH = void 0; | ||
const DEFAULT_WIDTH = 1200; | ||
@@ -26,2 +26,4 @@ exports.DEFAULT_WIDTH = DEFAULT_WIDTH; | ||
exports.EDGE_NAMES = EDGE_NAMES; | ||
const SUPPORTED_BROWSER = [...CHROME_NAMES, ...FIREFOX_NAMES, ...EDGE_NAMES]; | ||
exports.SUPPORTED_BROWSER = SUPPORTED_BROWSER; | ||
const DEFAULTS = { | ||
@@ -28,0 +30,0 @@ capabilities: { |
@@ -50,2 +50,3 @@ "use strict"; | ||
this.windows.set(pageId, page); | ||
this.currentFrame = page; | ||
this.currentWindowHandle = pageId; | ||
@@ -117,3 +118,8 @@ } | ||
}); | ||
log.info('RESULT', command.toLowerCase().includes('screenshot') && typeof result === 'string' && result.length > 64 ? `${result.substr(0, 61)}...` : result); | ||
if (typeof result !== 'undefined') { | ||
const isScreenshot = command.toLowerCase().includes('screenshot') && typeof result === 'string' && result.length > 64; | ||
log.info('RESULT', isScreenshot ? `${result.substr(0, 61)}...` : result); | ||
} | ||
return result; | ||
@@ -120,0 +126,0 @@ }; |
@@ -6,2 +6,8 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "SUPPORTED_BROWSER", { | ||
enumerable: true, | ||
get: function () { | ||
return _constants.SUPPORTED_BROWSER; | ||
} | ||
}); | ||
exports.default = exports.sessionMap = void 0; | ||
@@ -11,2 +17,4 @@ | ||
var _path = _interopRequireDefault(require("path")); | ||
var _v = _interopRequireDefault(require("uuid/v4")); | ||
@@ -36,2 +44,15 @@ | ||
const log = (0, _logger.default)('devtools:puppeteer'); | ||
const PREFIX = 'puppeteer:protocol'; | ||
const puppeteerDebugPkg = _path.default.resolve(_path.default.dirname(require.resolve('puppeteer-core')), 'node_modules', 'debug'); | ||
require(puppeteerDebugPkg).log = msg => { | ||
if (msg.includes('puppeteer:protocol')) { | ||
msg = msg.slice(msg.indexOf(PREFIX) + PREFIX.length).trim(); | ||
} | ||
log.debug(msg); | ||
}; | ||
const sessionMap = new Map(); | ||
@@ -38,0 +59,0 @@ exports.sessionMap = sessionMap; |
@@ -14,2 +14,6 @@ "use strict"; | ||
var _edge = _interopRequireDefault(require("./finder/edge")); | ||
var _firefox = _interopRequireDefault(require("./finder/firefox")); | ||
var _utils = require("./utils"); | ||
@@ -21,2 +25,8 @@ | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
const log = (0, _logger.default)('devtools'); | ||
@@ -27,3 +37,3 @@ | ||
const chromeFlags = [..._constants.DEFAULT_FLAGS, ...[`--window-position=${_constants.DEFAULT_X_POSITION},${_constants.DEFAULT_Y_POSITION}`, `--window-size=${_constants.DEFAULT_WIDTH},${_constants.DEFAULT_HEIGHT}`], ...(chromeOptions.headless ? ['--headless', '--no-sandbox'] : []), ...(chromeOptions.args || [])]; | ||
log.info(`Launch Chrome with flags: ${chromeFlags.join(' ')}`); | ||
log.info(`Launch Google Chrome with flags: ${chromeFlags.join(' ')}`); | ||
const chrome = await (0, _chromeLauncher.launch)({ | ||
@@ -34,6 +44,6 @@ chromePath: chromeOptions.binary, | ||
log.info(`Connect Puppeteer with browser on port ${chrome.port}`); | ||
const browser = await _puppeteerCore.default.connect({ | ||
const browser = await _puppeteerCore.default.connect(_objectSpread({}, chromeOptions, { | ||
browserURL: `http://localhost:${chrome.port}`, | ||
defaultViewport: null | ||
}); | ||
})); | ||
const pages = await (0, _utils.getPages)(browser); | ||
@@ -50,18 +60,38 @@ | ||
function launchBrowser(capabilities, executablePath, vendorCapKey) { | ||
const puppeteerOptions = Object.assign({ | ||
executablePath, | ||
defaultViewport: { | ||
width: _constants.DEFAULT_WIDTH, | ||
height: _constants.DEFAULT_HEIGHT | ||
} | ||
}, capabilities[vendorCapKey] || {}); | ||
if (!executablePath) { | ||
throw new Error('Couldn\'t find executeable for browser'); | ||
} | ||
log.info(`Launch ${executablePath} with config: ${JSON.stringify(puppeteerOptions)}`); | ||
return _puppeteerCore.default.launch(puppeteerOptions); | ||
} | ||
function launchFirefox(capabilities) { | ||
const puppeteerFirefox = require('puppeteer-firefox'); | ||
const executablePath = _firefox.default[process.platform]()[0]; | ||
const firefoxOptions = capabilities['moz:firefoxOptions'] || {}; | ||
return puppeteerFirefox.launch({ | ||
args: firefoxOptions.args || [], | ||
headless: Boolean(firefoxOptions.headless), | ||
defaultViewport: { | ||
width: firefoxOptions.width || _constants.DEFAULT_WIDTH, | ||
height: firefoxOptions.height || _constants.DEFAULT_HEIGHT | ||
} | ||
const vendorPrefix = 'moz:firefoxOptions'; | ||
if (!capabilities[vendorPrefix]) { | ||
capabilities[vendorPrefix] = {}; | ||
} | ||
capabilities[vendorPrefix].product = 'firefox'; | ||
return launchBrowser(capabilities, executablePath, vendorPrefix, { | ||
product: 'firefox' | ||
}); | ||
} | ||
function launchEdge() { | ||
throw new Error('not yet implemented'); | ||
function launchEdge(capabilities) { | ||
const executablePath = _edge.default[process.platform]()[0]; | ||
return launchBrowser(capabilities, executablePath, 'ms:edgeOptions'); | ||
} | ||
@@ -68,0 +98,0 @@ |
@@ -14,4 +14,12 @@ "use strict"; | ||
exports.getPages = getPages; | ||
exports.sort = sort; | ||
exports.canAccess = canAccess; | ||
exports.uniq = uniq; | ||
exports.findByWhich = findByWhich; | ||
exports.validate = void 0; | ||
var _fs = _interopRequireDefault(require("fs")); | ||
var _child_process = require("child_process"); | ||
var _logger = _interopRequireDefault(require("@wdio/logger")); | ||
@@ -195,2 +203,51 @@ | ||
return pages; | ||
} | ||
function sort(installations, priorities) { | ||
const defaultPriority = 10; | ||
return installations.map(inst => { | ||
for (const pair of priorities) { | ||
if (pair.regex.test(inst)) { | ||
return { | ||
path: inst, | ||
weight: pair.weight | ||
}; | ||
} | ||
} | ||
return { | ||
path: inst, | ||
weight: defaultPriority | ||
}; | ||
}).sort((a, b) => b.weight - a.weight).map(pair => pair.path); | ||
} | ||
function canAccess(file) { | ||
try { | ||
_fs.default.accessSync(file); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
function uniq(arr) { | ||
return Array.from(new Set(arr)); | ||
} | ||
function findByWhich(executables, priorities) { | ||
const installations = []; | ||
executables.forEach(executable => { | ||
try { | ||
const browserPath = (0, _child_process.execFileSync)('which', [executable], { | ||
stdio: 'pipe' | ||
}).toString().split(/\r?\n/)[0]; | ||
if (canAccess(browserPath)) { | ||
installations.push(browserPath); | ||
} | ||
} catch (e) {} | ||
}); | ||
return sort(uniq(installations.filter(Boolean)), priorities); | ||
} |
{ | ||
"name": "devtools", | ||
"version": "6.0.0-alpha.1", | ||
"version": "6.0.0-beta.0", | ||
"description": "A Chrome DevTools protocol binding that maps WebDriver commands into Chrome DevTools commands using Puppeteer", | ||
@@ -33,16 +33,13 @@ "author": "Christian Bromann <christian@saucelabs.com>", | ||
"dependencies": { | ||
"@wdio/config": "6.0.0-alpha.1", | ||
"@wdio/logger": "6.0.0-alpha.0", | ||
"@wdio/protocols": "6.0.0-alpha.1", | ||
"@wdio/utils": "6.0.0-alpha.1", | ||
"@wdio/config": "6.0.0-beta.0", | ||
"@wdio/logger": "6.0.0-beta.0", | ||
"@wdio/protocols": "6.0.0-beta.0", | ||
"@wdio/utils": "6.0.0-beta.0", | ||
"chrome-launcher": "^0.11.1", | ||
"puppeteer-core": "^1.18.1" | ||
"puppeteer-core": "^2.1.1" | ||
}, | ||
"devDependencies": { | ||
"@types/puppeteer": "^1.19.0" | ||
"@types/puppeteer": "^2.0.0" | ||
}, | ||
"optionalDependencies": { | ||
"puppeteer-firefox": "^0.5.0" | ||
}, | ||
"gitHead": "1b11d192fa30cd92724a21e3febbf40b9e5b3ba2" | ||
"gitHead": "478c5546246ce47c8344d29a4d36d067ab3a6983" | ||
} |
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
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 4 instances in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
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
81080
6
75
1995
1
14
3
+ Added@types/mime-types@2.1.4(transitive)
+ Added@wdio/config@6.0.0-beta.0(transitive)
+ Added@wdio/logger@6.0.0-beta.0(transitive)
+ Added@wdio/protocols@6.0.0-beta.0(transitive)
+ Added@wdio/utils@6.0.0-beta.0(transitive)
+ Addedagent-base@5.1.1(transitive)
+ Addedhttps-proxy-agent@4.0.0(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedpuppeteer-core@2.1.1(transitive)
- Removed@wdio/config@6.0.0-alpha.1(transitive)
- Removed@wdio/logger@6.0.0-alpha.0(transitive)
- Removed@wdio/protocols@6.0.0-alpha.1(transitive)
- Removed@wdio/utils@6.0.0-alpha.1(transitive)
- Removedagent-base@4.3.0(transitive)
- Removeddebug@3.2.7(transitive)
- Removedes6-promise@4.2.8(transitive)
- Removedes6-promisify@5.0.0(transitive)
- Removedhttps-proxy-agent@2.2.4(transitive)
- Removedpuppeteer-core@1.20.0(transitive)
- Removedpuppeteer-firefox@0.5.1(transitive)
Updated@wdio/config@6.0.0-beta.0
Updated@wdio/logger@6.0.0-beta.0
Updated@wdio/protocols@6.0.0-beta.0
Updated@wdio/utils@6.0.0-beta.0
Updatedpuppeteer-core@^2.1.1