Socket
Socket
Sign inDemoInstall

chromium-bidi

Package Overview
Dependencies
Maintainers
2
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chromium-bidi - npm Package Compare versions

Comparing version 0.4.6 to 0.4.7

lib/cjs/bidiMapper/domains/context/browsingContextStorage.spec.d.ts

4

lib/cjs/bidiMapper/BidiServer.js

@@ -33,3 +33,3 @@ "use strict";

#logger;
#handleIncomingMessage = async (message) => {
#handleIncomingMessage = (message) => {
this.#commandProcessor.processCommand(message);

@@ -49,3 +49,3 @@ };

this.#realmStorage = new realmStorage_js_1.RealmStorage();
this.#messageQueue = new processingQueue_js_1.ProcessingQueue(this.#processOutgoingMessage, undefined, this.#logger);
this.#messageQueue = new processingQueue_js_1.ProcessingQueue(this.#processOutgoingMessage, () => Promise.resolve(), this.#logger);
this.#transport = bidiTransport;

@@ -52,0 +52,0 @@ this.#transport.setOnMessage(this.#handleIncomingMessage);

@@ -19,5 +19,5 @@ /**

export interface BidiTransport {
setOnMessage: (handler: (message: Message.RawCommandRequest) => Promise<void>) => void;
sendMessage: (message: Message.OutgoingMessage) => Promise<void>;
setOnMessage: (handler: (message: Message.RawCommandRequest) => Promise<void> | void) => void;
sendMessage: (message: Message.OutgoingMessage) => Promise<void> | void;
close(): void;
}

@@ -29,2 +29,4 @@ /**

export interface BidiParser {
parseAddPreloadScriptParams(params: object): Script.AddPreloadScriptParameters;
parseRemovePreloadScriptParams(params: object): Script.RemovePreloadScriptParameters;
parseGetRealmsParams(params: object): Script.GetRealmsParameters;

@@ -31,0 +33,0 @@ parseCallFunctionParams(params: object): Script.CallFunctionParameters;

@@ -26,2 +26,8 @@ "use strict";

class BidiNoOpParser {
parseAddPreloadScriptParams(params) {
return params;
}
parseRemovePreloadScriptParams(params) {
return params;
}
parseGetRealmsParams(params) {

@@ -110,2 +116,6 @@ return params;

return this.#contextProcessor.process_browsingContext_print(this.#parser.parsePrintParams(commandData.params));
case 'script.addPreloadScript':
return this.#contextProcessor.process_script_addPreloadScript(this.#parser.parseAddPreloadScriptParams(commandData.params));
case 'script.removePreloadScript':
return this.#contextProcessor.process_script_removePreloadScript(this.#parser.parseRemovePreloadScriptParams(commandData.params));
case 'script.getRealms':

@@ -137,3 +147,3 @@ return this.#contextProcessor.process_script_getRealms(this.#parser.parseGetRealmsParams(commandData.params));

catch (e) {
if (e instanceof protocol_js_1.Message.ErrorResponseClass) {
if (e instanceof protocol_js_1.Message.ErrorResponse) {
const errorResponse = e;

@@ -145,3 +155,3 @@ this.emit('response', OutgoingBidiMessage_js_1.OutgoingBidiMessage.createResolved(errorResponse.toErrorResponse(command.id), command.channel ?? null));

this.#logger?.(log_js_1.LogType.bidi, error);
this.emit('response', OutgoingBidiMessage_js_1.OutgoingBidiMessage.createResolved(new protocol_js_1.Message.UnknownException(error.message).toErrorResponse(command.id), command.channel ?? null));
this.emit('response', OutgoingBidiMessage_js_1.OutgoingBidiMessage.createResolved(new protocol_js_1.Message.ErrorResponse(protocol_js_1.Message.ErrorCode.UnknownError, error.message).toErrorResponse(command.id), command.channel ?? null));
}

@@ -148,0 +158,0 @@ }

@@ -17,3 +17,3 @@ /**

*/
import { BrowsingContext } from '../../../protocol/protocol.js';
import { BrowsingContext, CommonDataTypes, Script } from '../../../protocol/protocol.js';
import { LoggerFn } from '../../../utils/log.js';

@@ -28,19 +28,31 @@ import { IEventManager } from '../events/EventManager.js';

private constructor();
static create(cdpTarget: CdpTarget, realmStorage: RealmStorage, contextId: string, parentId: string | null, eventManager: IEventManager, browsingContextStorage: BrowsingContextStorage, logger?: LoggerFn): Promise<void>;
static create(cdpTarget: CdpTarget, realmStorage: RealmStorage, contextId: CommonDataTypes.BrowsingContext, parentId: CommonDataTypes.BrowsingContext | null, eventManager: IEventManager, browsingContextStorage: BrowsingContextStorage, logger?: LoggerFn): BrowsingContextImpl;
/**
* @see https://html.spec.whatwg.org/multipage/document-sequences.html#navigable
*/
get navigableId(): string | null;
delete(): void;
/** Returns the ID of this context. */
get contextId(): CommonDataTypes.BrowsingContext;
/** Returns the parent context ID. */
get parentId(): CommonDataTypes.BrowsingContext | null;
/** Returns all children contexts. */
get children(): BrowsingContextImpl[];
/**
* Returns true if this is a top-level context.
* This is the case whenever the parent context ID is null.
*/
isTopLevelContext(): boolean;
addChild(child: BrowsingContextImpl): void;
get cdpTarget(): CdpTarget;
updateCdpTarget(cdpTarget: CdpTarget): void;
delete(): Promise<void>;
get contextId(): string;
get parentId(): string | null;
get cdpTarget(): CdpTarget;
get children(): BrowsingContextImpl[];
get url(): string;
addChild(child: BrowsingContextImpl): void;
awaitLoaded(): Promise<void>;
awaitUnblocked(): Promise<void>;
getOrCreateSandbox(sandbox: string | undefined): Promise<Realm>;
serializeToBidiValue(maxDepth?: number, addParentFiled?: boolean): BrowsingContext.Info;
navigate(url: string, wait: BrowsingContext.ReadinessState): Promise<BrowsingContext.NavigateResult>;
getOrCreateSandbox(sandbox: string | undefined): Promise<Realm>;
captureScreenshot(): Promise<BrowsingContext.CaptureScreenshotResult>;
print(params: BrowsingContext.PrintParameters): Promise<BrowsingContext.PrintResult>;
addPreloadScript(params: Script.AddPreloadScriptParameters): Promise<Script.AddPreloadScriptResult>;
}

@@ -26,2 +26,15 @@ "use strict";

class BrowsingContextImpl {
/** The ID of the current context. */
#contextId;
/**
* The ID of the parent context.
* If null, this is a top-level context.
*/
#parentId;
/**
* Children contexts.
* Map from children context ID to context implementation.
*/
#children = new Map();
#browsingContextStorage;
#defers = {

@@ -37,19 +50,9 @@ documentInitialized: new deferred_js_1.Deferred(),

};
#contextId;
#parentId;
#url = 'about:blank';
#eventManager;
#children = new Map();
#realmStorage;
#url = 'about:blank';
#loaderId = null;
#cdpTarget;
#maybeDefaultRealm;
#browsingContextStorage;
#logger;
get #defaultRealm() {
if (this.#maybeDefaultRealm === undefined) {
throw new Error(`No default realm for browsing context ${this.#contextId}`);
}
return this.#maybeDefaultRealm;
}
constructor(cdpTarget, realmStorage, contextId, parentId, eventManager, browsingContextStorage, logger) {

@@ -65,3 +68,3 @@ this.#cdpTarget = cdpTarget;

}
static async create(cdpTarget, realmStorage, contextId, parentId, eventManager, browsingContextStorage, logger) {
static create(cdpTarget, realmStorage, contextId, parentId, eventManager, browsingContextStorage, logger) {
const context = new BrowsingContextImpl(cdpTarget, realmStorage, contextId, parentId, eventManager, browsingContextStorage, logger);

@@ -73,13 +76,12 @@ browsingContextStorage.addContext(context);

}, context.contextId);
return context;
}
// https://html.spec.whatwg.org/multipage/document-sequences.html#navigable
/**
* @see https://html.spec.whatwg.org/multipage/document-sequences.html#navigable
*/
get navigableId() {
return this.#loaderId;
}
updateCdpTarget(cdpTarget) {
this.#cdpTarget = cdpTarget;
this.#initListeners();
}
async delete() {
await this.#removeChildContexts();
delete() {
this.#deleteChildren();
this.#realmStorage.deleteRealms({

@@ -90,3 +92,3 @@ browsingContextId: this.contextId,

if (this.parentId !== null) {
const parent = this.#browsingContextStorage.getKnownContext(this.parentId);
const parent = this.#browsingContextStorage.getContext(this.parentId);
parent.#children.delete(this.contextId);

@@ -98,18 +100,41 @@ }

}, this.contextId);
this.#browsingContextStorage.removeContext(this.contextId);
this.#browsingContextStorage.deleteContext(this.contextId);
}
async #removeChildContexts() {
await Promise.all(this.children.map((child) => child.delete()));
}
/** Returns the ID of this context. */
get contextId() {
return this.#contextId;
}
/** Returns the parent context ID. */
get parentId() {
return this.#parentId;
}
/** Returns all children contexts. */
get children() {
return Array.from(this.#children.values());
}
/**
* Returns true if this is a top-level context.
* This is the case whenever the parent context ID is null.
*/
isTopLevelContext() {
return this.#parentId === null;
}
addChild(child) {
this.#children.set(child.contextId, child);
}
#deleteChildren() {
this.children.map((child) => child.delete());
}
get #defaultRealm() {
if (this.#maybeDefaultRealm === undefined) {
throw new Error(`No default realm for browsing context ${this.#contextId}`);
}
return this.#maybeDefaultRealm;
}
get cdpTarget() {
return this.#cdpTarget;
}
get children() {
return Array.from(this.#children.values());
updateCdpTarget(cdpTarget) {
this.#cdpTarget = cdpTarget;
this.#initListeners();
}

@@ -119,11 +144,33 @@ get url() {

}
addChild(child) {
this.#children.set(child.contextId, child);
}
async awaitLoaded() {
await this.#defers.Page.lifecycleEvent.load;
}
async awaitUnblocked() {
awaitUnblocked() {
return this.#cdpTarget.targetUnblocked;
}
async getOrCreateSandbox(sandbox) {
if (sandbox === undefined || sandbox === '') {
return this.#defaultRealm;
}
let maybeSandboxes = this.#realmStorage.findRealms({
browsingContextId: this.contextId,
sandbox,
});
if (maybeSandboxes.length === 0) {
await this.#cdpTarget.cdpClient.sendCommand('Page.createIsolatedWorld', {
frameId: this.contextId,
worldName: sandbox,
});
// `Runtime.executionContextCreated` should be emitted by the time the
// previous command is done.
maybeSandboxes = this.#realmStorage.findRealms({
browsingContextId: this.contextId,
sandbox,
});
}
if (maybeSandboxes.length !== 1) {
throw Error(`Sandbox ${sandbox} wasn't created.`);
}
return maybeSandboxes[0];
}
serializeToBidiValue(maxDepth = 0, addParentFiled = true) {

@@ -146,3 +193,3 @@ return {

});
this.#cdpTarget.cdpClient.on('Page.frameNavigated', async (params) => {
this.#cdpTarget.cdpClient.on('Page.frameNavigated', (params) => {
if (this.contextId !== params.frame.id) {

@@ -155,5 +202,3 @@ return;

// Remove context's children.
await this.#removeChildContexts();
// Remove all the already created realms.
this.#realmStorage.deleteRealms({ browsingContextId: this.contextId });
this.#deleteChildren();
});

@@ -167,3 +212,3 @@ this.#cdpTarget.cdpClient.on('Page.navigatedWithinDocument', (params) => {

});
this.#cdpTarget.cdpClient.on('Page.lifecycleEvent', async (params) => {
this.#cdpTarget.cdpClient.on('Page.lifecycleEvent', (params) => {
if (this.contextId !== params.frameId) {

@@ -240,2 +285,7 @@ return;

});
this.#cdpTarget.cdpClient.on('Runtime.executionContextsCleared', () => {
this.#realmStorage.deleteRealms({
cdpSessionId: this.#cdpTarget.cdpSessionId,
});
});
}

@@ -292,3 +342,3 @@ #getOrigin(params) {

if (cdpNavigateResult.errorText) {
throw new protocol_js_1.Message.UnknownException(cdpNavigateResult.errorText);
throw new protocol_js_1.Message.UnknownErrorException(cdpNavigateResult.errorText);
}

@@ -318,4 +368,2 @@ this.#documentChanged(cdpNavigateResult.loaderId);

break;
default:
throw new Error(`Not implemented wait '${wait}'`);
}

@@ -329,27 +377,2 @@ return {

}
async getOrCreateSandbox(sandbox) {
if (sandbox === undefined || sandbox === '') {
return this.#defaultRealm;
}
let maybeSandboxes = this.#realmStorage.findRealms({
browsingContextId: this.contextId,
sandbox,
});
if (maybeSandboxes.length === 0) {
await this.#cdpTarget.cdpClient.sendCommand('Page.createIsolatedWorld', {
frameId: this.contextId,
worldName: sandbox,
});
// `Runtime.executionContextCreated` should be emitted by the time the
// previous command is done.
maybeSandboxes = this.#realmStorage.findRealms({
browsingContextId: this.contextId,
sandbox,
});
}
if (maybeSandboxes.length !== 1) {
throw Error(`Sandbox ${sandbox} wasn't created.`);
}
return maybeSandboxes[0];
}
async captureScreenshot() {

@@ -375,3 +398,3 @@ const [, result] = await Promise.all([

scale: params.scale,
// TODO(#518): Use `shrinkToFit`.
preferCSSPageSize: !params.shrinkToFit,
};

@@ -403,4 +426,16 @@ if (params.margin?.bottom) {

}
async addPreloadScript(params) {
const result = await this.#cdpTarget.cdpClient.sendCommand('Page.addScriptToEvaluateOnNewDocument', {
// The spec provides a function, and CDP expects an evaluation.
source: `(${params.expression})();`,
worldName: params.sandbox,
});
return {
result: {
script: result.identifier,
},
};
}
}
exports.BrowsingContextImpl = BrowsingContextImpl;
//# sourceMappingURL=browsingContextImpl.js.map

@@ -32,2 +32,4 @@ /**

process_browsingContext_print(params: BrowsingContext.PrintParameters): Promise<BrowsingContext.PrintResult>;
process_script_addPreloadScript(params: Script.AddPreloadScriptParameters): Promise<Script.AddPreloadScriptResult>;
process_script_removePreloadScript(_params: Script.RemovePreloadScriptParameters): Promise<Script.RemovePreloadScriptResult>;
process_script_evaluate(params: Script.EvaluateParameters): Promise<Script.EvaluateResult>;

@@ -39,3 +41,3 @@ process_script_getRealms(params: Script.GetRealmsParameters): Script.GetRealmsResult;

process_cdp_sendCommand(params: CDP.SendCommandParams): Promise<{
result: void | Protocol.Debugger.EnableResponse | Protocol.Debugger.EvaluateOnCallFrameResponse | Protocol.Debugger.GetPossibleBreakpointsResponse | Protocol.Debugger.GetScriptSourceResponse | Protocol.Debugger.GetWasmBytecodeResponse | Protocol.Debugger.GetStackTraceResponse | Protocol.Debugger.RestartFrameResponse | Protocol.Debugger.SearchInContentResponse | Protocol.Debugger.SetBreakpointResponse | Protocol.Debugger.SetInstrumentationBreakpointResponse | Protocol.Debugger.SetBreakpointByUrlResponse | Protocol.Debugger.SetBreakpointOnFunctionCallResponse | Protocol.Debugger.SetScriptSourceResponse | Protocol.HeapProfiler.GetHeapObjectIdResponse | Protocol.HeapProfiler.GetObjectByHeapObjectIdResponse | Protocol.HeapProfiler.GetSamplingProfileResponse | Protocol.HeapProfiler.StopSamplingResponse | Protocol.Profiler.GetBestEffortCoverageResponse | Protocol.Profiler.StartPreciseCoverageResponse | Protocol.Profiler.StopResponse | Protocol.Profiler.TakePreciseCoverageResponse | Protocol.Profiler.TakeTypeProfileResponse | Protocol.Runtime.AwaitPromiseResponse | Protocol.Runtime.CallFunctionOnResponse | Protocol.Runtime.CompileScriptResponse | Protocol.Runtime.EvaluateResponse | Protocol.Runtime.GetIsolateIdResponse | Protocol.Runtime.GetHeapUsageResponse | Protocol.Runtime.GetPropertiesResponse | Protocol.Runtime.GlobalLexicalScopeNamesResponse | Protocol.Runtime.QueryObjectsResponse | Protocol.Runtime.RunScriptResponse | Protocol.Runtime.GetExceptionDetailsResponse | Protocol.Schema.GetDomainsResponse | Protocol.Accessibility.GetPartialAXTreeResponse | Protocol.Accessibility.GetFullAXTreeResponse | Protocol.Accessibility.GetRootAXNodeResponse | Protocol.Accessibility.GetAXNodeAndAncestorsResponse | Protocol.Accessibility.GetChildAXNodesResponse | Protocol.Accessibility.QueryAXTreeResponse | Protocol.Animation.GetCurrentTimeResponse | Protocol.Animation.GetPlaybackRateResponse | Protocol.Animation.ResolveAnimationResponse | Protocol.Audits.GetEncodedResponseResponse | Protocol.Browser.GetVersionResponse | Protocol.Browser.GetBrowserCommandLineResponse | Protocol.Browser.GetHistogramsResponse | Protocol.Browser.GetHistogramResponse | Protocol.Browser.GetWindowBoundsResponse | Protocol.Browser.GetWindowForTargetResponse | Protocol.CSS.AddRuleResponse | Protocol.CSS.CollectClassNamesResponse | Protocol.CSS.CreateStyleSheetResponse | Protocol.CSS.GetBackgroundColorsResponse | Protocol.CSS.GetComputedStyleForNodeResponse | Protocol.CSS.GetInlineStylesForNodeResponse | Protocol.CSS.GetMatchedStylesForNodeResponse | Protocol.CSS.GetMediaQueriesResponse | Protocol.CSS.GetPlatformFontsForNodeResponse | Protocol.CSS.GetStyleSheetTextResponse | Protocol.CSS.GetLayersForNodeResponse | Protocol.CSS.TakeComputedStyleUpdatesResponse | Protocol.CSS.SetKeyframeKeyResponse | Protocol.CSS.SetMediaTextResponse | Protocol.CSS.SetContainerQueryTextResponse | Protocol.CSS.SetSupportsTextResponse | Protocol.CSS.SetRuleSelectorResponse | Protocol.CSS.SetStyleSheetTextResponse | Protocol.CSS.SetStyleTextsResponse | Protocol.CSS.StopRuleUsageTrackingResponse | Protocol.CSS.TakeCoverageDeltaResponse | Protocol.CacheStorage.RequestCacheNamesResponse | Protocol.CacheStorage.RequestCachedResponseResponse | Protocol.CacheStorage.RequestEntriesResponse | Protocol.DOM.CollectClassNamesFromSubtreeResponse | Protocol.DOM.CopyToResponse | Protocol.DOM.DescribeNodeResponse | Protocol.DOM.GetAttributesResponse | Protocol.DOM.GetBoxModelResponse | Protocol.DOM.GetContentQuadsResponse | Protocol.DOM.GetDocumentResponse | Protocol.DOM.GetFlattenedDocumentResponse | Protocol.DOM.GetNodesForSubtreeByStyleResponse | Protocol.DOM.GetNodeForLocationResponse | Protocol.DOM.GetOuterHTMLResponse | Protocol.DOM.GetRelayoutBoundaryResponse | Protocol.DOM.GetSearchResultsResponse | Protocol.DOM.MoveToResponse | Protocol.DOM.PerformSearchResponse | Protocol.DOM.PushNodeByPathToFrontendResponse | Protocol.DOM.PushNodesByBackendIdsToFrontendResponse | Protocol.DOM.QuerySelectorResponse | Protocol.DOM.QuerySelectorAllResponse | Protocol.DOM.RequestNodeResponse | Protocol.DOM.ResolveNodeResponse | Protocol.DOM.GetNodeStackTracesResponse | Protocol.DOM.GetFileInfoResponse | Protocol.DOM.SetNodeNameResponse | Protocol.DOM.GetFrameOwnerResponse | Protocol.DOM.GetContainerForNodeResponse | Protocol.DOM.GetQueryingDescendantsForContainerResponse | Protocol.DOMDebugger.GetEventListenersResponse | Protocol.DOMSnapshot.GetSnapshotResponse | Protocol.DOMSnapshot.CaptureSnapshotResponse | Protocol.DOMStorage.GetDOMStorageItemsResponse | Protocol.Database.ExecuteSQLResponse | Protocol.Database.GetDatabaseTableNamesResponse | Protocol.Emulation.CanEmulateResponse | Protocol.Emulation.SetVirtualTimePolicyResponse | Protocol.HeadlessExperimental.BeginFrameResponse | Protocol.IO.ReadResponse | Protocol.IO.ResolveBlobResponse | Protocol.IndexedDB.RequestDataResponse | Protocol.IndexedDB.GetMetadataResponse | Protocol.IndexedDB.RequestDatabaseResponse | Protocol.IndexedDB.RequestDatabaseNamesResponse | Protocol.LayerTree.CompositingReasonsResponse | Protocol.LayerTree.LoadSnapshotResponse | Protocol.LayerTree.MakeSnapshotResponse | Protocol.LayerTree.ProfileSnapshotResponse | Protocol.LayerTree.ReplaySnapshotResponse | Protocol.LayerTree.SnapshotCommandLogResponse | Protocol.Memory.GetDOMCountersResponse | Protocol.Memory.GetAllTimeSamplingProfileResponse | Protocol.Memory.GetBrowserSamplingProfileResponse | Protocol.Memory.GetSamplingProfileResponse | Protocol.Network.CanClearBrowserCacheResponse | Protocol.Network.CanClearBrowserCookiesResponse | Protocol.Network.CanEmulateNetworkConditionsResponse | Protocol.Network.GetAllCookiesResponse | Protocol.Network.GetCertificateResponse | Protocol.Network.GetCookiesResponse | Protocol.Network.GetResponseBodyResponse | Protocol.Network.GetRequestPostDataResponse | Protocol.Network.GetResponseBodyForInterceptionResponse | Protocol.Network.TakeResponseBodyForInterceptionAsStreamResponse | Protocol.Network.SearchInResponseBodyResponse | Protocol.Network.SetCookieResponse | Protocol.Network.GetSecurityIsolationStatusResponse | Protocol.Network.LoadNetworkResourceResponse | Protocol.Overlay.GetHighlightObjectForTestResponse | Protocol.Overlay.GetGridHighlightObjectsForTestResponse | Protocol.Overlay.GetSourceOrderHighlightObjectForTestResponse | Protocol.Page.AddScriptToEvaluateOnLoadResponse | Protocol.Page.AddScriptToEvaluateOnNewDocumentResponse | Protocol.Page.CaptureScreenshotResponse | Protocol.Page.CaptureSnapshotResponse | Protocol.Page.CreateIsolatedWorldResponse | Protocol.Page.GetAppManifestResponse | Protocol.Page.GetInstallabilityErrorsResponse | Protocol.Page.GetManifestIconsResponse | Protocol.Page.GetAppIdResponse | Protocol.Page.GetCookiesResponse | Protocol.Page.GetFrameTreeResponse | Protocol.Page.GetLayoutMetricsResponse | Protocol.Page.GetNavigationHistoryResponse | Protocol.Page.GetResourceContentResponse | Protocol.Page.GetResourceTreeResponse | Protocol.Page.NavigateResponse | Protocol.Page.PrintToPDFResponse | Protocol.Page.SearchInResourceResponse | Protocol.Page.GetPermissionsPolicyStateResponse | Protocol.Page.GetOriginTrialsResponse | Protocol.Performance.GetMetricsResponse | Protocol.Storage.GetStorageKeyForFrameResponse | Protocol.Storage.GetCookiesResponse | Protocol.Storage.GetUsageAndQuotaResponse | Protocol.Storage.GetTrustTokensResponse | Protocol.Storage.ClearTrustTokensResponse | Protocol.Storage.GetInterestGroupDetailsResponse | Protocol.SystemInfo.GetInfoResponse | Protocol.SystemInfo.GetProcessInfoResponse | Protocol.Target.AttachToTargetResponse | Protocol.Target.AttachToBrowserTargetResponse | Protocol.Target.CloseTargetResponse | Protocol.Target.CreateBrowserContextResponse | Protocol.Target.GetBrowserContextsResponse | Protocol.Target.CreateTargetResponse | Protocol.Target.GetTargetInfoResponse | Protocol.Target.GetTargetsResponse | Protocol.Tracing.GetCategoriesResponse | Protocol.Tracing.RequestMemoryDumpResponse | Protocol.Fetch.GetResponseBodyResponse | Protocol.Fetch.TakeResponseBodyAsStreamResponse | Protocol.WebAudio.GetRealtimeDataResponse | Protocol.WebAuthn.AddVirtualAuthenticatorResponse | Protocol.WebAuthn.GetCredentialResponse | Protocol.WebAuthn.GetCredentialsResponse;
result: void | Protocol.Debugger.EnableResponse | Protocol.Debugger.EvaluateOnCallFrameResponse | Protocol.Debugger.GetPossibleBreakpointsResponse | Protocol.Debugger.GetScriptSourceResponse | Protocol.Debugger.DisassembleWasmModuleResponse | Protocol.Debugger.NextWasmDisassemblyChunkResponse | Protocol.Debugger.GetWasmBytecodeResponse | Protocol.Debugger.GetStackTraceResponse | Protocol.Debugger.RestartFrameResponse | Protocol.Debugger.SearchInContentResponse | Protocol.Debugger.SetBreakpointResponse | Protocol.Debugger.SetInstrumentationBreakpointResponse | Protocol.Debugger.SetBreakpointByUrlResponse | Protocol.Debugger.SetBreakpointOnFunctionCallResponse | Protocol.Debugger.SetScriptSourceResponse | Protocol.HeapProfiler.GetHeapObjectIdResponse | Protocol.HeapProfiler.GetObjectByHeapObjectIdResponse | Protocol.HeapProfiler.GetSamplingProfileResponse | Protocol.HeapProfiler.StopSamplingResponse | Protocol.Profiler.GetBestEffortCoverageResponse | Protocol.Profiler.StartPreciseCoverageResponse | Protocol.Profiler.StopResponse | Protocol.Profiler.TakePreciseCoverageResponse | Protocol.Runtime.AwaitPromiseResponse | Protocol.Runtime.CallFunctionOnResponse | Protocol.Runtime.CompileScriptResponse | Protocol.Runtime.EvaluateResponse | Protocol.Runtime.GetIsolateIdResponse | Protocol.Runtime.GetHeapUsageResponse | Protocol.Runtime.GetPropertiesResponse | Protocol.Runtime.GlobalLexicalScopeNamesResponse | Protocol.Runtime.QueryObjectsResponse | Protocol.Runtime.RunScriptResponse | Protocol.Runtime.GetExceptionDetailsResponse | Protocol.Schema.GetDomainsResponse | Protocol.Accessibility.GetPartialAXTreeResponse | Protocol.Accessibility.GetFullAXTreeResponse | Protocol.Accessibility.GetRootAXNodeResponse | Protocol.Accessibility.GetAXNodeAndAncestorsResponse | Protocol.Accessibility.GetChildAXNodesResponse | Protocol.Accessibility.QueryAXTreeResponse | Protocol.Animation.GetCurrentTimeResponse | Protocol.Animation.GetPlaybackRateResponse | Protocol.Animation.ResolveAnimationResponse | Protocol.Audits.GetEncodedResponseResponse | Protocol.Browser.GetVersionResponse | Protocol.Browser.GetBrowserCommandLineResponse | Protocol.Browser.GetHistogramsResponse | Protocol.Browser.GetHistogramResponse | Protocol.Browser.GetWindowBoundsResponse | Protocol.Browser.GetWindowForTargetResponse | Protocol.CSS.AddRuleResponse | Protocol.CSS.CollectClassNamesResponse | Protocol.CSS.CreateStyleSheetResponse | Protocol.CSS.GetBackgroundColorsResponse | Protocol.CSS.GetComputedStyleForNodeResponse | Protocol.CSS.GetInlineStylesForNodeResponse | Protocol.CSS.GetMatchedStylesForNodeResponse | Protocol.CSS.GetMediaQueriesResponse | Protocol.CSS.GetPlatformFontsForNodeResponse | Protocol.CSS.GetStyleSheetTextResponse | Protocol.CSS.GetLayersForNodeResponse | Protocol.CSS.TakeComputedStyleUpdatesResponse | Protocol.CSS.SetKeyframeKeyResponse | Protocol.CSS.SetMediaTextResponse | Protocol.CSS.SetContainerQueryTextResponse | Protocol.CSS.SetSupportsTextResponse | Protocol.CSS.SetScopeTextResponse | Protocol.CSS.SetRuleSelectorResponse | Protocol.CSS.SetStyleSheetTextResponse | Protocol.CSS.SetStyleTextsResponse | Protocol.CSS.StopRuleUsageTrackingResponse | Protocol.CSS.TakeCoverageDeltaResponse | Protocol.CacheStorage.RequestCacheNamesResponse | Protocol.CacheStorage.RequestCachedResponseResponse | Protocol.CacheStorage.RequestEntriesResponse | Protocol.DOM.CollectClassNamesFromSubtreeResponse | Protocol.DOM.CopyToResponse | Protocol.DOM.DescribeNodeResponse | Protocol.DOM.GetAttributesResponse | Protocol.DOM.GetBoxModelResponse | Protocol.DOM.GetContentQuadsResponse | Protocol.DOM.GetDocumentResponse | Protocol.DOM.GetFlattenedDocumentResponse | Protocol.DOM.GetNodesForSubtreeByStyleResponse | Protocol.DOM.GetNodeForLocationResponse | Protocol.DOM.GetOuterHTMLResponse | Protocol.DOM.GetRelayoutBoundaryResponse | Protocol.DOM.GetSearchResultsResponse | Protocol.DOM.MoveToResponse | Protocol.DOM.PerformSearchResponse | Protocol.DOM.PushNodeByPathToFrontendResponse | Protocol.DOM.PushNodesByBackendIdsToFrontendResponse | Protocol.DOM.QuerySelectorResponse | Protocol.DOM.QuerySelectorAllResponse | Protocol.DOM.GetTopLayerElementsResponse | Protocol.DOM.RequestNodeResponse | Protocol.DOM.ResolveNodeResponse | Protocol.DOM.GetNodeStackTracesResponse | Protocol.DOM.GetFileInfoResponse | Protocol.DOM.SetNodeNameResponse | Protocol.DOM.GetFrameOwnerResponse | Protocol.DOM.GetContainerForNodeResponse | Protocol.DOM.GetQueryingDescendantsForContainerResponse | Protocol.DOMDebugger.GetEventListenersResponse | Protocol.DOMSnapshot.GetSnapshotResponse | Protocol.DOMSnapshot.CaptureSnapshotResponse | Protocol.DOMStorage.GetDOMStorageItemsResponse | Protocol.Database.ExecuteSQLResponse | Protocol.Database.GetDatabaseTableNamesResponse | Protocol.Emulation.CanEmulateResponse | Protocol.Emulation.SetVirtualTimePolicyResponse | Protocol.HeadlessExperimental.BeginFrameResponse | Protocol.IO.ReadResponse | Protocol.IO.ResolveBlobResponse | Protocol.IndexedDB.RequestDataResponse | Protocol.IndexedDB.GetMetadataResponse | Protocol.IndexedDB.RequestDatabaseResponse | Protocol.IndexedDB.RequestDatabaseNamesResponse | Protocol.LayerTree.CompositingReasonsResponse | Protocol.LayerTree.LoadSnapshotResponse | Protocol.LayerTree.MakeSnapshotResponse | Protocol.LayerTree.ProfileSnapshotResponse | Protocol.LayerTree.ReplaySnapshotResponse | Protocol.LayerTree.SnapshotCommandLogResponse | Protocol.Memory.GetDOMCountersResponse | Protocol.Memory.GetAllTimeSamplingProfileResponse | Protocol.Memory.GetBrowserSamplingProfileResponse | Protocol.Memory.GetSamplingProfileResponse | Protocol.Network.CanClearBrowserCacheResponse | Protocol.Network.CanClearBrowserCookiesResponse | Protocol.Network.CanEmulateNetworkConditionsResponse | Protocol.Network.GetAllCookiesResponse | Protocol.Network.GetCertificateResponse | Protocol.Network.GetCookiesResponse | Protocol.Network.GetResponseBodyResponse | Protocol.Network.GetRequestPostDataResponse | Protocol.Network.GetResponseBodyForInterceptionResponse | Protocol.Network.TakeResponseBodyForInterceptionAsStreamResponse | Protocol.Network.SearchInResponseBodyResponse | Protocol.Network.SetCookieResponse | Protocol.Network.GetSecurityIsolationStatusResponse | Protocol.Network.LoadNetworkResourceResponse | Protocol.Overlay.GetHighlightObjectForTestResponse | Protocol.Overlay.GetGridHighlightObjectsForTestResponse | Protocol.Overlay.GetSourceOrderHighlightObjectForTestResponse | Protocol.Page.AddScriptToEvaluateOnLoadResponse | Protocol.Page.AddScriptToEvaluateOnNewDocumentResponse | Protocol.Page.CaptureScreenshotResponse | Protocol.Page.CaptureSnapshotResponse | Protocol.Page.CreateIsolatedWorldResponse | Protocol.Page.GetAppManifestResponse | Protocol.Page.GetInstallabilityErrorsResponse | Protocol.Page.GetManifestIconsResponse | Protocol.Page.GetAppIdResponse | Protocol.Page.GetAdScriptIdResponse | Protocol.Page.GetCookiesResponse | Protocol.Page.GetFrameTreeResponse | Protocol.Page.GetLayoutMetricsResponse | Protocol.Page.GetNavigationHistoryResponse | Protocol.Page.GetResourceContentResponse | Protocol.Page.GetResourceTreeResponse | Protocol.Page.NavigateResponse | Protocol.Page.PrintToPDFResponse | Protocol.Page.SearchInResourceResponse | Protocol.Page.GetPermissionsPolicyStateResponse | Protocol.Page.GetOriginTrialsResponse | Protocol.Performance.GetMetricsResponse | Protocol.Storage.GetStorageKeyForFrameResponse | Protocol.Storage.GetCookiesResponse | Protocol.Storage.GetUsageAndQuotaResponse | Protocol.Storage.GetTrustTokensResponse | Protocol.Storage.ClearTrustTokensResponse | Protocol.Storage.GetInterestGroupDetailsResponse | Protocol.Storage.GetSharedStorageMetadataResponse | Protocol.Storage.GetSharedStorageEntriesResponse | Protocol.SystemInfo.GetInfoResponse | Protocol.SystemInfo.GetFeatureStateResponse | Protocol.SystemInfo.GetProcessInfoResponse | Protocol.Target.AttachToTargetResponse | Protocol.Target.AttachToBrowserTargetResponse | Protocol.Target.CloseTargetResponse | Protocol.Target.CreateBrowserContextResponse | Protocol.Target.GetBrowserContextsResponse | Protocol.Target.CreateTargetResponse | Protocol.Target.GetTargetInfoResponse | Protocol.Target.GetTargetsResponse | Protocol.Tracing.GetCategoriesResponse | Protocol.Tracing.RequestMemoryDumpResponse | Protocol.Fetch.GetResponseBodyResponse | Protocol.Fetch.TakeResponseBodyAsStreamResponse | Protocol.WebAudio.GetRealtimeDataResponse | Protocol.WebAuthn.AddVirtualAuthenticatorResponse | Protocol.WebAuthn.GetCredentialResponse | Protocol.WebAuthn.GetCredentialsResponse;
cdpSession: any;

@@ -42,0 +44,0 @@ }>;

@@ -25,18 +25,17 @@ "use strict";

/**
* `BrowsingContextProcessor` is responsible for creating and destroying all
* the targets and browsing contexts. This method is called for each CDP
* session.
* This method is called for each CDP session, since this class is responsible
* for creating and destroying all targets and browsing contexts.
*/
#setEventListeners(cdpClient) {
cdpClient.on('Target.attachedToTarget', async (params) => {
await this.#handleAttachedToTargetEvent(params, cdpClient);
cdpClient.on('Target.attachedToTarget', (params) => {
this.#handleAttachedToTargetEvent(params, cdpClient);
});
cdpClient.on('Target.detachedFromTarget', async (params) => {
await this.#handleDetachedFromTargetEvent(params);
cdpClient.on('Target.detachedFromTarget', (params) => {
this.#handleDetachedFromTargetEvent(params);
});
cdpClient.on('Page.frameAttached', async (params) => {
await this.#handleFrameAttachedEvent(params);
cdpClient.on('Page.frameAttached', (params) => {
this.#handleFrameAttachedEvent(params);
});
cdpClient.on('Page.frameDetached', async (params) => {
await this.#handleFrameDetachedEvent(params);
cdpClient.on('Page.frameDetached', (params) => {
this.#handleFrameDetachedEvent(params);
});

@@ -48,6 +47,6 @@ }

// "parentFrameId": "722BB0526C73B067A479BED6D0DB1156" } }
async #handleFrameAttachedEvent(params) {
#handleFrameAttachedEvent(params) {
const parentBrowsingContext = this.#browsingContextStorage.findContext(params.parentFrameId);
if (parentBrowsingContext !== undefined) {
await browsingContextImpl_js_1.BrowsingContextImpl.create(parentBrowsingContext.cdpTarget, this.#realmStorage, params.frameId, params.parentFrameId, this.#eventManager, this.#browsingContextStorage, this.#logger);
browsingContextImpl_js_1.BrowsingContextImpl.create(parentBrowsingContext.cdpTarget, this.#realmStorage, params.frameId, params.parentFrameId, this.#eventManager, this.#browsingContextStorage, this.#logger);
}

@@ -59,3 +58,3 @@ }

// "reason": "swap" } }
async #handleFrameDetachedEvent(params) {
#handleFrameDetachedEvent(params) {
// In case of OOPiF no need in deleting BrowsingContext.

@@ -65,3 +64,3 @@ if (params.reason === 'swap') {

}
await this.#browsingContextStorage.findContext(params.frameId)?.delete();
this.#browsingContextStorage.findContext(params.frameId)?.delete();
}

@@ -80,9 +79,11 @@ // { "method": "Target.attachedToTarget",

// "waitingForDebugger": false } }
async #handleAttachedToTargetEvent(params, parentSessionCdpClient) {
#handleAttachedToTargetEvent(params, parentSessionCdpClient) {
const { sessionId, targetInfo } = params;
const targetCdpClient = this.#cdpConnection.getCdpClient(sessionId);
if (!this.#isValidTarget(targetInfo)) {
// DevTools or some other not supported by BiDi target.
await targetCdpClient.sendCommand('Runtime.runIfWaitingForDebugger');
await parentSessionCdpClient.sendCommand('Target.detachFromTarget', params);
// DevTools or some other not supported by BiDi target. Just release
// debugger and ignore them.
void targetCdpClient
.sendCommand('Runtime.runIfWaitingForDebugger')
.then(() => parentSessionCdpClient.sendCommand('Target.detachFromTarget', params));
return;

@@ -93,10 +94,10 @@ }

const cdpTarget = cdpTarget_js_1.CdpTarget.create(targetInfo.targetId, targetCdpClient, sessionId, this.#realmStorage, this.#eventManager);
if (this.#browsingContextStorage.hasKnownContext(targetInfo.targetId)) {
if (this.#browsingContextStorage.hasContext(targetInfo.targetId)) {
// OOPiF.
this.#browsingContextStorage
.getKnownContext(targetInfo.targetId)
.getContext(targetInfo.targetId)
.updateCdpTarget(cdpTarget);
}
else {
await browsingContextImpl_js_1.BrowsingContextImpl.create(cdpTarget, this.#realmStorage, targetInfo.targetId, null, this.#eventManager, this.#browsingContextStorage, this.#logger);
browsingContextImpl_js_1.BrowsingContextImpl.create(cdpTarget, this.#realmStorage, targetInfo.targetId, null, this.#eventManager, this.#browsingContextStorage, this.#logger);
}

@@ -108,3 +109,3 @@ }

// "targetId": "19416886405CBA4E03DBB59FA67FF4E8" } }
async #handleDetachedFromTargetEvent(params) {
#handleDetachedFromTargetEvent(params) {
// TODO: params.targetId is deprecated. Update this class to track using

@@ -114,8 +115,17 @@ // params.sessionId instead.

const contextId = params.targetId;
await this.#browsingContextStorage.findContext(contextId)?.delete();
this.#browsingContextStorage.findContext(contextId)?.delete();
}
async #getRealm(target) {
if ('realm' in target) {
return this.#realmStorage.getRealm({
realmId: target.realm,
});
}
const context = this.#browsingContextStorage.getContext(target.context);
return context.getOrCreateSandbox(target.sandbox);
}
process_browsingContext_getTree(params) {
const resultContexts = params.root === undefined
? this.#browsingContextStorage.getTopLevelContexts()
: [this.#browsingContextStorage.getKnownContext(params.root)];
: [this.#browsingContextStorage.getContext(params.root)];
return {

@@ -131,4 +141,4 @@ result: {

if (params.referenceContext !== undefined) {
referenceContext = this.#browsingContextStorage.getKnownContext(params.referenceContext);
if (referenceContext.parentId !== null) {
referenceContext = this.#browsingContextStorage.getContext(params.referenceContext);
if (!referenceContext.isTopLevelContext()) {
throw new protocol_js_1.Message.InvalidArgumentException(`referenceContext should be a top-level context`);

@@ -147,3 +157,3 @@ }

const contextId = result.targetId;
const context = this.#browsingContextStorage.getKnownContext(contextId);
const context = this.#browsingContextStorage.getContext(contextId);
await context.awaitLoaded();

@@ -154,23 +164,36 @@ return {

}
async process_browsingContext_navigate(params) {
const context = this.#browsingContextStorage.getKnownContext(params.context);
process_browsingContext_navigate(params) {
const context = this.#browsingContextStorage.getContext(params.context);
return context.navigate(params.url, params.wait === undefined ? 'none' : params.wait);
}
async process_browsingContext_captureScreenshot(params) {
const context = this.#browsingContextStorage.getKnownContext(params.context);
const context = this.#browsingContextStorage.getContext(params.context);
return context.captureScreenshot();
}
async process_browsingContext_print(params) {
const context = this.#browsingContextStorage.getKnownContext(params.context);
const context = this.#browsingContextStorage.getContext(params.context);
return context.print(params);
}
async #getRealm(target) {
if ('realm' in target) {
return this.#realmStorage.getRealm({
realmId: target.realm,
});
async process_script_addPreloadScript(params) {
const contexts = [];
const scripts = [];
if (params.context) {
// TODO(#293): Handle edge case with OOPiF. Whenever a frame is moved out
// of process, we have to add those scripts as well.
contexts.push(this.#browsingContextStorage.getContext(params.context));
}
const context = this.#browsingContextStorage.getKnownContext(target.context);
return context.getOrCreateSandbox(target.sandbox);
else {
// Add all contexts.
// TODO(#293): Add preload scripts to all new browsing contexts as well.
contexts.push(...this.#browsingContextStorage.getAllContexts());
}
scripts.push(...(await Promise.all(contexts.map((context) => context.addPreloadScript(params)))));
// TODO(#293): What to return whenever there are multiple contexts?
return scripts[0];
}
// eslint-disable-next-line @typescript-eslint/require-await
async process_script_removePreloadScript(_params) {
throw new protocol_js_1.Message.UnknownErrorException('Not implemented.');
return {};
}
async process_script_evaluate(params) {

@@ -183,3 +206,3 @@ const realm = await this.#getRealm(params.target);

// Make sure the context is known.
this.#browsingContextStorage.getKnownContext(params.context);
this.#browsingContextStorage.getContext(params.context);
}

@@ -209,5 +232,5 @@ const realms = this.#realmStorage

const browserCdpClient = this.#cdpConnection.browserClient();
const context = this.#browsingContextStorage.getKnownContext(commandParams.context);
if (context.parentId !== null) {
throw new protocol_js_1.Message.InvalidArgumentException('Not a top-level browsing context cannot be closed.');
const context = this.#browsingContextStorage.getContext(commandParams.context);
if (!context.isTopLevelContext()) {
throw new protocol_js_1.Message.InvalidArgumentException('A top-level browsing context cannot be closed.');
}

@@ -223,5 +246,3 @@ const detachedFromTargetPromise = new Promise((resolve) => {

});
await this.#cdpConnection
.browserClient()
.sendCommand('Target.closeTarget', {
await browserCdpClient.sendCommand('Target.closeTarget', {
targetId: commandParams.context,

@@ -253,4 +274,3 @@ });

const context = params.context;
const sessionId = this.#browsingContextStorage.getKnownContext(context).cdpTarget
.cdpSessionId;
const sessionId = this.#browsingContextStorage.getContext(context).cdpTarget.cdpSessionId;
if (sessionId === undefined) {

@@ -257,0 +277,0 @@ return { result: { cdpSession: null } };

@@ -17,12 +17,23 @@ /**

*/
import { CommonDataTypes } from '../../../protocol/protocol.js';
import { BrowsingContextImpl } from './browsingContextImpl.js';
/** Container class for browsing contexts. */
export declare class BrowsingContextStorage {
#private;
/** Gets all top-level contexts, i.e. those with no parent. */
getTopLevelContexts(): BrowsingContextImpl[];
/** Gets all contexts. */
getAllContexts(): BrowsingContextImpl[];
removeContext(contextId: string): void;
/** Deletes the context with the given ID. */
deleteContext(contextId: CommonDataTypes.BrowsingContext): void;
/** Adds the given context. */
addContext(context: BrowsingContextImpl): void;
hasKnownContext(contextId: string): boolean;
findContext(contextId: string): BrowsingContextImpl | undefined;
getKnownContext(contextId: string): BrowsingContextImpl;
/** Returns true whether there is an existing context with the given ID. */
hasContext(contextId: CommonDataTypes.BrowsingContext): boolean;
/** Gets the context with the given ID, if any. */
findContext(contextId: CommonDataTypes.BrowsingContext): BrowsingContextImpl | undefined;
/** Returns the top-level context ID of the given context, if any. */
findTopLevelContextId(contextId: CommonDataTypes.BrowsingContext | null): CommonDataTypes.BrowsingContext | null;
/** Gets the context with the given ID, if any, otherwise throws. */
getContext(contextId: CommonDataTypes.BrowsingContext): BrowsingContextImpl;
}

@@ -21,26 +21,47 @@ "use strict";

const protocol_js_1 = require("../../../protocol/protocol.js");
/** Container class for browsing contexts. */
class BrowsingContextStorage {
/** Map from context ID to context implementation. */
#contexts = new Map();
/** Gets all top-level contexts, i.e. those with no parent. */
getTopLevelContexts() {
return Array.from(this.#contexts.values()).filter((c) => c.parentId === null);
return this.getAllContexts().filter((c) => c.isTopLevelContext());
}
/** Gets all contexts. */
getAllContexts() {
return Array.from(this.#contexts.values());
}
removeContext(contextId) {
/** Deletes the context with the given ID. */
deleteContext(contextId) {
this.#contexts.delete(contextId);
}
/** Adds the given context. */
addContext(context) {
this.#contexts.set(context.contextId, context);
if (context.parentId !== null) {
this.getKnownContext(context.parentId).addChild(context);
if (!context.isTopLevelContext()) {
this.getContext(context.parentId).addChild(context);
}
}
hasKnownContext(contextId) {
/** Returns true whether there is an existing context with the given ID. */
hasContext(contextId) {
return this.#contexts.has(contextId);
}
/** Gets the context with the given ID, if any. */
findContext(contextId) {
return this.#contexts.get(contextId);
}
getKnownContext(contextId) {
/** Returns the top-level context ID of the given context, if any. */
findTopLevelContextId(contextId) {
if (contextId === null) {
return null;
}
const maybeContext = this.findContext(contextId);
const parentId = maybeContext?.parentId ?? null;
if (parentId === null) {
return contextId;
}
return this.findTopLevelContextId(parentId);
}
/** Gets the context with the given ID, if any, otherwise throws. */
getContext(contextId) {
const result = this.findContext(contextId);

@@ -47,0 +68,0 @@ if (result === undefined) {

@@ -99,3 +99,3 @@ "use strict";

#setEventListeners() {
this.#cdpClient.on('*', async (method, params) => {
this.#cdpClient.on('*', (method, params) => {
this.#eventManager.registerEvent({

@@ -102,0 +102,0 @@ method: protocol_1.CDP.EventNames.EventReceivedEvent,

@@ -17,3 +17,3 @@ /**

*/
import type { CommonDataTypes, Message, Session } from '../../../protocol/protocol.js';
import { CommonDataTypes, Message, Session } from '../../../protocol/protocol.js';
import type { BidiServer } from '../../BidiServer.js';

@@ -24,3 +24,3 @@ export interface IEventManager {

subscribe(events: Session.SubscribeParametersEvent[], contextIds: (CommonDataTypes.BrowsingContext | null)[], channel: string | null): Promise<void>;
unsubscribe(events: Session.SubscribeParametersEvent[], contextIds: (CommonDataTypes.BrowsingContext | null)[], channel: string | null): Promise<void>;
unsubscribe(events: Session.SubscribeParametersEvent[], contextIds: (CommonDataTypes.BrowsingContext | null)[], channel: string | null): Promise<void> | void;
get isNetworkDomainEnabled(): boolean;

@@ -35,3 +35,3 @@ }

subscribe(eventNames: Session.SubscribeParametersEvent[], contextIds: (CommonDataTypes.BrowsingContext | null)[], channel: string | null): Promise<void>;
unsubscribe(eventNames: Session.SubscribeParametersEvent[], contextIds: (CommonDataTypes.BrowsingContext | null)[], channel: string | null): Promise<void>;
unsubscribe(eventNames: Session.SubscribeParametersEvent[], contextIds: (CommonDataTypes.BrowsingContext | null)[], channel: string | null): void;
}

@@ -20,5 +20,7 @@ "use strict";

exports.EventManager = void 0;
const protocol_js_1 = require("../../../protocol/protocol.js");
const buffer_js_1 = require("../../../utils/buffer.js");
const idWrapper_js_1 = require("../../../utils/idWrapper.js");
const OutgoingBidiMessage_js_1 = require("../../OutgoingBidiMessage.js");
const DefaultMap_js_1 = require("../../../utils/DefaultMap.js");
const SubscriptionManager_js_1 = require("./SubscriptionManager.js");

@@ -48,3 +50,3 @@ class EventWrapper {

const eventBufferLength = new Map([
['log.entryAdded', 100],
[protocol_js_1.Log.EventNames.LogEntryAddedEvent, 100],
]);

@@ -58,3 +60,3 @@ class EventManager {

*/
#eventToContextsMap = new Map();
#eventToContextsMap = new DefaultMap_js_1.DefaultMap(() => new Set());
/**

@@ -106,3 +108,3 @@ * Maps `eventName` + `browsingContext` to buffer. Used to get buffered events

// Assert the context is known. Throw exception otherwise.
this.#bidiServer.getBrowsingContextStorage().getKnownContext(contextId);
this.#bidiServer.getBrowsingContextStorage().getContext(contextId);
}

@@ -140,3 +142,3 @@ }

.getBrowsingContextStorage()
.getKnownContext(contextId)
.getContext(contextId)
.cdpTarget.enableNetworkDomain();

@@ -146,3 +148,3 @@ }

}
async unsubscribe(eventNames, contextIds, channel) {
unsubscribe(eventNames, contextIds, channel) {
this.#subscriptionManager.unsubscribeAll(eventNames, contextIds, channel);

@@ -164,5 +166,2 @@ }

// Add the context to the list of contexts having `eventName` events.
if (!this.#eventToContextsMap.has(eventName)) {
this.#eventToContextsMap.set(eventName, new Set());
}
this.#eventToContextsMap.get(eventName).add(eventWrapper.contextId);

@@ -194,3 +193,3 @@ }

// For global subscriptions, events buffered in each context should be sent back.
Array.from(this.#eventToContextsMap.get(eventName)?.keys() ?? [])
Array.from(this.#eventToContextsMap.get(eventName).keys())
.filter((_contextId) =>

@@ -200,5 +199,3 @@ // Events without context are already in the result.

// Events from deleted contexts should not be sent.
this.#bidiServer
.getBrowsingContextStorage()
.hasKnownContext(_contextId))
this.#bidiServer.getBrowsingContextStorage().hasContext(_contextId))
.map((_contextId) => this.#getBufferedEvents(eventName, _contextId, channel))

@@ -205,0 +202,0 @@ .forEach((events) => result.push(...events));

@@ -21,3 +21,2 @@ "use strict";

const protocol_js_1 = require("../../../protocol/protocol.js");
var InvalidArgumentException = protocol_js_1.Message.InvalidArgumentException;
/**

@@ -87,3 +86,3 @@ * Returns the cartesian product of the given arrays.

}
const maybeTopLevelContextId = this.#findTopLevelContextId(contextId);
const maybeTopLevelContextId = this.#browsingContextStorage.findTopLevelContextId(contextId);
// `null` covers global subscription.

@@ -102,16 +101,5 @@ const relevantContexts = [...new Set([null, maybeTopLevelContextId])];

}
#findTopLevelContextId(contextId) {
if (contextId === null) {
return null;
}
const maybeContext = this.#browsingContextStorage.findContext(contextId);
const parentId = maybeContext?.parentId ?? null;
if (parentId !== null) {
return this.#findTopLevelContextId(parentId);
}
return contextId;
}
subscribe(event, contextId, channel) {
// All the subscriptions are handled on the top-level contexts.
contextId = this.#findTopLevelContextId(contextId);
contextId = this.#browsingContextStorage.findTopLevelContextId(contextId);
if (event === protocol_js_1.BrowsingContext.AllEvents) {

@@ -158,3 +146,3 @@ Object.values(protocol_js_1.BrowsingContext.EventNames).map((specificEvent) => this.subscribe(specificEvent, contextId, channel));

if (contextId !== null) {
this.#browsingContextStorage.getKnownContext(contextId);
this.#browsingContextStorage.getContext(contextId);
}

@@ -178,13 +166,13 @@ }

// All the subscriptions are handled on the top-level contexts.
contextId = this.#findTopLevelContextId(contextId);
contextId = this.#browsingContextStorage.findTopLevelContextId(contextId);
if (!this.#channelToContextToEventMap.has(channel)) {
throw new InvalidArgumentException(`Cannot unsubscribe from ${event}, ${contextId}. No subscription found.`);
throw new protocol_js_1.Message.InvalidArgumentException(`Cannot unsubscribe from ${event}, ${contextId === null ? 'null' : contextId}. No subscription found.`);
}
const contextToEventMap = this.#channelToContextToEventMap.get(channel);
if (!contextToEventMap.has(contextId)) {
throw new InvalidArgumentException(`Cannot unsubscribe from ${event}, ${contextId}. No subscription found.`);
throw new protocol_js_1.Message.InvalidArgumentException(`Cannot unsubscribe from ${event}, ${contextId === null ? 'null' : contextId}. No subscription found.`);
}
const eventMap = contextToEventMap.get(contextId);
if (!eventMap.has(event)) {
throw new InvalidArgumentException(`Cannot unsubscribe from ${event}, ${contextId}. No subscription found.`);
throw new protocol_js_1.Message.InvalidArgumentException(`Cannot unsubscribe from ${event}, ${contextId === null ? 'null' : contextId}. No subscription found.`);
}

@@ -191,0 +179,0 @@ return () => {

@@ -61,12 +61,18 @@ "use strict";

const browsingContextStorage = sinon.createStubInstance(browsingContextStorage_js_1.BrowsingContextStorage);
browsingContextStorage.findContext = sinon
browsingContextStorage.findTopLevelContextId = sinon
.stub()
.callsFake((contextId) => {
if (contextId === SOME_NESTED_CONTEXT) {
return { parentId: SOME_CONTEXT };
return SOME_CONTEXT;
}
if (contextId === SOME_CONTEXT) {
return SOME_CONTEXT;
}
if (contextId === ANOTHER_NESTED_CONTEXT) {
return { parentId: ANOTHER_CONTEXT };
return ANOTHER_CONTEXT;
}
return { parentId: null };
if (contextId === ANOTHER_CONTEXT) {
return ANOTHER_CONTEXT;
}
return null;
});

@@ -261,2 +267,3 @@ subscriptionManager = new SubscriptionManager_js_1.SubscriptionManager(browsingContextStorage);

protocol_js_1.Network.EventNames.ResponseCompletedEvent,
protocol_js_1.Network.EventNames.FetchErrorEvent,
]);

@@ -263,0 +270,0 @@ });

@@ -125,3 +125,3 @@ "use strict";

if (arg.type === 'array') {
return `[${arg.value?.map((val) => toJson(val)).join(',')}]`;
return `[${arg.value?.map((val) => toJson(val)).join(',') ?? ''}]`;
}

@@ -141,9 +141,9 @@ throw Error(`Invalid value type: ${arg.toString()}`);

case 'regexp':
return `/${arg.value.pattern}/${arg.value.flags}`;
return `/${arg.value.pattern}/${arg.value.flags ?? ''}`;
case 'date':
return new Date(arg.value).toString();
case 'object':
return `Object(${arg.value?.length})`;
return `Object(${arg.value?.length ?? ''})`;
case 'array':
return `Array(${arg.value?.length})`;
return `Array(${arg.value?.length ?? ''})`;
case 'map':

@@ -170,3 +170,3 @@ return `Map(${arg.value.length})`;

}
// if args[0] is not a format specifier, just join the args with \u0020
// if args[0] is not a format specifier, just join the args with \u0020 (unicode 'SPACE')
return args

@@ -173,0 +173,0 @@ .map((arg) => {

@@ -6,3 +6,3 @@ "use strict";

const logHelper_js_1 = require("./logHelper.js");
/** Converts CDP StackTrace object to Bidi StackTrace object. */
/** Converts CDP StackTrace object to BiDi StackTrace object. */
function getBidiStackTrace(cdpStackTrace) {

@@ -9,0 +9,0 @@ const stackFrames = cdpStackTrace?.callFrames.map((callFrame) => {

@@ -20,2 +20,3 @@ "use strict";

exports.NetworkProcessor = void 0;
const DefaultMap_1 = require("../../../utils/DefaultMap");
const networkRequest_1 = require("./networkRequest");

@@ -28,5 +29,6 @@ class NetworkProcessor {

*/
#requestMap = new Map();
#requestMap;
constructor(eventManager) {
this.#eventManager = eventManager;
this.#requestMap = new DefaultMap_1.DefaultMap((requestId) => new networkRequest_1.NetworkRequest(requestId, this.#eventManager));
}

@@ -55,2 +57,7 @@ static async create(cdpClient, eventManager) {

});
cdpClient.on('Network.loadingFailed', (params) => {
networkProcessor
.#getOrCreateNetworkRequest(params.requestId)
.onLoadingFailedEvent(params);
});
await cdpClient.sendCommand('Network.enable');

@@ -60,6 +67,2 @@ return networkProcessor;

#getOrCreateNetworkRequest(requestId) {
if (!this.#requestMap.has(requestId)) {
const networkRequest = new networkRequest_1.NetworkRequest(requestId, this.#eventManager);
this.#requestMap.set(requestId, networkRequest);
}
return this.#requestMap.get(requestId);

@@ -66,0 +69,0 @@ }

@@ -15,2 +15,3 @@ /**

onResponseReceivedEventExtraInfo(responseReceivedExtraInfoEvent: Protocol.Network.ResponseReceivedExtraInfoEvent): void;
onLoadingFailedEvent(loadingFailedEvent: Protocol.Network.LoadingFailedEvent): void;
}

@@ -24,2 +24,3 @@ "use strict";

class NetworkRequest {
static #unknown = 'UNKNOWN';
requestId;

@@ -77,2 +78,14 @@ #eventManager;

}
onLoadingFailedEvent(loadingFailedEvent) {
this.#beforeRequestSentDeferred.resolve();
this.#responseReceivedDeferred.reject(loadingFailedEvent);
const params = {
...this.#getBaseEventParams(),
errorText: loadingFailedEvent.errorText,
};
this.#eventManager.registerEvent({
method: protocol_1.Network.EventNames.FetchErrorEvent,
params,
}, this.#requestWillBeSentEvent?.frameId ?? null);
}
#sendBeforeRequestEvent() {

@@ -87,18 +100,4 @@ if (!this.#isIgnoredEvent()) {

}
if (this.#requestWillBeSentExtraInfoEvent === undefined) {
throw new Error('RequestWillBeSentExtraInfoEvent is not set');
}
const requestWillBeSentEvent = this.#requestWillBeSentEvent;
const requestWillBeSentExtraInfoEvent = this.#requestWillBeSentExtraInfoEvent;
const baseEventParams = {
context: requestWillBeSentEvent.frameId ?? null,
navigation: requestWillBeSentEvent.loaderId,
// TODO: implement.
redirectCount: 0,
request: this.#getRequestData(requestWillBeSentEvent, requestWillBeSentExtraInfoEvent),
// Timestamp should be in milliseconds, while CDP provides it in seconds.
timestamp: Math.round(requestWillBeSentEvent.wallTime * 1000),
};
const params = {
...baseEventParams,
...this.#getBaseEventParams(),
initiator: { type: this.#getInitiatorType() },

@@ -111,12 +110,26 @@ };

}
#getRequestData(requestWillBeSentEvent, requestWillBeSentExtraInfoEvent) {
#getBaseEventParams() {
return {
request: requestWillBeSentEvent.requestId,
url: requestWillBeSentEvent.request.url,
method: requestWillBeSentEvent.request.method,
headers: Object.keys(requestWillBeSentEvent.request.headers).map((key) => ({
context: this.#requestWillBeSentEvent?.frameId ?? null,
navigation: this.#requestWillBeSentEvent?.loaderId ?? null,
// TODO: implement.
redirectCount: 0,
request: this.#getRequestData(),
// Timestamp should be in milliseconds, while CDP provides it in seconds.
timestamp: Math.round((this.#requestWillBeSentEvent?.wallTime ?? 0) * 1000),
};
}
#getRequestData() {
const cookies = this.#requestWillBeSentExtraInfoEvent === undefined
? []
: NetworkRequest.#getCookies(this.#requestWillBeSentExtraInfoEvent.associatedCookies);
return {
request: this.#requestWillBeSentEvent?.requestId ?? NetworkRequest.#unknown,
url: this.#requestWillBeSentEvent?.request.url ?? NetworkRequest.#unknown,
method: this.#requestWillBeSentEvent?.request.method ?? NetworkRequest.#unknown,
headers: Object.keys(this.#requestWillBeSentEvent?.request.headers ?? []).map((key) => ({
name: key,
value: requestWillBeSentEvent.request.headers[key],
value: this.#requestWillBeSentEvent?.request.headers[key],
})),
cookies: NetworkRequest.#getCookies(requestWillBeSentExtraInfoEvent.associatedCookies),
cookies,
// TODO: implement.

@@ -163,3 +176,3 @@ headersSize: -1,

case 'preflight':
return this.#requestWillBeSentEvent?.initiator.type;
return this.#requestWillBeSentEvent.initiator.type;
default:

@@ -204,44 +217,22 @@ return 'other';

}
if (this.#responseReceivedExtraInfoEvent === undefined) {
throw new Error('ResponseReceivedExtraInfoEvent is not set');
}
if (this.#requestWillBeSentEvent === undefined) {
throw new Error('RequestWillBeSentEvent is not set');
}
if (this.#requestWillBeSentExtraInfoEvent === undefined) {
throw new Error('RequestWillBeSentExtraInfoEvent is not set');
}
const requestWillBeSentEvent = this.#requestWillBeSentEvent;
const requestWillBeSentExtraInfoEvent = this.#requestWillBeSentExtraInfoEvent;
const responseReceivedEvent = this.#responseReceivedEvent;
const responseReceivedExtraInfoEvent = this.#responseReceivedExtraInfoEvent;
const baseEventParams = {
context: responseReceivedEvent.frameId ?? null,
navigation: responseReceivedEvent.loaderId,
// TODO: implement.
redirectCount: 0,
request: this.#getRequestData(requestWillBeSentEvent, requestWillBeSentExtraInfoEvent),
// Timestamp normalized to wall time using `RequestWillBeSent` event as a
// baseline.
timestamp: Math.round(requestWillBeSentEvent.wallTime * 1000 -
requestWillBeSentEvent.timestamp +
responseReceivedEvent.timestamp),
};
return {
method: protocol_1.Network.EventNames.ResponseCompletedEvent,
params: {
...baseEventParams,
...this.#getBaseEventParams(),
response: {
url: responseReceivedEvent.response.url,
protocol: responseReceivedEvent.response.protocol,
status: responseReceivedEvent.response.status,
statusText: responseReceivedEvent.response.statusText,
url: this.#responseReceivedEvent.response.url,
protocol: this.#responseReceivedEvent.response.protocol,
status: this.#responseReceivedEvent.response.status,
statusText: this.#responseReceivedEvent.response.statusText,
// Check if this is correct.
fromCache: responseReceivedEvent.response.fromDiskCache ||
responseReceivedEvent.response.fromPrefetchCache,
fromCache: this.#responseReceivedEvent.response.fromDiskCache ||
this.#responseReceivedEvent.response.fromPrefetchCache,
// TODO: implement.
headers: this.#getHeaders(responseReceivedEvent.response.headers),
mimeType: responseReceivedEvent.response.mimeType,
bytesReceived: responseReceivedEvent.response.encodedDataLength,
headersSize: responseReceivedExtraInfoEvent.headersText?.length ?? -1,
headers: this.#getHeaders(this.#responseReceivedEvent.response.headers),
mimeType: this.#responseReceivedEvent.response.mimeType,
bytesReceived: this.#responseReceivedEvent.response.encodedDataLength,
headersSize: this.#responseReceivedExtraInfoEvent?.headersText?.length ?? -1,
// TODO: consider removing from spec.

@@ -248,0 +239,0 @@ bodySize: -1,

@@ -28,10 +28,10 @@ /**

readonly cdpSessionId: string;
constructor(realmStorage: RealmStorage, browsingContextStorage: BrowsingContextStorage, realmId: string, browsingContextId: string, executionContextId: Protocol.Runtime.ExecutionContextId, origin: string, type: RealmType, sandbox: string | undefined, cdpSessionId: string, cdpClient: CdpClient, eventManager: IEventManager);
constructor(realmStorage: RealmStorage, browsingContextStorage: BrowsingContextStorage, realmId: Script.Realm, browsingContextId: CommonDataTypes.BrowsingContext, executionContextId: Protocol.Runtime.ExecutionContextId, origin: string, type: RealmType, sandbox: string | undefined, cdpSessionId: string, cdpClient: CdpClient, eventManager: IEventManager);
disown(handle: string): Promise<void>;
cdpToBidiValue(cdpValue: Protocol.Runtime.CallFunctionOnResponse | Protocol.Runtime.EvaluateResponse, resultOwnership: Script.ResultOwnership): Promise<CommonDataTypes.RemoteValue>;
cdpToBidiValue(cdpValue: Protocol.Runtime.CallFunctionOnResponse | Protocol.Runtime.EvaluateResponse, resultOwnership: Script.ResultOwnership): CommonDataTypes.RemoteValue;
webDriverValueToBiDi(webDriverValue: Protocol.Runtime.WebDriverValue): CommonDataTypes.RemoteValue;
toBiDi(): Script.RealmInfo;
get realmId(): string;
get realmId(): Script.Realm;
get navigableId(): string;
get browsingContextId(): string;
get browsingContextId(): CommonDataTypes.BrowsingContext;
get executionContextId(): Protocol.Runtime.ExecutionContextId;

@@ -38,0 +38,0 @@ get origin(): string;

@@ -68,3 +68,3 @@ "use strict";

}
async cdpToBidiValue(cdpValue, resultOwnership) {
cdpToBidiValue(cdpValue, resultOwnership) {
const cdpWebDriverValue = cdpValue.result.webDriverValue;

@@ -83,3 +83,3 @@ const bidiValue = this.webDriverValueToBiDi(cdpWebDriverValue);

// No need in awaiting for the object to be released.
this.cdpClient.sendCommand('Runtime.releaseObject', { objectId });
void this.cdpClient.sendCommand('Runtime.releaseObject', { objectId });
}

@@ -91,4 +91,9 @@ }

// This relies on the CDP to implement proper BiDi serialization, except
// backendNodeId/sharedId.
// backendNodeId/sharedId and `platformobject`.
const result = webDriverValue;
// Platform object is a special case. It should have only `{type: object}`
// without `value` field.
if (result.type === 'platformobject') {
return { type: 'object' };
}
const bidiValue = result.value;

@@ -100,2 +105,3 @@ if (bidiValue === undefined) {

if (Object.hasOwn(bidiValue, 'backendNodeId')) {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
bidiValue.sharedId = `${this.navigableId}${scriptEvaluator_js_1.SHARED_ID_DIVIDER}${bidiValue.backendNodeId}`;

@@ -158,3 +164,3 @@ delete bidiValue['backendNodeId'];

async callFunction(functionDeclaration, _this, _arguments, awaitPromise, resultOwnership) {
const context = this.#browsingContextStorage.getKnownContext(this.browsingContextId);
const context = this.#browsingContextStorage.getContext(this.browsingContextId);
await context.awaitUnblocked();

@@ -166,3 +172,3 @@ return {

async scriptEvaluate(expression, awaitPromise, resultOwnership) {
const context = this.#browsingContextStorage.getKnownContext(this.browsingContextId);
const context = this.#browsingContextStorage.getContext(this.browsingContextId);
await context.awaitUnblocked();

@@ -169,0 +175,0 @@ return {

@@ -18,6 +18,7 @@ /**

import { Protocol } from 'devtools-protocol';
import { CommonDataTypes, Script } from '../../../protocol/protocol.js';
import { Realm, RealmType } from './realm.js';
declare type RealmFilter = {
realmId?: string;
browsingContextId?: string;
realmId?: Script.Realm;
browsingContextId?: CommonDataTypes.BrowsingContext;
navigableId?: string;

@@ -24,0 +25,0 @@ executionContextId?: Protocol.Runtime.ExecutionContextId;

@@ -8,2 +8,3 @@ "use strict";

#knownHandlesToRealm = new Map();
/** Map from realm ID to Realm. */
#realmMap = new Map();

@@ -10,0 +11,0 @@ get knownHandlesToRealm() {

@@ -69,3 +69,3 @@ "use strict";

type: 'success',
result: await realm.cdpToBidiValue(cdpEvaluateResult, resultOwnership),
result: realm.cdpToBidiValue(cdpEvaluateResult, resultOwnership),
realm: realm.realmId,

@@ -105,4 +105,5 @@ };

'Argument should belong to the same JavaScript world as target object',
'Invalid remote object id',
].includes(e.message)) {
throw new protocol_js_1.Message.InvalidArgumentException('Handle was not found.');
throw new protocol_js_1.Message.NoSuchHandleException('Handle was not found.');
}

@@ -121,3 +122,3 @@ throw e;

type: 'success',
result: await realm.cdpToBidiValue(cdpCallFunctionResult, resultOwnership),
result: realm.cdpToBidiValue(cdpCallFunctionResult, resultOwnership),
realm: realm.realmId,

@@ -318,3 +319,3 @@ };

// Long-poll the message queue asynchronously.
this.#initChannelListener(argumentValue, channelHandle, realm);
void this.#initChannelListener(argumentValue, channelHandle, realm);
const sendMessageArgResult = await realm.cdpClient.sendCommand('Runtime.callFunctionOn', {

@@ -340,7 +341,5 @@ functionDeclaration: String((channelHandle) => {

}
async #flattenKeyValuePairs(value, realm) {
async #flattenKeyValuePairs(mapping, realm) {
const keyValueArray = [];
for (const pair of value) {
const key = pair[0];
const value = pair[1];
for (const [key, value] of mapping) {
let keyArg;

@@ -362,7 +361,3 @@ if (typeof key === 'string') {

async #flattenValueList(list, realm) {
const result = [];
for (const value of list) {
result.push(await this.#deserializeToCdpArg(value, realm));
}
return result;
return Promise.all(list.map((value) => this.#deserializeToCdpArg(value, realm)));
}

@@ -385,9 +380,7 @@ async #initChannelListener(channel, channelHandle, realm) {

});
this.#eventManager.registerPromiseEvent(realm
.cdpToBidiValue(message, channel.value.ownership ?? 'none')
.then((data) => ({
this.#eventManager.registerEvent({
method: protocol_js_1.Script.EventNames.MessageEvent,
params: {
channel: channelId,
data,
data: realm.cdpToBidiValue(message, channel.value.ownership ?? 'none'),
source: {

@@ -398,3 +391,3 @@ realm: realm.realmId,

},
})), realm.browsingContextId, protocol_js_1.Script.EventNames.MessageEvent);
}, realm.browsingContextId);
}

@@ -401,0 +394,0 @@ }

@@ -28,4 +28,3 @@ "use strict";

static async createFromPromise(messagePromise, channel) {
const message = await messagePromise;
return new OutgoingBidiMessage(message, channel);
return messagePromise.then((message) => new OutgoingBidiMessage(message, channel));
}

@@ -32,0 +31,0 @@ static createResolved(message, channel) {

@@ -12,3 +12,3 @@ import { ITransport } from '../utils/transport.js';

*/
run(bidiPort: number, onNewBidiConnectionOpen: (bidiServer: ITransport) => Promise<() => void>): void;
run(bidiPort: number, onNewBidiConnectionOpen: (bidiServer: ITransport) => Promise<() => void> | (() => void)): void;
}

@@ -55,3 +55,3 @@ "use strict";

const server = http_1.default.createServer(async (request, response) => {
debugInternal(`${new Date()} Received ${request.method} request for ${request.url}`);
debugInternal(`${new Date().toString()} Received ${request.method ?? 'UNKNOWN METHOD'} request for ${request.url ?? 'UNKNOWN URL'}`);
if (!request.url)

@@ -75,3 +75,3 @@ return response.end(404);

else if (request.url.startsWith('/session')) {
debugInternal(`Unknown session command ${request.method} request for ${request.url} with payload ${await getHttpRequestPayload(request)}. 200 returned.`);
debugInternal(`Unknown session command ${request.method ?? 'UNKNOWN METHOD'} request for ${request.url} with payload ${await getHttpRequestPayload(request)}. 200 returned.`);
response.writeHead(200, {

@@ -114,3 +114,3 @@ 'Content-Type': 'application/json;charset=utf-8',

connection.on('close', () => {
debugInternal(`${new Date()} Peer ${connection.remoteAddress} disconnected.`);
debugInternal(`${new Date().toString()} Peer ${connection.remoteAddress} disconnected.`);
onBidiConnectionClosed();

@@ -134,3 +134,3 @@ });

const errorResponse = this.#getErrorResponse(plainCommandData, errorCode, errorMessage);
this.#sendClientMessage(errorResponse, connection);
void this.#sendClientMessage(errorResponse, connection);
}

@@ -165,3 +165,3 @@ #getErrorResponse(plainCommandData, errorCode, errorMessage) {

if (!this.#sendBidiMessage)
throw new Error('Bidi connection is not initialised yet');
throw new Error('BiDi connection is not initialised yet');
return this.#sendBidiMessage(message);

@@ -168,0 +168,0 @@ }

@@ -121,3 +121,2 @@ "use strict";

debugInternal('Connection opened.');
// await browserClient.Log.enable();
const browserClient = cdpConnection.browserClient();

@@ -129,5 +128,2 @@ const { targetId } = await browserClient.sendCommand('Target.createTarget', {

const mapperCdpClient = cdpConnection.getCdpClient(mapperSessionId);
if (!mapperCdpClient) {
throw new Error('Unable to connect to mapper CDP target');
}
await mapperCdpClient.sendCommand('Runtime.enable');

@@ -134,0 +130,0 @@ await browserClient.sendCommand('Target.exposeDevToolsProtocol', {

@@ -45,2 +45,3 @@ "use strict";

const Parser = __importStar(require("../protocol-parser/protocol-parser.js"));
const protocol_1 = require("../protocol/protocol");
const BidiServer_js_1 = require("../bidiMapper/BidiServer.js");

@@ -53,3 +54,3 @@ const index_js_1 = require("../cdp/index.js");

const waitSelfTargetIdPromise = waitSelfTargetId();
(async () => {
void (async () => {
(0, mapperTabPage_js_1.generatePage)();

@@ -77,3 +78,3 @@ // Needed to filter out info related to BiDi target.

}
async sendMessage(message) {
sendMessage(message) {
window.cdp.send(message);

@@ -90,3 +91,3 @@ }

}
async function createBidiServer(selfTargetId) {
function createBidiServer(selfTargetId) {
class WindowBidiTransport {

@@ -103,3 +104,3 @@ #onMessage = null;

// Transport-level error does not provide channel.
this.#respondWithError(messageStr, 'invalid argument', e.message, null);
this.#respondWithError(messageStr, protocol_1.Message.ErrorCode.InvalidArgument, e.message, null);
return;

@@ -113,3 +114,3 @@ }

}
async sendMessage(message) {
sendMessage(message) {
const messageStr = JSON.stringify(message);

@@ -209,2 +210,8 @@ window.sendBidiResponse(messageStr);

class BidiParserImpl {
parseAddPreloadScriptParams(params) {
return Parser.Script.parseAddPreloadScriptParams(params);
}
parseRemovePreloadScriptParams(params) {
return Parser.Script.parseRemovePreloadScriptParams(params);
}
parseGetRealmsParams(params) {

@@ -211,0 +218,0 @@ return Parser.Script.parseGetRealmsParams(params);

@@ -49,6 +49,6 @@ "use strict";

// If run not in browser (e.g. unit test), do nothing.
if (!globalThis.document?.documentElement) {
if (!globalThis.document.documentElement) {
return;
}
window.document.documentElement.innerHTML = mapperPageSource;
globalThis.document.documentElement.innerHTML = mapperPageSource;
// Create main log containers in proper order.

@@ -63,3 +63,3 @@ findOrCreateTypeLogContainer(log_js_1.LogType.system);

// If run not in browser (e.g. unit test), do nothing.
if (!globalThis.document?.documentElement) {
if (!globalThis.document.documentElement) {
return;

@@ -66,0 +66,0 @@ }

@@ -66,3 +66,5 @@ "use strict";

const cdpClient = cdpConnection.browserClient();
cdpClient.sendCommand('Target.activateTarget', { targetId: TEST_TARGET_ID });
void cdpClient.sendCommand('Target.activateTarget', {
targetId: TEST_TARGET_ID,
});
sinon.assert.calledOnceWithExactly(mockCdpServer.sendMessage, expectedMessageStr);

@@ -83,3 +85,3 @@ });

// Assert 'cdpClient' resolved message promise.
(0, chai_1.expect)(commandPromise).to.eventually.equal({});
await (0, chai_1.expect)(commandPromise).to.eventually.deep.equal({});
});

@@ -166,3 +168,3 @@ it(`when some command is called 2 times and it's done each command promise is resolved with proper results`, async () => {

// Assert sendCommand resolved message promise.
(0, chai_1.expect)(commandPromise).to.eventually.equal({
await (0, chai_1.expect)(commandPromise).to.eventually.deep.equal({
targetId: TEST_TARGET_ID,

@@ -169,0 +171,0 @@ });

@@ -66,3 +66,3 @@ "use strict";

}
#onMessage = async (message) => {
#onMessage = (message) => {
const parsed = JSON.parse(message);

@@ -69,0 +69,0 @@ const messagePretty = JSON.stringify(parsed, null, 2);

@@ -62,3 +62,3 @@ "use strict";

});
cdpConnection.browserClient().sendCommand('Browser.getVersion');
void cdpConnection.browserClient().sendCommand('Browser.getVersion');
sinon.assert.calledOnceWithExactly(mockCdpServer.sendMessage, browserMessage);

@@ -65,0 +65,0 @@ });

@@ -49,7 +49,7 @@ /**

}, "strip", zod.ZodTypeAny, {
context?: string | undefined;
type?: "worker" | "window" | "dedicated-worker" | "shared-worker" | "service-worker" | "paint-worklet" | "audio-worklet" | "worklet" | undefined;
}, {
context?: string | undefined;
}, {
type?: "worker" | "window" | "dedicated-worker" | "shared-worker" | "service-worker" | "paint-worklet" | "audio-worklet" | "worklet" | undefined;
context?: string | undefined;
}>;

@@ -59,2 +59,25 @@ function parseGetRealmsParams(params: object): ScriptTypes.GetRealmsParameters;

function parseDisownParams(params: object): ScriptTypes.DisownParameters;
const PreloadScriptSchema: zod.ZodString;
const AddPreloadScriptParametersSchema: zod.ZodObject<{
expression: zod.ZodString;
sandbox: zod.ZodOptional<zod.ZodString>;
context: zod.ZodOptional<zod.ZodString>;
}, "strip", zod.ZodTypeAny, {
expression: string;
sandbox?: string | undefined;
context?: string | undefined;
}, {
expression: string;
sandbox?: string | undefined;
context?: string | undefined;
}>;
function parseAddPreloadScriptParams(params: object): ScriptTypes.AddPreloadScriptParameters;
const RemovePreloadScriptParametersSchema: zod.ZodObject<{
script: zod.ZodString;
}, "strip", zod.ZodTypeAny, {
script: string;
}, {
script: string;
}>;
function parseRemovePreloadScriptParams(params: object): ScriptTypes.RemovePreloadScriptParameters;
const ChannelSchema: zod.ZodObject<{

@@ -67,9 +90,9 @@ type: zod.ZodLiteral<"channel">;

}, "strip", zod.ZodTypeAny, {
channel: string;
maxDepth?: number | undefined;
ownership?: "none" | "root" | undefined;
}, {
channel: string;
}, {
maxDepth?: number | undefined;
ownership?: "none" | "root" | undefined;
channel: string;
}>;

@@ -79,5 +102,5 @@ }, "strip", zod.ZodTypeAny, {

value: {
channel: string;
maxDepth?: number | undefined;
ownership?: "none" | "root" | undefined;
channel: string;
};

@@ -87,5 +110,5 @@ }, {

value: {
channel: string;
maxDepth?: number | undefined;
ownership?: "none" | "root" | undefined;
channel: string;
};

@@ -92,0 +115,0 @@ }>;

@@ -245,2 +245,19 @@ "use strict";

Script.parseDisownParams = parseDisownParams;
Script.PreloadScriptSchema = zod_1.z.string();
Script.AddPreloadScriptParametersSchema = zod_1.z.object({
expression: zod_1.z.string(),
sandbox: zod_1.z.string().optional(),
context: CommonDataTypes.BrowsingContextSchema.optional(),
});
function parseAddPreloadScriptParams(params) {
return parseObject(params, Script.AddPreloadScriptParametersSchema);
}
Script.parseAddPreloadScriptParams = parseAddPreloadScriptParams;
Script.RemovePreloadScriptParametersSchema = zod_1.z.object({
script: Script.PreloadScriptSchema,
});
function parseRemovePreloadScriptParams(params) {
return parseObject(params, Script.RemovePreloadScriptParametersSchema);
}
Script.parseRemovePreloadScriptParams = parseRemovePreloadScriptParams;
const ChannelIdSchema = zod_1.z.string();

@@ -247,0 +264,0 @@ const ChannelPropertiesSchema = zod_1.z.object({

@@ -28,3 +28,7 @@ /**

}
export declare type BiDiMethod = 'browsingContext.captureScreenshot' | 'browsingContext.close' | 'browsingContext.create' | 'browsingContext.getTree' | 'browsingContext.navigate' | 'browsingContext.print' | 'cdp.getSession' | 'cdp.sendCommand' | 'cdp.sendMessage' | 'script.callFunction' | 'script.disown' | 'script.evaluate' | 'script.getRealms' | 'session.status' | 'session.subscribe' | 'session.unsubscribe';
export declare type BiDiMethod = 'browsingContext.captureScreenshot' | 'browsingContext.close' | 'browsingContext.create' | 'browsingContext.getTree' | 'browsingContext.navigate' | 'browsingContext.print' | 'cdp.getSession' | 'cdp.sendCommand' | 'cdp.sendMessage' | 'script.addPreloadScript' | 'script.callFunction' | 'script.disown' | 'script.evaluate' | 'script.getRealms' | 'script.removePreloadScript' | 'session.status' | 'session.subscribe' | 'session.unsubscribe';
export declare type EmptyResult = Record<never, never>;
export declare type EmptyResultWithCommandId = {
id: number;
} | EmptyResult;
export declare namespace Message {

@@ -40,11 +44,20 @@ type OutgoingMessage = CommandResponse | EventMessage | {

};
type CommandRequest = {
id: number;
} & (BrowsingContext.Command | Script.Command | Session.Command | CDP.Command);
type CommandResponse = {
id: number;
} & CommandResponseResult;
type CommandRequest = Pick<RawCommandRequest, 'id'> & (BrowsingContext.Command | Script.Command | Session.Command | CDP.Command);
type CommandResponse = Pick<RawCommandRequest, 'id'> & CommandResponseResult;
type CommandResponseResult = BrowsingContext.CommandResult | Script.CommandResult | Session.CommandResult | CDP.CommandResult | ErrorResult;
type EventMessage = BrowsingContext.Event | CDP.Event | Log.Event | Network.Event | Script.Event;
type ErrorCode = 'unknown error' | 'unknown command' | 'invalid argument' | 'no such frame' | 'no such node';
type EventNames = BrowsingContext.EventNames | CDP.EventNames | Log.EventNames | Network.EventNames | Script.EventNames;
enum ErrorCode {
InvalidArgument = "invalid argument",
InvalidSessionId = "invalid session id",
NoSuchAlert = "no such alert",
NoSuchFrame = "no such frame",
NoSuchHandle = "no such handle",
NoSuchNode = "no such node",
NoSuchScript = "no such script",
SessionNotCreated = "session not created",
UnknownCommand = "unknown command",
UnknownError = "unknown error",
UnsupportedOperation = "unsupported operation"
}
type ErrorResult = {

@@ -55,25 +68,42 @@ readonly error: ErrorCode;

};
type EventNames = BrowsingContext.EventNames | CDP.EventNames | Log.EventNames | Network.EventNames | Script.EventNames;
class ErrorResponseClass implements Message.ErrorResult {
protected constructor(error: Message.ErrorCode, message: string, stacktrace?: string);
readonly error: Message.ErrorCode;
readonly message: string;
readonly stacktrace?: string;
class ErrorResponse implements Message.ErrorResult {
error: Message.ErrorCode;
message: string;
stacktrace?: string | undefined;
constructor(error: Message.ErrorCode, message: string, stacktrace?: string | undefined);
toErrorResponse(commandId: number): Message.CommandResponse;
}
class UnknownException extends ErrorResponseClass {
class InvalidArgumentException extends ErrorResponse {
constructor(message: string, stacktrace?: string);
}
class UnknownCommandException extends ErrorResponseClass {
class NoSuchHandleException extends ErrorResponse {
constructor(message: string, stacktrace?: string);
}
class InvalidArgumentException extends ErrorResponseClass {
class InvalidSessionIdException extends ErrorResponse {
constructor(message: string, stacktrace?: string);
}
class NoSuchNodeException extends ErrorResponseClass {
class NoSuchAlertException extends ErrorResponse {
constructor(message: string, stacktrace?: string);
}
class NoSuchFrameException extends ErrorResponseClass {
class NoSuchFrameException extends ErrorResponse {
constructor(message: string);
}
class NoSuchNodeException extends ErrorResponse {
constructor(message: string, stacktrace?: string);
}
class NoSuchScriptException extends ErrorResponse {
constructor(message: string, stacktrace?: string);
}
class SessionNotCreatedException extends ErrorResponse {
constructor(message: string, stacktrace?: string);
}
class UnknownCommandException extends ErrorResponse {
constructor(message: string, stacktrace?: string);
}
class UnknownErrorException extends ErrorResponse {
constructor(message: string, stacktrace?: string);
}
class UnsupportedOperationException extends ErrorResponse {
constructor(message: string, stacktrace?: string);
}
}

@@ -220,4 +250,4 @@ export declare namespace CommonDataTypes {

export declare namespace Script {
type Command = EvaluateCommand | CallFunctionCommand | GetRealmsCommand | DisownCommand;
type CommandResult = EvaluateResult | CallFunctionResult | GetRealmsResult | DisownResult;
type Command = EvaluateCommand | CallFunctionCommand | GetRealmsCommand | DisownCommand | AddPreloadScriptCommand | RemovePreloadScriptCommand;
type CommandResult = EvaluateResult | CallFunctionResult | GetRealmsResult | DisownResult | AddPreloadScriptResult | RemovePreloadScriptResult;
type Event = MessageEvent;

@@ -319,3 +349,3 @@ type Realm = string;

type DisownResult = {
result: {};
result: Record<string, unknown>;
};

@@ -351,2 +381,25 @@ type CallFunctionCommand = {

};
type PreloadScript = string;
type AddPreloadScriptCommand = {
method: 'script.addPreloadScript';
params: AddPreloadScriptParameters;
};
type AddPreloadScriptParameters = {
expression: string;
sandbox?: string;
context?: CommonDataTypes.BrowsingContext;
};
type AddPreloadScriptResult = {
result: {
script: PreloadScript;
};
};
type RemovePreloadScriptCommand = {
method: 'script.removePreloadScript';
params: RemovePreloadScriptParameters;
};
type RemovePreloadScriptParameters = {
script: PreloadScript;
};
type RemovePreloadScriptResult = EmptyResultWithCommandId;
type ChannelId = string;

@@ -437,3 +490,3 @@ type ChannelProperties = {

type CloseResult = {
result: {};
result: Record<string, unknown>;
};

@@ -529,5 +582,6 @@ type CaptureScreenshotCommand = {

export declare namespace Network {
export type Event = BeforeRequestSentEvent | ResponseCompletedEvent;
export type Event = BeforeRequestSentEvent | ResponseCompletedEvent | FetchErrorEvent;
export type BeforeRequestSentEvent = EventResponse<EventNames.BeforeRequestSentEvent, BeforeRequestSentParams>;
export type ResponseCompletedEvent = EventResponse<EventNames.ResponseCompletedEvent, ResponseCompletedParams>;
export type FetchErrorEvent = EventResponse<EventNames.FetchErrorEvent, FetchErrorParams>;
type Header = {

@@ -566,3 +620,3 @@ name: string;

};
type RequestData = {
export type RequestData = {
request: string;

@@ -613,6 +667,10 @@ url: string;

};
export type FetchErrorParams = BaseEventParams & {
errorText: string;
};
export const AllEvents = "network";
export enum EventNames {
BeforeRequestSentEvent = "network.beforeRequestSent",
ResponseCompletedEvent = "network.responseCompleted"
ResponseCompletedEvent = "network.responseCompleted",
FetchErrorEvent = "network.fetchError"
}

@@ -666,3 +724,3 @@ export {};

method: 'session.status';
params: {};
params: Record<string, unknown>;
};

@@ -685,3 +743,3 @@ type StatusResult = {

type SubscribeResult = {
result: {};
result: Record<string, unknown>;
};

@@ -693,4 +751,4 @@ type UnsubscribeCommand = {

type UnsubscribeResult = {
result: {};
result: Record<string, unknown>;
};
}

@@ -20,7 +20,25 @@ "use strict";

exports.CDP = exports.Network = exports.Log = exports.BrowsingContext = exports.Script = exports.Message = void 0;
// keep-sorted end
var Message;
(function (Message) {
// keep-sorted end;
class ErrorResponseClass {
let ErrorCode;
(function (ErrorCode) {
// keep-sorted start
ErrorCode["InvalidArgument"] = "invalid argument";
ErrorCode["InvalidSessionId"] = "invalid session id";
ErrorCode["NoSuchAlert"] = "no such alert";
ErrorCode["NoSuchFrame"] = "no such frame";
ErrorCode["NoSuchHandle"] = "no such handle";
ErrorCode["NoSuchNode"] = "no such node";
ErrorCode["NoSuchScript"] = "no such script";
ErrorCode["SessionNotCreated"] = "session not created";
ErrorCode["UnknownCommand"] = "unknown command";
ErrorCode["UnknownError"] = "unknown error";
ErrorCode["UnsupportedOperation"] = "unsupported operation";
// keep-sorted end
})(ErrorCode = Message.ErrorCode || (Message.ErrorCode = {}));
class ErrorResponse {
error;
message;
stacktrace;
constructor(error, message, stacktrace) {

@@ -31,5 +49,2 @@ this.error = error;

}
error;
message;
stacktrace;
toErrorResponse(commandId) {

@@ -44,33 +59,69 @@ return {

}
Message.ErrorResponseClass = ErrorResponseClass;
class UnknownException extends ErrorResponseClass {
Message.ErrorResponse = ErrorResponse;
class InvalidArgumentException extends ErrorResponse {
constructor(message, stacktrace) {
super('unknown error', message, stacktrace);
super(ErrorCode.InvalidArgument, message, stacktrace);
}
}
Message.UnknownException = UnknownException;
class UnknownCommandException extends ErrorResponseClass {
Message.InvalidArgumentException = InvalidArgumentException;
class NoSuchHandleException extends ErrorResponse {
constructor(message, stacktrace) {
super('unknown command', message, stacktrace);
super(ErrorCode.NoSuchHandle, message, stacktrace);
}
}
Message.UnknownCommandException = UnknownCommandException;
class InvalidArgumentException extends ErrorResponseClass {
Message.NoSuchHandleException = NoSuchHandleException;
class InvalidSessionIdException extends ErrorResponse {
constructor(message, stacktrace) {
super('invalid argument', message, stacktrace);
super(ErrorCode.InvalidSessionId, message, stacktrace);
}
}
Message.InvalidArgumentException = InvalidArgumentException;
class NoSuchNodeException extends ErrorResponseClass {
Message.InvalidSessionIdException = InvalidSessionIdException;
class NoSuchAlertException extends ErrorResponse {
constructor(message, stacktrace) {
super('no such node', message, stacktrace);
super(ErrorCode.NoSuchAlert, message, stacktrace);
}
}
Message.NoSuchNodeException = NoSuchNodeException;
class NoSuchFrameException extends ErrorResponseClass {
Message.NoSuchAlertException = NoSuchAlertException;
class NoSuchFrameException extends ErrorResponse {
constructor(message) {
super('no such frame', message);
super(ErrorCode.NoSuchFrame, message);
}
}
Message.NoSuchFrameException = NoSuchFrameException;
class NoSuchNodeException extends ErrorResponse {
constructor(message, stacktrace) {
super(ErrorCode.NoSuchNode, message, stacktrace);
}
}
Message.NoSuchNodeException = NoSuchNodeException;
class NoSuchScriptException extends ErrorResponse {
constructor(message, stacktrace) {
super(ErrorCode.NoSuchScript, message, stacktrace);
}
}
Message.NoSuchScriptException = NoSuchScriptException;
class SessionNotCreatedException extends ErrorResponse {
constructor(message, stacktrace) {
super(ErrorCode.SessionNotCreated, message, stacktrace);
}
}
Message.SessionNotCreatedException = SessionNotCreatedException;
class UnknownCommandException extends ErrorResponse {
constructor(message, stacktrace) {
super(ErrorCode.UnknownCommand, message, stacktrace);
}
}
Message.UnknownCommandException = UnknownCommandException;
class UnknownErrorException extends ErrorResponse {
constructor(message, stacktrace) {
super(ErrorCode.UnknownError, message, stacktrace);
}
}
Message.UnknownErrorException = UnknownErrorException;
class UnsupportedOperationException extends ErrorResponse {
constructor(message, stacktrace) {
super(ErrorCode.UnsupportedOperation, message, stacktrace);
}
}
Message.UnsupportedOperationException = UnsupportedOperationException;
})(Message = exports.Message || (exports.Message = {}));

@@ -114,2 +165,3 @@ /** @see https://w3c.github.io/webdriver-bidi/#module-script */

EventNames["ResponseCompletedEvent"] = "network.responseCompleted";
EventNames["FetchErrorEvent"] = "network.fetchError";
})(EventNames = Network.EventNames || (Network.EventNames = {}));

@@ -116,0 +168,0 @@ })(Network = exports.Network || (exports.Network = {}));

@@ -33,2 +33,5 @@ "use strict";

});
// Needed to avoid `Uncaught (in promise)`. The promises returned by `then`
// and `catch` will be rejected anyway.
this.#promise.catch(() => { });
}

@@ -35,0 +38,0 @@ then(onFulfilled, onRejected) {

@@ -23,13 +23,22 @@ "use strict";

describe('isFinished', () => {
it('resolve', () => {
it('resolve', async () => {
const deferred = new deferred_js_1.Deferred();
const deferredThen = deferred.then((v) => v);
deferred.catch((e) => {
throw e;
});
(0, chai_1.expect)(deferred.isFinished).to.be.false;
deferred.resolve('done');
(0, chai_1.expect)(deferred.isFinished).to.be.true;
await (0, chai_1.expect)(deferredThen).to.eventually.equal('done');
});
it('reject', () => {
it('reject', async () => {
const deferred = new deferred_js_1.Deferred();
const deferredThen = deferred.then(() => { });
const deferredCatch = deferred.catch((e) => e);
(0, chai_1.expect)(deferred.isFinished).to.be.false;
deferred.reject(new Error('error'));
deferred.reject('some error');
(0, chai_1.expect)(deferred.isFinished).to.be.true;
await (0, chai_1.expect)(deferredThen).to.eventually.be.rejectedWith('some error');
await (0, chai_1.expect)(deferredCatch).to.eventually.equal('some error');
});

@@ -36,0 +45,0 @@ });

@@ -36,3 +36,3 @@ "use strict";

// No need in waiting. Just initialise processor if needed.
this.#processIfNeeded();
void this.#processIfNeeded();
}

@@ -52,4 +52,3 @@ async #processIfNeeded() {

this.#catch(e);
})
.finally();
});
}

@@ -56,0 +55,0 @@ }

@@ -22,5 +22,5 @@ /**

export interface ITransport {
setOnMessage: (handler: (message: string) => Promise<void>) => void;
sendMessage: (message: string) => Promise<void>;
setOnMessage: (handler: (message: string) => Promise<void> | void) => void;
sendMessage: (message: string) => Promise<void> | void;
close(): void;
}

@@ -23,4 +23,4 @@ /**

setOnMessage(onMessage: (message: string) => void): void;
sendMessage(message: string): Promise<void>;
sendMessage(message: string): void;
close(): void;
}

@@ -32,3 +32,3 @@ "use strict";

}
async sendMessage(message) {
sendMessage(message) {
this.#websocket.send(message);

@@ -35,0 +35,0 @@ }

{
"name": "chromium-bidi",
"version": "0.4.6",
"version": "0.4.7",
"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.",

@@ -8,2 +8,3 @@ "scripts": {

"clean": "rimraf lib",
"coverage": "nyc mocha",
"e2e-headful": "npm run server-no-build -- --headless=false & npm run e2e-only",

@@ -23,3 +24,3 @@ "e2e-headless": "npm run server-no-build & npm run e2e-only",

"test": "npm run build && mocha",
"watch": "tsc -b src/tsconfig.json --watch & rollup -c --watch",
"watch": "tsc -b src/tsconfig.json --watch && rollup -c --watch",
"yapf": "yapf --in-place --parallel --recursive --exclude=wpt examples/ tests/"

@@ -52,5 +53,5 @@ },

"@types/websocket": "1.0.5",
"@types/ws": "8.5.3",
"@typescript-eslint/eslint-plugin": "5.38.0",
"@typescript-eslint/parser": "5.38.0",
"@types/ws": "8.5.4",
"@typescript-eslint/eslint-plugin": "5.58.0",
"@typescript-eslint/parser": "5.58.0",
"argparse": "2.0.1",

@@ -61,6 +62,6 @@ "chai": "4.3.6",

"debug": "4.3.4",
"devtools-protocol": "0.0.1007249",
"eslint": "8.24.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-import": "2.26.0",
"devtools-protocol": "0.0.1107588",
"eslint": "8.38.0",
"eslint-config-prettier": "8.8.0",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-mocha": "10.1.0",

@@ -70,13 +71,14 @@ "eslint-plugin-prettier": "4.2.1",

"mocha": "10.0.0",
"nyc": "^15.1.0",
"prettier": "2.8.4",
"rimraf": "3.0.2",
"rollup": "2.74.1",
"sinon": "14.0.0",
"sinon": "15.0.3",
"source-map-support": "^0.5.21",
"terser": "5.14.2",
"tslib": "2.4.0",
"tslib": "2.5.0",
"typescript": "4.7.4",
"websocket": "1.0.34",
"ws": "8.6.0",
"zod": "3.17.3"
"ws": "8.13.0",
"zod": "3.21.4"
},

@@ -83,0 +85,0 @@ "dependencies": {

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 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 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 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 not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc