scriptEvaluator.d.ts 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 { type CommonDataTypes, type Script } from '../../../protocol/protocol.js';
  19. import type { IEventManager } from '../events/EventManager.js';
  20. import type { Realm } from './realm.js';
  21. export declare const SHARED_ID_DIVIDER = "_element_";
  22. export declare class ScriptEvaluator {
  23. #private;
  24. constructor(eventManager: IEventManager);
  25. /**
  26. * Gets the string representation of an object. This is equivalent to
  27. * calling toString() on the object value.
  28. * @param cdpObject CDP remote object representing an object.
  29. * @param realm
  30. * @return string The stringified object.
  31. */
  32. static stringifyObject(cdpObject: Protocol.Runtime.RemoteObject, realm: Realm): Promise<string>;
  33. /**
  34. * Serializes a given CDP object into BiDi, keeping references in the
  35. * target's `globalThis`.
  36. * @param cdpRemoteObject CDP remote object to be serialized.
  37. * @param resultOwnership Indicates desired ResultOwnership.
  38. * @param realm
  39. */
  40. serializeCdpObject(cdpRemoteObject: Protocol.Runtime.RemoteObject, resultOwnership: Script.ResultOwnership, realm: Realm): Promise<CommonDataTypes.RemoteValue>;
  41. scriptEvaluate(realm: Realm, expression: string, awaitPromise: boolean, resultOwnership: Script.ResultOwnership, serializationOptions: Script.SerializationOptions): Promise<Script.ScriptResult>;
  42. callFunction(realm: Realm, functionDeclaration: string, _this: Script.ArgumentValue, _arguments: Script.ArgumentValue[], awaitPromise: boolean, resultOwnership: Script.ResultOwnership, serializationOptions: Script.SerializationOptions): Promise<Script.ScriptResult>;
  43. }