browsingContextImpl.d.ts 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 { BrowsingContext, type CommonDataTypes, Message } from '../../../protocol/protocol.js';
  19. import { type LoggerFn } from '../../../utils/log.js';
  20. import type { IEventManager } from '../events/EventManager.js';
  21. import { Realm } from '../script/realm.js';
  22. import type { RealmStorage } from '../script/realmStorage.js';
  23. import type { BrowsingContextStorage } from './browsingContextStorage.js';
  24. import type { CdpTarget } from './cdpTarget.js';
  25. export declare class BrowsingContextImpl {
  26. #private;
  27. private constructor();
  28. static create(cdpTarget: CdpTarget, realmStorage: RealmStorage, id: CommonDataTypes.BrowsingContext, parentId: CommonDataTypes.BrowsingContext | null, eventManager: IEventManager, browsingContextStorage: BrowsingContextStorage, logger?: LoggerFn): BrowsingContextImpl;
  29. static getTimestamp(): number;
  30. /**
  31. * @see https://html.spec.whatwg.org/multipage/document-sequences.html#navigable
  32. */
  33. get navigableId(): string | undefined;
  34. delete(): void;
  35. /** Returns the ID of this context. */
  36. get id(): CommonDataTypes.BrowsingContext;
  37. /** Returns the parent context ID. */
  38. get parentId(): CommonDataTypes.BrowsingContext | null;
  39. /** Returns the parent context. */
  40. get parent(): BrowsingContextImpl | null;
  41. /** Returns all direct children contexts. */
  42. get directChildren(): BrowsingContextImpl[];
  43. /** Returns all children contexts, flattened. */
  44. get allChildren(): BrowsingContextImpl[];
  45. /**
  46. * Returns true if this is a top-level context.
  47. * This is the case whenever the parent context ID is null.
  48. */
  49. isTopLevelContext(): boolean;
  50. get top(): BrowsingContextImpl;
  51. addChild(childId: CommonDataTypes.BrowsingContext): void;
  52. get cdpTarget(): CdpTarget;
  53. updateCdpTarget(cdpTarget: CdpTarget): void;
  54. get url(): string;
  55. awaitLoaded(): Promise<void>;
  56. awaitUnblocked(): Promise<void>;
  57. getOrCreateSandbox(sandbox: string | undefined): Promise<Realm>;
  58. serializeToBidiValue(maxDepth?: number, addParentField?: boolean): BrowsingContext.Info;
  59. onTargetInfoChanged(params: Protocol.Target.TargetInfoChangedEvent): void;
  60. navigate(url: string, wait: BrowsingContext.ReadinessState): Promise<BrowsingContext.NavigateResult>;
  61. reload(ignoreCache: boolean, wait: BrowsingContext.ReadinessState): Promise<Message.EmptyResult>;
  62. setViewport(viewport: BrowsingContext.Viewport | null): Promise<void>;
  63. captureScreenshot(): Promise<BrowsingContext.CaptureScreenshotResult>;
  64. print(params: BrowsingContext.PrintParameters): Promise<BrowsingContext.PrintResult>;
  65. }