diff --git a/src/common/ElementHandle.ts b/src/common/ElementHandle.ts index d6a95199ea5..3078ee202ca 100644 --- a/src/common/ElementHandle.ts +++ b/src/common/ElementHandle.ts @@ -2,7 +2,8 @@ import {Protocol} from 'devtools-protocol'; import {assert} from '../util/assert.js'; import {CDPSession} from './Connection.js'; import {ExecutionContext} from './ExecutionContext.js'; -import {Frame, FrameManager} from './FrameManager.js'; +import {FrameManager} from './FrameManager.js'; +import {Frame} from './Frame.js'; import { MAIN_WORLD, PUPPETEER_WORLD, diff --git a/src/common/ExecutionContext.ts b/src/common/ExecutionContext.ts index 86c44d47142..114652b0f89 100644 --- a/src/common/ExecutionContext.ts +++ b/src/common/ExecutionContext.ts @@ -17,7 +17,7 @@ import {Protocol} from 'devtools-protocol'; import {assert} from '../util/assert.js'; import {CDPSession} from './Connection.js'; -import {Frame} from './FrameManager.js'; +import {Frame} from './Frame.js'; import {IsolatedWorld} from './IsolatedWorld.js'; import {JSHandle} from './JSHandle.js'; import {EvaluateFunc, HandleFor} from './types.js'; diff --git a/src/common/Frame.ts b/src/common/Frame.ts new file mode 100644 index 00000000000..62ad69cd63d --- /dev/null +++ b/src/common/Frame.ts @@ -0,0 +1,975 @@ +import {Protocol} from 'devtools-protocol'; +import {isErrorLike} from '../util/ErrorLike.js'; +import {CDPSession} from './Connection.js'; +import {ElementHandle} from './ElementHandle.js'; +import {ExecutionContext} from './ExecutionContext.js'; +import {FrameManager} from './FrameManager.js'; +import {HTTPResponse} from './HTTPResponse.js'; +import {MouseButton} from './Input.js'; +import { + IsolatedWorld, + IsolatedWorldChart, + MAIN_WORLD, + PUPPETEER_WORLD, + WaitForSelectorOptions, +} from './IsolatedWorld.js'; +import {LifecycleWatcher, PuppeteerLifeCycleEvent} from './LifecycleWatcher.js'; +import {Page} from './Page.js'; +import {EvaluateFunc, HandleFor, NodeFor} from './types.js'; + +/** + * @public + */ +export interface FrameWaitForFunctionOptions { + /** + * An interval at which the `pageFunction` is executed, defaults to `raf`. If + * `polling` is a number, then it is treated as an interval in milliseconds at + * which the function would be executed. If `polling` is a string, then it can + * be one of the following values: + * + * - `raf` - to constantly execute `pageFunction` in `requestAnimationFrame` + * callback. This is the tightest polling mode which is suitable to observe + * styling changes. + * + * - `mutation` - to execute `pageFunction` on every DOM mutation. + */ + polling?: string | number; + /** + * Maximum time to wait in milliseconds. Defaults to `30000` (30 seconds). + * Pass `0` to disable the timeout. Puppeteer's default timeout can be changed + * using {@link Page.setDefaultTimeout}. + */ + timeout?: number; +} + +/** + * @public + */ +export interface FrameAddScriptTagOptions { + /** + * the URL of the script to be added. + */ + url?: string; + /** + * The path to a JavaScript file to be injected into the frame. + * @remarks + * If `path` is a relative path, it is resolved relative to the current + * working directory (`process.cwd()` in Node.js). + */ + path?: string; + /** + * Raw JavaScript content to be injected into the frame. + */ + content?: string; + /** + * Set the script's `type`. Use `module` in order to load an ES2015 module. + */ + type?: string; +} + +/** + * @public + */ +export interface FrameAddStyleTagOptions { + /** + * the URL of the CSS file to be added. + */ + url?: string; + /** + * The path to a CSS file to be injected into the frame. + * @remarks + * If `path` is a relative path, it is resolved relative to the current + * working directory (`process.cwd()` in Node.js). + */ + path?: string; + /** + * Raw CSS content to be injected into the frame. + */ + content?: string; +} + +/** + * Represents a DOM frame. + * + * To understand frames, you can think of frames as `