@applitools/driver 1.11.46 → 1.11.48

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/dist/driver.js CHANGED
@@ -181,12 +181,11 @@ class Driver {
181
181
  (_c = (_f = this._driverInfo).userAgent) !== null && _c !== void 0 ? _c : (_f.userAgent = (_d = (await this.currentContext.executePoll(snippets.getUserAgent))) !== null && _d !== void 0 ? _d : null);
182
182
  this._logger.log('Extracted user agent', this._driverInfo.userAgent);
183
183
  }
184
- return (_e = this._driverInfo.userAgent) !== null && _e !== void 0 ? _e : null;
184
+ return (_e = this._driverInfo.userAgent) !== null && _e !== void 0 ? _e : undefined;
185
185
  }
186
186
  async getUserAgentLegacy({ force } = {}) {
187
- var _a;
188
187
  const userAgent = await this.getUserAgent({ force });
189
- return utils.types.isObject(userAgent) ? (_a = userAgent === null || userAgent === void 0 ? void 0 : userAgent.legacy) !== null && _a !== void 0 ? _a : null : userAgent;
188
+ return utils.types.isObject(userAgent) ? userAgent === null || userAgent === void 0 ? void 0 : userAgent.legacy : userAgent;
190
189
  }
191
190
  async getEnvironment() {
192
191
  var _a, _b, _c, _d;
@@ -237,11 +236,11 @@ class Driver {
237
236
  this._environment.isAndroid = /Android/i.test(this._environment.platformName);
238
237
  this._environment.isIOS = /iOS/i.test(this._environment.platformName);
239
238
  }
240
- if (!this._environment.isMobile &&
239
+ if ((this._environment.isAndroid || this._environment.isIOS) &&
241
240
  this._environment.isWeb &&
242
- (this._environment.isAndroid || this._environment.isIOS)) {
241
+ !this._environment.isMobile) {
243
242
  this._environment.isMobile = true;
244
- this._environment.isEmulation = this._environment.isChromium;
243
+ this._environment.isEmulation = true;
245
244
  }
246
245
  this._environment.isEC =
247
246
  this._environment.isECClient || /exec-wus.applitools.com/.test((_d = (await this.getDriverUrl())) !== null && _d !== void 0 ? _d : '');
@@ -25,34 +25,29 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.extractUserAgentEnvironment = void 0;
27
27
  const utils = __importStar(require("@applitools/utils"));
28
- const MAJOR_MINOR = '(\\d+)(?:[_.](\\d+))?';
29
- const PLATFORM_REGEXES = [
30
- new RegExp(`(?:(Windows NT) ${MAJOR_MINOR})`),
31
- new RegExp('(?:(Windows XP))'),
32
- new RegExp('(?:(Windows 2000))'),
33
- new RegExp('(?:(Windows NT))'),
34
- new RegExp('(?:(Windows))'),
35
- new RegExp(`(?:(Mac OS X) ${MAJOR_MINOR})`),
36
- new RegExp(`(?:(Android) ${MAJOR_MINOR})`),
37
- new RegExp(`(?:(CPU(?: i[a-zA-Z]+)? OS) ${MAJOR_MINOR})`),
38
- new RegExp('(?:(Mac OS X))'),
39
- new RegExp('(?:(Mac_PowerPC))'),
40
- new RegExp('(?:(Linux))'),
41
- new RegExp('(?:(CrOS))'),
42
- new RegExp('(?:(SymbOS))'),
28
+ const majorMinorRegexpString = '(?<majorVersion>[^ .;_)]+)[_.;](?<minorVersion>[^ .;_)]*)';
29
+ const platformRegexpMapping = [
30
+ ['Windows', new RegExp(`Windows(?:(?: NT)? ${majorMinorRegexpString}?)?`)],
31
+ ['iOS', new RegExp(`CPU(?: i[a-zA-Z]+)? OS ${majorMinorRegexpString}`)],
32
+ ['Mac OS X', new RegExp(`Mac OS X(?: ${majorMinorRegexpString})?`)],
33
+ ['Android', new RegExp(`Android ${majorMinorRegexpString}`)],
34
+ ['Macintosh', new RegExp(`Mac_PowerPC`)],
35
+ ['Linux', new RegExp(`Linux`)],
36
+ ['Chrome OS', new RegExp(`CrOS`)],
37
+ ['SymbOS', new RegExp(`SymbOS`)],
43
38
  ];
44
- const BROWSER_REGEXPES = [
45
- new RegExp(`(?:(Opera)/${MAJOR_MINOR})`),
46
- new RegExp(`(?:(Edg)/${MAJOR_MINOR})`),
47
- new RegExp(`(?:(Edge)/${MAJOR_MINOR})`),
48
- new RegExp(`(?:(Chrome)/${MAJOR_MINOR})`),
49
- new RegExp(`(?:(Safari)/${MAJOR_MINOR})`),
50
- new RegExp(`(?:(Firefox)/${MAJOR_MINOR})`),
51
- new RegExp(`(?:MS(IE) ${MAJOR_MINOR})`),
39
+ const browserRegexpMapping = [
40
+ ['IE', new RegExp(`rv:${majorMinorRegexpString}\\) like Gecko`)],
41
+ ['IE', new RegExp(`MSIE ${majorMinorRegexpString}`)],
42
+ ['Electron', new RegExp(`Electron/${majorMinorRegexpString}`)],
43
+ ['Opera', new RegExp(`Opera/${majorMinorRegexpString}`)],
44
+ ['Edge', new RegExp(`(?:Edg|Edge)/${majorMinorRegexpString}`)],
45
+ ['Chrome', new RegExp(`Chrome/${majorMinorRegexpString}`)],
46
+ ['Safari', new RegExp(`Safari/${majorMinorRegexpString}`)],
47
+ ['Firefox', new RegExp(`Firefox/${majorMinorRegexpString}`)],
52
48
  ];
53
- const HIDDEN_IE_REGEX = new RegExp(`(?:rv:${MAJOR_MINOR}\\) like Gecko)`);
54
- const BROWSER_VERSION_REGEX = new RegExp(`(?:Version/${MAJOR_MINOR})`);
55
- const WINDOWS_VERSIONS = {
49
+ const browserVersionRegexp = new RegExp(`(?:Version/${majorMinorRegexpString})`);
50
+ const windowsVersionsMapping = {
56
51
  '0.1.0': '7',
57
52
  '0.2.0': '8',
58
53
  '0.3.0': '8.1',
@@ -74,68 +69,78 @@ function extractUserAgentEnvironment(userAgent) {
74
69
  ...extractUserAgentLegacyBrowser(userAgentLegacy),
75
70
  };
76
71
  const userAgentEnvironment = userAgentObject && extractUserAgentObjectEnvironment(userAgentObject);
77
- const environment = { ...userAgentEnvironment };
78
- (_a = environment.platformName) !== null && _a !== void 0 ? _a : (environment.platformName = userAgentLegacyEnvironment.platformName);
79
- (_b = environment.platformVersion) !== null && _b !== void 0 ? _b : (environment.platformVersion = userAgentLegacyEnvironment.platformVersion);
80
- environment.browserName = (_c = userAgentLegacyEnvironment.browserName) !== null && _c !== void 0 ? _c : environment.browserName;
81
- environment.browserVersion = (_d = userAgentLegacyEnvironment.browserVersion) !== null && _d !== void 0 ? _d : environment.browserVersion;
82
- return environment;
72
+ return {
73
+ ...userAgentEnvironment,
74
+ platformName: (_a = userAgentEnvironment === null || userAgentEnvironment === void 0 ? void 0 : userAgentEnvironment.platformName) !== null && _a !== void 0 ? _a : userAgentLegacyEnvironment.platformName,
75
+ platformVersion: (_b = userAgentEnvironment === null || userAgentEnvironment === void 0 ? void 0 : userAgentEnvironment.platformVersion) !== null && _b !== void 0 ? _b : userAgentLegacyEnvironment.platformVersion,
76
+ browserName: (_c = userAgentLegacyEnvironment.browserName) !== null && _c !== void 0 ? _c : userAgentEnvironment === null || userAgentEnvironment === void 0 ? void 0 : userAgentEnvironment.browserName,
77
+ browserVersion: (_d = userAgentLegacyEnvironment.browserVersion) !== null && _d !== void 0 ? _d : userAgentEnvironment === null || userAgentEnvironment === void 0 ? void 0 : userAgentEnvironment.browserVersion,
78
+ isReliable: !!((userAgentEnvironment === null || userAgentEnvironment === void 0 ? void 0 : userAgentEnvironment.platformName) && (userAgentEnvironment === null || userAgentEnvironment === void 0 ? void 0 : userAgentEnvironment.platformVersion)),
79
+ };
83
80
  }
84
81
  exports.extractUserAgentEnvironment = extractUserAgentEnvironment;
85
82
  function extractUserAgentLegacyPlatform(userAgent) {
86
- const platformRegExp = PLATFORM_REGEXES.find(regexp => regexp.test(userAgent));
87
- if (!platformRegExp)
88
- return { platformName: 'Unknown' };
89
- const [_, platformName, platformMajorVersion, platformMinorVersion] = platformRegExp.exec(userAgent);
90
- if (platformName.startsWith('CPU')) {
91
- return { platformName: 'iOS', platformVersion: platformMajorVersion };
83
+ let info;
84
+ for (const [platformName, regexp] of platformRegexpMapping) {
85
+ const match = regexp.exec(userAgent);
86
+ if (match) {
87
+ info = { platformName, ...match.groups };
88
+ break;
89
+ }
92
90
  }
93
- else if (platformName === 'Windows 2000' || platformName === 'Windows XP') {
94
- return { platformName: 'Windows', platformVersion: '5' };
91
+ if (!info)
92
+ return { platformName: 'Unknown' };
93
+ if (info.platformName === 'Macintosh' || info.platformName === 'Chrome OS') {
94
+ info.minorVersion = undefined;
95
95
  }
96
- else if (platformName === 'Windows NT') {
97
- const result = { platformName: 'Windows', platformVersion: platformMajorVersion };
98
- if (!platformMajorVersion) {
99
- result.platformVersion = '4';
96
+ else if (info.platformName === 'Windows') {
97
+ if (info.majorVersion === 'XP') {
98
+ info.majorVersion = '5';
99
+ info.minorVersion = '1';
100
100
  }
101
- else if (platformMajorVersion === '6' && platformMinorVersion === '1') {
102
- result.platformVersion = '7';
101
+ else if (info.majorVersion === '6' && info.minorVersion === '1') {
102
+ info.majorVersion = '7';
103
+ info.minorVersion = undefined;
103
104
  }
104
- else if (platformMajorVersion === '6' && (platformMinorVersion === '2' || platformMinorVersion === '3')) {
105
- result.platformVersion = '8';
105
+ else if (info.majorVersion === '6' && info.minorVersion === '2') {
106
+ info.majorVersion = '8';
107
+ info.minorVersion = undefined;
106
108
  }
107
- return result;
108
- }
109
- else if (platformName === 'Mac_PowerPC') {
110
- return { platformName: 'Macintosh', platformVersion: platformMajorVersion };
111
- }
112
- else if (platformName === 'CrOS') {
113
- return { platformName: 'Chrome OS', platformVersion: platformMajorVersion };
114
- }
115
- else {
116
- return { platformName, platformVersion: platformMajorVersion };
117
- }
118
- }
119
- function extractUserAgentLegacyBrowser(userAgent) {
120
- const browserRegExp = BROWSER_REGEXPES.find(regexp => regexp.test(userAgent));
121
- if (!browserRegExp) {
122
- if (HIDDEN_IE_REGEX.test(userAgent)) {
123
- const [_, browserVersion] = HIDDEN_IE_REGEX.exec(userAgent);
124
- return { browserName: 'IE', browserVersion };
109
+ else if (info.majorVersion === '6' && info.minorVersion === '3') {
110
+ info.majorVersion = '8';
111
+ info.minorVersion = '1';
112
+ }
113
+ else if (info.majorVersion === '10') {
114
+ info.minorVersion = undefined;
125
115
  }
126
116
  else {
127
- return { browserName: 'Unknown' };
117
+ info.majorVersion = undefined;
118
+ info.minorVersion = undefined;
128
119
  }
129
120
  }
130
- const [_, browserName, browserVersion] = browserRegExp.exec(userAgent);
131
- const result = { browserName, browserVersion };
132
- if (result.browserName === 'Edg')
133
- result.browserName = 'Edge';
134
- if (BROWSER_VERSION_REGEX.test(userAgent)) {
135
- const [_, browserVersion] = BROWSER_VERSION_REGEX.exec(userAgent);
136
- result.browserVersion = browserVersion;
121
+ return {
122
+ platformName: info.platformName,
123
+ platformVersion: info.minorVersion ? `${info.majorVersion}.${info.minorVersion}` : info.majorVersion,
124
+ };
125
+ }
126
+ function extractUserAgentLegacyBrowser(userAgent) {
127
+ let info;
128
+ for (const [browserName, browserRegexp] of browserRegexpMapping) {
129
+ const browserMatch = browserRegexp.exec(userAgent);
130
+ if (browserMatch) {
131
+ info = { browserName, ...browserMatch.groups };
132
+ const versionMatch = browserVersionRegexp.exec(userAgent);
133
+ if (versionMatch)
134
+ info = { ...info, ...versionMatch.groups };
135
+ break;
136
+ }
137
137
  }
138
- return result;
138
+ if (!info)
139
+ return { browserName: 'Unknown' };
140
+ return {
141
+ browserName: info.browserName,
142
+ browserVersion: info.minorVersion ? `${info.majorVersion}.${info.minorVersion}` : info.majorVersion,
143
+ };
139
144
  }
140
145
  function extractUserAgentObjectEnvironment(userAgent) {
141
146
  var _a, _b, _c, _d;
@@ -151,7 +156,8 @@ function extractUserAgentObjectEnvironment(userAgent) {
151
156
  isChromium: Boolean(chromiumBrand),
152
157
  };
153
158
  if (environment.platformName === 'Windows') {
154
- environment.platformVersion = WINDOWS_VERSIONS[environment.platformVersion];
159
+ environment.platformVersion =
160
+ windowsVersionsMapping[environment.platformVersion];
155
161
  }
156
162
  else if (environment.platformName === 'macOS') {
157
163
  environment.platformName = 'Mac OS X';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/driver",
3
- "version": "1.11.46",
3
+ "version": "1.11.48",
4
4
  "description": "Applitools universal framework wrapper",
5
5
  "keywords": [
6
6
  "applitools",
package/types/driver.d.ts CHANGED
@@ -45,10 +45,10 @@ export declare class Driver<T extends SpecType> {
45
45
  }): Promise<Capabilities | null>;
46
46
  getUserAgent({ force }?: {
47
47
  force?: boolean;
48
- }): Promise<UserAgent | null>;
48
+ }): Promise<UserAgent | undefined>;
49
49
  getUserAgentLegacy({ force }?: {
50
50
  force?: boolean;
51
- }): Promise<string | null>;
51
+ }): Promise<string | undefined>;
52
52
  getEnvironment(): Promise<Environment>;
53
53
  getViewport(): Promise<Viewport>;
54
54
  getFeatures(): Promise<Features>;
package/types/types.d.ts CHANGED
@@ -28,6 +28,7 @@ export type Environment = {
28
28
  platformName?: string;
29
29
  platformVersion?: string;
30
30
  deviceName?: string;
31
+ isReliable?: boolean;
31
32
  isW3C?: boolean;
32
33
  isEC?: boolean;
33
34
  isECClient?: boolean;