feat: export Frame._client through getter (#8041)

Co-authored-by: Randolf Jung <jrandolf@chromium.org>
This commit is contained in:
jrandolf 2022-02-21 15:58:37 +01:00 committed by GitHub
parent c5e01efdef
commit e9278fcfcf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 0 deletions

View File

@ -702,6 +702,11 @@ export class Frame {
); );
} }
/**
* @remarks
*
* @returns `true` if the frame is an OOP frame, or `false` otherwise.
*/
isOOPFrame(): boolean { isOOPFrame(): boolean {
return this._client !== this._frameManager._client; return this._client !== this._frameManager._client;
} }
@ -785,6 +790,13 @@ export class Frame {
return await this._frameManager.waitForFrameNavigation(this, options); 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. * @returns a promise that resolves to the frame's default execution context.
*/ */

View File

@ -22,6 +22,7 @@ import {
setupTestPageAndContextHooks, setupTestPageAndContextHooks,
itFailsFirefox, itFailsFirefox,
} from './mocha-utils'; // eslint-disable-line import/extensions } from './mocha-utils'; // eslint-disable-line import/extensions
import { CDPSession } from '../lib/cjs/puppeteer/common/Connection.js';
describe('Frame specs', function () { describe('Frame specs', function () {
setupTestBrowserHooks(); setupTestBrowserHooks();
@ -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);
});
});
}); });

View File

@ -24,6 +24,7 @@ const {
const EXCLUDE_PROPERTIES = new Set([ const EXCLUDE_PROPERTIES = new Set([
'Browser.create', 'Browser.create',
'Frame.client',
'Headers.fromPayload', 'Headers.fromPayload',
'Page.client', 'Page.client',
'Page.create', 'Page.create',