browsertime 16.8.1 → 16.9.0
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/CHANGELOG.md +7 -0
- package/lib/chrome/longTaskMetrics.js +15 -0
- package/lib/core/engine/command/wait.js +23 -0
- package/lib/core/seleniumRunner.js +27 -17
- package/lib/support/cli.js +2 -1
- package/lib/support/errors.js +9 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Browsertime changelog (we do [semantic versioning](https://semver.org))
|
|
2
2
|
|
|
3
|
+
## 16.9.0 - 2022-06-15
|
|
4
|
+
### Added
|
|
5
|
+
* New `wait.byCondition` command. Thank you [Icecold777](https://github.com/Icecold777) for PR [#1803](https://github.com/sitespeedio/browsertime/pull/1803).
|
|
6
|
+
* Collect number of CPU longtasks before largest contentful paint [#1806](https://github.com/sitespeedio/browsertime/pull/1806).
|
|
7
|
+
|
|
8
|
+
### Fixed
|
|
9
|
+
* Instead of throwing errors and exit the tests if the page hasn't finished loading after 5 minutes, we now gracefully ends the test after 2 minutes (you can change that time with `--maxLoadTime`). That makes more sense than just throwing errors [#1810](https://github.com/sitespeedio/browsertime/pull/1810).
|
|
3
10
|
## 16.8.1 - 2022-06-09
|
|
4
11
|
### Fixed
|
|
5
12
|
* Fix for getting the MOZ log, thank you [Gregory Mierzwinski](https://github.com/gmierz) for PR [#1802](https://github.com/sitespeedio/browsertime/pull/1802).
|
|
@@ -5,6 +5,7 @@ const get = require('lodash.get');
|
|
|
5
5
|
module.exports = function (result, options) {
|
|
6
6
|
let totalDurationFirstPaint = 0;
|
|
7
7
|
let totalDurationFirstContentFulPaint = 0;
|
|
8
|
+
let totalDurationLargestContentFulPaint = 0;
|
|
8
9
|
let totalDurationAfterLoadEventEnd = 0;
|
|
9
10
|
let totalDuration = 0;
|
|
10
11
|
|
|
@@ -22,10 +23,16 @@ module.exports = function (result, options) {
|
|
|
22
23
|
'browserScripts.timings.paintTiming.first-contentful-paint'
|
|
23
24
|
);
|
|
24
25
|
|
|
26
|
+
const largestContentfulPaint = get(
|
|
27
|
+
result,
|
|
28
|
+
'browserScripts.timings.largestContentfulPaint.renderTime'
|
|
29
|
+
); // result.browserScripts.timings.largestContentfulPaint.loadTime;
|
|
30
|
+
|
|
25
31
|
const loadEventEnd = get(result, 'browserScripts.timings.loadEventEnd');
|
|
26
32
|
|
|
27
33
|
let longTasksBeforeFirstPaint = 0;
|
|
28
34
|
let longTasksBeforeFirstContentfulPaint = 0;
|
|
35
|
+
let longTasksBeforeLargestContentfulPaint = 0;
|
|
29
36
|
let longTasksAfterLoadEventEnd = 0;
|
|
30
37
|
let lastLongTask = 0;
|
|
31
38
|
|
|
@@ -42,6 +49,10 @@ module.exports = function (result, options) {
|
|
|
42
49
|
longTasksBeforeFirstContentfulPaint++;
|
|
43
50
|
totalDurationFirstContentFulPaint += longTask.duration;
|
|
44
51
|
}
|
|
52
|
+
if (largestContentfulPaint && longTask.startTime < largestContentfulPaint) {
|
|
53
|
+
longTasksBeforeLargestContentfulPaint++;
|
|
54
|
+
totalDurationLargestContentFulPaint += longTask.duration;
|
|
55
|
+
}
|
|
45
56
|
if (
|
|
46
57
|
firstContentfulPaint &&
|
|
47
58
|
longTask.startTime > firstContentfulPaint &&
|
|
@@ -74,6 +85,10 @@ module.exports = function (result, options) {
|
|
|
74
85
|
tasks: longTasksBeforeFirstContentfulPaint,
|
|
75
86
|
totalDuration: totalDurationFirstContentFulPaint
|
|
76
87
|
},
|
|
88
|
+
beforeLargestContentfulPaint: {
|
|
89
|
+
tasks: longTasksBeforeLargestContentfulPaint,
|
|
90
|
+
totalDuration: totalDurationLargestContentFulPaint
|
|
91
|
+
},
|
|
77
92
|
afterLoadEventEnd: {
|
|
78
93
|
tasks: longTasksAfterLoadEventEnd,
|
|
79
94
|
totalDuration: totalDurationAfterLoadEventEnd
|
|
@@ -101,5 +101,28 @@ class Wait {
|
|
|
101
101
|
async byPageToComplete() {
|
|
102
102
|
return this.browser.extraWait(this.pageCompleteCheck);
|
|
103
103
|
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Wait for an condition that will eventually return a truthy-value for maxTime.
|
|
107
|
+
* @param {string} jsExpression The js code condition to wait for
|
|
108
|
+
* @param {number} maxTime Max time to wait in ms
|
|
109
|
+
* @returns {Promise} Promise object represents when the expression becomes truthy or the time times out
|
|
110
|
+
* @throws Will throw an error if the condition returned false
|
|
111
|
+
*/
|
|
112
|
+
async byCondition(jsExpression, maxTime) {
|
|
113
|
+
const driver = this.browser.getDriver();
|
|
114
|
+
const time = maxTime || 6000;
|
|
115
|
+
|
|
116
|
+
try {
|
|
117
|
+
const script = `return ${jsExpression}`;
|
|
118
|
+
await driver.wait(() => {
|
|
119
|
+
return driver.executeScript(script);
|
|
120
|
+
}, time);
|
|
121
|
+
} catch (e) {
|
|
122
|
+
log.error('Condition was not met', jsExpression, time);
|
|
123
|
+
log.verbose(e);
|
|
124
|
+
throw Error(`Condition ${jsExpression} was not met in ${time} ms`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
104
127
|
}
|
|
105
128
|
module.exports = Wait;
|
|
@@ -5,7 +5,11 @@ const merge = require('lodash.merge');
|
|
|
5
5
|
const get = require('lodash.get');
|
|
6
6
|
const { Condition } = require('selenium-webdriver/lib/webdriver');
|
|
7
7
|
const { isAndroidConfigured } = require('../android');
|
|
8
|
-
const {
|
|
8
|
+
const {
|
|
9
|
+
UrlLoadError,
|
|
10
|
+
BrowserError,
|
|
11
|
+
TimeoutError
|
|
12
|
+
} = require('../support/errors');
|
|
9
13
|
const builder = require('./webdriver');
|
|
10
14
|
const getViewPort = require('../support/getViewPort');
|
|
11
15
|
const defaultPageCompleteCheck = require('./pageCompleteChecks/defaultPageCompleteCheck');
|
|
@@ -18,7 +22,7 @@ const defaults = {
|
|
|
18
22
|
pageLoad: 300000,
|
|
19
23
|
script: 120000,
|
|
20
24
|
logs: 90000,
|
|
21
|
-
pageCompleteCheck:
|
|
25
|
+
pageCompleteCheck: 60000
|
|
22
26
|
},
|
|
23
27
|
index: 0
|
|
24
28
|
};
|
|
@@ -36,7 +40,7 @@ async function timeout(promise, ms, errorMessage) {
|
|
|
36
40
|
|
|
37
41
|
return Promise.race([
|
|
38
42
|
new Promise((resolve, reject) => {
|
|
39
|
-
timer = setTimeout(reject, ms, new
|
|
43
|
+
timer = setTimeout(reject, ms, new TimeoutError(errorMessage));
|
|
40
44
|
return timer;
|
|
41
45
|
}),
|
|
42
46
|
promise.then(value => {
|
|
@@ -182,20 +186,26 @@ class SeleniumRunner {
|
|
|
182
186
|
`Running page complete check ${pageCompleteCheck} took too long`
|
|
183
187
|
);
|
|
184
188
|
} catch (e) {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
189
|
+
if (e instanceof TimeoutError) {
|
|
190
|
+
log.info(
|
|
191
|
+
`The page did not finishied loading in ${pageCompleteCheckTimeout} ms. You can adjust the timeout by setting the --maxLoadTime option (in ms).`
|
|
192
|
+
);
|
|
193
|
+
} else {
|
|
194
|
+
log.error(
|
|
195
|
+
`Failed waiting on page ${
|
|
196
|
+
url ? url : ''
|
|
197
|
+
} to finished loading, timed out after ${pageCompleteCheckTimeout} ms`,
|
|
198
|
+
e
|
|
199
|
+
);
|
|
200
|
+
throw new UrlLoadError(
|
|
201
|
+
`Failed waiting on page ${
|
|
202
|
+
url ? url : ''
|
|
203
|
+
} to finished loading, timed out after ${pageCompleteCheckTimeout} ms `,
|
|
204
|
+
{
|
|
205
|
+
cause: e
|
|
206
|
+
}
|
|
207
|
+
);
|
|
208
|
+
}
|
|
199
209
|
}
|
|
200
210
|
}
|
|
201
211
|
|
package/lib/support/cli.js
CHANGED
|
@@ -162,7 +162,8 @@ module.exports.parseCommandLine = function parseCommandLine() {
|
|
|
162
162
|
group: 'timeouts'
|
|
163
163
|
})
|
|
164
164
|
.option('timeouts.pageCompleteCheck', {
|
|
165
|
-
|
|
165
|
+
alias: 'maxLoadTime',
|
|
166
|
+
default: 120000,
|
|
166
167
|
type: 'number',
|
|
167
168
|
describe:
|
|
168
169
|
'Timeout when waiting for page to complete loading, in milliseconds',
|
package/lib/support/errors.js
CHANGED
|
@@ -21,8 +21,16 @@ class UrlLoadError extends BrowsertimeError {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
class TimeoutError extends BrowsertimeError {
|
|
25
|
+
constructor(message, url, extra) {
|
|
26
|
+
super(message, extra);
|
|
27
|
+
this.url = url;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
24
31
|
module.exports = {
|
|
25
32
|
BrowsertimeError,
|
|
26
33
|
BrowserError,
|
|
27
|
-
UrlLoadError
|
|
34
|
+
UrlLoadError,
|
|
35
|
+
TimeoutError
|
|
28
36
|
};
|