Skip to content

Commit fb8a55f

Browse files
committed
feat: add t.openIsolatedSession() for multi-user e2e tests via CDP
Add the ability to open fully isolated browser sessions within a single test. Each session gets its own Chrome browser context (separate cookies, localStorage, sessionStorage, service workers) via CDP's Target.createBrowserContext(). Includes 40 functional tests, selector chaining support, t2.run() for transparent Selector/ClientFunction evaluation, and automatic cleanup. Requires Native Automation mode (Chrome only).
1 parent cd8b2c6 commit fb8a55f

File tree

25 files changed

+3262
-1
lines changed

25 files changed

+3262
-1
lines changed

gulp/constants/functional-test-globs.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const MULTIPLE_WINDOWS_TESTS_GLOB = 'test/functional/fixtures/multiple-windows/test.js';
2+
const ISOLATED_SESSIONS_TESTS_GLOB = 'test/functional/fixtures/isolated-sessions/test.js';
23
const HEADED_CHROME_FIREFOX_TESTS_GLOB = ['test/functional/fixtures/live/test.js', 'test/functional/fixtures/ui/test.js'];
34
const COMPILER_SERVICE_TESTS_GLOB = 'test/functional/fixtures/compiler-service/test.js';
45
const LEGACY_TESTS_GLOB = 'test/functional/legacy-fixtures/**/test.js';
@@ -12,13 +13,15 @@ const SCREENSHOT_TESTS_GLOB = [
1213
const TESTS_GLOB = [
1314
BASIC_TESTS_GLOB,
1415
`!${MULTIPLE_WINDOWS_TESTS_GLOB}`,
16+
`!${ISOLATED_SESSIONS_TESTS_GLOB}`,
1517
`!${COMPILER_SERVICE_TESTS_GLOB}`,
1618
];
1719

1820
module.exports = {
1921
TESTS_GLOB,
2022
LEGACY_TESTS_GLOB,
2123
MULTIPLE_WINDOWS_TESTS_GLOB,
24+
ISOLATED_SESSIONS_TESTS_GLOB,
2225
BASIC_TESTS_GLOB,
2326
COMPILER_SERVICE_TESTS_GLOB,
2427
SCREENSHOT_TESTS_GLOB,

src/api/test-controller/index.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,23 @@ export default class TestController {
647647
[delegatedAPI(ReportCommand.methodName)] (...args) {
648648
return this.enqueueCommand(ReportCommand, { args });
649649
}
650+
651+
// Open an isolated browser session via CDP Target.createBrowserContext
652+
_openIsolatedSession$ () {
653+
const callsite = getCallsiteForMethod('openIsolatedSession');
654+
655+
return this._enqueueTask('openIsolatedSession', () => {
656+
return async () => {
657+
if (!this.testRun.isNativeAutomation)
658+
throw new Error('openIsolatedSession requires Native Automation mode');
659+
660+
const isolatedSession = await this.testRun.createIsolatedSession();
661+
662+
return isolatedSession.controller;
663+
};
664+
}, callsite);
665+
}
666+
650667
shouldStop (command) {
651668
// NOTE: should always stop on Debug command
652669
return command === 'debug';

0 commit comments

Comments
 (0)