realm.d.ts 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /**
  2. * Copyright 2022 Google LLC.
  3. * Copyright (c) Microsoft Corporation.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. import type { Protocol } from 'devtools-protocol';
  18. import { Script } from '../../../protocol/protocol.js';
  19. import type { CommonDataTypes } from '../../../protocol/protocol.js';
  20. import type { BrowsingContextStorage } from '../context/browsingContextStorage.js';
  21. import type { IEventManager } from '../events/EventManager.js';
  22. import type { ICdpClient } from '../../../cdp/cdpClient.js';
  23. import { type LoggerFn } from '../../../utils/log.js';
  24. import type { RealmStorage } from './realmStorage.js';
  25. export type RealmType = Script.RealmType;
  26. export declare class Realm {
  27. #private;
  28. readonly sandbox?: string;
  29. readonly cdpSessionId: string;
  30. 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: ICdpClient, eventManager: IEventManager, logger?: LoggerFn);
  31. disown(handle: CommonDataTypes.Handle): Promise<void>;
  32. cdpToBidiValue(cdpValue: Protocol.Runtime.CallFunctionOnResponse | Protocol.Runtime.EvaluateResponse, resultOwnership: Script.ResultOwnership): CommonDataTypes.RemoteValue;
  33. deepSerializedToBiDi(webDriverValue: Protocol.Runtime.DeepSerializedValue): CommonDataTypes.RemoteValue;
  34. toBiDi(): Script.RealmInfo;
  35. get realmId(): Script.Realm;
  36. get navigableId(): string;
  37. get browsingContextId(): CommonDataTypes.BrowsingContext;
  38. get executionContextId(): Protocol.Runtime.ExecutionContextId;
  39. get origin(): string;
  40. get type(): RealmType;
  41. get cdpClient(): ICdpClient;
  42. callFunction(functionDeclaration: string, _this: Script.ArgumentValue, _arguments: Script.ArgumentValue[], awaitPromise: boolean, resultOwnership: Script.ResultOwnership, serializationOptions: Script.SerializationOptions): Promise<Script.CallFunctionResult>;
  43. scriptEvaluate(expression: string, awaitPromise: boolean, resultOwnership: Script.ResultOwnership, serializationOptions: Script.SerializationOptions): Promise<Script.EvaluateResult>;
  44. /**
  45. * Serializes a given CDP object into BiDi, keeping references in the
  46. * target's `globalThis`.
  47. * @param cdpObject CDP remote object to be serialized.
  48. * @param resultOwnership Indicates desired ResultOwnership.
  49. */
  50. serializeCdpObject(cdpObject: Protocol.Runtime.RemoteObject, resultOwnership: Script.ResultOwnership): Promise<CommonDataTypes.RemoteValue>;
  51. /**
  52. * Gets the string representation of an object. This is equivalent to
  53. * calling toString() on the object value.
  54. * @param cdpObject CDP remote object representing an object.
  55. * @return string The stringified object.
  56. */
  57. stringifyObject(cdpObject: Protocol.Runtime.RemoteObject): Promise<string>;
  58. delete(): void;
  59. }