Skip to content

Commit 62c28b4

Browse files
committed
feat: add isolated multi-browser-session support via CDP (t2 API)
Fork of TestCafe 3.7.4 adding t.openIsolatedSession() — fully isolated browser sessions within a single test via CDP Target.createBrowserContext. All modifications to existing files are marked with // SAMEDI comments.
1 parent cd8b2c6 commit 62c28b4

30 files changed

Lines changed: 5855 additions & 3757 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ Gemfile.lock
1414
.DS_Store
1515
!gulp
1616
/test/functional/fixtures/**/package.json
17+
_uploads_/
18+
testcafe-*.tgz
19+
yarn.lock

.gitlab-ci.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
image: node:22
2+
3+
stages:
4+
- publish
5+
6+
publish:
7+
stage: publish
8+
script:
9+
- npm install --ignore-scripts
10+
- npx gulp build
11+
- echo "@qa:registry=https://git.samedi.cc/api/v4/projects/${CI_PROJECT_ID}/packages/npm/" > .npmrc
12+
- echo "//git.samedi.cc/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=${CI_JOB_TOKEN}" >> .npmrc
13+
- npm publish --ignore-scripts
14+
rules:
15+
- if: '$CI_COMMIT_BRANCH == "main"'

README.md

Lines changed: 388 additions & 294 deletions
Large diffs are not rendered by default.

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'; // SAMEDI
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}`, // SAMEDI
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, // SAMEDI
2225
BASIC_TESTS_GLOB,
2326
COMPILER_SERVICE_TESTS_GLOB,
2427
SCREENSHOT_TESTS_GLOB,

package-lock.json

Lines changed: 2183 additions & 3460 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "testcafe",
2+
"name": "@qa/testcafe-fork",
33
"description": "Automated browser testing for the modern web development stack.",
44
"license": "MIT",
55
"version": "3.7.4",
@@ -54,6 +54,7 @@
5454
"scripts": {
5555
"test": "gulp travis",
5656
"build": "gulp build",
57+
"prepare": "gulp build",
5758
"test-functional-local-headless-chrome-run-esm": "cross-env NODE_OPTIONS='--experimental-loader=./lib/compiler/esm-loader.js' gulp test-functional-local-headless-chrome-run --steps-as-tasks",
5859
"test-functional-local-headless-chrome-esm": "npm run build && npm run test-functional-local-headless-chrome-run-esm",
5960
"publish-please-only": "publish-please",
@@ -229,7 +230,7 @@
229230
"sinon": "^7.3.0",
230231
"stack-chain": "^2.0.0",
231232
"strip-ansi": "^3.0.0",
232-
"testcafe-browser-provider-browserstack": "^1.14.1",
233+
"testcafe-browser-provider-browserstack": "^1.14.1",
233234
"tslib": "^2.4.0",
234235
"uglify-js": "~3.10.4"
235236
},

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+
// SAMEDI: isolated session opener — creates a CDP-isolated browser context
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)