Skip to content

Commit

Permalink
feat: export Frame._client through getter (#8041)
Browse files Browse the repository at this point in the history
Co-authored-by: Randolf Jung <jrandolf@chromium.org>
  • Loading branch information
jrandolf-zz and jrandolf committed Feb 21, 2022
1 parent c5e01ef commit e9278fc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
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.
*/
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

0 comments on commit e9278fc

Please sign in to comment.