Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
commands.setWindow = async function setWindow (name, skipReadyCheck) {
try {
await this.setContext(name, _.noop, skipReadyCheck);
} catch (err) {
// translate the error in terms of windows
throw isErrorType(err, errors.NoSuchContextError)
? new errors.NoSuchWindowError()
: err;
}
};
commands.setWindow = async function setWindow (name, skipReadyCheck) {
if (!this.isWebContext()) {
throw new errors.NotImplementedError();
}
if (!_.includes(_.map(this.windowHandleCache, 'id'), name)) {
throw new errors.NoSuchWindowError();
}
let pageIdKey = parseInt(name, 10);
if (!this.isRealDevice()) {
await this.remote.selectPage(pageIdKey, skipReadyCheck);
this.curContext = this.curWindowHandle = name;
} else {
if (name === this.curWindowHandle) {
logger.debug(`Remote debugger is already connected to window '${name}'`);
} else if (!_.includes(_.map(this.windowHandleCache, 'id'), name)) {
throw new errors.NoSuchWindowError();
} else {
await this.remote.disconnect();
this.curContext = this.curWindowHandle = name;
await this.remote.connect(name);
}
}