chromium-bidi
Advanced tools
Comparing version 0.8.1 to 0.9.0
@@ -32,2 +32,3 @@ import type { Protocol } from 'devtools-protocol'; | ||
toggleDeviceAccessIfNeeded(): Promise<void>; | ||
toggleNetwork(): Promise<void>; | ||
/** | ||
@@ -34,0 +35,0 @@ * All the ProxyChannels from all the preload scripts of the given |
@@ -187,3 +187,18 @@ "use strict"; | ||
else { | ||
await this.#cdpClient.sendCommand('Fetch.disable'); | ||
const blockedRequest = this.#networkStorage | ||
.getRequestsByTarget(this) | ||
.filter((request) => request.interceptPhase); | ||
void Promise.allSettled(blockedRequest.map((request) => request.waitNextPhase)) | ||
.then(async () => { | ||
const blockedRequest = this.#networkStorage | ||
.getRequestsByTarget(this) | ||
.filter((request) => request.interceptPhase); | ||
if (blockedRequest.length) { | ||
return await this.toggleFetchIfNeeded(); | ||
} | ||
return await this.#cdpClient.sendCommand('Fetch.disable'); | ||
}) | ||
.catch((error) => { | ||
this.#logger?.(log_js_1.LogType.bidi, 'Disable failed', error); | ||
}); | ||
} | ||
@@ -282,2 +297,78 @@ } | ||
} | ||
async #toggleNetwork(enable) { | ||
this.#networkDomainEnabled = enable; | ||
try { | ||
await this.#cdpClient.sendCommand(enable ? 'Network.enable' : 'Network.disable'); | ||
} | ||
catch { | ||
this.#networkDomainEnabled = !enable; | ||
} | ||
} | ||
async #enableFetch(stages) { | ||
const patterns = []; | ||
if (stages.request || stages.auth) { | ||
// CDP quirk we need request interception when we intercept auth | ||
patterns.push({ | ||
urlPattern: '*', | ||
requestStage: 'Request', | ||
}); | ||
} | ||
if (stages.response) { | ||
patterns.push({ | ||
urlPattern: '*', | ||
requestStage: 'Response', | ||
}); | ||
} | ||
if ( | ||
// Only enable interception when Network is enabled | ||
this.#networkDomainEnabled && | ||
patterns.length) { | ||
const oldStages = this.#fetchDomainStages; | ||
this.#fetchDomainStages = stages; | ||
try { | ||
await this.#cdpClient.sendCommand('Fetch.enable', { | ||
patterns, | ||
handleAuthRequests: stages.auth, | ||
}); | ||
} | ||
catch { | ||
this.#fetchDomainStages = oldStages; | ||
} | ||
} | ||
} | ||
async #disableFetch() { | ||
const blockedRequest = this.#networkStorage | ||
.getRequestsByTarget(this) | ||
.filter((request) => request.interceptPhase); | ||
if (blockedRequest.length === 0) { | ||
this.#fetchDomainStages = { | ||
request: false, | ||
response: false, | ||
auth: false, | ||
}; | ||
await this.#cdpClient.sendCommand('Fetch.disable'); | ||
} | ||
} | ||
async toggleNetwork() { | ||
const stages = this.#networkStorage.getInterceptionStages(this.topLevelId); | ||
const fetchEnable = Object.values(stages).some((value) => value); | ||
const fetchChanged = this.#fetchDomainStages.request !== stages.request || | ||
this.#fetchDomainStages.response !== stages.response || | ||
this.#fetchDomainStages.auth !== stages.auth; | ||
const networkEnable = this.isSubscribedTo(chromium_bidi_js_1.BiDiModule.Network); | ||
const networkChanged = this.#networkDomainEnabled !== networkEnable; | ||
this.#logger?.(log_js_1.LogType.debugInfo, 'Toggle Network', `Fetch (${fetchEnable}) ${fetchChanged}`, `Network (${networkEnable}) ${networkChanged}`); | ||
if (networkEnable && networkChanged) { | ||
await this.#toggleNetwork(true); | ||
} | ||
if (fetchEnable && fetchChanged) { | ||
await this.#enableFetch(stages); | ||
} | ||
if (!fetchEnable && fetchChanged) { | ||
await this.#disableFetch(); | ||
} | ||
if (!networkEnable && networkChanged && !fetchEnable && !fetchChanged) { | ||
await this.#toggleNetwork(false); | ||
} | ||
} | ||
/** | ||
@@ -284,0 +375,0 @@ * All the ProxyChannels from all the preload scripts of the given |
@@ -305,2 +305,14 @@ "use strict"; | ||
} | ||
if (params.navigationType === 'historyApi') { | ||
this.#url = params.url; | ||
this.#eventManager.registerEvent({ | ||
type: 'event', | ||
method: 'browsingContext.historyUpdated', | ||
params: { | ||
context: this.id, | ||
url: this.#url, | ||
}, | ||
}, this.id); | ||
return; | ||
} | ||
this.#pendingNavigationUrl = undefined; | ||
@@ -310,12 +322,14 @@ const timestamp = _a.getTimestamp(); | ||
this.#navigation.withinDocument.resolve(); | ||
this.#eventManager.registerEvent({ | ||
type: 'event', | ||
method: protocol_js_1.ChromiumBidi.BrowsingContext.EventNames.FragmentNavigated, | ||
params: { | ||
context: this.id, | ||
navigation: this.#navigationId, | ||
timestamp, | ||
url: this.#url, | ||
}, | ||
}, this.id); | ||
if (params.navigationType === 'fragment') { | ||
this.#eventManager.registerEvent({ | ||
type: 'event', | ||
method: protocol_js_1.ChromiumBidi.BrowsingContext.EventNames.FragmentNavigated, | ||
params: { | ||
context: this.id, | ||
navigation: this.#navigationId, | ||
timestamp, | ||
url: this.#url, | ||
}, | ||
}, this.id); | ||
} | ||
}); | ||
@@ -356,4 +370,17 @@ this.#cdpTarget.cdpClient.on('Page.frameStartedLoading', (params) => { | ||
} | ||
// If there is a pending navigation, reject it. | ||
this.#pendingCommandNavigation?.reject(new protocol_js_1.UnknownErrorException(`navigation canceled, as new navigation is requested by ${params.reason}`)); | ||
if (this.#pendingCommandNavigation !== undefined) { | ||
// The pending navigation was aborted by the new one. | ||
this.#eventManager.registerEvent({ | ||
type: 'event', | ||
method: protocol_js_1.ChromiumBidi.BrowsingContext.EventNames.NavigationAborted, | ||
params: { | ||
context: this.id, | ||
navigation: this.#navigationId, | ||
timestamp: _a.getTimestamp(), | ||
url: this.#url, | ||
}, | ||
}, this.id); | ||
this.#pendingCommandNavigation.reject(protocol_js_1.ChromiumBidi.BrowsingContext.EventNames.NavigationAborted); | ||
this.#pendingCommandNavigation = undefined; | ||
} | ||
this.#pendingNavigationUrl = params.url; | ||
@@ -641,3 +668,3 @@ }); | ||
// Do not wait for the result of the navigation promise. | ||
this.#pendingCommandNavigation.resolve(); | ||
this.#pendingCommandNavigation?.resolve(); | ||
this.#pendingCommandNavigation = undefined; | ||
@@ -656,8 +683,15 @@ return { | ||
this.#pendingCommandNavigation, | ||
]); | ||
this.#pendingCommandNavigation.resolve(); | ||
]).catch((e) => { | ||
// Aborting navigation should not fail the original navigation command for now. | ||
// https://github.com/w3c/webdriver-bidi/issues/799#issue-2605618955 | ||
if (e !== protocol_js_1.ChromiumBidi.BrowsingContext.EventNames.NavigationAborted) { | ||
throw e; | ||
} | ||
}); | ||
// `#pendingCommandNavigation` can be already rejected and set to undefined. | ||
this.#pendingCommandNavigation?.resolve(); | ||
this.#pendingCommandNavigation = undefined; | ||
return { | ||
navigation: navigationId, | ||
// Url can change due to redirect get the latest one. | ||
// Url can change due to redirect. Get the latest one. | ||
url: this.#url, | ||
@@ -816,2 +850,5 @@ }; | ||
async print(params) { | ||
if (!this.isTopLevelContext()) { | ||
throw new protocol_js_1.UnsupportedOperationException('Printing of non-top level contexts is not supported'); | ||
} | ||
const cdpParams = {}; | ||
@@ -818,0 +855,0 @@ if (params.background !== undefined) { |
@@ -57,9 +57,9 @@ /** | ||
count: number; | ||
"__#90798@#x": number; | ||
"__#90798@#y": number; | ||
"__#90798@#time": number; | ||
"__#90920@#x": number; | ||
"__#90920@#y": number; | ||
"__#90920@#time": number; | ||
compare(context: any): boolean; | ||
}; | ||
"__#90798@#DOUBLE_CLICK_TIME_MS": number; | ||
"__#90798@#MAX_DOUBLE_CLICK_RADIUS": number; | ||
"__#90920@#DOUBLE_CLICK_TIME_MS": number; | ||
"__#90920@#MAX_DOUBLE_CLICK_RADIUS": number; | ||
}; | ||
@@ -66,0 +66,0 @@ setClickCount(button: number, context: InstanceType<typeof PointerSource.ClickContext>): number; |
@@ -40,3 +40,3 @@ "use strict"; | ||
await Promise.all(this.#browsingContextStorage.getAllContexts().map((context) => { | ||
return context.cdpTarget.toggleFetchIfNeeded(); | ||
return context.cdpTarget.toggleNetwork(); | ||
})); | ||
@@ -125,3 +125,3 @@ return { | ||
await Promise.all(this.#browsingContextStorage.getAllContexts().map((context) => { | ||
return context.cdpTarget.toggleFetchIfNeeded(); | ||
return context.cdpTarget.toggleNetwork(); | ||
})); | ||
@@ -128,0 +128,0 @@ return {}; |
@@ -48,2 +48,3 @@ /** | ||
provideResponse(overrides: Omit<Network.ProvideResponseParameters, 'request'>): Promise<void>; | ||
dispose(): void; | ||
} |
@@ -518,2 +518,5 @@ "use strict"; | ||
} | ||
dispose() { | ||
this.waitNextPhase.reject(new Error('waitNextPhase disposed')); | ||
} | ||
async #continueWithAuth(authChallengeResponse) { | ||
@@ -520,0 +523,0 @@ (0, assert_js_1.assert)(this.#fetchId, 'Network Interception not set-up.'); |
@@ -35,2 +35,3 @@ import { type BrowsingContext, Network } from '../../../protocol/protocol.js'; | ||
removeIntercept(intercept: Network.Intercept): void; | ||
getRequestsByTarget(target: CdpTarget): NetworkRequest[]; | ||
getRequestById(id: Network.Request): NetworkRequest | undefined; | ||
@@ -37,0 +38,0 @@ getRequestByFetchId(fetchId: Network.Request): NetworkRequest | undefined; |
@@ -158,2 +158,3 @@ "use strict"; | ||
this.#requests.delete(request.id); | ||
request.dispose(); | ||
} | ||
@@ -183,2 +184,11 @@ } | ||
} | ||
getRequestsByTarget(target) { | ||
const requests = []; | ||
for (const request of this.#requests.values()) { | ||
if (request.cdpTarget === target) { | ||
requests.push(request); | ||
} | ||
} | ||
return requests; | ||
} | ||
getRequestById(id) { | ||
@@ -185,0 +195,0 @@ return this.#requests.get(id); |
@@ -288,3 +288,4 @@ "use strict"; | ||
function parseHandleRequestDevicePromptParams(params) { | ||
return parseObject(params, WebDriverBidiBluetooth.Bluetooth.HandleRequestDevicePromptParametersSchema); | ||
return parseObject(params, WebDriverBidiBluetooth.Bluetooth | ||
.HandleRequestDevicePromptParametersSchema); | ||
} | ||
@@ -291,0 +292,0 @@ Bluetooth.parseHandleRequestDevicePromptParams = parseHandleRequestDevicePromptParams; |
@@ -52,2 +52,3 @@ /** | ||
FragmentNavigated = "browsingContext.fragmentNavigated", | ||
HistoryUpdated = "browsingContext.historyUpdated", | ||
Load = "browsingContext.load", | ||
@@ -54,0 +55,0 @@ NavigationAborted = "browsingContext.navigationAborted", |
@@ -63,2 +63,3 @@ "use strict"; | ||
EventNames["FragmentNavigated"] = "browsingContext.fragmentNavigated"; | ||
EventNames["HistoryUpdated"] = "browsingContext.historyUpdated"; | ||
EventNames["Load"] = "browsingContext.load"; | ||
@@ -65,0 +66,0 @@ EventNames["NavigationAborted"] = "browsingContext.navigationAborted"; |
@@ -102,3 +102,2 @@ /** | ||
unhandledPromptBehavior?: Session.UserPromptHandler; | ||
'goog:prerenderingDisabled'?: boolean; | ||
} & Extensible; | ||
@@ -326,3 +325,3 @@ } | ||
export type BrowsingContextCommand = BrowsingContext.Activate | BrowsingContext.CaptureScreenshot | BrowsingContext.Close | BrowsingContext.Create | BrowsingContext.GetTree | BrowsingContext.HandleUserPrompt | BrowsingContext.LocateNodes | BrowsingContext.Navigate | BrowsingContext.Print | BrowsingContext.Reload | BrowsingContext.SetViewport | BrowsingContext.TraverseHistory; | ||
export type BrowsingContextEvent = BrowsingContext.ContextCreated | BrowsingContext.ContextDestroyed | BrowsingContext.DomContentLoaded | BrowsingContext.DownloadWillBegin | BrowsingContext.FragmentNavigated | BrowsingContext.Load | BrowsingContext.NavigationAborted | BrowsingContext.NavigationFailed | BrowsingContext.NavigationStarted | BrowsingContext.UserPromptClosed | BrowsingContext.UserPromptOpened; | ||
export type BrowsingContextEvent = BrowsingContext.ContextCreated | BrowsingContext.ContextDestroyed | BrowsingContext.DomContentLoaded | BrowsingContext.DownloadWillBegin | BrowsingContext.FragmentNavigated | BrowsingContext.HistoryUpdated | BrowsingContext.Load | BrowsingContext.NavigationAborted | BrowsingContext.NavigationFailed | BrowsingContext.NavigationStarted | BrowsingContext.UserPromptClosed | BrowsingContext.UserPromptOpened; | ||
export type BrowsingContextResult = BrowsingContext.CaptureScreenshotResult | BrowsingContext.CreateResult | BrowsingContext.GetTreeResult | BrowsingContext.LocateNodesResult | BrowsingContext.NavigateResult | BrowsingContext.PrintResult | BrowsingContext.TraverseHistoryResult; | ||
@@ -736,2 +735,14 @@ export declare namespace BrowsingContext { | ||
export declare namespace BrowsingContext { | ||
type HistoryUpdated = { | ||
method: 'browsingContext.historyUpdated'; | ||
params: BrowsingContext.HistoryUpdatedParameters; | ||
}; | ||
} | ||
export declare namespace BrowsingContext { | ||
type HistoryUpdatedParameters = { | ||
context: BrowsingContext.BrowsingContext; | ||
url: string; | ||
}; | ||
} | ||
export declare namespace BrowsingContext { | ||
type DomContentLoaded = { | ||
@@ -738,0 +749,0 @@ method: 'browsingContext.domContentLoaded'; |
@@ -50,3 +50,3 @@ "use strict"; | ||
// https://nodejs.org/dist/latest-v20.x/docs/api/globals.html#crypto_1. | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-require-imports | ||
// eslint-disable-next-line @typescript-eslint/no-require-imports | ||
require('crypto').webcrypto.getRandomValues(randomValues); | ||
@@ -53,0 +53,0 @@ } |
@@ -32,2 +32,3 @@ import type { Protocol } from 'devtools-protocol'; | ||
toggleDeviceAccessIfNeeded(): Promise<void>; | ||
toggleNetwork(): Promise<void>; | ||
/** | ||
@@ -34,0 +35,0 @@ * All the ProxyChannels from all the preload scripts of the given |
@@ -184,3 +184,18 @@ import { BiDiModule } from '../../../protocol/chromium-bidi.js'; | ||
else { | ||
await this.#cdpClient.sendCommand('Fetch.disable'); | ||
const blockedRequest = this.#networkStorage | ||
.getRequestsByTarget(this) | ||
.filter((request) => request.interceptPhase); | ||
void Promise.allSettled(blockedRequest.map((request) => request.waitNextPhase)) | ||
.then(async () => { | ||
const blockedRequest = this.#networkStorage | ||
.getRequestsByTarget(this) | ||
.filter((request) => request.interceptPhase); | ||
if (blockedRequest.length) { | ||
return await this.toggleFetchIfNeeded(); | ||
} | ||
return await this.#cdpClient.sendCommand('Fetch.disable'); | ||
}) | ||
.catch((error) => { | ||
this.#logger?.(LogType.bidi, 'Disable failed', error); | ||
}); | ||
} | ||
@@ -279,2 +294,78 @@ } | ||
} | ||
async #toggleNetwork(enable) { | ||
this.#networkDomainEnabled = enable; | ||
try { | ||
await this.#cdpClient.sendCommand(enable ? 'Network.enable' : 'Network.disable'); | ||
} | ||
catch { | ||
this.#networkDomainEnabled = !enable; | ||
} | ||
} | ||
async #enableFetch(stages) { | ||
const patterns = []; | ||
if (stages.request || stages.auth) { | ||
// CDP quirk we need request interception when we intercept auth | ||
patterns.push({ | ||
urlPattern: '*', | ||
requestStage: 'Request', | ||
}); | ||
} | ||
if (stages.response) { | ||
patterns.push({ | ||
urlPattern: '*', | ||
requestStage: 'Response', | ||
}); | ||
} | ||
if ( | ||
// Only enable interception when Network is enabled | ||
this.#networkDomainEnabled && | ||
patterns.length) { | ||
const oldStages = this.#fetchDomainStages; | ||
this.#fetchDomainStages = stages; | ||
try { | ||
await this.#cdpClient.sendCommand('Fetch.enable', { | ||
patterns, | ||
handleAuthRequests: stages.auth, | ||
}); | ||
} | ||
catch { | ||
this.#fetchDomainStages = oldStages; | ||
} | ||
} | ||
} | ||
async #disableFetch() { | ||
const blockedRequest = this.#networkStorage | ||
.getRequestsByTarget(this) | ||
.filter((request) => request.interceptPhase); | ||
if (blockedRequest.length === 0) { | ||
this.#fetchDomainStages = { | ||
request: false, | ||
response: false, | ||
auth: false, | ||
}; | ||
await this.#cdpClient.sendCommand('Fetch.disable'); | ||
} | ||
} | ||
async toggleNetwork() { | ||
const stages = this.#networkStorage.getInterceptionStages(this.topLevelId); | ||
const fetchEnable = Object.values(stages).some((value) => value); | ||
const fetchChanged = this.#fetchDomainStages.request !== stages.request || | ||
this.#fetchDomainStages.response !== stages.response || | ||
this.#fetchDomainStages.auth !== stages.auth; | ||
const networkEnable = this.isSubscribedTo(BiDiModule.Network); | ||
const networkChanged = this.#networkDomainEnabled !== networkEnable; | ||
this.#logger?.(LogType.debugInfo, 'Toggle Network', `Fetch (${fetchEnable}) ${fetchChanged}`, `Network (${networkEnable}) ${networkChanged}`); | ||
if (networkEnable && networkChanged) { | ||
await this.#toggleNetwork(true); | ||
} | ||
if (fetchEnable && fetchChanged) { | ||
await this.#enableFetch(stages); | ||
} | ||
if (!fetchEnable && fetchChanged) { | ||
await this.#disableFetch(); | ||
} | ||
if (!networkEnable && networkChanged && !fetchEnable && !fetchChanged) { | ||
await this.#toggleNetwork(false); | ||
} | ||
} | ||
/** | ||
@@ -281,0 +372,0 @@ * All the ProxyChannels from all the preload scripts of the given |
@@ -301,2 +301,14 @@ /** | ||
} | ||
if (params.navigationType === 'historyApi') { | ||
this.#url = params.url; | ||
this.#eventManager.registerEvent({ | ||
type: 'event', | ||
method: 'browsingContext.historyUpdated', | ||
params: { | ||
context: this.id, | ||
url: this.#url, | ||
}, | ||
}, this.id); | ||
return; | ||
} | ||
this.#pendingNavigationUrl = undefined; | ||
@@ -306,12 +318,14 @@ const timestamp = _a.getTimestamp(); | ||
this.#navigation.withinDocument.resolve(); | ||
this.#eventManager.registerEvent({ | ||
type: 'event', | ||
method: ChromiumBidi.BrowsingContext.EventNames.FragmentNavigated, | ||
params: { | ||
context: this.id, | ||
navigation: this.#navigationId, | ||
timestamp, | ||
url: this.#url, | ||
}, | ||
}, this.id); | ||
if (params.navigationType === 'fragment') { | ||
this.#eventManager.registerEvent({ | ||
type: 'event', | ||
method: ChromiumBidi.BrowsingContext.EventNames.FragmentNavigated, | ||
params: { | ||
context: this.id, | ||
navigation: this.#navigationId, | ||
timestamp, | ||
url: this.#url, | ||
}, | ||
}, this.id); | ||
} | ||
}); | ||
@@ -352,4 +366,17 @@ this.#cdpTarget.cdpClient.on('Page.frameStartedLoading', (params) => { | ||
} | ||
// If there is a pending navigation, reject it. | ||
this.#pendingCommandNavigation?.reject(new UnknownErrorException(`navigation canceled, as new navigation is requested by ${params.reason}`)); | ||
if (this.#pendingCommandNavigation !== undefined) { | ||
// The pending navigation was aborted by the new one. | ||
this.#eventManager.registerEvent({ | ||
type: 'event', | ||
method: ChromiumBidi.BrowsingContext.EventNames.NavigationAborted, | ||
params: { | ||
context: this.id, | ||
navigation: this.#navigationId, | ||
timestamp: _a.getTimestamp(), | ||
url: this.#url, | ||
}, | ||
}, this.id); | ||
this.#pendingCommandNavigation.reject(ChromiumBidi.BrowsingContext.EventNames.NavigationAborted); | ||
this.#pendingCommandNavigation = undefined; | ||
} | ||
this.#pendingNavigationUrl = params.url; | ||
@@ -637,3 +664,3 @@ }); | ||
// Do not wait for the result of the navigation promise. | ||
this.#pendingCommandNavigation.resolve(); | ||
this.#pendingCommandNavigation?.resolve(); | ||
this.#pendingCommandNavigation = undefined; | ||
@@ -652,8 +679,15 @@ return { | ||
this.#pendingCommandNavigation, | ||
]); | ||
this.#pendingCommandNavigation.resolve(); | ||
]).catch((e) => { | ||
// Aborting navigation should not fail the original navigation command for now. | ||
// https://github.com/w3c/webdriver-bidi/issues/799#issue-2605618955 | ||
if (e !== ChromiumBidi.BrowsingContext.EventNames.NavigationAborted) { | ||
throw e; | ||
} | ||
}); | ||
// `#pendingCommandNavigation` can be already rejected and set to undefined. | ||
this.#pendingCommandNavigation?.resolve(); | ||
this.#pendingCommandNavigation = undefined; | ||
return { | ||
navigation: navigationId, | ||
// Url can change due to redirect get the latest one. | ||
// Url can change due to redirect. Get the latest one. | ||
url: this.#url, | ||
@@ -812,2 +846,5 @@ }; | ||
async print(params) { | ||
if (!this.isTopLevelContext()) { | ||
throw new UnsupportedOperationException('Printing of non-top level contexts is not supported'); | ||
} | ||
const cdpParams = {}; | ||
@@ -814,0 +851,0 @@ if (params.background !== undefined) { |
@@ -57,9 +57,9 @@ /** | ||
count: number; | ||
"__#90798@#x": number; | ||
"__#90798@#y": number; | ||
"__#90798@#time": number; | ||
"__#90920@#x": number; | ||
"__#90920@#y": number; | ||
"__#90920@#time": number; | ||
compare(context: any): boolean; | ||
}; | ||
"__#90798@#DOUBLE_CLICK_TIME_MS": number; | ||
"__#90798@#MAX_DOUBLE_CLICK_RADIUS": number; | ||
"__#90920@#DOUBLE_CLICK_TIME_MS": number; | ||
"__#90920@#MAX_DOUBLE_CLICK_RADIUS": number; | ||
}; | ||
@@ -66,0 +66,0 @@ setClickCount(button: number, context: InstanceType<typeof PointerSource.ClickContext>): number; |
@@ -37,3 +37,3 @@ /** | ||
await Promise.all(this.#browsingContextStorage.getAllContexts().map((context) => { | ||
return context.cdpTarget.toggleFetchIfNeeded(); | ||
return context.cdpTarget.toggleNetwork(); | ||
})); | ||
@@ -122,3 +122,3 @@ return { | ||
await Promise.all(this.#browsingContextStorage.getAllContexts().map((context) => { | ||
return context.cdpTarget.toggleFetchIfNeeded(); | ||
return context.cdpTarget.toggleNetwork(); | ||
})); | ||
@@ -125,0 +125,0 @@ return {}; |
@@ -48,2 +48,3 @@ /** | ||
provideResponse(overrides: Omit<Network.ProvideResponseParameters, 'request'>): Promise<void>; | ||
dispose(): void; | ||
} |
@@ -515,2 +515,5 @@ /* | ||
} | ||
dispose() { | ||
this.waitNextPhase.reject(new Error('waitNextPhase disposed')); | ||
} | ||
async #continueWithAuth(authChallengeResponse) { | ||
@@ -517,0 +520,0 @@ assert(this.#fetchId, 'Network Interception not set-up.'); |
@@ -35,2 +35,3 @@ import { type BrowsingContext, Network } from '../../../protocol/protocol.js'; | ||
removeIntercept(intercept: Network.Intercept): void; | ||
getRequestsByTarget(target: CdpTarget): NetworkRequest[]; | ||
getRequestById(id: Network.Request): NetworkRequest | undefined; | ||
@@ -37,0 +38,0 @@ getRequestByFetchId(fetchId: Network.Request): NetworkRequest | undefined; |
@@ -155,2 +155,3 @@ import { NoSuchInterceptException, } from '../../../protocol/protocol.js'; | ||
this.#requests.delete(request.id); | ||
request.dispose(); | ||
} | ||
@@ -180,2 +181,11 @@ } | ||
} | ||
getRequestsByTarget(target) { | ||
const requests = []; | ||
for (const request of this.#requests.values()) { | ||
if (request.cdpTarget === target) { | ||
requests.push(request); | ||
} | ||
} | ||
return requests; | ||
} | ||
getRequestById(id) { | ||
@@ -182,0 +192,0 @@ return this.#requests.get(id); |
@@ -20,3 +20,2 @@ /** | ||
import url from 'url'; | ||
// eslint-disable-next-line no-underscore-dangle | ||
const __dirname = url.fileURLToPath(new URL('.', import.meta.url)); | ||
@@ -23,0 +22,0 @@ export async function getMapperTabSource() { |
@@ -261,3 +261,4 @@ /** | ||
function parseHandleRequestDevicePromptParams(params) { | ||
return parseObject(params, WebDriverBidiBluetooth.Bluetooth.HandleRequestDevicePromptParametersSchema); | ||
return parseObject(params, WebDriverBidiBluetooth.Bluetooth | ||
.HandleRequestDevicePromptParametersSchema); | ||
} | ||
@@ -264,0 +265,0 @@ Bluetooth.parseHandleRequestDevicePromptParams = parseHandleRequestDevicePromptParams; |
@@ -52,2 +52,3 @@ /** | ||
FragmentNavigated = "browsingContext.fragmentNavigated", | ||
HistoryUpdated = "browsingContext.historyUpdated", | ||
Load = "browsingContext.load", | ||
@@ -54,0 +55,0 @@ NavigationAborted = "browsingContext.navigationAborted", |
@@ -60,2 +60,3 @@ /** | ||
EventNames["FragmentNavigated"] = "browsingContext.fragmentNavigated"; | ||
EventNames["HistoryUpdated"] = "browsingContext.historyUpdated"; | ||
EventNames["Load"] = "browsingContext.load"; | ||
@@ -62,0 +63,0 @@ EventNames["NavigationAborted"] = "browsingContext.navigationAborted"; |
@@ -102,3 +102,2 @@ /** | ||
unhandledPromptBehavior?: Session.UserPromptHandler; | ||
'goog:prerenderingDisabled'?: boolean; | ||
} & Extensible; | ||
@@ -326,3 +325,3 @@ } | ||
export type BrowsingContextCommand = BrowsingContext.Activate | BrowsingContext.CaptureScreenshot | BrowsingContext.Close | BrowsingContext.Create | BrowsingContext.GetTree | BrowsingContext.HandleUserPrompt | BrowsingContext.LocateNodes | BrowsingContext.Navigate | BrowsingContext.Print | BrowsingContext.Reload | BrowsingContext.SetViewport | BrowsingContext.TraverseHistory; | ||
export type BrowsingContextEvent = BrowsingContext.ContextCreated | BrowsingContext.ContextDestroyed | BrowsingContext.DomContentLoaded | BrowsingContext.DownloadWillBegin | BrowsingContext.FragmentNavigated | BrowsingContext.Load | BrowsingContext.NavigationAborted | BrowsingContext.NavigationFailed | BrowsingContext.NavigationStarted | BrowsingContext.UserPromptClosed | BrowsingContext.UserPromptOpened; | ||
export type BrowsingContextEvent = BrowsingContext.ContextCreated | BrowsingContext.ContextDestroyed | BrowsingContext.DomContentLoaded | BrowsingContext.DownloadWillBegin | BrowsingContext.FragmentNavigated | BrowsingContext.HistoryUpdated | BrowsingContext.Load | BrowsingContext.NavigationAborted | BrowsingContext.NavigationFailed | BrowsingContext.NavigationStarted | BrowsingContext.UserPromptClosed | BrowsingContext.UserPromptOpened; | ||
export type BrowsingContextResult = BrowsingContext.CaptureScreenshotResult | BrowsingContext.CreateResult | BrowsingContext.GetTreeResult | BrowsingContext.LocateNodesResult | BrowsingContext.NavigateResult | BrowsingContext.PrintResult | BrowsingContext.TraverseHistoryResult; | ||
@@ -736,2 +735,14 @@ export declare namespace BrowsingContext { | ||
export declare namespace BrowsingContext { | ||
type HistoryUpdated = { | ||
method: 'browsingContext.historyUpdated'; | ||
params: BrowsingContext.HistoryUpdatedParameters; | ||
}; | ||
} | ||
export declare namespace BrowsingContext { | ||
type HistoryUpdatedParameters = { | ||
context: BrowsingContext.BrowsingContext; | ||
url: string; | ||
}; | ||
} | ||
export declare namespace BrowsingContext { | ||
type DomContentLoaded = { | ||
@@ -738,0 +749,0 @@ method: 'browsingContext.domContentLoaded'; |
@@ -47,3 +47,3 @@ /** | ||
// https://nodejs.org/dist/latest-v20.x/docs/api/globals.html#crypto_1. | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-require-imports | ||
// eslint-disable-next-line @typescript-eslint/no-require-imports | ||
require('crypto').webcrypto.getRandomValues(randomValues); | ||
@@ -50,0 +50,0 @@ } |
{ | ||
"name": "chromium-bidi", | ||
"version": "0.8.1", | ||
"version": "0.9.0", | ||
"description": "An implementation of the WebDriver BiDi protocol for Chromium implemented as a JavaScript layer translating between BiDi and CDP, running inside a Chrome tab.", | ||
@@ -163,15 +163,15 @@ "scripts": { | ||
"devDependencies": { | ||
"@actions/core": "1.10.1", | ||
"@eslint/compat": "1.1.1", | ||
"@actions/core": "1.11.1", | ||
"@eslint/compat": "1.2.1", | ||
"@eslint/eslintrc": "3.1.0", | ||
"@eslint/js": "9.10.0", | ||
"@eslint/js": "9.13.0", | ||
"@puppeteer/browsers": "2.4.0", | ||
"@rollup/plugin-alias": "5.1.0", | ||
"@rollup/plugin-node-resolve": "15.2.3", | ||
"@rollup/wasm-node": "4.22.1", | ||
"@rollup/plugin-alias": "5.1.1", | ||
"@rollup/plugin-node-resolve": "15.3.0", | ||
"@rollup/wasm-node": "4.24.0", | ||
"@types/chai": "4.3.17", | ||
"@types/chai-as-promised": "7.1.8", | ||
"@types/debug": "4.1.12", | ||
"@types/mocha": "10.0.8", | ||
"@types/node": "20.16.5", | ||
"@types/mocha": "10.0.9", | ||
"@types/node": "20.16.13", | ||
"@types/sinon": "17.0.3", | ||
@@ -181,17 +181,17 @@ "@types/websocket": "1.0.10", | ||
"@types/yargs": "17.0.33", | ||
"@typescript-eslint/eslint-plugin": "8.6.0", | ||
"@typescript-eslint/parser": "8.6.0", | ||
"@typescript-eslint/eslint-plugin": "8.10.0", | ||
"@typescript-eslint/parser": "8.10.0", | ||
"chai": "4.5.0", | ||
"chai-as-promised": "7.1.2", | ||
"debug": "4.3.7", | ||
"devtools-protocol": "0.0.1363470", | ||
"eslint": "8.57.1", | ||
"devtools-protocol": "0.0.1368592", | ||
"eslint": "9.12.0", | ||
"eslint-config-prettier": "9.1.0", | ||
"eslint-import-resolver-typescript": "3.6.3", | ||
"eslint-plugin-import": "2.30.0", | ||
"eslint-plugin-import": "2.31.0", | ||
"eslint-plugin-mocha": "10.5.0", | ||
"eslint-plugin-prettier": "5.2.1", | ||
"eslint-plugin-promise": "7.1.0", | ||
"globals": "15.9.0", | ||
"gts": "5.3.1", | ||
"globals": "15.11.0", | ||
"gts": "6.0.0", | ||
"mocha": "10.7.3", | ||
@@ -201,11 +201,11 @@ "pkg-dir": "8.0.0", | ||
"rimraf": "6.0.1", | ||
"rollup": "4.22.4", | ||
"rollup-plugin-license": "3.5.2", | ||
"selenium-webdriver": "4.24.1", | ||
"rollup": "4.24.0", | ||
"rollup-plugin-license": "3.5.3", | ||
"selenium-webdriver": "4.25.0", | ||
"semver": "7.6.3", | ||
"sinon": "19.0.2", | ||
"source-map-support": "0.5.21", | ||
"tslib": "2.7.0", | ||
"typescript": "5.6.2", | ||
"webdriverio": "9.0.9", | ||
"tslib": "2.8.0", | ||
"typescript": "5.6.3", | ||
"webdriverio": "9.2.1", | ||
"websocket": "1.0.35", | ||
@@ -212,0 +212,0 @@ "wireit": "0.14.9", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
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
11011440
170397
71
3
6
1
38