Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(oop iframes): integrate OOP iframes with the frame manager #7556

Merged
merged 36 commits into from Oct 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
df7b551
feat(oop iframes): integrate OOP iframes with the frame manager
jschfflr Sep 10, 2021
cb7181a
Merge branch 'main' into oopiframes
jschfflr Sep 16, 2021
06efa14
Merge remote-tracking branch 'origin/main' into oopiframes
jschfflr Sep 28, 2021
8b4e6ab
chore: address comments
jschfflr Sep 29, 2021
33a0697
chore: doc
jschfflr Sep 29, 2021
596aca6
chore: remove waitForDebugger
jschfflr Sep 30, 2021
809967e
Merge branch 'main' into oopiframes
jschfflr Sep 30, 2021
427161f
chore: remove comment
jschfflr Sep 30, 2021
60dc380
chore: refactor
jschfflr Sep 30, 2021
98ff402
chore: refactor
jschfflr Sep 30, 2021
2bff462
chore: remove eslint comment
jschfflr Sep 30, 2021
3409e0d
Merge remote-tracking branch 'origin/main' into oopiframes
jschfflr Oct 12, 2021
a0c20d1
chore: remove changes to target.spec.js
jschfflr Oct 12, 2021
4c7c086
chore: waitForFrame
jschfflr Oct 12, 2021
caff71a
chore: fix
jschfflr Oct 12, 2021
d23f0c7
chore: fix waitForFrame
jschfflr Oct 13, 2021
dbb40dc
chore: fix waitForFrame
jschfflr Oct 13, 2021
a1ff4f6
chore: fix waitForFrame
jschfflr Oct 13, 2021
88592b5
Merge branch 'main' into oopiframes
jschfflr Oct 27, 2021
81e227b
chore: rebase test
jschfflr Oct 27, 2021
e949b21
chore: waitForFrame
jschfflr Oct 27, 2021
2d9cc48
Merge branch 'main' into oopiframes
jschfflr Oct 27, 2021
719c45f
chore: fix session for initial frame tree
jschfflr Oct 27, 2021
dc473e7
Merge branch 'main' into oopiframes
jschfflr Oct 27, 2021
b3fdd34
chore: fix test
jschfflr Oct 27, 2021
aa3b26f
chore: eslint fix
jschfflr Oct 27, 2021
0e93395
chore: remove promise
jschfflr Oct 27, 2021
1c3867e
chore: debug protocol
jschfflr Oct 27, 2021
18696ef
chore: only oop iframe tests
jschfflr Oct 27, 2021
a1281cd
chore: test
jschfflr Oct 27, 2021
30995b3
chore: update
jschfflr Oct 28, 2021
33b1558
Merge remote-tracking branch 'origin/main' into oopiframes
jschfflr Oct 28, 2021
d8adbb8
chore: update docs
jschfflr Oct 28, 2021
ee378a3
chore: ignore session closed errors
jschfflr Oct 28, 2021
9e04124
Merge branch 'main' into oopiframes
jschfflr Oct 28, 2021
7d7210a
chore: address comment
jschfflr Oct 28, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 28 additions & 0 deletions docs/api.md
Expand Up @@ -195,6 +195,7 @@
* [page.viewport()](#pageviewport)
* [page.waitFor(selectorOrFunctionOrTimeout[, options[, ...args]])](#pagewaitforselectororfunctionortimeout-options-args)
* [page.waitForFileChooser([options])](#pagewaitforfilechooseroptions)
* [page.waitForFrame(urlOrPredicate[, options])](#pagewaitforframeurlorpredicate-options)
* [page.waitForFunction(pageFunction[, options[, ...args]])](#pagewaitforfunctionpagefunction-options-args)
* [page.waitForNavigation([options])](#pagewaitfornavigationoptions)
* [page.waitForNetworkIdle([options])](#pagewaitfornetworkidleoptions)
Expand Down Expand Up @@ -269,6 +270,7 @@
* [frame.goto(url[, options])](#framegotourl-options)
* [frame.hover(selector)](#framehoverselector)
* [frame.isDetached()](#frameisdetached)
* [frame.isOOPFrame()](#frameisoopframe)
* [frame.name()](#framename)
* [frame.parentFrame()](#frameparentframe)
* [frame.select(selector, ...values)](#frameselectselector-values)
Expand Down Expand Up @@ -385,6 +387,7 @@
- [class: CDPSession](#class-cdpsession)
* [cdpSession.connection()](#cdpsessionconnection)
* [cdpSession.detach()](#cdpsessiondetach)
* [cdpSession.id()](#cdpsessionid)
* [cdpSession.send(method[, ...paramArgs])](#cdpsessionsendmethod-paramargs)
- [class: Coverage](#class-coverage)
* [coverage.startCSSCoverage([options])](#coveragestartcsscoverageoptions)
Expand Down Expand Up @@ -2769,6 +2772,19 @@ await fileChooser.accept(['/tmp/myfile.pdf']);

> **NOTE** “File picker” refers to the operating system’s file selection UI that lets you browse to a folder and select file(s) to be shared with the web app. It’s not the “Save file” dialog.

#### page.waitForFrame(urlOrPredicate[, options])

- `urlOrPredicate` <[string]|[Function]> A URL or predicate to wait for.
- `options` <[Object]> Optional waiting parameters
- `timeout` <[number]> Maximum wait time in milliseconds, defaults to 30 seconds, pass `0` to disable the timeout. The default value can be changed by using the [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) method.
- returns: <[Promise]<[Frame]>> Promise which resolves to the matched frame.

```js
const frame = await page.waitForFrame(async (frame) => {
return frame.name() === 'Test';
});
```

#### page.waitForFunction(pageFunction[, options[, ...args]])

- `pageFunction` <[function]|[string]> Function to be evaluated in browser context
Expand Down Expand Up @@ -3833,6 +3849,12 @@ If there's no element matching `selector`, the method throws an error.

Returns `true` if the frame has been detached, or `false` otherwise.

#### frame.isOOPFrame()

- returns: <[boolean]>

Returns `true` if the frame is an OOP frame, or `false` otherwise.

#### frame.name()

- returns: <[string]>
Expand Down Expand Up @@ -5088,6 +5110,12 @@ Returns the underlying connection associated with the session. Can be used to ob
Detaches the cdpSession from the target. Once detached, the cdpSession object won't emit any events and can't be used
to send messages.

#### cdpSession.id()

- returns: <[string]>

Returns the session's id.

#### cdpSession.send(method[, ...paramArgs])

- `method` <[string]> protocol method name
Expand Down
7 changes: 7 additions & 0 deletions src/common/Connection.ts
Expand Up @@ -350,6 +350,13 @@ export class CDPSession extends EventEmitter {
this._connection = null;
this.emit(CDPSessionEmittedEvents.Disconnected);
}

/**
* @internal
*/
id(): string {
return this._sessionId;
}
}

/**
Expand Down
8 changes: 7 additions & 1 deletion src/common/DOMWorld.ts
Expand Up @@ -37,6 +37,7 @@ import {
} from './EvalTypes.js';
import { isNode } from '../environment.js';
import { Protocol } from 'devtools-protocol';
import { CDPSession } from './Connection.js';

// predicateQueryHandler and checkWaitForOptions are declared here so that
// TypeScript knows about them when used in the predicate function below.
Expand Down Expand Up @@ -72,6 +73,7 @@ export interface PageBinding {
*/
export class DOMWorld {
private _frameManager: FrameManager;
private _client: CDPSession;
private _frame: Frame;
private _timeoutSettings: TimeoutSettings;
private _documentPromise?: Promise<ElementHandle> = null;
Expand All @@ -96,15 +98,19 @@ export class DOMWorld {
`${name}_${contextId}`;

constructor(
client: CDPSession,
frameManager: FrameManager,
frame: Frame,
timeoutSettings: TimeoutSettings
) {
// Keep own reference to client because it might differ from the FrameManager's
// client for OOP iframes.
this._client = client;
jschfflr marked this conversation as resolved.
Show resolved Hide resolved
this._frameManager = frameManager;
this._frame = frame;
this._timeoutSettings = timeoutSettings;
this._setContext(null);
frameManager._client.on('Runtime.bindingCalled', (event) =>
this._client.on('Runtime.bindingCalled', (event) =>
this._onBindingCalled(event)
);
}
Expand Down