Skip to content

Commit fde816f

Browse files
authored
use mini version if no browser info was given (#60)
1 parent f6a7a2a commit fde816f

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

lib/driver.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -253,16 +253,18 @@ export class WebOSDriver extends BaseDriver {
253253

254254
/**
255255
* Set chrome version v63.0.3239.0 as the minimal version
256-
* for autodownload to use proper chromedriver version.
257-
* Older than the chromedriver version could raise no Chrome binary found error,
258-
* which no makes sense for TV automation usage.
256+
* for autodownload to use proper chromedriver version if
257+
* - the 'Browser' info does not have proper chrome version, or
258+
* - older than the chromedriver version could raise no Chrome binary found error,
259+
* which no makes sense for TV automation usage.
259260
*
260261
* @param {BrowserVersionInfo} browserVersionInfo
261262
* @return {BrowserVersionInfo}
262263
*/
263264
fixChromeVersionForAutodownload(browserVersionInfo) {
264265
const chromeVersion = VERSION_PATTERN.exec(browserVersionInfo.Browser ?? '');
265266
if (!chromeVersion) {
267+
browserVersionInfo.Browser = MIN_CHROME_VERSION;
266268
return browserVersionInfo;
267269
}
268270

@@ -307,6 +309,7 @@ export class WebOSDriver extends BaseDriver {
307309
log.info(`The response of http://${debuggerAddress}/json/version was ${JSON.stringify(result)}`);
308310
result = this.useUAForBrowserIfNotPresent(result);
309311
result = this.fixChromeVersionForAutodownload(result);
312+
log.info(`Fixed browser info is ${JSON.stringify(result)}`);
310313

311314
// To respect the executableDir.
312315
executable = undefined;

test/unit/driver.spec.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,16 @@ describe('WebOSDriver', function () {
139139
const driver = new WebOSDriver();
140140
const browserInfo = {
141141
'Browser': '',
142-
'Protocol-Version': '1.3',
143-
'User-Agent': 'Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36',
144-
'V8-Version': '8.7.220.(29*1000 + 2)',
145-
'WebKit-Version': '537.36 (@cec52f3dd4465dd7389298b97ab723856c556bd)',
146-
'webSocketDebuggerUrl': 'ws://192.168.0.1:9998/devtools/browser/a4b3786c-2d2f-4751-9e05-aee2023bc226'
142+
'Protocol-Version': '1.1',
143+
'User-Agent': '',
144+
'WebKit-Version': '537.36 (@fa89da905405aab455e0f0d4ec7f49631c7ca70b)'
147145
};
148-
driver.fixChromeVersionForAutodownload(browserInfo).should.eql(browserInfo);
146+
driver.fixChromeVersionForAutodownload(browserInfo).should.eql({
147+
'Browser': 'Chrome/63.0.3239.0',
148+
'Protocol-Version': '1.1',
149+
'User-Agent': '',
150+
'WebKit-Version': '537.36 (@fa89da905405aab455e0f0d4ec7f49631c7ca70b)'
151+
});
149152
});
150153

151154
it('Use the given chrome version', function () {

0 commit comments

Comments
 (0)