Skip to content

Commit 25da91e

Browse files
committed
[js] Fix enhancements manifest issues found in code review
- back()/forward(): accept a context id instead of hard-coding an empty string; delegate to traverseHistory({ context, delta: ±1 }) - continueWithAuth: replace username!/password! non-null assertions with an explicit undefined guard that throws a descriptive error - continueWithAuth: capture bidi.send() response and apply the same response['type'] === 'error' check as generated methods, preventing silent failures
1 parent 5ec2e30 commit 25da91e

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

javascript/selenium-webdriver/private/bidi_enhancements_manifest.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"excludeTypes": [],
1010
"excludeMethods": [],
1111
"extraMethods": {
12-
"back": " async back(): Promise<void> {\n await this.traverseHistory({ context: '', delta: -1 } as BrowsingContextTraverseHistoryParameters)\n }",
13-
"forward": " async forward(): Promise<void> {\n await this.traverseHistory({ context: '', delta: 1 } as BrowsingContextTraverseHistoryParameters)\n }",
12+
"back": " async back(context: BrowsingContextBrowsingContext): Promise<void> {\n await this.traverseHistory({ context, delta: -1 })\n }",
13+
"forward": " async forward(context: BrowsingContextBrowsingContext): Promise<void> {\n await this.traverseHistory({ context, delta: 1 })\n }",
1414
"getTopLevelContexts": " async getTopLevelContexts(): Promise<BrowsingContextGetTreeResult> {\n return this.getTree({})\n }",
1515
"printPage": " async printPage(params: BrowsingContextPrintParameters): Promise<BrowsingContextPrintResult> {\n return this.print(params)\n }"
1616
},
@@ -48,7 +48,7 @@
4848
"extraMethods": {
4949
"cancelAuth": " async cancelAuth(requestId: NetworkRequest): Promise<void> {\n await this.continueWithAuth({ request: requestId, action: 'cancel' } as NetworkContinueWithAuthParameters)\n }",
5050
"continueWithAuthNoCredentials": " async continueWithAuthNoCredentials(requestId: NetworkRequest): Promise<void> {\n await this.continueWithAuth({ request: requestId, action: 'default' } as NetworkContinueWithAuthParameters)\n }",
51-
"continueWithAuth": " async continueWithAuth(params: NetworkContinueWithAuthParameters): Promise<void>\n /** @deprecated Pass a NetworkContinueWithAuthParameters object instead — will be removed in a future major version. */\n async continueWithAuth(requestId: NetworkRequest, username: string, password: string): Promise<void>\n async continueWithAuth(\n paramsOrRequestId: NetworkContinueWithAuthParameters | NetworkRequest,\n username?: string,\n password?: string,\n ): Promise<void> {\n const params: NetworkContinueWithAuthParameters =\n typeof paramsOrRequestId === 'string'\n ? ({\n request: paramsOrRequestId,\n action: 'provideCredentials',\n credentials: { type: 'password', username: username!, password: password! },\n } as NetworkContinueWithAuthParameters)\n : (paramsOrRequestId as NetworkContinueWithAuthParameters)\n await this.bidi.send({\n method: 'network.continueWithAuth',\n params: params as unknown as Record<string, unknown>,\n })\n }",
51+
"continueWithAuth": " async continueWithAuth(params: NetworkContinueWithAuthParameters): Promise<void>\n /** @deprecated Pass a NetworkContinueWithAuthParameters object instead — will be removed in a future major version. */\n async continueWithAuth(requestId: NetworkRequest, username: string, password: string): Promise<void>\n async continueWithAuth(\n paramsOrRequestId: NetworkContinueWithAuthParameters | NetworkRequest,\n username?: string,\n password?: string,\n ): Promise<void> {\n let params: NetworkContinueWithAuthParameters\n if (typeof paramsOrRequestId === 'string') {\n if (username === undefined || password === undefined) {\n throw new Error('username and password are required when calling continueWithAuth with a request id')\n }\n params = {\n request: paramsOrRequestId,\n action: 'provideCredentials',\n credentials: { type: 'password', username, password },\n } as NetworkContinueWithAuthParameters\n } else {\n params = paramsOrRequestId as NetworkContinueWithAuthParameters\n }\n const response = await this.bidi.send({\n method: 'network.continueWithAuth',\n params: params as unknown as Record<string, unknown>,\n }) as Record<string, unknown>\n if (response['type'] === 'error') {\n throw new Error(`${response['error']}: ${response['message']}`)\n }\n }",
5252
"beforeRequestSent": " /** @deprecated Use {@link onBeforeRequestSent} instead — will be removed in a future major version. */\n async beforeRequestSent(callback: (params: NetworkBeforeRequestSentParameters) => void): Promise<void> {\n await this.onBeforeRequestSent(callback)\n }",
5353
"authRequired": " /** @deprecated Use {@link onAuthRequired} instead — will be removed in a future major version. */\n async authRequired(callback: (params: NetworkAuthRequiredParameters) => void): Promise<void> {\n await this.onAuthRequired(callback)\n }",
5454
"fetchError": " /** @deprecated Use {@link onFetchError} instead — will be removed in a future major version. */\n async fetchError(callback: (params: NetworkFetchErrorParameters) => void): Promise<void> {\n await this.onFetchError(callback)\n }",

0 commit comments

Comments
 (0)