-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
36 lines (29 loc) · 1.08 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
'use strict';
const parseConfig = require('./config');
const DevTools = require('./dev-tools');
const debug = require('debug')('hermione-hide-scrollbars');
module.exports = (hermione, opts) => {
const config = parseConfig(opts);
if (!config.enabled) {
return;
}
hermione.on(hermione.events.SESSION_START, async (browser, {browserId, sessionId}) => {
if (!config.browsers.includes(browserId)) {
return;
}
try {
const browserWSEndpoint = config.browserWSEndpoint({
sessionId,
gridUrl: hermione.config.forBrowser(browserId).gridUrl
});
debug(`connecting devtools via endpoint ${browserWSEndpoint}`);
const devtools = await DevTools.create({browserWSEndpoint});
debug('preventing scrollbars on any new page');
devtools.setScrollbarsHiddenOnNewPage();
debug('hiding scrollbars on active pages');
await devtools.hideScrollbarsOnActivePages();
} catch (e) {
throw (e.error || e);
}
});
};