diff --git a/notNeededPackages.json b/notNeededPackages.json index 028ded51dae0f7..676e532439ce8a 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -3833,6 +3833,10 @@ "libraryName": "libra-core", "asOfVersion": "1.0.5" }, + "libxmljs": { + "libraryName": "libxmljs", + "asOfVersion": "1.0.1" + }, "lifeomic__axios-fetch": { "libraryName": "@lifeomic/axios-fetch", "asOfVersion": "2.0.0" diff --git a/types/firefox-webext-browser/firefox-webext-browser-tests.ts b/types/firefox-webext-browser/firefox-webext-browser-tests.ts index fe33da1fc6b998..a82ae7b77138e4 100644 --- a/types/firefox-webext-browser/firefox-webext-browser-tests.ts +++ b/types/firefox-webext-browser/firefox-webext-browser-tests.ts @@ -124,3 +124,21 @@ console.log(filter.status); browser.storage.session.get("sessionObject"); browser.storage.session.set({ "sessionObject": "value" }); + +browser.scripting.executeScript({ + target: { tabId: 1 }, + func: () => {}, +}); + +browser.scripting.executeScript({ + target: { tabId: 1 }, + // @ts-expect-error + args: [true], + func: (_n: number) => {}, +}); + +browser.scripting.executeScript({ + target: { tabId: 1 }, + args: [0, "", false, [], {}], + func: (_n: number, _s: string, _b: boolean, _a: [], _o: {}) => {}, +}); diff --git a/types/firefox-webext-browser/index.d.ts b/types/firefox-webext-browser/index.d.ts index 868c7d24b74b64..c5059f142d508b 100644 --- a/types/firefox-webext-browser/index.d.ts +++ b/types/firefox-webext-browser/index.d.ts @@ -4664,11 +4664,11 @@ declare namespace browser.runtime { declare namespace browser.scripting { /* scripting types */ /** Details of a script injection */ - interface ScriptInjection { + interface ScriptInjection { /** * The arguments to curry into a provided function. This is only valid if the `func` parameter is specified. These arguments must be JSON-serializable. */ - args?: any[] | undefined; + args?: Args | undefined; /** * The path of the JS files to inject, relative to the extension's root directory. Exactly one of `files` and `func` must be specified. */ @@ -4677,7 +4677,7 @@ declare namespace browser.scripting { * A JavaScript function to inject. This function will be serialized, and then deserialized for injection. This means that any bound parameters and execution context will be lost. Exactly one of `files` and `func` must be specified. */ // eslint-disable-next-line @typescript-eslint/no-invalid-void-type - func?: () => void | undefined; + func?: (...args: Args) => void | undefined; /** Details specifying the target into which to inject the script. */ target: InjectionTarget; world?: ExecutionWorld | undefined; @@ -4801,7 +4801,8 @@ declare namespace browser.scripting { * Injects a script into a target context. The script will be run at `document_idle`. * @param injection The details of the script which to inject. */ - function executeScript(injection: ScriptInjection): Promise; + // eslint-disable-next-line @definitelytyped/no-unnecessary-generics + function executeScript(injection: ScriptInjection): Promise; /** * Inserts a CSS stylesheet into a target context. If multiple frames are specified, unsuccessful injections are ignored. diff --git a/types/libxmljs/.npmignore b/types/libxmljs/.npmignore deleted file mode 100644 index 93e307400a5456..00000000000000 --- a/types/libxmljs/.npmignore +++ /dev/null @@ -1,5 +0,0 @@ -* -!**/*.d.ts -!**/*.d.cts -!**/*.d.mts -!**/*.d.*.ts diff --git a/types/libxmljs/index.d.ts b/types/libxmljs/index.d.ts deleted file mode 100644 index 6f3232c8e4896f..00000000000000 --- a/types/libxmljs/index.d.ts +++ /dev/null @@ -1,225 +0,0 @@ -/// -import { EventEmitter } from "events"; - -export const version: string; -export const libxml_version: string; -export const libxml_parser_version: string; - -// eslint-disable-next-line @definitelytyped/strict-export-declare-modifiers -interface StringMap { - [key: string]: string; -} - -// eslint-disable-next-line @definitelytyped/strict-export-declare-modifiers -interface ParserOptions { - recover?: boolean | undefined; - noent?: boolean | undefined; - dtdload?: boolean | undefined; - doctype?: boolean | undefined; - dtdattr?: any; - dtdvalid?: boolean | undefined; - noerror?: boolean | undefined; - errors?: boolean | undefined; - nowarning?: boolean | undefined; - warnings?: boolean | undefined; - pedantic?: boolean | undefined; - noblanks?: boolean | undefined; - blanks?: boolean | undefined; - sax1?: boolean | undefined; - xinclude?: boolean | undefined; - nonet?: boolean | undefined; - net?: boolean | undefined; - nodict?: boolean | undefined; - dict?: boolean | undefined; - nsclean?: boolean | undefined; - implied?: boolean | undefined; - nocdata?: boolean | undefined; - cdata?: boolean | undefined; - noxincnode?: boolean | undefined; - compact?: boolean | undefined; - old?: boolean | undefined; - nobasefix?: boolean | undefined; - basefix?: boolean | undefined; - huge?: boolean | undefined; - oldsax?: boolean | undefined; - ignore_enc?: boolean | undefined; - big_lines?: boolean | undefined; - baseUrl?: string | undefined; -} - -export function parseXml(source: string, options?: ParserOptions): Document; -export function parseXmlString(source: string, options?: ParserOptions): Document; - -export function parseHtml(source: string, options?: ParserOptions): Document; -export function parseHtmlString(source: string, options?: ParserOptions): Document; -export function parseHtmlFragment(source: string, options?: ParserOptions): Document; - -export function memoryUsage(): number; -export function nodeCount(): number; - -export class Document { - /** - * Create a new XML Document - * @param version XML document version, defaults to 1.0 - * @param encoding Encoding, defaults to utf8 - */ - constructor(version?: number, encoding?: string); - - errors: SyntaxError[]; - validationErrors: ValidationError[]; - - child(idx: number): Element | null; - childNodes(): Element[]; - encoding(): string; - encoding(enc: string): this; - find(xpath: string, ns_uri?: string): Element[]; - find(xpath: string, namespaces: StringMap): Element[]; - get(xpath: string, namespaces?: StringMap): Element | null; - node(name: string, content?: string): Element; - root(): Element | null; - root(newRoot: Node): Node; - toString(formatted?: boolean): string; - type(): "document"; - validate(xsdDoc: Document): boolean; - version(): string; - setDtd(name: string, ext: string, sys: string): void; - getDtd(): { - name: string; - externalId: string; - systemId: string; - }; -} - -export class Node { - doc(): Document; - parent(): Element | Document; - /** - * The namespace or null in case of comment nodes - */ - namespace(): Namespace | null; - - /** - * An array of namespaces that the object belongs to. - * - * @param local If it is true, only the namespace declarations local to this - * node are returned, rather than all of the namespaces in scope - * at this node (including the ones from the parent elements). - */ - namespaces(local?: boolean): Namespace[]; - - prevSibling(): Node | null; - nextSibling(): Node | null; - - type(): "comment" | "element" | "text" | "attribute"; - remove(): this; - clone(): this; - /** - * Serializes the node to a string. The string will contain all contents of the node formatted as XML and can be used to print the node. - */ - toString( - format?: boolean | { - declaration: boolean; - selfCloseEmpty: boolean; - whitespace: boolean; - type: "xml" | "html" | "xhtml"; - }, - ): string; - text(): string; - text(newText: string): this; -} - -export class Element extends Node { - constructor(doc: Document, name: string, content?: string); - node(name: string, content?: string): Element; - name(): string; - name(newName: string): this; - text(): string; - text(newText: string): this; - attr(name: string): Attribute | null; - attr(attrObject: StringMap): this; - attrs(): Attribute[]; - - doc(): Document; - child(idx: number): Node | null; - childNodes(): Node[]; - - /** - * @return The original element, not the child. - */ - addChild(child: Element): this; - - prevElement(): Element | null; - nextElement(): Element | null; - addNextSibling(siblingNode: Node): Node; - addPrevSibling(siblingNode: Node): Node; - - find(xpath: string, ns_uri?: string): Node[]; - find(xpath: string, namespaces: StringMap): Node[]; - get(xpath: string, ns_uri?: string): Element | null; - get(xpath: string, namespaces: StringMap): Element | null; - - defineNamespace(prefixOrHref: string, hrefInCaseOfPrefix?: string): Namespace; - - namespace(): Namespace | null; - namespace(newNamespace: Namespace): this; - namespace(prefixOrHref: string, hrefInCaseOfPrefix?: string): Namespace; - - replace(replacement: string): string; - replace(replacement: Element): Element; - - path(): string; -} - -export class Attribute { - name(): string; - value(): string; - value(newValue: string): Attribute; - namespace(): Namespace; - - remove(): void; -} - -export class Namespace { - href(): string; - prefix(): string; -} - -export class SaxParser extends EventEmitter { - constructor(); - parseString(source: string): boolean; -} - -export class SaxPushParser extends EventEmitter { - constructor(); - push(source: string): boolean; -} - -export interface SyntaxError { - domain: number | null; - code: number | null; - message: string | null; - level: number | null; - file: string | null; - line: number | null; - /** - * 1-based column number, 0 if not applicable/available. - */ - column: number; - - str1: number | null; - str2: number | null; - str3: number | null; - int1: number | null; -} - -export interface ValidationError extends Error { - domain: number | null; - code: number | null; - level: number | null; - - line: number | null; - /** - * 1-based column number, 0 if not applicable/available. - */ - column: number; -} diff --git a/types/libxmljs/libxmljs-tests.ts b/types/libxmljs/libxmljs-tests.ts deleted file mode 100644 index af229cf2aeece3..00000000000000 --- a/types/libxmljs/libxmljs-tests.ts +++ /dev/null @@ -1,107 +0,0 @@ -import * as libxmljs from "libxmljs"; - -const xml = "" - + "" - + "" - + "grandchild content" - + "" - + "with content!" - + ""; - -const xmlDoc = libxmljs.parseXml(xml); - -// xpath queries -const gchild = xmlDoc.get("//grandchild")!; - -console.log(gchild.text()); // prints "grandchild content" - -const children = xmlDoc.root()!.childNodes(); -const child = children[0] as libxmljs.Element; - -console.log(child.attr("foo")!.value()); // prints "bar" - -// find by namespace - -const nsXml = ` - - Some title - `; - -const nsXmlDoc = libxmljs.parseXml(nsXml); - -const notFound = nsXmlDoc.find("p"); - -console.log(notFound.length); // prints 0 - -const p = nsXmlDoc.find( - "xmlns:p", - "urn:oasis:names:tc:opendocument:xmlns:text:1.0", -); - -console.log(p[0].text()); // prints "Some title" - -const p2 = nsXmlDoc.find("//text:p", { - text: "urn:oasis:names:tc:opendocument:xmlns:text:1.0", -}); - -console.log(p2[0].text()); // prints "Some title" - -const parser = new libxmljs.SaxParser(); - -parser.on("startDocument", () => 0); -parser.on("startElement", () => 0); - -const parser2 = new libxmljs.SaxPushParser(); - -// connect any callbacks here -parser2 - .on("startDocument", () => 0) - .on("startElement", () => 0); - -const xmlChunk = ""; - -while (xmlChunk) { - parser2.push(xmlChunk); -} - -const doc = new libxmljs.Document(); -((doc.node("root") - .node("child").attr({ foo: "bar" }) - .node("grandchild", "grandchild content").attr({ baz: "fizbuzz" }) - .parent()) as libxmljs.Element).parent() - .node("sibling", "with content!"); - -const { name, externalId, systemId } = doc.getDtd(); - -const xmlWithNs = "" - + "" - + "" - + "grandchild content" - + "" - + "with content!" - + ""; - -const xmlDocWithNs = libxmljs.parseXml(xmlWithNs); - -// xpath queries -const gchildWithNs = xmlDocWithNs.get("//a:grandchild", { a: "http://test.com/test" })!; - -console.log(gchildWithNs.text()); // prints "grandchild content" - -// xpath queries on element -const childElWithNs = xmlDocWithNs.get("//child")!; -const gchilEldWithNs = childElWithNs.get("//a:grandchild", { a: "http://test.com/test" })!; - -const validated: boolean = doc.validate(doc); -doc.validationErrors[0].message; // inherited from Error -doc.validationErrors[0].line; - -// text accessors on node. -const element = libxmljs.parseXmlString("Hello user1").get("//child"); -const node = element?.childNodes()?.[0]; -if (node) { - console.log(node.text()); // prints "Hello" - - node.text("Welcome"); - console.log(node.text()); // prints "Welcome" -} diff --git a/types/libxmljs/package.json b/types/libxmljs/package.json deleted file mode 100644 index 3ad97d4c27dc0f..00000000000000 --- a/types/libxmljs/package.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "private": true, - "name": "@types/libxmljs", - "version": "0.18.9999", - "projects": [ - "https://github.com/libxmljs/libxmljs" - ], - "dependencies": { - "@types/node": "*" - }, - "devDependencies": { - "@types/libxmljs": "workspace:." - }, - "owners": [ - { - "name": "François de Campredon", - "githubUsername": "fdecampredon" - }, - { - "name": "ComFreek", - "githubUsername": "ComFreek" - } - ] -} diff --git a/types/libxmljs/tsconfig.json b/types/libxmljs/tsconfig.json deleted file mode 100644 index ba83743e8b4ae8..00000000000000 --- a/types/libxmljs/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "compilerOptions": { - "module": "node16", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "libxmljs-tests.ts" - ] -} diff --git a/types/libxslt/package.json b/types/libxslt/package.json index 854b1fbe120558..e6a0caab5725bf 100644 --- a/types/libxslt/package.json +++ b/types/libxslt/package.json @@ -6,7 +6,7 @@ "https://github.com/albanm/node-libxslt" ], "dependencies": { - "@types/libxmljs": "*" + "@types/libxmljs": "<1" }, "devDependencies": { "@types/libxslt": "workspace:." diff --git a/types/selenium-webdriver/bidi/networkTypes.d.ts b/types/selenium-webdriver/bidi/networkTypes.d.ts new file mode 100644 index 00000000000000..4a2ae7c15a43f2 --- /dev/null +++ b/types/selenium-webdriver/bidi/networkTypes.d.ts @@ -0,0 +1,449 @@ +import { NavigationInfo } from "./browsingContextTypes"; + +/** + * Represents the navigation parameters used in network requests. + */ +export interface NavigationParameters { + context: string; + navigation: string; + timestamp: number; + url: string; +} + +/** + * Represents the possible values for the SameSite attribute of a cookie. + * @enum {string} + */ +export declare const SameSite: { + readonly STRICT: "strict"; + readonly LAX: "lax"; + readonly NONE: "none"; + readonly DEFAULT: "default"; + /** + * Finds a SameSite value by name + * @param {string} name - The name to look up + * @returns {string|null} The matching SameSite value or null if not found + */ + findByName(name: string): string | null; +}; + +/** + * Represents a BytesValue object. + * Described in https://w3c.github.io/webdriver-bidi/#type-network-BytesValue. + */ +export declare class BytesValue { + static readonly Type: { + readonly STRING: "string"; + readonly BASE64: "base64"; + }; + /** + * Creates a new BytesValue instance. + * @param {string} type - The type of the BytesValue. + * @param {string} value - The value of the BytesValue. + */ + constructor(type: string, value: string); + + /** + * Gets the type of the BytesValue. + * @returns {string} The type of the BytesValue. + */ + get type(): string; + + /** + * Gets the value of the BytesValue. + * @returns {string} The value of the BytesValue. + */ + get value(): string; + + /** + * Converts the BytesValue to a map. + * @returns {Map} A map representation of the BytesValue. + */ + asMap(): Map; +} + +/** + * Represents a header with a name and value. + * Described in https://w3c.github.io/webdriver-bidi/#type-network-Header. + */ +export declare class Header { + /** + * Creates a new Header instance. + * @param {string} name - The name of the header. + * @param {BytesValue} value - The value of the header. + * @throws {Error} If the value is not an instance of BytesValue. + */ + constructor(name: string, value: BytesValue); + + /** + * Gets the name of the header. + * @returns {string} The name of the header. + */ + get name(): string; + + /** + * Gets the value of the header. + * @returns {BytesValue} The value of the header. + */ + get value(): BytesValue; +} + +/** + * Represents a cookie. + * Described in https://w3c.github.io/webdriver-bidi/#type-network-Cookie. + */ +export declare class Cookie { + constructor( + name: string, + value: BytesValue, + domain: string, + path: string, + size: number, + httpOnly: boolean, + secure: boolean, + sameSite: string, + expires?: number, + ); + + /** + * Gets the name of the cookie. + * @returns {string} The name of the cookie. + */ + get name(): string; + + /** + * Gets the value of the cookie. + * @returns {BytesValue} The value of the cookie. + */ + get value(): BytesValue; + + /** + * Gets the domain of the cookie. + * @returns {string} The domain of the cookie. + */ + get domain(): string; + + /** + * Gets the path of the cookie. + * @returns {string} The path of the cookie. + */ + get path(): string; + + /** + * Gets the expiration date of the cookie. + * @returns {number} The expiration date of the cookie. + */ + get expires(): number | undefined; + + /** + * Gets the size of the cookie. + * @returns {number} The size of the cookie. + */ + get size(): number; + + /** + * Checks if the cookie is HTTP-only. + * @returns {boolean} True if the cookie is HTTP-only, false otherwise. + */ + get httpOnly(): boolean; + + /** + * Checks if the cookie is secure. + * @returns {boolean} True if the cookie is secure, false otherwise. + */ + get secure(): boolean; + + /** + * Gets the same-site attribute of the cookie. + * @returns {string} The same-site attribute of the cookie. + */ + get sameSite(): string; +} + +/** + * Represents the time of each part of the request. + * Described in https://w3c.github.io/webdriver-bidi/#type-network-FetchTimingInfo. + */ +export interface FetchTimingInfo { + /** The origin time. */ + originTime: number; + /** The request time. */ + requestTime: number; + /** The timestamp when the redirect started. */ + redirectStart: number; + /** The timestamp when the redirect ended. */ + redirectEnd: number; + /** The timestamp when the fetch started. */ + fetchStart: number; + /** The timestamp when the domain lookup started. */ + dnsStart: number; + /** The timestamp when the domain lookup ended. */ + dnsEnd: number; + /** The timestamp when the connection started. */ + connectStart: number; + /** The timestamp when the connection ended. */ + connectEnd: number; + /** The timestamp when the secure connection started. */ + tlsStart: number; + /** The timestamp when the request started. */ + requestStart: number; + /** The timestamp when the response started. */ + responseStart: number; + /** The timestamp when the response ended. */ + responseEnd: number; +} + +/** + * Represents the data of a network request. + * Described in https://w3c.github.io/webdriver-bidi/#type-network-RequestData. + */ +export interface RequestData { + /** The request id. */ + request: string; + /** The URL of the request. */ + url: string; + /** The HTTP method of the request. */ + method: string; + /** The headers of the request. */ + headers: Header[]; + /** The cookies of the request. */ + cookies: Cookie[]; + /** The size of the headers in bytes. */ + headersSize: number; + /** The size of the request body in bytes. */ + bodySize: number; + /** The timing information of the request. */ + timings: FetchTimingInfo; +} + +/** + * Represents the base parameters for a network request. + * Described in https://w3c.github.io/webdriver-bidi/#type-network-BaseParameters. + */ +export interface BaseParameters { + /** The browsing context ID of the network request. */ + id: string; + /** The navigation information associated with the network request, or null if not available. */ + navigation: NavigationInfo | null; + /** The number of redirects that occurred during the network request. */ + redirectCount: number; + /** The request data for the network request. */ + request: RequestData; + /** The timestamp of the network request. */ + timestamp: number; +} + +/** + * Represents source in the network. + * Described in https://w3c.github.io/webdriver-bidi/#type-network-Initiator. + */ +export interface Initiator { + /** The type of the initiator. */ + type: string; + /** The column number. */ + columnNumber: number; + /** The line number. */ + lineNumber: number; + /** The stack trace. */ + stackTrace: string; + /** The request ID. */ + request: string; +} + +/** + * Represents the BeforeRequestSent event parameters. + * Described in https://w3c.github.io/webdriver-bidi/#event-network-beforeSendRequest. + */ +export declare class BeforeRequestSent implements BaseParameters { + /** The browsing context ID of the network request. */ + id: string; + /** The navigation information associated with the network request, or null if not available. */ + navigation: NavigationInfo | null; + /** The number of redirects that occurred during the network request. */ + redirectCount: number; + /** The request data for the network request. */ + request: RequestData; + /** The timestamp of the network request. */ + timestamp: number; + + constructor( + id: string, + navigation: NavigationParameters | null, + redirectCount: number, + request: RequestData, + timestamp: number, + initiator: Initiator, + ); + + /** + * Get the initiator of the request. + * @returns {Initiator} The initiator object. + */ + get initiator(): Initiator; +} + +/** + * Represents the response data received from a network request. + * Described in https://w3c.github.io/webdriver-bidi/#type-network-ResponseData. + */ +export interface ResponseData { + /** The URL. */ + url: string; + /** The protocol. */ + protocol: string; + /** The HTTP status. */ + status: number; + /** The status text. */ + statusText: string; + /** The value indicating whether the data is retrieved from cache. */ + fromCache: boolean; + /** The headers object. */ + headers: Record; + /** The MIME type of the network resource. */ + mimeType: string; + /** The number of bytes received. */ + bytesReceived: number; + /** The size of the headers. */ + headerSize: number; + /** The size of the body. */ + bodySize: number; + /** The content. */ + content: unknown; +} + +/** + * Represents the response data received from a network request. + * Described in https://w3c.github.io/webdriver-bidi/#type-network-ResponseData. + */ +declare class ResponseData { + constructor( + url: string, + protocol: string, + status: number, + statusText: string, + fromCache: boolean, + headers: Record, + mimeType: string, + bytesReceived: number, + headersSize: number, + bodySize: number, + content: unknown, + ); + + /** + * Get the URL. + * @returns {string} The URL. + */ + get url(): string; + + /** + * Get the protocol. + * @returns {string} The protocol. + */ + get protocol(): string; + + /** + * Get the HTTP status. + * @returns {string} The HTTP status. + */ + get status(): number; + + /** + * Gets the status text. + * @returns {string} The status text. + */ + get statusText(): string; + + /** + * Gets the value indicating whether the data is retrieved from cache. + * @returns {boolean} The value indicating whether the data is retrieved from cache. + */ + get fromCache(): boolean; + + /** + * Get the headers. + * @returns {Object} The headers object. + */ + get headers(): Record; + + /** + * The MIME type of the network resource. + * @returns {string} The MIME type of the network resource. + */ + get mimeType(): string; + + /** + * Gets the number of bytes received. + * @returns {number} The number of bytes received. + */ + get bytesReceived(): number; + + /** + * Get the size of the headers. + * @returns {number} The size of the headers. + */ + get headerSize(): number; + + /** + * Get the size of the body. + * @returns {number} The size of the body. + */ + get bodySize(): number; + + /** + * Gets the content. + * @returns {any} The content. + */ + get content(): unknown; +} + +/** + * Represents the ResponseStarted event parameters. + * Described in https://w3c.github.io/webdriver-bidi/#event-network-responseStarted. + */ +export declare class ResponseStarted extends BaseParameters { + constructor( + id: string, + navigation: NavigationParameters | null, + redirectCount: number, + request: RequestData, + timestamp: number, + response: ResponseData, + ); + + /** + * Get the response data. + * @returns {ResponseData} The response data. + */ + get response(): ResponseData; +} + +/** + * Represents the FetchError event parameters. + * Described https://w3c.github.io/webdriver-bidi/#event-network-fetchError + */ +export declare class FetchError extends BaseParameters { + /** + * Creates a new FetchError instance. + * @param {string} id - The ID of the error. + * @param {string} navigation - The navigation information. + * @param {number} redirectCount - The number of redirects. + * @param {RequestData} request - The request object. + * @param {number} timestamp - The timestamp of the error. + * @param {string} errorText - The error text. + */ + constructor( + id: string, + navigation: NavigationParameters | null, + redirectCount: number, + request: RequestData, + timestamp: number, + errorText: string, + ); + + /** + * Gets the error text. + * @returns {string} The error text. + */ + get errorText(): string; +} diff --git a/types/selenium-webdriver/package.json b/types/selenium-webdriver/package.json index 4b04f02f2f1e75..4b1a4388671ff3 100644 --- a/types/selenium-webdriver/package.json +++ b/types/selenium-webdriver/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@types/selenium-webdriver", - "version": "4.1.9999", + "version": "4.35.9999", "projects": [ "https://github.com/SeleniumHQ/selenium" ], diff --git a/types/selenium-webdriver/test/bidi/networkTypes.ts b/types/selenium-webdriver/test/bidi/networkTypes.ts new file mode 100644 index 00000000000000..d31f503d5183ba --- /dev/null +++ b/types/selenium-webdriver/test/bidi/networkTypes.ts @@ -0,0 +1,171 @@ +import { + BeforeRequestSent, + BytesValue, + Cookie, + FetchError, + Header, + ResponseStarted, + SameSite, +} from "selenium-webdriver/bidi/networkTypes"; + +// $ExpectType "strict" +SameSite.STRICT; +// $ExpectType "lax" +SameSite.LAX; +// $ExpectType "none" +SameSite.NONE; +// $ExpectType "default" +SameSite.DEFAULT; + +// $ExpectType string | null +SameSite.findByName("strict"); + +// $ExpectType string | null +SameSite.findByName("invalid"); + +// $ExpectType BytesValue +const bytesValue = new BytesValue("string", "test"); +// $ExpectType string +bytesValue.type; +// $ExpectType string +bytesValue.value; +// $ExpectType Map +bytesValue.asMap(); + +// $ExpectType "string" +BytesValue.Type.STRING; +// $ExpectType "base64" +BytesValue.Type.BASE64; + +// $ExpectType Header +const header = new Header("content-type", bytesValue); +// $ExpectType string +header.name; +// $ExpectType BytesValue +header.value; + +// @ts-expect-error +new Header("content-type", "invalid"); + +// $ExpectType Cookie +const cookie = new Cookie("name", bytesValue, "domain", "/", 100, true, true, "strict"); +// $ExpectType string +cookie.name; +// $ExpectType BytesValue +cookie.value; +// $ExpectType string +cookie.domain; +// $ExpectType string +cookie.path; +// $ExpectType number | undefined +cookie.expires; +// $ExpectType number +cookie.size; +// $ExpectType boolean +cookie.httpOnly; +// $ExpectType boolean +cookie.secure; +// $ExpectType string +cookie.sameSite; + +// $ExpectType BeforeRequestSent +const beforeRequestSent = new BeforeRequestSent( + "id1", + { + context: "ctx1", + navigation: "nav1", + timestamp: 123456789, + url: "https://example.com", + }, + 0, + { + request: "req1", + url: "https://example.com", + method: "GET", + headers: [{ name: "content-type", value: new BytesValue("string", "text/html") }], + cookies: [], + headersSize: 100, + bodySize: 200, + timings: { + originTime: 100, + requestTime: 200, + redirectStart: 300, + redirectEnd: 400, + fetchStart: 500, + dnsStart: 600, + dnsEnd: 700, + connectStart: 800, + connectEnd: 900, + tlsStart: 1000, + requestStart: 1100, + responseStart: 1200, + responseEnd: 1300, + }, + }, + 123456789, + { + type: "script", + columnNumber: 1, + lineNumber: 1, + stackTrace: "stack trace", + request: "req1", + }, +); + +// $ExpectType string +beforeRequestSent.id; +// $ExpectType string +beforeRequestSent.request.url; + +// $ExpectType ResponseStarted +const responseStarted = new ResponseStarted( + "id1", + { + context: "ctx1", + navigation: "nav1", + timestamp: 123456789, + url: "https://example.com", + }, + 0, + beforeRequestSent.request, + 123456789, + { + url: "https://example.com", + protocol: "https", + status: 200, + statusText: "OK", + fromCache: false, + headers: { "content-type": "text/html" }, + mimeType: "text/html", + bytesReceived: 1000, + headerSize: 100, + bodySize: 900, + content: "content", + }, +); + +// $ExpectType string +responseStarted.response.url; +// $ExpectType number +responseStarted.response.status; + +// $ExpectType FetchError +const fetchError = new FetchError( + "id1", + { + context: "ctx1", + navigation: "nav1", + timestamp: 123456789, + url: "https://example.com", + }, + 0, + beforeRequestSent.request, + 123456789, + "Network error", +); + +// $ExpectType string +fetchError.errorText; + +// @ts-expect-error +new FetchError(); diff --git a/types/selenium-webdriver/tsconfig.json b/types/selenium-webdriver/tsconfig.json index 5c615fafb99318..56667968f26056 100644 --- a/types/selenium-webdriver/tsconfig.json +++ b/types/selenium-webdriver/tsconfig.json @@ -19,6 +19,7 @@ "test/bidi/filterBy.ts", "test/bidi/logEntries.ts", "test/bidi/logInspector.ts", + "test/bidi/networkTypes.ts", "test/ie.ts", "test/index.ts", "test/chrome.ts",