webdriverio
Version:
Next-gen browser and mobile automation test framework for Node.js
46 lines • 2.19 kB
TypeScript
/**
* BiDi script results have no Blob type. `execute` runs the helper below in the
* browser and turns Blob/File into a plain object. `deserialize` rebuilds a
* Blob or File from that object.
*
* Graphs that do not contain a Blob or File are returned unchanged so BiDi can
* keep shared references and cycles. A cycle inside a graph that does contain
* one is replaced with `null`, because that graph has to be copied before BiDi
* sees it.
*
* Blob, File, and FileList are detected by the brand they inherit, so a value
* created in a same-origin iframe still transfers. Own fields on that value are
* copied onto the result. An ordinary object that sets the brand itself is left
* unchanged. The helper is appended after the user
* script so BiDi exception line numbers keep pointing at the user's code.
*
* This module does not import Node builtins. The browser runner loads it too.
*/
export declare const SERIALIZED_BLOB_KEY = "__wdioSerializedBlob__";
export declare const SERIALIZED_BLOB_KIND_BLOB = "blob";
export declare const SERIALIZED_BLOB_KIND_FILE = "file";
type SerializedBlobKind = typeof SERIALIZED_BLOB_KIND_BLOB | typeof SERIALIZED_BLOB_KIND_FILE;
export interface SerializedBlobValue {
[SERIALIZED_BLOB_KEY]: true;
data: string;
type: string;
size: number;
kind: SerializedBlobKind;
name?: string;
lastModified?: number;
props?: Record<string, unknown>;
}
/**
* BiDi function declaration for `execute`.
*
* The user script stays between the script markers, on the same lines
* `createFunctionDeclarationFromString` would emit, so a thrown line still
* points at the user's code. Blob encoding runs only after that call returns.
* A rejected user promise is returned as-is: the `.then` has no rejection
* handler, so the original throw location is preserved.
*/
export declare function createBidiFunctionDeclaration(script: string | Function): string;
export declare function isSerializedBlobValue(value: unknown): value is SerializedBlobValue;
export declare function createBlobFromSerializedValue(value: SerializedBlobValue): Uint8Array<ArrayBufferLike> | Blob;
export {};
//# sourceMappingURL=serialize.d.ts.map