@mablhq/mabl-cli 1.10.10 → 1.11.15
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/browserLauncher/elementHandle.js +11 -0
- package/browserLauncher/playwrightBrowserLauncher/internals.js +2 -0
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowser.js +9 -13
- package/browserLauncher/playwrightBrowserLauncher/playwrightBrowserLauncher.js +16 -8
- package/browserLauncher/playwrightBrowserLauncher/playwrightFrame.js +1 -1
- package/browserLauncher/playwrightBrowserLauncher/playwrightHttpRequest.js +46 -8
- package/browserLauncher/playwrightBrowserLauncher/playwrightHttpResponse.js +6 -5
- package/browserLauncher/playwrightBrowserLauncher/playwrightPage.js +55 -28
- package/browserLauncher/puppeteerBrowserLauncher/internals.js +2 -0
- package/browserLauncher/puppeteerBrowserLauncher/puppeteerBrowserLauncher.js +4 -1
- package/browserLauncher/puppeteerBrowserLauncher/puppeteerHttpRequest.js +3 -0
- package/browserLauncher/puppeteerBrowserLauncher/puppeteerPage.js +24 -10
- package/commands/commandUtil/awaitCompletion.js +4 -2
- package/commands/commandUtil/codeInsights.js +5 -2
- package/commands/deploy/deploy_cmds/create.js +2 -2
- package/commands/tests/mobileEmulationUtil.js +3 -3
- package/commands/tests/testsUtil.js +33 -21
- package/commands/tests/tests_cmds/import.js +10 -1
- package/core/execution/ApiTestUtils.js +18 -0
- package/domUtil/index.js +2 -0
- package/domUtil/index.js.LICENSE.txt +14 -0
- package/execution/index.js +1 -1
- package/mablscript/actions/JavaScriptAction.js +101 -38
- package/mablscript/types/ConditionDescriptor.js +6 -1
- package/mablscript/types/JavaScriptDescriptor.js +25 -9
- package/package.json +2 -2
- package/providers/exportRequestProvider.js +4 -2
|
@@ -1,2 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isElementHandle = void 0;
|
|
4
|
+
function isElementHandle(value) {
|
|
5
|
+
return (value &&
|
|
6
|
+
typeof value === 'object' &&
|
|
7
|
+
typeof value.evaluate === 'function' &&
|
|
8
|
+
typeof value.focus === 'function' &&
|
|
9
|
+
typeof value.select === 'function' &&
|
|
10
|
+
typeof value.type === 'function' &&
|
|
11
|
+
typeof value.$x === 'function');
|
|
12
|
+
}
|
|
13
|
+
exports.isElementHandle = isElementHandle;
|
|
@@ -30,13 +30,15 @@ const playwrightPage_1 = require("./playwrightPage");
|
|
|
30
30
|
const path_1 = __importDefault(require("path"));
|
|
31
31
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
32
32
|
class PlaywrightBrowser extends events_1.default {
|
|
33
|
-
constructor(
|
|
33
|
+
constructor(defaultContext, downloadDirectory, browserWSEndpoint) {
|
|
34
34
|
super();
|
|
35
|
-
this.browser = browser;
|
|
36
35
|
this.defaultContext = defaultContext;
|
|
37
36
|
this.downloadDirectory = downloadDirectory;
|
|
38
37
|
this.browserWSEndpoint = browserWSEndpoint;
|
|
39
38
|
this.playwrightPages = new Map();
|
|
39
|
+
const contextImpl = playwright._toImpl(defaultContext);
|
|
40
|
+
this.browser = contextImpl._browser;
|
|
41
|
+
this.cdpSession = this.browser._connection.rootSession;
|
|
40
42
|
this.defaultContext.on('page', async (page) => {
|
|
41
43
|
this.emit(browserLauncher_1.BrowserEvent.PageCreated, await this.getOrCreatePage(page));
|
|
42
44
|
});
|
|
@@ -47,15 +49,11 @@ class PlaywrightBrowser extends events_1.default {
|
|
|
47
49
|
fs_extra_1.default.mkdirSync(path_1.default.join(this.downloadDirectory));
|
|
48
50
|
}
|
|
49
51
|
}
|
|
50
|
-
|
|
51
|
-
var _a;
|
|
52
|
-
if (this.cdpSession === undefined) {
|
|
53
|
-
this.cdpSession = await ((_a = this.browser) === null || _a === void 0 ? void 0 : _a.newBrowserCDPSession());
|
|
54
|
-
}
|
|
52
|
+
makeCdpCall(method, paramArgs) {
|
|
55
53
|
return this.cdpSession.send(method, paramArgs);
|
|
56
54
|
}
|
|
57
55
|
close() {
|
|
58
|
-
return this.
|
|
56
|
+
return this.defaultContext.close();
|
|
59
57
|
}
|
|
60
58
|
disconnect() {
|
|
61
59
|
return this.close();
|
|
@@ -78,11 +76,9 @@ class PlaywrightBrowser extends events_1.default {
|
|
|
78
76
|
.map(page => this.getOrCreatePage(page)));
|
|
79
77
|
}
|
|
80
78
|
async getExtensionBackgroundPage(extensionId) {
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
.
|
|
84
|
-
.forEach(context => backgroundPages.concat(context.backgroundPages()));
|
|
85
|
-
const backgroundExtensionPage = backgroundPages.find(page => page.url().includes(extensionId));
|
|
79
|
+
const backgroundExtensionPage = this.defaultContext
|
|
80
|
+
.backgroundPages()
|
|
81
|
+
.find(page => page.url().includes(extensionId));
|
|
86
82
|
if (!backgroundExtensionPage) {
|
|
87
83
|
throw new Error('mabl test initialization failure, unable to locate mabl extension page, please try again');
|
|
88
84
|
}
|
|
@@ -10,24 +10,32 @@ const playwrightBrowser_1 = require("./playwrightBrowser");
|
|
|
10
10
|
class PlaywrightBrowserLauncher {
|
|
11
11
|
async connect(options, currentDownloadPath) {
|
|
12
12
|
const browser = await test_1.chromium.connect(options.browserWSEndpoint);
|
|
13
|
-
return new playwrightBrowser_1.PlaywrightBrowser(browser
|
|
13
|
+
return new playwrightBrowser_1.PlaywrightBrowser(browser.contexts()[0], currentDownloadPath, options.browserWSEndpoint);
|
|
14
14
|
}
|
|
15
15
|
async launch(options) {
|
|
16
|
-
var _a;
|
|
17
|
-
const
|
|
16
|
+
var _a, _b, _c;
|
|
17
|
+
const viewport = options.defaultDeviceDescriptor
|
|
18
|
+
? {
|
|
19
|
+
width: options.defaultDeviceDescriptor.width,
|
|
20
|
+
height: options.defaultDeviceDescriptor.height,
|
|
21
|
+
}
|
|
22
|
+
:
|
|
23
|
+
null;
|
|
24
|
+
const defaultContext = await test_1.chromium.launchPersistentContext(options.userDataDir, {
|
|
25
|
+
ignoreHTTPSErrors: true,
|
|
18
26
|
headless: options.headless,
|
|
19
27
|
args: options.args,
|
|
20
28
|
ignoreDefaultArgs: options.ignoreDefaultArgs,
|
|
21
29
|
downloadsPath: options.downloadPath,
|
|
22
30
|
executablePath: options.executablePath,
|
|
23
|
-
|
|
24
|
-
const defaultContext = await browser.newContext({
|
|
25
|
-
viewport: (_a = options.defaultViewport) !== null && _a !== void 0 ? _a : null,
|
|
31
|
+
viewport,
|
|
26
32
|
acceptDownloads: true,
|
|
27
33
|
httpCredentials: options.credentials,
|
|
34
|
+
isMobile: (_a = options.defaultDeviceDescriptor) === null || _a === void 0 ? void 0 : _a.isMobile,
|
|
35
|
+
deviceScaleFactor: (_b = options.defaultDeviceDescriptor) === null || _b === void 0 ? void 0 : _b.deviceScaleFactor,
|
|
36
|
+
hasTouch: (_c = options.defaultDeviceDescriptor) === null || _c === void 0 ? void 0 : _c.hasTouch,
|
|
28
37
|
});
|
|
29
|
-
|
|
30
|
-
return new playwrightBrowser_1.PlaywrightBrowser(browser, defaultContext, path_1.default.join(options.downloadPath, 'final'), '');
|
|
38
|
+
return new playwrightBrowser_1.PlaywrightBrowser(defaultContext, path_1.default.join(options.downloadPath, 'final'), '');
|
|
31
39
|
}
|
|
32
40
|
}
|
|
33
41
|
exports.PlaywrightBrowserLauncher = PlaywrightBrowserLauncher;
|
|
@@ -107,7 +107,7 @@ class PlaywrightFrame {
|
|
|
107
107
|
async goto(url, options) {
|
|
108
108
|
try {
|
|
109
109
|
const response = await this.frame.goto(url, options);
|
|
110
|
-
return utils_1.mapIfNotNull(response, response => new playwrightHttpResponse_1.PlaywrightHttpResponse(response));
|
|
110
|
+
return utils_1.mapIfNotNull(response, response => new playwrightHttpResponse_1.PlaywrightHttpResponse(this.parentPage, response));
|
|
111
111
|
}
|
|
112
112
|
catch (e) {
|
|
113
113
|
if (e instanceof playwright.errors.TimeoutError) {
|
|
@@ -1,27 +1,65 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
22
|
exports.PlaywrightHttpRequest = void 0;
|
|
23
|
+
const playwright = __importStar(require("@playwright/test"));
|
|
4
24
|
class PlaywrightHttpRequest {
|
|
5
|
-
constructor(request) {
|
|
25
|
+
constructor(page, request, route) {
|
|
26
|
+
this.page = page;
|
|
6
27
|
this.request = request;
|
|
28
|
+
this.route = route;
|
|
29
|
+
this.documentId = playwright._toImpl(this.request)._documentId;
|
|
7
30
|
}
|
|
8
31
|
abort() {
|
|
9
|
-
|
|
32
|
+
var _a;
|
|
33
|
+
if (this.route === undefined) {
|
|
34
|
+
throw new Error('Unable to abort an unrouted request');
|
|
35
|
+
}
|
|
36
|
+
return (_a = this.route) === null || _a === void 0 ? void 0 : _a.abort();
|
|
10
37
|
}
|
|
11
38
|
continue() {
|
|
12
|
-
|
|
39
|
+
var _a;
|
|
40
|
+
if (this.route === undefined) {
|
|
41
|
+
throw new Error('Unable to continue an unrouted request');
|
|
42
|
+
}
|
|
43
|
+
return (_a = this.route) === null || _a === void 0 ? void 0 : _a.continue();
|
|
13
44
|
}
|
|
14
45
|
frame() {
|
|
15
|
-
|
|
46
|
+
return this.page.getOrCreateFrame(this.request.frame());
|
|
16
47
|
}
|
|
17
48
|
requestId() {
|
|
18
|
-
return this.
|
|
49
|
+
return this.documentId;
|
|
19
50
|
}
|
|
20
|
-
respond(
|
|
21
|
-
|
|
51
|
+
respond(response) {
|
|
52
|
+
var _a;
|
|
53
|
+
if (this.route === undefined) {
|
|
54
|
+
throw new Error('Unable to respond an unrouted request');
|
|
55
|
+
}
|
|
56
|
+
return (_a = this.route) === null || _a === void 0 ? void 0 : _a.fulfill(response);
|
|
22
57
|
}
|
|
23
58
|
url() {
|
|
24
|
-
|
|
59
|
+
return this.request.url();
|
|
60
|
+
}
|
|
61
|
+
headers() {
|
|
62
|
+
return this.request.allHeaders();
|
|
25
63
|
}
|
|
26
64
|
}
|
|
27
65
|
exports.PlaywrightHttpRequest = PlaywrightHttpRequest;
|
|
@@ -3,20 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PlaywrightHttpResponse = void 0;
|
|
4
4
|
const playwrightHttpRequest_1 = require("./playwrightHttpRequest");
|
|
5
5
|
class PlaywrightHttpResponse {
|
|
6
|
-
constructor(response) {
|
|
6
|
+
constructor(page, response) {
|
|
7
|
+
this.page = page;
|
|
7
8
|
this.response = response;
|
|
8
9
|
}
|
|
9
10
|
frame() {
|
|
10
|
-
|
|
11
|
+
return this.page.getOrCreateFrame(this.response.frame());
|
|
11
12
|
}
|
|
12
13
|
headers() {
|
|
13
|
-
|
|
14
|
+
return this.response.headers();
|
|
14
15
|
}
|
|
15
16
|
request() {
|
|
16
|
-
return new playwrightHttpRequest_1.PlaywrightHttpRequest(this.response.request());
|
|
17
|
+
return new playwrightHttpRequest_1.PlaywrightHttpRequest(this.page, this.response.request());
|
|
17
18
|
}
|
|
18
19
|
url() {
|
|
19
|
-
|
|
20
|
+
return this.response.url();
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
exports.PlaywrightHttpResponse = PlaywrightHttpResponse;
|
|
@@ -34,6 +34,8 @@ const utils_1 = require("../utils");
|
|
|
34
34
|
const wrappers_1 = require("./wrappers");
|
|
35
35
|
const testsUtil_1 = require("../../commands/tests/testsUtil");
|
|
36
36
|
const path_1 = __importDefault(require("path"));
|
|
37
|
+
const logUtils_1 = require("../../util/logUtils");
|
|
38
|
+
const uuid = __importStar(require("uuid"));
|
|
37
39
|
exports.MAX_HIGHLIGHT_OPACITY = 0.9;
|
|
38
40
|
exports.highlightColor = (transparency) => ({
|
|
39
41
|
r: 196,
|
|
@@ -56,7 +58,21 @@ class PlaywrightPage extends events_1.default {
|
|
|
56
58
|
this.browser.onPageClose(this);
|
|
57
59
|
});
|
|
58
60
|
page.on('download', async (download) => {
|
|
61
|
+
var _a, _b;
|
|
62
|
+
const guid = uuid.v4();
|
|
63
|
+
const downloadSize = (_b = (_a = (await download.createReadStream())) === null || _a === void 0 ? void 0 : _a.readableLength) !== null && _b !== void 0 ? _b : 0;
|
|
59
64
|
await download.saveAs(path_1.default.join(this.browser.getDownloadDirectory(), download.suggestedFilename()));
|
|
65
|
+
browser.emit(browserLauncher_1.BrowserEvent.DownloadWillBegin, {
|
|
66
|
+
guid,
|
|
67
|
+
suggestedFilename: download.suggestedFilename(),
|
|
68
|
+
url: download.url(),
|
|
69
|
+
});
|
|
70
|
+
browser.emit(browserLauncher_1.BrowserEvent.DownloadProgress, {
|
|
71
|
+
guid,
|
|
72
|
+
totalBytes: downloadSize,
|
|
73
|
+
receivedBytes: downloadSize,
|
|
74
|
+
state: 'completed',
|
|
75
|
+
});
|
|
60
76
|
});
|
|
61
77
|
}
|
|
62
78
|
async waitForInitialization() {
|
|
@@ -73,14 +89,20 @@ class PlaywrightPage extends events_1.default {
|
|
|
73
89
|
return this;
|
|
74
90
|
}
|
|
75
91
|
wireEvents(event) {
|
|
92
|
+
if (event === browserLauncher_1.PageEvent.RequestWillBeSentExtraInfo &&
|
|
93
|
+
!this.listenerCount(event)) {
|
|
94
|
+
this.client.on('Network.requestWillBeSentExtraInfo', (event) => {
|
|
95
|
+
this.emit(browserLauncher_1.PageEvent.RequestWillBeSentExtraInfo, event);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
76
98
|
if (event === browserLauncher_1.PageEvent.Response && !this.listenerCount(event)) {
|
|
77
99
|
this.page.on('response', (event) => {
|
|
78
|
-
this.emit(browserLauncher_1.PageEvent.Response, new playwrightHttpResponse_1.PlaywrightHttpResponse(event));
|
|
100
|
+
this.emit(browserLauncher_1.PageEvent.Response, new playwrightHttpResponse_1.PlaywrightHttpResponse(this, event));
|
|
79
101
|
});
|
|
80
102
|
}
|
|
81
103
|
if (event === browserLauncher_1.PageEvent.Request && !this.listenerCount(event)) {
|
|
82
|
-
this.page.
|
|
83
|
-
this.emit(browserLauncher_1.PageEvent.Request, new playwrightHttpRequest_1.PlaywrightHttpRequest(request));
|
|
104
|
+
void this.page.route('**/*', route => {
|
|
105
|
+
this.emit(browserLauncher_1.PageEvent.Request, new playwrightHttpRequest_1.PlaywrightHttpRequest(this, route.request(), route));
|
|
84
106
|
});
|
|
85
107
|
}
|
|
86
108
|
if (event === browserLauncher_1.PageEvent.FrameNavigated && !this.listenerCount(event)) {
|
|
@@ -174,7 +196,7 @@ class PlaywrightPage extends events_1.default {
|
|
|
174
196
|
throw new Error('PlaywrightPage.authenticate not implemented');
|
|
175
197
|
}
|
|
176
198
|
bringToFront() {
|
|
177
|
-
return
|
|
199
|
+
return this.page.bringToFront();
|
|
178
200
|
}
|
|
179
201
|
cookies() {
|
|
180
202
|
return this.page.context().cookies();
|
|
@@ -200,7 +222,7 @@ class PlaywrightPage extends events_1.default {
|
|
|
200
222
|
async goto(url, options) {
|
|
201
223
|
try {
|
|
202
224
|
const response = await this.page.goto(url, options);
|
|
203
|
-
return utils_1.mapIfNotNull(response, response => new playwrightHttpResponse_1.PlaywrightHttpResponse(response));
|
|
225
|
+
return utils_1.mapIfNotNull(response, response => new playwrightHttpResponse_1.PlaywrightHttpResponse(this, response));
|
|
204
226
|
}
|
|
205
227
|
catch (e) {
|
|
206
228
|
if (e instanceof playwright.errors.TimeoutError) {
|
|
@@ -254,7 +276,7 @@ class PlaywrightPage extends events_1.default {
|
|
|
254
276
|
}
|
|
255
277
|
async reload(options) {
|
|
256
278
|
try {
|
|
257
|
-
return utils_1.mapIfNotNull(await this.page.reload(options), response => new playwrightHttpResponse_1.PlaywrightHttpResponse(response));
|
|
279
|
+
return utils_1.mapIfNotNull(await this.page.reload(options), response => new playwrightHttpResponse_1.PlaywrightHttpResponse(this, response));
|
|
258
280
|
}
|
|
259
281
|
catch (e) {
|
|
260
282
|
if (e instanceof playwright.errors.TimeoutError) {
|
|
@@ -265,8 +287,16 @@ class PlaywrightPage extends events_1.default {
|
|
|
265
287
|
}
|
|
266
288
|
async resizeViewport() {
|
|
267
289
|
}
|
|
268
|
-
async setBrowserBounds(
|
|
269
|
-
|
|
290
|
+
async setBrowserBounds(width, height) {
|
|
291
|
+
const windowInfo = await this.makeCdpCall('Browser.getWindowForTarget');
|
|
292
|
+
const setWindowBoundsRequest = {
|
|
293
|
+
windowId: windowInfo.windowId,
|
|
294
|
+
bounds: {
|
|
295
|
+
width,
|
|
296
|
+
height,
|
|
297
|
+
},
|
|
298
|
+
};
|
|
299
|
+
await this.makeCdpCall('Browser.setWindowBounds', setWindowBoundsRequest);
|
|
270
300
|
}
|
|
271
301
|
async setCookie(...cookies) {
|
|
272
302
|
const pageUrl = this.url();
|
|
@@ -280,25 +310,22 @@ class PlaywrightPage extends events_1.default {
|
|
|
280
310
|
}));
|
|
281
311
|
}
|
|
282
312
|
setRequestInterception(_value) {
|
|
283
|
-
|
|
284
|
-
}
|
|
285
|
-
async setViewport(
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
};
|
|
299
|
-
const overridesPromise = this.makeCdpCall('Emulation.setDeviceMetricsOverride', params);
|
|
300
|
-
const touchEmulationPromise = await this.makeCdpCall('Emulation.setTouchEmulationEnabled', { enabled: true });
|
|
301
|
-
await Promise.all([overridesPromise, touchEmulationPromise]);
|
|
313
|
+
return Promise.resolve();
|
|
314
|
+
}
|
|
315
|
+
async setViewport(viewport) {
|
|
316
|
+
try {
|
|
317
|
+
await this.page.setViewportSize(viewport);
|
|
318
|
+
await this.setBrowserBounds(viewport.width, viewport.height);
|
|
319
|
+
}
|
|
320
|
+
catch (error) {
|
|
321
|
+
logUtils_1.logInternal(`Set Browser Bounds during setViewport step failed: ${error}`);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
async emulateDevice(deviceDescriptor) {
|
|
325
|
+
return this.setViewport({
|
|
326
|
+
width: deviceDescriptor.width,
|
|
327
|
+
height: deviceDescriptor.height,
|
|
328
|
+
});
|
|
302
329
|
}
|
|
303
330
|
title() {
|
|
304
331
|
return this.page.title();
|
|
@@ -306,7 +333,7 @@ class PlaywrightPage extends events_1.default {
|
|
|
306
333
|
async waitForNavigation(options) {
|
|
307
334
|
try {
|
|
308
335
|
const result = await this.page.waitForNavigation(options);
|
|
309
|
-
return utils_1.mapIfNotNull(result, result => new playwrightHttpResponse_1.PlaywrightHttpResponse(result));
|
|
336
|
+
return utils_1.mapIfNotNull(result, result => new playwrightHttpResponse_1.PlaywrightHttpResponse(this, result));
|
|
310
337
|
}
|
|
311
338
|
catch (e) {
|
|
312
339
|
if (e instanceof playwright.errors.TimeoutError) {
|
|
@@ -9,7 +9,10 @@ const types_1 = require("../types");
|
|
|
9
9
|
const puppeteerBrowser_1 = require("./puppeteerBrowser");
|
|
10
10
|
class PuppeteerBrowserLauncher {
|
|
11
11
|
async connect(options, currentDownloadPath) {
|
|
12
|
-
return new puppeteerBrowser_1.PuppeteerBrowser(await puppeteer_core_1.default.connect(
|
|
12
|
+
return new puppeteerBrowser_1.PuppeteerBrowser(await puppeteer_core_1.default.connect({
|
|
13
|
+
browserWSEndpoint: options.browserWSEndpoint,
|
|
14
|
+
defaultViewport: options.defaultDeviceDescriptor,
|
|
15
|
+
}), currentDownloadPath);
|
|
13
16
|
}
|
|
14
17
|
async launch(options) {
|
|
15
18
|
const browser = new puppeteerBrowser_1.PuppeteerBrowser(await puppeteer_core_1.default.launch({
|
|
@@ -16,6 +16,7 @@ const puppeteerJsHandle_1 = require("./puppeteerJsHandle");
|
|
|
16
16
|
const puppeteerFrame_1 = require("./puppeteerFrame");
|
|
17
17
|
const utils_1 = require("../utils");
|
|
18
18
|
const wrappers_1 = require("./wrappers");
|
|
19
|
+
const logUtils_1 = require("../../util/logUtils");
|
|
19
20
|
exports.MAX_HIGHLIGHT_OPACITY = 0.9;
|
|
20
21
|
exports.highlightColor = (transparency) => ({
|
|
21
22
|
r: 196,
|
|
@@ -55,8 +56,7 @@ class PuppeteerPage extends events_1.default {
|
|
|
55
56
|
this.openerPage = await utils_1.mapIfNotNull(opener, page => this.browser.getOrCreatePage(page));
|
|
56
57
|
}
|
|
57
58
|
makeCdpCall(method, paramArgs) {
|
|
58
|
-
|
|
59
|
-
return client.send(method, paramArgs);
|
|
59
|
+
return this.getCdpClient().send(method, paramArgs);
|
|
60
60
|
}
|
|
61
61
|
sendCharacter(key) {
|
|
62
62
|
return this.page.keyboard.sendCharacter(key);
|
|
@@ -66,7 +66,10 @@ class PuppeteerPage extends events_1.default {
|
|
|
66
66
|
}
|
|
67
67
|
viewport() {
|
|
68
68
|
const viewport = this.page.viewport();
|
|
69
|
-
return utils_1.mapIfNotNull(
|
|
69
|
+
return utils_1.mapIfNotNull(viewport, (descriptor) => ({
|
|
70
|
+
width: descriptor.width,
|
|
71
|
+
height: descriptor.height,
|
|
72
|
+
}));
|
|
70
73
|
}
|
|
71
74
|
async setBrowserBounds(width, height) {
|
|
72
75
|
const windowInfo = await this.makeCdpCall('Browser.getWindowForTarget');
|
|
@@ -161,8 +164,17 @@ class PuppeteerPage extends events_1.default {
|
|
|
161
164
|
authenticate(credentials) {
|
|
162
165
|
return this.page.authenticate(credentials);
|
|
163
166
|
}
|
|
164
|
-
setViewport(
|
|
165
|
-
return this.
|
|
167
|
+
async setViewport(viewport) {
|
|
168
|
+
return this.emulateDevice(viewport);
|
|
169
|
+
}
|
|
170
|
+
async emulateDevice(deviceDescriptor) {
|
|
171
|
+
await this.page.setViewport(deviceDescriptor);
|
|
172
|
+
try {
|
|
173
|
+
await this.setBrowserBounds(deviceDescriptor.width, deviceDescriptor.height);
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
logUtils_1.logInternal(`Set Browser Bounds during setViewport step failed: ${error}`);
|
|
177
|
+
}
|
|
166
178
|
}
|
|
167
179
|
on(event, listener) {
|
|
168
180
|
this.wireEvents(event);
|
|
@@ -177,7 +189,8 @@ class PuppeteerPage extends events_1.default {
|
|
|
177
189
|
wireEvents(event) {
|
|
178
190
|
if (event === browserLauncher_1.PageEvent.RequestWillBeSentExtraInfo &&
|
|
179
191
|
!this.listenerCount(event)) {
|
|
180
|
-
this.
|
|
192
|
+
const client = this.getCdpClient();
|
|
193
|
+
client.on('Network.requestWillBeSentExtraInfo', (event) => {
|
|
181
194
|
this.emit(browserLauncher_1.PageEvent.RequestWillBeSentExtraInfo, event);
|
|
182
195
|
});
|
|
183
196
|
}
|
|
@@ -217,14 +230,12 @@ class PuppeteerPage extends events_1.default {
|
|
|
217
230
|
});
|
|
218
231
|
}
|
|
219
232
|
if (event === browserLauncher_1.PageEvent.TracingBufferUsage && !this.listenerCount(event)) {
|
|
220
|
-
|
|
221
|
-
client.on('Tracing.bufferUsage', (tracing) => {
|
|
233
|
+
this.getCdpClient().on('Tracing.bufferUsage', (tracing) => {
|
|
222
234
|
this.emit(browserLauncher_1.PageEvent.TracingBufferUsage, tracing);
|
|
223
235
|
});
|
|
224
236
|
}
|
|
225
237
|
if (event === browserLauncher_1.PageEvent.TracingComplete && !this.listenerCount(event)) {
|
|
226
|
-
|
|
227
|
-
client.on('Tracing.tracingComplete', (tracingComplete) => {
|
|
238
|
+
this.getCdpClient().on('Tracing.tracingComplete', (tracingComplete) => {
|
|
228
239
|
this.emit(browserLauncher_1.PageEvent.TracingComplete, tracingComplete);
|
|
229
240
|
});
|
|
230
241
|
}
|
|
@@ -345,5 +356,8 @@ class PuppeteerPage extends events_1.default {
|
|
|
345
356
|
}
|
|
346
357
|
return this.puppeteerFrames.get(frameId);
|
|
347
358
|
}
|
|
359
|
+
getCdpClient() {
|
|
360
|
+
return this.page._client;
|
|
361
|
+
}
|
|
348
362
|
}
|
|
349
363
|
exports.PuppeteerPage = PuppeteerPage;
|
|
@@ -57,8 +57,10 @@ class AwaitCompletion {
|
|
|
57
57
|
status: PollingOutcomeType.Complete,
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
|
-
return new Promise(resolve => {
|
|
61
|
-
setTimeout(() => this.awaitCompletion(seedId)
|
|
60
|
+
return new Promise((resolve, reject) => {
|
|
61
|
+
setTimeout(() => this.awaitCompletion(seedId)
|
|
62
|
+
.then(result => resolve(result))
|
|
63
|
+
.catch(error => reject(error)), this.pollingIntervalMilliseconds);
|
|
62
64
|
});
|
|
63
65
|
}
|
|
64
66
|
}
|
|
@@ -141,13 +141,16 @@ async function putCodeReportAndAnnotations(executionResult, executionEventId, ou
|
|
|
141
141
|
}
|
|
142
142
|
exports.putCodeReportAndAnnotations = putCodeReportAndAnnotations;
|
|
143
143
|
async function maybeOutputToBitbucket(executionResult, deploymentId, outputLink) {
|
|
144
|
-
var _a, _b, _c;
|
|
144
|
+
var _a, _b, _c, _d;
|
|
145
145
|
const repoSlug = (_a = process.env.BITBUCKET_REPO_SLUG) !== null && _a !== void 0 ? _a : '';
|
|
146
146
|
const workspace = (_b = process.env.BITBUCKET_REPO_OWNER) !== null && _b !== void 0 ? _b : '';
|
|
147
147
|
const node = (_c = process.env.BITBUCKET_COMMIT) !== null && _c !== void 0 ? _c : '';
|
|
148
148
|
const isCustomBitBucketPipe = process.env.IS_CUSTOM_BITBUCKET_PIPE === 'true';
|
|
149
149
|
const noProxy = process.env.CODE_INSIGHTS_PROXY_OFF === 'true';
|
|
150
|
-
if (repoSlug &&
|
|
150
|
+
if (repoSlug &&
|
|
151
|
+
workspace &&
|
|
152
|
+
node && ((_d = executionResult === null || executionResult === void 0 ? void 0 : executionResult.executions) === null || _d === void 0 ? void 0 : _d.length) &&
|
|
153
|
+
executionResult.executions.length > 0) {
|
|
151
154
|
const codeReport = await putCodeReportAndAnnotations(executionResult, deploymentId, outputLink, workspace, repoSlug, node, isCustomBitBucketPipe, noProxy);
|
|
152
155
|
loggingProvider_1.logger.info(chalk.cyan(`Bitbucket Code Insights Report generated ${codeReport.uuid}`));
|
|
153
156
|
}
|
|
@@ -238,8 +238,8 @@ async function createDeployment(parsed) {
|
|
|
238
238
|
await codeInsights_1.maybeOutputToBitbucket(pollingResult.newEntity, deploymentEvent.id, outputWebappLink);
|
|
239
239
|
}
|
|
240
240
|
catch (error) {
|
|
241
|
-
loggingProvider_1.logger.info(chalk.
|
|
242
|
-
loggingProvider_1.logger.info(error);
|
|
241
|
+
loggingProvider_1.logger.info(chalk.yellow.bold('Unable to generate code insights due to BitBucket integration API error'));
|
|
242
|
+
loggingProvider_1.logger.info(`details: ${error}`);
|
|
243
243
|
}
|
|
244
244
|
const textOutput = printDeploymentEventResultOutput(deploymentEvent.id, outputWebappLink, parsed.output, pollingResult === null || pollingResult === void 0 ? void 0 : pollingResult.newEntity);
|
|
245
245
|
if (!isSuccess) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getDeviceDescriptorForEmulation = exports.getProperScreenConfig = void 0;
|
|
4
4
|
const mablApi_1 = require("../../mablApi");
|
|
5
5
|
function getProperScreenConfig(emulationConfig) {
|
|
6
6
|
var _a, _b, _c, _d;
|
|
@@ -16,7 +16,7 @@ function getProperScreenConfig(emulationConfig) {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
exports.getProperScreenConfig = getProperScreenConfig;
|
|
19
|
-
function
|
|
19
|
+
function getDeviceDescriptorForEmulation(emulationConfig) {
|
|
20
20
|
var _a, _b, _c, _d, _e;
|
|
21
21
|
if (emulationConfig) {
|
|
22
22
|
const screenConfig = getProperScreenConfig(emulationConfig);
|
|
@@ -37,7 +37,7 @@ function getViewportSettingsForEmulation(emulationConfig) {
|
|
|
37
37
|
}
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
|
-
exports.
|
|
40
|
+
exports.getDeviceDescriptorForEmulation = getDeviceDescriptorForEmulation;
|
|
41
41
|
function isMobile(emulationConfig) {
|
|
42
42
|
return (emulationConfig.device_config.type ===
|
|
43
43
|
mablApi_1.DeviceEmulationConfiguration.TypeEnum.Phone ||
|