Skip to content

Commit afbe2be

Browse files
authored
Fix some vulnerabilities and other enhancements (#2663)
1 parent ab0d2ea commit afbe2be

File tree

17 files changed

+4183
-9601
lines changed

17 files changed

+4183
-9601
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/*.d.ts

.github/workflows/taiko.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,14 @@ jobs:
3535
libcups2 \
3636
libxrandr2 \
3737
libpangocairo-1.0-0 \
38-
libgtk-3-0
38+
libgtk-3-0 \
39+
libdrm-dev \
40+
libgbm-dev \
41+
libasound-dev
3942
- name: unit-tests
40-
run: npm test
43+
run: |
44+
npm run lint:check
45+
npm test
4146
4247
functional-tests:
4348
needs: unit-tests
@@ -65,7 +70,10 @@ jobs:
6570
libcups2 \
6671
libxrandr2 \
6772
libpangocairo-1.0-0 \
68-
libgtk-3-0
73+
libgtk-3-0 \
74+
libdrm-dev \
75+
libgbm-dev \
76+
libasound-dev
6977
- name: functional-tests
7078
run: npm run test-functional
7179

@@ -104,7 +112,10 @@ jobs:
104112
libcups2 \
105113
libxrandr2 \
106114
libpangocairo-1.0-0 \
107-
libgtk-3-0
115+
libgtk-3-0 \
116+
libdrm-dev \
117+
libgbm-dev \
118+
libasound-dev
108119
- name: install xvfb
109120
run: sudo apt install xvfb
110121
- name: functional-tests-headful
@@ -152,7 +163,10 @@ jobs:
152163
libcups2 \
153164
libxrandr2 \
154165
libpangocairo-1.0-0 \
155-
libgtk-3-0
166+
libgtk-3-0 \
167+
libdrm-dev \
168+
libgbm-dev \
169+
libasound-dev
156170
- name: test-docs
157171
run: npm run test-docs
158172
- name: Upload html report

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodejs 16.18.1

lib/actions/scrollTo.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ const { doActionAwaitingNavigation } = require('../doActionAwaitingNavigation');
66

77
const scrollToElement = async (element, options = {}) => {
88
options = setScrollOptions(options);
9-
9+
1010
function scrollToNode(opt) {
1111
const element = this.nodeType === Node.TEXT_NODE ? this.parentElement : this;
1212
element.scrollIntoView({ block: opt.blockAlignment, inline: opt.inlineAlignment });
1313
return 'result';
1414
}
15-
await runtimeHandler.runtimeCallFunctionOn(scrollToNode, null, {
15+
await runtimeHandler.runtimeCallFunctionOn(scrollToNode, null, {
1616
objectId: element.get(),
1717
arg: {
1818
blockAlignment: options.blockAlignment,
19-
inlineAlignment: options.inlineAlignment
19+
inlineAlignment: options.inlineAlignment,
2020
},
2121
});
2222
};

lib/browserLauncher.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ function updateArgsFromOptions(args, options) {
1717
args = options.args ? args.concat(options.args) : args;
1818
args = process.env.TAIKO_BROWSER_ARGS
1919
? args.concat(
20-
process.env.TAIKO_BROWSER_ARGS.split(/\s*,?\s*--/)
21-
.filter((arg) => arg !== '')
22-
.map((arg) => `--${arg}`),
23-
)
20+
process.env.TAIKO_BROWSER_ARGS.split(/\s*,?\s*--/)
21+
.filter((arg) => arg !== '')
22+
.map((arg) => `--${arg}`),
23+
)
2424
: args;
2525
return args;
2626
}
@@ -366,7 +366,7 @@ const closeBrowser = async () => {
366366
if (temporaryUserDataDir) {
367367
try {
368368
fs.removeSync(temporaryUserDataDir);
369-
} catch (e) { }
369+
} catch (e) {}
370370
}
371371
};
372372

lib/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ const setClickOptions = (options, x, y) => {
9898

9999
const setScrollOptions = (options) => {
100100
options.blockAlignment = options.blockAlignment || defaultConfig.blockAlignment;
101-
options.inlineAlignment = options.inlineAlignment ||defaultConfig.inlineAlignment;
101+
options.inlineAlignment = options.inlineAlignment || defaultConfig.inlineAlignment;
102102
return options;
103103
};
104104

lib/data/devices.js

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -523,54 +523,6 @@ let DEVICES = {
523523
isLandscape: true,
524524
},
525525
},
526-
'iPhone 11': {
527-
userAgent:
528-
'Mozilla/5.0 (iPhone; CPU iPhone OS 15_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1',
529-
viewport: {
530-
width: 414,
531-
height: 896,
532-
deviceScaleFactor: 2,
533-
isMobile: true,
534-
hasTouch: true,
535-
isLandscape: false,
536-
},
537-
},
538-
'iPhone 11 landscape': {
539-
userAgent:
540-
'Mozilla/5.0 (iPhone; CPU iPhone OS 15_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1',
541-
viewport: {
542-
width: 896,
543-
height: 414,
544-
deviceScaleFactor: 2,
545-
isMobile: true,
546-
hasTouch: true,
547-
isLandscape: true,
548-
},
549-
},
550-
'iPhone 11 Pro': {
551-
userAgent:
552-
'Mozilla/5.0 (iPhone; CPU iPhone OS 15_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1',
553-
viewport: {
554-
width: 375,
555-
height: 812,
556-
deviceScaleFactor: 3,
557-
isMobile: true,
558-
hasTouch: true,
559-
isLandscape: false,
560-
},
561-
},
562-
'iPhone 11 Pro landscape': {
563-
userAgent:
564-
'Mozilla/5.0 (iPhone; CPU iPhone OS 15_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1',
565-
viewport: {
566-
width: 812,
567-
height: 375,
568-
deviceScaleFactor: 3,
569-
isMobile: true,
570-
hasTouch: true,
571-
isLandscape: true,
572-
},
573-
},
574526
'Kindle Fire HDX': {
575527
userAgent:
576528
'Mozilla/5.0 (Linux; U; en-us; KFAPWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.13 Safari/535.19 Silk-Accelerated=true',

lib/documentation.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
const documentation = require('documentation');
21
const fs = require('fs');
32

43
const jsDocToJson = async (sourceFiles, outputFile) => {
5-
documentation
6-
.build(sourceFiles, { shallow: true })
7-
.then(documentation.formats.json)
8-
.then((output) => {
9-
// output is a string of JSON data
10-
fs.writeFileSync(outputFile, output);
11-
});
4+
try {
5+
const documentation = await import('documentation');
6+
documentation
7+
.build(sourceFiles, { shallow: true })
8+
.then(documentation.formats.json)
9+
.then((output) => {
10+
// output is a string of JSON data
11+
fs.writeFileSync(outputFile, output);
12+
});
13+
} catch (error) {
14+
console.error('Failed to load `documentation`:', error);
15+
}
1216
};
1317

1418
module.exports.jsDocToJson = jsDocToJson;

lib/elements/elementHelper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const highlightElement = async (element) => {
77
// Adding a wait as tests fail on newer versions of chrome
88
if (!defaultConfig.highlightOnAction) {
99
await wait(1000);
10-
return
10+
return;
1111
}
1212

1313
if (await element.isVisible()) {

lib/repl/repl.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ function initCommands(taiko, repl, previousSessionFile) {
112112
},
113113
});
114114
repl.defineCommand('step', {
115-
help:
116-
'Generate gauge steps from recorded script. (openBrowser and closeBrowser are not recorded as part of step)',
115+
help: 'Generate gauge steps from recorded script. (openBrowser and closeBrowser are not recorded as part of step)',
117116
action(file) {
118117
if (!file) {
119118
console.log(step());

0 commit comments

Comments
 (0)