test: add a test for newCDPSession rejecting on non-pages (#3353)
This commit is contained in:
parent
83f5628549
commit
7e2cc77524
|
|
@ -463,6 +463,8 @@ export class CRBrowserContext extends BrowserContextBase {
|
|||
}
|
||||
|
||||
async newCDPSession(page: Page): Promise<CRSession> {
|
||||
if (!(page instanceof Page))
|
||||
throw new Error('page: expected Page');
|
||||
const targetId = (page._delegate as CRPage)._targetId;
|
||||
const rootSession = await this._browser._clientRootSession();
|
||||
const { sessionId } = await rootSession.send('Target.attachToTarget', { targetId, flatten: true });
|
||||
|
|
|
|||
|
|
@ -36,6 +36,11 @@ it.skip(!CHROMIUM)('should send events', async function({page, server}) {
|
|||
expect(events.length).toBe(1);
|
||||
});
|
||||
|
||||
it.skip(!CHROMIUM)('should only accept a page', async function({page}) {
|
||||
const error = await page.context().newCDPSession(page.context()).catch(e => e);
|
||||
expect(error.message).toContain('page: expected Page');
|
||||
});
|
||||
|
||||
it.skip(!CHROMIUM)('should enable and disable domains independently', async function({page}) {
|
||||
const client = await page.context().newCDPSession(page);
|
||||
await client.send('Runtime.enable');
|
||||
|
|
|
|||
Loading…
Reference in a new issue