@mablhq/mabl-cli 1.47.12 → 1.47.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browserEngines/chromiumBrowserEngine.js +16 -17
- package/browserEngines/firefoxBrowserEngine.js +44 -11
- package/browserEngines/unsupportedBrowserEngine.js +3 -4
- package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumBrowserDelegate.js +3 -0
- package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumElementHandleDelegate.js +5 -2
- package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxBrowserDelegate.js +3 -0
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowser.js +3 -0
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowserLauncher.js +2 -2
- package/browserLauncher/playwrightBrowserLauncher/playwrightDom.js +1 -1
- package/browserLauncher/playwrightBrowserLauncher/playwrightHttpRequest.js +33 -1
- package/commands/tests/testsUtil.js +23 -39
- package/execution/index.js +1 -1
- package/mablApi/index.js +1 -1
- package/mablscript/importer.js +3 -0
- package/mablscriptFind/index.js +1 -1
- package/package.json +4 -4
- package/proxy/index.js +1 -1
- package/resources/mablFind.js +1 -1
- package/resources/pdf-viewer/index.js +1 -1
- package/resources/pdf-viewer/libmablPdfViewer.js +117 -113
- package/resources/pdf-viewer/pdf.worker.0ceac9378bfc3bfcb634.js +81 -0
- package/resources/pdf-viewer/pdf.worker.df20a5600902b0735d4b.js +2 -0
- package/util/browserTestUtils.js +18 -0
- package/util/clickUtil.js +5 -0
- package/util/jestUtil.js +2 -2
- package/api/entities/Plan.js +0 -2
- package/resources/pdf-viewer/pdf.worker.5953c23fa7251d236190.js +0 -2
- package/resources/pdf-viewer/pdf.worker.5f2736435a8b46d97859.js +0 -81
|
@@ -56,14 +56,14 @@ class ChromiumBrowserEngine {
|
|
|
56
56
|
name() {
|
|
57
57
|
return 'chromium';
|
|
58
58
|
}
|
|
59
|
-
getBrowserLaunchOptions(
|
|
59
|
+
getBrowserLaunchOptions(options) {
|
|
60
60
|
const commandLineArgs = [];
|
|
61
61
|
const ignoreCommandLineDefaultArgs = [];
|
|
62
62
|
const disableFeaturesFlags = [];
|
|
63
|
-
if (containerTesting) {
|
|
63
|
+
if (options.containerTesting) {
|
|
64
64
|
commandLineArgs.push('--no-sandbox');
|
|
65
65
|
}
|
|
66
|
-
if (disableIsolation) {
|
|
66
|
+
if (options.disableIsolation) {
|
|
67
67
|
disableFeaturesFlags.push('IsolateOrigins');
|
|
68
68
|
}
|
|
69
69
|
disableFeaturesFlags.push('site-per-process');
|
|
@@ -71,35 +71,34 @@ class ChromiumBrowserEngine {
|
|
|
71
71
|
if (options.autoOpenDevtoolsForTabs) {
|
|
72
72
|
commandLineArgs.push('--auto-open-devtools-for-tabs');
|
|
73
73
|
}
|
|
74
|
-
const fakeMicrophoneMedia = (0, resourceUtil_1.findResource)('media/mabl_test_audio.wav', resourcesDirectoryOverride);
|
|
75
|
-
const fakeWebcamMedia = (0, resourceUtil_1.findResource)('media/mabl_test_pattern.y4m', resourcesDirectoryOverride);
|
|
76
|
-
const defaultDeviceDescriptor = (0, mobileEmulationUtil_1.getDeviceDescriptorForEmulation)(emulationConfig);
|
|
77
|
-
this.addBasicLaunchArgs(commandLineArgs, browserWidth, browserHeight, fakeMicrophoneMedia, fakeWebcamMedia, ignoreCertificateErrors, defaultDeviceDescriptor);
|
|
78
|
-
if (enableExtensions) {
|
|
74
|
+
const fakeMicrophoneMedia = (0, resourceUtil_1.findResource)('media/mabl_test_audio.wav', options.resourcesDirectoryOverride);
|
|
75
|
+
const fakeWebcamMedia = (0, resourceUtil_1.findResource)('media/mabl_test_pattern.y4m', options.resourcesDirectoryOverride);
|
|
76
|
+
const defaultDeviceDescriptor = (0, mobileEmulationUtil_1.getDeviceDescriptorForEmulation)(options.emulationConfig);
|
|
77
|
+
this.addBasicLaunchArgs(commandLineArgs, options.browserWidth, options.browserHeight, fakeMicrophoneMedia, fakeWebcamMedia, options.ignoreCertificateErrors, defaultDeviceDescriptor);
|
|
78
|
+
if (options.enableExtensions) {
|
|
79
79
|
ignoreCommandLineDefaultArgs.push('--disable-extensions');
|
|
80
80
|
}
|
|
81
81
|
return {
|
|
82
82
|
commandLineArgs,
|
|
83
|
-
engineSpecificOptions: undefined,
|
|
84
83
|
ignoreCommandLineDefaultArgs,
|
|
85
84
|
defaultDeviceDescriptor,
|
|
86
85
|
};
|
|
87
86
|
}
|
|
88
|
-
getExecutionEngineBrowserLaunchOptions(
|
|
89
|
-
const
|
|
87
|
+
getExecutionEngineBrowserLaunchOptions(options, proxyInfo) {
|
|
88
|
+
const commandLineArgs = [...baseExecutionEngineLaunchArgs];
|
|
90
89
|
if (proxyInfo.pacProxy) {
|
|
91
|
-
|
|
90
|
+
commandLineArgs.push(`--proxy-pac-url=${proxyInfo.pacProxy}`);
|
|
92
91
|
}
|
|
93
92
|
else if (proxyInfo.socksProxy) {
|
|
94
|
-
|
|
93
|
+
commandLineArgs.push(`--proxy-server=socks=${proxyInfo.socksProxy}`);
|
|
95
94
|
}
|
|
96
95
|
else {
|
|
97
96
|
throw new Error('no proxy provided for cloud run');
|
|
98
97
|
}
|
|
99
|
-
const defaultDeviceDescriptor = (0, mobileEmulationUtil_1.getDeviceDescriptorForEmulation)(emulationConfig);
|
|
100
|
-
this.addBasicLaunchArgs(
|
|
101
|
-
loggingProvider_1.logger.debug(`launchArgs: ${JSON.stringify(
|
|
102
|
-
return {
|
|
98
|
+
const defaultDeviceDescriptor = (0, mobileEmulationUtil_1.getDeviceDescriptorForEmulation)(options.emulationConfig);
|
|
99
|
+
this.addBasicLaunchArgs(commandLineArgs, options.browserWidth, options.browserHeight, ExecutionEngineFakeAudioFilePath, ExecutionEngineFakeVideoFilePath, true, defaultDeviceDescriptor);
|
|
100
|
+
loggingProvider_1.logger.debug(`launchArgs: ${JSON.stringify(commandLineArgs)}`);
|
|
101
|
+
return { commandLineArgs, defaultDeviceDescriptor };
|
|
103
102
|
}
|
|
104
103
|
addBasicLaunchArgs(launchArgs, browserWidth, browserHeight, fakeMicrophoneMediaPath, fakeWebcamMediaPath, ignoreCertificateErrors, deviceDescriptor) {
|
|
105
104
|
var _a, _b;
|
|
@@ -1,42 +1,75 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
29
|
exports.FirefoxBrowserEngine = void 0;
|
|
7
30
|
const mobileEmulationUtil_1 = require("../commands/tests/mobileEmulationUtil");
|
|
31
|
+
const path_1 = __importDefault(require("path"));
|
|
32
|
+
const fs = __importStar(require("fs-extra"));
|
|
8
33
|
const browserEngine_1 = require("./browserEngine");
|
|
9
34
|
const async_retry_1 = __importDefault(require("async-retry"));
|
|
10
|
-
const browserTypes_1 = require("../commands/browserTypes");
|
|
11
35
|
class FirefoxBrowserEngine {
|
|
12
36
|
name() {
|
|
13
37
|
return 'firefox';
|
|
14
38
|
}
|
|
15
|
-
getBrowserLaunchOptions(
|
|
39
|
+
getBrowserLaunchOptions(options) {
|
|
16
40
|
return {
|
|
17
41
|
commandLineArgs: [],
|
|
18
|
-
engineSpecificOptions: {
|
|
19
|
-
browserType: browserTypes_1.BrowserType.Firefox,
|
|
20
|
-
firefoxUserPrefs: this.getFirefoxUserPrefs(),
|
|
21
|
-
},
|
|
22
42
|
ignoreCommandLineDefaultArgs: [],
|
|
23
|
-
defaultDeviceDescriptor: (0, mobileEmulationUtil_1.getDeviceDescriptorForEmulation)(emulationConfig),
|
|
43
|
+
defaultDeviceDescriptor: (0, mobileEmulationUtil_1.getDeviceDescriptorForEmulation)(options.emulationConfig),
|
|
24
44
|
};
|
|
25
45
|
}
|
|
26
|
-
getExecutionEngineBrowserLaunchOptions(
|
|
46
|
+
getExecutionEngineBrowserLaunchOptions(options, _proxyInfo) {
|
|
27
47
|
return {
|
|
28
|
-
|
|
29
|
-
|
|
48
|
+
commandLineArgs: [],
|
|
49
|
+
defaultDeviceDescriptor: (0, mobileEmulationUtil_1.getDeviceDescriptorForEmulation)(options.emulationConfig),
|
|
30
50
|
};
|
|
31
51
|
}
|
|
32
52
|
prepareBrowserPreferencesDirectory(_windowPlacement) {
|
|
33
|
-
return (0, async_retry_1.default)(() =>
|
|
53
|
+
return (0, async_retry_1.default)(() => {
|
|
54
|
+
const preferenceFileName = 'user.js';
|
|
55
|
+
const tempBrowserPreferencesDirectory = (0, browserEngine_1.getTempBrowserPrefDirectory)(this.name());
|
|
56
|
+
const prefFilePath = path_1.default.normalize(`${tempBrowserPreferencesDirectory}/${preferenceFileName}`);
|
|
57
|
+
fs.writeFileSync(prefFilePath, this.generatePreferencesInfo());
|
|
58
|
+
return tempBrowserPreferencesDirectory;
|
|
59
|
+
}, {
|
|
34
60
|
retries: 5,
|
|
35
61
|
});
|
|
36
62
|
}
|
|
37
63
|
findBrowserExecutable() {
|
|
38
64
|
return Promise.resolve('');
|
|
39
65
|
}
|
|
66
|
+
generatePreferencesInfo() {
|
|
67
|
+
const lines = [];
|
|
68
|
+
for (const [name, value] of Object.entries(this.getFirefoxUserPrefs())) {
|
|
69
|
+
lines.push(`user_pref(${JSON.stringify(name)}, ${JSON.stringify(value)});`);
|
|
70
|
+
}
|
|
71
|
+
return lines.join('\n');
|
|
72
|
+
}
|
|
40
73
|
getFirefoxUserPrefs() {
|
|
41
74
|
return {
|
|
42
75
|
'xpinstall.signatures.required': false,
|
|
@@ -6,15 +6,14 @@ class UnsupportedBrowserEngine {
|
|
|
6
6
|
name() {
|
|
7
7
|
throw new Error('Unsupported browser engine');
|
|
8
8
|
}
|
|
9
|
-
getBrowserLaunchOptions(
|
|
9
|
+
getBrowserLaunchOptions(options) {
|
|
10
10
|
return {
|
|
11
11
|
commandLineArgs: [],
|
|
12
|
-
engineSpecificOptions: undefined,
|
|
13
12
|
ignoreCommandLineDefaultArgs: [],
|
|
14
|
-
defaultDeviceDescriptor: (0, mobileEmulationUtil_1.getDeviceDescriptorForEmulation)(emulationConfig),
|
|
13
|
+
defaultDeviceDescriptor: (0, mobileEmulationUtil_1.getDeviceDescriptorForEmulation)(options.emulationConfig),
|
|
15
14
|
};
|
|
16
15
|
}
|
|
17
|
-
getExecutionEngineBrowserLaunchOptions(
|
|
16
|
+
getExecutionEngineBrowserLaunchOptions(_options, _proxyInfo) {
|
|
18
17
|
throw new Error('Unsupported browser engine');
|
|
19
18
|
}
|
|
20
19
|
prepareBrowserPreferencesDirectory(_windowPlacement) {
|
|
@@ -44,7 +44,7 @@ class ChromiumElementHandleDelegate {
|
|
|
44
44
|
if (this.elementImpl === undefined) {
|
|
45
45
|
(0, logUtils_1.logInternal)(`Unable to get the Element's internal implementation. Some functionality, such as getting the clickable point or element highlighting might not work.`);
|
|
46
46
|
}
|
|
47
|
-
else if (this.
|
|
47
|
+
else if (this.getInternalCDPSession() === undefined) {
|
|
48
48
|
const undefinedField = ((_b = (_a = this.elementImpl) === null || _a === void 0 ? void 0 : _a._context) === null || _b === void 0 ? void 0 : _b._delegate) !== undefined
|
|
49
49
|
? '_client'
|
|
50
50
|
: ((_c = this.elementImpl) === null || _c === void 0 ? void 0 : _c._context) !== undefined
|
|
@@ -54,8 +54,11 @@ class ChromiumElementHandleDelegate {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
getCDPSession() {
|
|
57
|
-
var _a, _b, _c;
|
|
58
57
|
this.checkCDPSession();
|
|
58
|
+
return this.getInternalCDPSession();
|
|
59
|
+
}
|
|
60
|
+
getInternalCDPSession() {
|
|
61
|
+
var _a, _b, _c;
|
|
59
62
|
return (_c = (_b = (_a = this.elementImpl) === null || _a === void 0 ? void 0 : _a._context) === null || _b === void 0 ? void 0 : _b._delegate) === null || _c === void 0 ? void 0 : _c._client;
|
|
60
63
|
}
|
|
61
64
|
}
|
|
@@ -157,6 +157,9 @@ class PlaywrightBrowser extends events_1.default {
|
|
|
157
157
|
exposeFunction(name, callback) {
|
|
158
158
|
return this.defaultContext.exposeFunction(name, callback);
|
|
159
159
|
}
|
|
160
|
+
supportsTracing() {
|
|
161
|
+
return this.browserDelegate.supportsTracing();
|
|
162
|
+
}
|
|
160
163
|
}
|
|
161
164
|
exports.PlaywrightBrowser = PlaywrightBrowser;
|
|
162
165
|
function getBrowserDelegate(browserType, browserContext) {
|
|
@@ -35,7 +35,7 @@ class PlaywrightBrowserLauncher {
|
|
|
35
35
|
const playwrightBrowserType = getPlaywrightBrowserType(options.browserType);
|
|
36
36
|
const defaultContext = await playwrightBrowserType.launchPersistentContext(options.userDataDir, {
|
|
37
37
|
acceptDownloads: true,
|
|
38
|
-
args: options.
|
|
38
|
+
args: options.commandLineArgs,
|
|
39
39
|
bypassCSP: options.bypassContentSecurityPolicy,
|
|
40
40
|
channel: browserTypes_1.SupportedBrowserTypeProperties[options.browserType]
|
|
41
41
|
.browserReleaseChannel,
|
|
@@ -46,7 +46,7 @@ class PlaywrightBrowserLauncher {
|
|
|
46
46
|
hasTouch: (_b = options.defaultDeviceDescriptor) === null || _b === void 0 ? void 0 : _b.hasTouch,
|
|
47
47
|
headless: options.headless,
|
|
48
48
|
httpCredentials: options.credentials,
|
|
49
|
-
ignoreDefaultArgs: options.
|
|
49
|
+
ignoreDefaultArgs: options.ignoreCommandLineDefaultArgs,
|
|
50
50
|
ignoreHTTPSErrors: true,
|
|
51
51
|
isMobile: (_c = options.defaultDeviceDescriptor) === null || _c === void 0 ? void 0 : _c.isMobile,
|
|
52
52
|
logger: playwrightLogger,
|
|
@@ -77,7 +77,7 @@ class PlaywrightElementHandle extends PlaywrightJsHandle {
|
|
|
77
77
|
this.cdpSession = delegate.getCDPSession();
|
|
78
78
|
}
|
|
79
79
|
catch (e) {
|
|
80
|
-
(0, logUtils_1.logInternal)(`Unable to get the element handle
|
|
80
|
+
(0, logUtils_1.logInternal)(`Unable to get a CDP session for the element handle. Error: ${e}`);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
uploadFile(filePath) {
|
|
@@ -1,12 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.PlaywrightHttpRequest = void 0;
|
|
27
|
+
const playwright = __importStar(require("@playwright/test"));
|
|
28
|
+
const logUtils_1 = require("../../util/logUtils");
|
|
4
29
|
class PlaywrightHttpRequest {
|
|
5
30
|
constructor(page, request, route) {
|
|
31
|
+
var _a;
|
|
6
32
|
this.page = page;
|
|
7
33
|
this.request = request;
|
|
8
34
|
this.route = route;
|
|
9
|
-
|
|
35
|
+
try {
|
|
36
|
+
this.documentId = playwright._toImpl(this.request)._documentId;
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
(0, logUtils_1.logInternal)(`Unable to get documentId from request: ${e.message}`);
|
|
40
|
+
}
|
|
41
|
+
(_a = this.documentId) !== null && _a !== void 0 ? _a : (this.documentId = this.request._guid);
|
|
10
42
|
}
|
|
11
43
|
abort() {
|
|
12
44
|
var _a;
|
|
@@ -51,8 +51,8 @@ function getFinalUrl(test, parsedUrl) {
|
|
|
51
51
|
return finalUrl;
|
|
52
52
|
}
|
|
53
53
|
exports.getFinalUrl = getFinalUrl;
|
|
54
|
-
async function launchBrowserInstance(
|
|
55
|
-
|
|
54
|
+
async function launchBrowserInstance(options) {
|
|
55
|
+
var _a;
|
|
56
56
|
const optionsProxy = await maybeGetProxyOptions(options);
|
|
57
57
|
if (optionsProxy) {
|
|
58
58
|
options = {
|
|
@@ -62,13 +62,13 @@ async function launchBrowserInstance(engine, launchArgs, headless, credentials,
|
|
|
62
62
|
}
|
|
63
63
|
let browser;
|
|
64
64
|
try {
|
|
65
|
-
browser = await maybeLaunchBrowser(
|
|
65
|
+
browser = await maybeLaunchBrowser(options);
|
|
66
66
|
}
|
|
67
67
|
catch (error) {
|
|
68
68
|
if (error.message.includes('Running as root without --no-sandbox is not supported')) {
|
|
69
|
-
|
|
69
|
+
(_a = options.commandLineArgs) === null || _a === void 0 ? void 0 : _a.push('--no-sandbox');
|
|
70
70
|
messaging_1.mablEventEmitter.log('Unable to initialize browser with standard settings, attempting to run with --no-sandbox setting', Date.now(), logLineMessaging_1.LogLineColor.yellow);
|
|
71
|
-
return maybeLaunchBrowser(
|
|
71
|
+
return maybeLaunchBrowser(options).catch((error) => {
|
|
72
72
|
messaging_1.mablEventEmitter.log('Browser launch failed', Date.now(), logLineMessaging_1.LogLineColor.red);
|
|
73
73
|
messaging_1.mablEventEmitter.log(error.message);
|
|
74
74
|
});
|
|
@@ -98,15 +98,8 @@ async function maybeGetProxyOptions(options) {
|
|
|
98
98
|
}
|
|
99
99
|
return optionsProxy;
|
|
100
100
|
}
|
|
101
|
-
function maybeLaunchBrowser(
|
|
102
|
-
return browserLauncher_1.BrowserLauncherFactory.createRunner(options === null || options === void 0 ? void 0 : options.runnerType, options === null || options === void 0 ? void 0 : options.loggerFunc).launch(
|
|
103
|
-
...options,
|
|
104
|
-
headless,
|
|
105
|
-
args: launchArgs,
|
|
106
|
-
userDataDir,
|
|
107
|
-
downloadPath: createDownloadDirectory(),
|
|
108
|
-
credentials,
|
|
109
|
-
});
|
|
101
|
+
function maybeLaunchBrowser(options) {
|
|
102
|
+
return browserLauncher_1.BrowserLauncherFactory.createRunner(options === null || options === void 0 ? void 0 : options.runnerType, options === null || options === void 0 ? void 0 : options.loggerFunc).launch(options);
|
|
110
103
|
}
|
|
111
104
|
function removeTempBrowserPreferencesDirectory(tempDirPath) {
|
|
112
105
|
try {
|
|
@@ -115,18 +108,14 @@ function removeTempBrowserPreferencesDirectory(tempDirPath) {
|
|
|
115
108
|
catch (error) {
|
|
116
109
|
}
|
|
117
110
|
}
|
|
118
|
-
async function createBrowser(engine,
|
|
119
|
-
|
|
120
|
-
const
|
|
121
|
-
const
|
|
122
|
-
const maybeBrowser = await launchBrowserInstance(engine, launchArgs, headless, credentials, {
|
|
111
|
+
async function createBrowser(engine, options) {
|
|
112
|
+
const userDataDir = await engine.prepareBrowserPreferencesDirectory(options.windowPlacement);
|
|
113
|
+
const browserEngineLaunchOptions = engine.getBrowserLaunchOptions(options);
|
|
114
|
+
const maybeBrowser = await launchBrowserInstance({
|
|
123
115
|
...options,
|
|
124
|
-
...
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
userAgent: (_a = options === null || options === void 0 ? void 0 : options.userAgent) !== null && _a !== void 0 ? _a : emulationConfig === null || emulationConfig === void 0 ? void 0 : emulationConfig.device_config.user_agent,
|
|
128
|
-
defaultUserAgent: options === null || options === void 0 ? void 0 : options.defaultUserAgent,
|
|
129
|
-
windowPlacement: options.windowPlacement,
|
|
116
|
+
...browserEngineLaunchOptions,
|
|
117
|
+
downloadPath: createDownloadDirectory(),
|
|
118
|
+
userDataDir,
|
|
130
119
|
});
|
|
131
120
|
if (!maybeBrowser) {
|
|
132
121
|
throw new Error('Unable to start browser session');
|
|
@@ -135,20 +124,15 @@ async function createBrowser(engine, browserWidth, browserHeight, headless, cont
|
|
|
135
124
|
return maybeBrowser;
|
|
136
125
|
}
|
|
137
126
|
exports.createBrowser = createBrowser;
|
|
138
|
-
async function createBrowserForExecutionEngine(engine,
|
|
139
|
-
const
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
options
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
const { launchArgs, defaultDeviceDescriptor } = engine.getExecutionEngineBrowserLaunchOptions(browserWidth, browserHeight, proxyInfo, deviceEmulationConfig);
|
|
148
|
-
if (defaultDeviceDescriptor) {
|
|
149
|
-
options = { ...options, defaultDeviceDescriptor };
|
|
150
|
-
}
|
|
151
|
-
const maybeBrowser = await maybeLaunchBrowser(launchArgs, tempBrowserPreferencesDirectory, headless, credentials, options);
|
|
127
|
+
async function createBrowserForExecutionEngine(engine, proxyInfo, options) {
|
|
128
|
+
const userDataDir = await engine.prepareBrowserPreferencesDirectory();
|
|
129
|
+
const launchOptions = engine.getExecutionEngineBrowserLaunchOptions(options, proxyInfo);
|
|
130
|
+
const maybeBrowser = await maybeLaunchBrowser({
|
|
131
|
+
...options,
|
|
132
|
+
...launchOptions,
|
|
133
|
+
downloadPath: createDownloadDirectory(),
|
|
134
|
+
userDataDir,
|
|
135
|
+
});
|
|
152
136
|
if (!maybeBrowser) {
|
|
153
137
|
throw new Error('Unable to start browser session');
|
|
154
138
|
}
|