@applitools/driver 1.11.47 → 1.11.49
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 +5 -6
- package/dist/user-agent.js +82 -76
- package/package.json +1 -1
- package/types/driver.d.ts +2 -2
- package/types/types.d.ts +1 -0
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 :
|
|
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) ?
|
|
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;
|
|
@@ -224,10 +223,10 @@ class Driver {
|
|
|
224
223
|
}
|
|
225
224
|
if (this._environment.browserName) {
|
|
226
225
|
this._environment.isIE = /(internet explorer|ie)/i.test(this._environment.browserName);
|
|
227
|
-
this._environment.isEdgeLegacy =
|
|
228
|
-
/edge/i.test(this._environment.browserName) && Number(this._environment.browserVersion) <= 44;
|
|
229
226
|
this._environment.isEdge =
|
|
230
|
-
/edge/i.test(this._environment.browserName) && Number(this._environment.browserVersion)
|
|
227
|
+
/edge/i.test(this._environment.browserName) && Number.parseInt(this._environment.browserVersion) >= 79;
|
|
228
|
+
this._environment.isEdgeLegacy =
|
|
229
|
+
/edge/i.test(this._environment.browserName) && Number.parseInt(this._environment.browserVersion) < 79;
|
|
231
230
|
this._environment.isChrome = /chrome/i.test(this._environment.browserName);
|
|
232
231
|
this._environment.isChromium = this._environment.isChrome || this._environment.isEdge;
|
|
233
232
|
}
|
package/dist/user-agent.js
CHANGED
|
@@ -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
|
|
29
|
-
const
|
|
30
|
-
new RegExp(`(?:(
|
|
31
|
-
new RegExp(
|
|
32
|
-
new RegExp(
|
|
33
|
-
new RegExp(
|
|
34
|
-
new RegExp(
|
|
35
|
-
new RegExp(`
|
|
36
|
-
new RegExp(`
|
|
37
|
-
new RegExp(`
|
|
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
|
|
45
|
-
new RegExp(`
|
|
46
|
-
new RegExp(`
|
|
47
|
-
new RegExp(`
|
|
48
|
-
new RegExp(`
|
|
49
|
-
new RegExp(`(?:
|
|
50
|
-
new RegExp(`
|
|
51
|
-
new RegExp(`
|
|
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
|
|
54
|
-
const
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
94
|
-
return { platformName: '
|
|
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
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
else if (info.platformName === 'Windows') {
|
|
97
|
+
if (info.majorVersion === 'XP') {
|
|
98
|
+
info.majorVersion = '5';
|
|
99
|
+
info.minorVersion = '1';
|
|
100
100
|
}
|
|
101
|
-
else if (
|
|
102
|
-
|
|
101
|
+
else if (info.majorVersion === '6' && info.minorVersion === '1') {
|
|
102
|
+
info.majorVersion = '7';
|
|
103
|
+
info.minorVersion = undefined;
|
|
103
104
|
}
|
|
104
|
-
else if (
|
|
105
|
-
|
|
105
|
+
else if (info.majorVersion === '6' && info.minorVersion === '2') {
|
|
106
|
+
info.majorVersion = '8';
|
|
107
|
+
info.minorVersion = undefined;
|
|
106
108
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
-
|
|
117
|
+
info.majorVersion = undefined;
|
|
118
|
+
info.minorVersion = undefined;
|
|
128
119
|
}
|
|
129
120
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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
|
-
|
|
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 =
|
|
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
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 |
|
|
48
|
+
}): Promise<UserAgent | undefined>;
|
|
49
49
|
getUserAgentLegacy({ force }?: {
|
|
50
50
|
force?: boolean;
|
|
51
|
-
}): Promise<string |
|
|
51
|
+
}): Promise<string | undefined>;
|
|
52
52
|
getEnvironment(): Promise<Environment>;
|
|
53
53
|
getViewport(): Promise<Viewport>;
|
|
54
54
|
getFeatures(): Promise<Features>;
|