Skip to content

Commit

Permalink
Merge branch 'main' into block-bidi
Browse files Browse the repository at this point in the history
  • Loading branch information
soulgalore committed Mar 20, 2024
2 parents e1b0385 + 26fa281 commit 942d47a
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM sitespeedio/webbrowsers:chrome-122.0-firefox-123.0-edge-121.0
FROM sitespeedio/webbrowsers:chrome-123.0-firefox-124.0-edge-122.0

ARG TARGETPLATFORM=linux/amd64

Expand Down
32 changes: 22 additions & 10 deletions lib/core/engine/command/measure.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,19 +205,22 @@ export class Measure {
} else {
this.result.at(-1).error.push(message);
}
} else {
// error not associated to a start/run so far
log.error('No page that could be associated with the error:' + message);
}
}
// Add the error in the generic failure
if (this.result.failureMessages) {
this.result.failureMessages.push(message);
} else {
this.result.failureMessages = [message];
}
}

/**
* Have a consistent way of adding an failure
* @private
*/
_failure(message) {
log.debug('Mark run as failure with message %s', message);
log.info('Mark run as failure with message: %s', message);
this.result.markedAsFailure = 1;
if (this.result.failureMessages) {
this.result.failureMessages.push(message);
Expand Down Expand Up @@ -378,14 +381,22 @@ export class Measure {
*
* @async
* @param {string} errorMessage - The message about the error. This will end up on the HTML report for sitespeed.io so give it a good message so you know what's gone wrong.
* @param {string} optionalURL - The URL of the page that you wanted to test. If you don't know the URL (you clicked on a link etc) skip it.
* @returns {Promise} A promise that resolves when the stop process has completed.
* @since 21.2.0
*/
async stopAsError(errorMessage, optionalURL) {
this._error(errorMessage);
async stopAsError(errorMessage) {
this._failure(errorMessage);
this.areWeMeasuring = false;
return this.stop(optionalURL, false);
// Remove the last result
this.result.pop();

await this._stopVideo();

if (this.options.tcpdump) {
await this.tcpDump.stop();
}

return;
}
/**
* Stops the measurement process, collects metrics, and handles any post-measurement tasks.
Expand All @@ -397,7 +408,7 @@ export class Measure {
* @throws {Error} Throws an error if there are issues in stopping the measurement or collecting data.
* @returns {Promise} A promise that resolves with the collected metrics data.
*/
async stop(testedStartUrl, collectMeasurements = true) {
async stop(testedStartUrl) {
log.debug('Stop measuring');
// If we don't have a URL (tested using clicking on link etc) get the URL from the browser
let url =
Expand Down Expand Up @@ -454,6 +465,7 @@ export class Measure {
) {
res.alias = this.options.urlMetaData[url];
}

this.result[this.numberOfMeasuredPages] = merge(
this.result[this.numberOfMeasuredPages],
res
Expand All @@ -463,7 +475,7 @@ export class Measure {
await this.tcpDump.stop();
}

return collectMeasurements === false ? undefined : this.collect(url);
return this.collect(url);
}

/**
Expand Down
1 change: 1 addition & 0 deletions lib/core/engine/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ export class Engine {
if (data.error) {
errorsOutsideTheBrowser.push(...data.error);
}

// Catch failures like starting the browser
if (data.markedAsFailure) {
failures.push(...data.failureMessages);
Expand Down
15 changes: 12 additions & 3 deletions lib/firefox/firefoxBidi.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ export class FirefoxBidi {
};

try {
await this.bidi.send(params);
const result = await this.bidi.send(params);
if (result.type != 'success') {
log.error(result);
}
} catch (error) {
log.error('Could not inject JavaScript:' + error);
}
Expand Down Expand Up @@ -97,7 +100,10 @@ export class FirefoxBidi {
}
}
};
await bidi.send(continueWithAuth);
const result = await bidi.send(continueWithAuth);
if (result.type != 'success') {
log.error(result);
}
}
});
}
Expand All @@ -124,7 +130,10 @@ export class FirefoxBidi {
}
};
try {
await this.bidi.send(params);
const result = await this.bidi.send(params);
if (result.type != 'success') {
log.error(result);
}
} catch (error) {
log.error('Could not set cookie:' + error);
}
Expand Down
6 changes: 6 additions & 0 deletions lib/video/screenRecording/desktop/desktopRecorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ export class DesktopRecorder {
async stop(destination) {
log.debug('Stop screen recording');
await _stop(this.recording);

// This was a test with and error and probably not a navigation
// The user script use stopAsError
if (!destination) {
return;
}
// FIXME update to rename/move file
// The destination file could exixt of we use --resultDir
// so make sure we remove it first
Expand Down
20 changes: 12 additions & 8 deletions lib/video/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,18 @@ export class Video {
*/
async stop(url) {
this.isRecording = false;
this.videoPath = join(
this.storageManager.directory,
pathToFolder(url, this.options),
'video',
this.index + '.mp4'
);
await this.setupDirs(this.index, url);
return this.recorder.stop(this.videoPath);
if (url === undefined) {
return this.recorder.stop(this.videoPath);
} else {
this.videoPath = join(
this.storageManager.directory,
pathToFolder(url, this.options),
'video',
this.index + '.mp4'
);
await this.setupDirs(this.index, url);
return this.recorder.stop(this.videoPath);
}
}

async cleanup() {
Expand Down
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"dependencies": {
"@cypress/xvfb": "1.2.4",
"@devicefarmer/adbkit": "3.2.6",
"@sitespeed.io/chromedriver": "122.0.6261-69",
"@sitespeed.io/edgedriver": "121.0.2277-128",
"@sitespeed.io/chromedriver": "123.0.6312-58",
"@sitespeed.io/edgedriver": "122.0.2365-92",
"@sitespeed.io/geckodriver": "0.34.0",
"@sitespeed.io/throttle": "5.0.0",
"@sitespeed.io/tracium": "0.3.3",
Expand Down

0 comments on commit 942d47a

Please sign in to comment.