Skip to content

Commit

Permalink
[JS] Fixes lint issues and updates npm packages
Browse files Browse the repository at this point in the history
  • Loading branch information
harsha509 committed Jun 2, 2022
1 parent b0057b5 commit 6d2a782
Show file tree
Hide file tree
Showing 33 changed files with 830 additions and 1,329 deletions.
5 changes: 2 additions & 3 deletions javascript/node/selenium-webdriver/chrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,8 @@ Driver.prototype.VENDOR_COMMAND_PREFIX = 'goog'
module.exports = {
Driver: Driver,
Options,
ServiceBuilder ,
ServiceBuilder,
getDefaultService,
setDefaultService,
locateSynchronously
locateSynchronously,
}

2 changes: 1 addition & 1 deletion javascript/node/selenium-webdriver/chromium.js
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ class Driver extends webdriver.WebDriver {
* @return {!promise.Thenable<void>} A promise that will be resolved
* when the mirror command has been issued to the device.
*/
startDesktopMirroring(deviceName) {
startDesktopMirroring(deviceName) {
return this.schedule(
new command.Command(Command.START_CAST_DESKTOP_MIRRORING).setParameter(
'sinkName',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CDPConnection {
constructor(wsConnection) {
this._wsConnection = wsConnection
this.cmd_id = 0
this.targetID = null;
this.targetID = null
this.sessionId = null
}

Expand Down
2 changes: 1 addition & 1 deletion javascript/node/selenium-webdriver/firefox.js
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ class Driver extends webdriver.WebDriver {
*/
async installAddon(path, temporary = false) {
let stats = fs.statSync(path)
let buf;
let buf
if (stats.isDirectory()) {
let zip = new Zip()
await zip.addDir(path)
Expand Down
6 changes: 3 additions & 3 deletions javascript/node/selenium-webdriver/ie.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,9 @@ function createServiceFromCapabilities(capabilities) {
if (!exe || !fs.existsSync(exe)) {
throw Error(
`${IEDRIVER_EXE} could not be found on the current PATH. Please ` +
`download the latest version of ${IEDRIVER_EXE} from ` +
'https://www.selenium.dev/downloads/ and ' +
'ensure it can be found on your system PATH.'
`download the latest version of ${IEDRIVER_EXE} from ` +
'https://www.selenium.dev/downloads/ and ' +
'ensure it can be found on your system PATH.'
)
}

Expand Down
2 changes: 1 addition & 1 deletion javascript/node/selenium-webdriver/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function startSeleniumServer(jar) {
function ensureFileDetectorsAreEnabled(ctor) {
return class extends ctor {
/** @param {input.FileDetector} detector */
setFileDetector (detector) {
setFileDetector(detector) {
webdriver.WebDriver.prototype.setFileDetector.call(this, detector)
}
}
Expand Down
14 changes: 7 additions & 7 deletions javascript/node/selenium-webdriver/lib/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,13 @@ const Name = {
FIND_ELEMENTS_FROM_SHADOWROOT: 'findElementsFromShadowRoot',

// Virtual Authenticator Commands
ADD_VIRTUAL_AUTHENTICATOR : 'addVirtualAuthenticator',
REMOVE_VIRTUAL_AUTHENTICATOR : 'removeVirtualAuthenticator',
ADD_CREDENTIAL : 'addCredential',
GET_CREDENTIALS : 'getCredentials',
REMOVE_CREDENTIAL : 'removeCredential',
REMOVE_ALL_CREDENTIALS : 'removeAllCredentials',
SET_USER_VERIFIED : 'setUserVerified',
ADD_VIRTUAL_AUTHENTICATOR: 'addVirtualAuthenticator',
REMOVE_VIRTUAL_AUTHENTICATOR: 'removeVirtualAuthenticator',
ADD_CREDENTIAL: 'addCredential',
GET_CREDENTIALS: 'getCredentials',
REMOVE_CREDENTIAL: 'removeCredential',
REMOVE_ALL_CREDENTIALS: 'removeAllCredentials',
SET_USER_VERIFIED: 'setUserVerified',

GET_AVAILABLE_LOG_TYPES: 'getAvailableLogTypes',
GET_LOG: 'getLog',
Expand Down
43 changes: 36 additions & 7 deletions javascript/node/selenium-webdriver/lib/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,13 +349,42 @@ const W3C_COMMAND_MAP = new Map([
[cmd.Name.UPLOAD_FILE, post('/session/:sessionId/se/file')],

// Virtual Authenticator
[cmd.Name.ADD_VIRTUAL_AUTHENTICATOR, post('/session/:sessionId/webauthn/authenticator')],
[cmd.Name.REMOVE_VIRTUAL_AUTHENTICATOR, del('/session/:sessionId/webauthn/authenticator/:authenticatorId')],
[cmd.Name.ADD_CREDENTIAL, post('/session/:sessionId/webauthn/authenticator/:authenticatorId/credential')],
[cmd.Name.GET_CREDENTIALS, get('/session/:sessionId/webauthn/authenticator/:authenticatorId/credentials')],
[cmd.Name.REMOVE_CREDENTIAL, del('/session/:sessionId/webauthn/authenticator/:authenticatorId/credentials/:credentialId')],
[cmd.Name.REMOVE_ALL_CREDENTIALS, del('/session/:sessionId/webauthn/authenticator/:authenticatorId/credentials')],
[cmd.Name.SET_USER_VERIFIED, post('/session/:sessionId/webauthn/authenticator/:authenticatorId/uv')],
[
cmd.Name.ADD_VIRTUAL_AUTHENTICATOR,
post('/session/:sessionId/webauthn/authenticator'),
],
[
cmd.Name.REMOVE_VIRTUAL_AUTHENTICATOR,
del('/session/:sessionId/webauthn/authenticator/:authenticatorId'),
],
[
cmd.Name.ADD_CREDENTIAL,
post(
'/session/:sessionId/webauthn/authenticator/:authenticatorId/credential'
),
],
[
cmd.Name.GET_CREDENTIALS,
get(
'/session/:sessionId/webauthn/authenticator/:authenticatorId/credentials'
),
],
[
cmd.Name.REMOVE_CREDENTIAL,
del(
'/session/:sessionId/webauthn/authenticator/:authenticatorId/credentials/:credentialId'
),
],
[
cmd.Name.REMOVE_ALL_CREDENTIALS,
del(
'/session/:sessionId/webauthn/authenticator/:authenticatorId/credentials'
),
],
[
cmd.Name.SET_USER_VERIFIED,
post('/session/:sessionId/webauthn/authenticator/:authenticatorId/uv'),
],
])

/**
Expand Down
78 changes: 61 additions & 17 deletions javascript/node/selenium-webdriver/lib/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,13 +349,30 @@ class Pointer extends Device {
* @return {!Action} An action to press the specified button with this device.
* @package
*/
press(button = Button.LEFT, width = 0, height = 0, pressure = 0,
tangentialPressure = 0, tiltX = 0, tiltY = 0, twist = 0,
altitudeAngle = 0, azimuthAngle = 0) {
press(
button = Button.LEFT,
width = 0,
height = 0,
pressure = 0,
tangentialPressure = 0,
tiltX = 0,
tiltY = 0,
twist = 0,
altitudeAngle = 0,
azimuthAngle = 0
) {
return {
type: Action.Type.POINTER_DOWN, button, width, height,
pressure, tangentialPressure, tiltX, tiltY, twist,
altitudeAngle, azimuthAngle
type: Action.Type.POINTER_DOWN,
button,
width,
height,
pressure,
tangentialPressure,
tiltX,
tiltY,
twist,
altitudeAngle,
azimuthAngle,
}
}

Expand Down Expand Up @@ -385,15 +402,36 @@ class Pointer extends Device {
* @return {!Action} The new action.
* @package
*/
move({ x = 0, y = 0, duration = 100, origin = Origin.VIEWPORT,
width = 0, height = 0, pressure = 0,
tangentialPressure = 0, tiltX = 0, tiltY = 0, twist = 0,
altitudeAngle = 0, azimuthAngle = 0
move({
x = 0,
y = 0,
duration = 100,
origin = Origin.VIEWPORT,
width = 0,
height = 0,
pressure = 0,
tangentialPressure = 0,
tiltX = 0,
tiltY = 0,
twist = 0,
altitudeAngle = 0,
azimuthAngle = 0,
}) {
return {
type: Action.Type.POINTER_MOVE, origin, duration, x, y,
width, height, pressure, tangentialPressure, tiltX, tiltY, twist,
altitudeAngle, azimuthAngle
type: Action.Type.POINTER_MOVE,
origin,
duration,
x,
y,
width,
height,
pressure,
tangentialPressure,
tiltX,
tiltY,
twist,
altitudeAngle,
azimuthAngle,
}
}
}
Expand Down Expand Up @@ -429,9 +467,12 @@ class Wheel extends Device {
scroll(x, y, deltaX, deltaY, origin, duration) {
return {
type: Action.Type.SCROLL,
duration: duration, x: x, y: y,
deltaX: deltaX, deltaY: deltaY,
origin: origin
duration: duration,
x: x,
y: y,
deltaX: deltaX,
deltaY: deltaY,
origin: origin,
}
}
}
Expand Down Expand Up @@ -798,7 +839,10 @@ class Actions {
* @returns {!Action} An action to scroll with this device.
*/
scroll(x, y, targetDeltaX, targetDeltaY, origin, duration) {
return this.insert(this.wheel_, this.wheel_.scroll(x, y, targetDeltaX, targetDeltaY, origin, duration))
return this.insert(
this.wheel_,
this.wheel_.scroll(x, y, targetDeltaX, targetDeltaY, origin, duration)
)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class VirtualAuthenticatorOptions {
"CTAP2": 'ctap2',
"U2F": 'ctap1/u2f',
}

static Transport = {
"BLE": 'ble',
"USB": 'usb',
Expand Down
15 changes: 8 additions & 7 deletions javascript/node/selenium-webdriver/lib/webdriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -1522,7 +1522,7 @@ class WebDriver {
}

/**
*
*
* @returns The value of authenticator ID added
*/
virtualAuthenticatorId() {
Expand Down Expand Up @@ -2874,17 +2874,18 @@ class WebElement {
* when the form has been submitted.
*/
submit() {
const script = "var form = arguments[0];\n" +
"while (form.nodeName != \"FORM\" && form.parentNode) {\n" +
" form = form.parentNode;\n" +
"}\n" +
const script =
'var form = arguments[0];\n' +
'while (form.nodeName != "FORM" && form.parentNode) {\n' +
' form = form.parentNode;\n' +
'}\n' +
"if (!form) { throw Error('Unable to find containing form element'); }\n" +
"if (!form.ownerDocument) { throw Error('Unable to find owning document'); }\n" +
"var e = form.ownerDocument.createEvent('Event');\n" +
"e.initEvent('submit', true, true);\n" +
"if (form.dispatchEvent(e)) { HTMLFormElement.prototype.submit.call(form) }\n";
'if (form.dispatchEvent(e)) { HTMLFormElement.prototype.submit.call(form) }\n'

this.driver_.executeScript(script, this);
this.driver_.executeScript(script, this)
}

/**
Expand Down
5 changes: 4 additions & 1 deletion javascript/node/selenium-webdriver/net/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ function getIPAddress(loopback, family) {
}

for (let ipAddress of interfaces[key]) {
if ((ipAddress.family === family || `IPv${ipAddress.family}` === family) && ipAddress.internal === loopback) {
if (
(ipAddress.family === family || `IPv${ipAddress.family}` === family) &&
ipAddress.internal === loopback
) {
return ipAddress.address
}
}
Expand Down
Loading

0 comments on commit 6d2a782

Please sign in to comment.