test: verify closing last page does not close connection (#12095)

Co-authored-by: Nikolay Vitkov <34244704+Lightning00Blade@users.noreply.github.com>
This commit is contained in:
Maksim Sadym 2024-03-15 13:21:51 +01:00 committed by GitHub
parent 9b7b443f9e
commit a1c527df96
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6,7 +6,7 @@
import expect from 'expect';
import {getTestState, setupTestBrowserHooks} from './mocha-utils.js';
import {getTestState, launch, setupTestBrowserHooks} from './mocha-utils.js';
describe('Browser specs', function () {
setupTestBrowserHooks();
@ -64,6 +64,23 @@ describe('Browser specs', function () {
expect(remoteBrowser.process()).toBe(null);
await remoteBrowser.disconnect();
});
it('should keep connected after the last page is closed', async () => {
const {browser, close} = await launch({}, {createContext: false});
try {
const pages = await browser.pages();
await Promise.all(
pages.map(page => {
return page.close();
})
);
// Verify the browser is still connected.
expect(browser.connected).toBe(true);
// Verify the browser can open a new page.
await browser.newPage();
} finally {
await close();
}
});
});
describe('Browser.isConnected', () => {