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: export Frame._client through getter #8041

Merged
merged 1 commit into from Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions src/common/FrameManager.ts
Expand Up @@ -702,6 +702,11 @@ export class Frame {
);
}

/**
* @remarks
*
* @returns `true` if the frame is an OOP frame, or `false` otherwise.
*/
isOOPFrame(): boolean {
return this._client !== this._frameManager._client;
}
Expand Down Expand Up @@ -785,6 +790,13 @@ export class Frame {
return await this._frameManager.waitForFrameNavigation(this, options);
}

/**
* @internal
*/
client(): CDPSession {
return this._client;
}

/**
* @returns a promise that resolves to the frame's default execution context.
*/
jrandolf-zz marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
8 changes: 8 additions & 0 deletions test/frame.spec.ts
Expand Up @@ -22,6 +22,7 @@ import {
setupTestPageAndContextHooks,
itFailsFirefox,
} from './mocha-utils'; // eslint-disable-line import/extensions
import { CDPSession } from '../lib/cjs/puppeteer/common/Connection.js';

describe('Frame specs', function () {
setupTestBrowserHooks();
Expand Down Expand Up @@ -278,4 +279,11 @@ describe('Frame specs', function () {
);
});
});

describe('Frame.client', function () {
it('should return the client instance', async () => {
const { page } = getTestState();
expect(page.mainFrame().client()).toBeInstanceOf(CDPSession);
});
});
});
1 change: 1 addition & 0 deletions utils/doclint/check_public_api/index.js
Expand Up @@ -24,6 +24,7 @@ const {

const EXCLUDE_PROPERTIES = new Set([
'Browser.create',
'Frame.client',
'Headers.fromPayload',
'Page.client',
'Page.create',
Expand Down