Skip to content

Commit 13b86c2

Browse files
committed
[js] Rename websocket connection variables
1 parent 61379c9 commit 13b86c2

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

javascript/node/selenium-webdriver/lib/webdriver.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -789,12 +789,13 @@ class WebDriver {
789789
// If the websocket connection is not closed,
790790
// and we are running CDP sessions against the Selenium Grid,
791791
// the node process never exits since the websocket connection is open until the Grid is shutdown.
792-
if (this._wsConnection !== undefined) {
793-
this._wsConnection.close()
792+
if (this._cdpConnection !== undefined) {
793+
this._cdpConnection.close()
794794
}
795795

796-
if (this._bidi !== undefined) {
797-
this._bidi.close()
796+
// Close the BiDi websocket connection
797+
if (this._bidiConnection !== undefined) {
798+
this._bidiConnection.close()
798799
}
799800
})
800801
}
@@ -1245,18 +1246,18 @@ class WebDriver {
12451246
this._wsUrl = await this.getWsUrl(debuggerUrl, target, caps)
12461247
return new Promise((resolve, reject) => {
12471248
try {
1248-
this._wsConnection = new WebSocket(this._wsUrl.replace('localhost', '127.0.0.1'))
1249-
this._cdpConnection = new cdp.CdpConnection(this._wsConnection)
1249+
this._cdpConnection = new WebSocket(this._wsUrl.replace('localhost', '127.0.0.1'))
1250+
this._cdpConnection = new cdp.CdpConnection(this._cdpConnection)
12501251
} catch (err) {
12511252
reject(err)
12521253
return
12531254
}
12541255

1255-
this._wsConnection.on('open', async () => {
1256+
this._cdpConnection.on('open', async () => {
12561257
await this.getCdpTargets()
12571258
})
12581259

1259-
this._wsConnection.on('message', async (message) => {
1260+
this._cdpConnection.on('message', async (message) => {
12601261
const params = JSON.parse(message)
12611262
if (params.result) {
12621263
if (params.result.targetInfos) {
@@ -1277,7 +1278,7 @@ class WebDriver {
12771278
}
12781279
})
12791280

1280-
this._wsConnection.on('error', (error) => {
1281+
this._cdpConnection.on('error', (error) => {
12811282
reject(error)
12821283
})
12831284
})
@@ -1292,12 +1293,12 @@ class WebDriver {
12921293
* @returns {BIDI}
12931294
*/
12941295
async getBidi() {
1295-
if (this._bidi === undefined) {
1296+
if (this._bidiConnection === undefined) {
12961297
const caps = await this.getCapabilities()
12971298
let WebSocketUrl = caps['map_'].get('webSocketUrl')
1298-
this._bidi = new BIDI(WebSocketUrl.replace('localhost', '127.0.0.1'))
1299+
this._bidiConnection = new BIDI(WebSocketUrl.replace('localhost', '127.0.0.1'))
12991300
}
1300-
return this._bidi
1301+
return this._bidiConnection
13011302
}
13021303

13031304
/**
@@ -1345,7 +1346,7 @@ class WebDriver {
13451346
* @param connection CDP Connection
13461347
*/
13471348
async register(username, password, connection) {
1348-
this._wsConnection.on('message', (message) => {
1349+
this._cdpConnection.on('message', (message) => {
13491350
const params = JSON.parse(message)
13501351

13511352
if (params.method === 'Fetch.authRequired') {
@@ -1390,7 +1391,7 @@ class WebDriver {
13901391
* @param callback callback called when we intercept requests.
13911392
*/
13921393
async onIntercept(connection, httpResponse, callback) {
1393-
this._wsConnection.on('message', (message) => {
1394+
this._cdpConnection.on('message', (message) => {
13941395
const params = JSON.parse(message)
13951396
if (params.method === 'Fetch.requestPaused') {
13961397
const requestPausedParams = params['params']
@@ -1427,7 +1428,7 @@ class WebDriver {
14271428
* @returns {Promise<void>}
14281429
*/
14291430
async onLogEvent(connection, callback) {
1430-
this._wsConnection.on('message', (message) => {
1431+
this._cdpConnection.on('message', (message) => {
14311432
const params = JSON.parse(message)
14321433
if (params.method === 'Runtime.consoleAPICalled') {
14331434
const consoleEventParams = params['params']
@@ -1464,7 +1465,7 @@ class WebDriver {
14641465
async onLogException(connection, callback) {
14651466
await connection.execute('Runtime.enable', {}, null)
14661467

1467-
this._wsConnection.on('message', (message) => {
1468+
this._cdpConnection.on('message', (message) => {
14681469
const params = JSON.parse(message)
14691470

14701471
if (params.method === 'Runtime.exceptionThrown') {
@@ -1517,7 +1518,7 @@ class WebDriver {
15171518
null,
15181519
)
15191520

1520-
this._wsConnection.on('message', async (message) => {
1521+
this._cdpConnection.on('message', async (message) => {
15211522
const params = JSON.parse(message)
15221523
if (params.method === 'Runtime.bindingCalled') {
15231524
let payload = JSON.parse(params['params']['payload'])

0 commit comments

Comments
 (0)