MCPcopy Index your code
hub / github.com/SeleniumHQ/selenium / onIntercept

Method onIntercept

javascript/selenium-webdriver/lib/webdriver.js:1398–1427  ·  view source on GitHub ↗

* Handle Network interception requests * @param connection WebSocket connection to the browser * @param httpResponse Object representing what we are intercepting * as well as what should be returned. * @param callback callback called when we intercept requests.

(connection, httpResponse, callback)

Source from the content-addressed store, hash-verified

1396 * @param callback callback called when we intercept requests.
1397 */
1398 async onIntercept(connection, httpResponse, callback) {
1399 this._cdpWsConnection.on('message', (message) => {
1400 const params = JSON.parse(message)
1401 if (params.method === 'Fetch.requestPaused') {
1402 const requestPausedParams = params['params']
1403 if (requestPausedParams.request.url == httpResponse.urlToIntercept) {
1404 connection.execute('Fetch.fulfillRequest', {
1405 requestId: requestPausedParams['requestId'],
1406 responseCode: httpResponse.status,
1407 responseHeaders: httpResponse.headers,
1408 body: httpResponse.body,
1409 })
1410 callback()
1411 } else {
1412 connection.execute('Fetch.continueRequest', {
1413 requestId: requestPausedParams['requestId'],
1414 })
1415 }
1416 }
1417 })
1418
1419 await connection.execute('Fetch.enable', {}, null)
1420 await connection.execute(
1421 'Network.setCacheDisabled',
1422 {
1423 cacheDisabled: true,
1424 },
1425 null,
1426 )
1427 }
1428
1429 /**
1430 *

Callers 1

devtools_test.jsFile · 0.80

Calls 4

executeMethod · 0.65
callbackFunction · 0.50
onMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected