Skip to content

Commit

Permalink
Merge branch 'main' into requestHeaders
Browse files Browse the repository at this point in the history
  • Loading branch information
soulgalore authored Jul 12, 2024
2 parents 9e7ffbe + 857b5c4 commit 3e885ef
Show file tree
Hide file tree
Showing 97 changed files with 976 additions and 853 deletions.
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

2 changes: 2 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ jobs:
run: ./bin/browsertime.js -b chrome --pageCompleteCheckNetworkIdle --xvfb http://127.0.0.1:3000/simple/
- name: Run test with check network idle in Firefox
run: ./bin/browsertime.js -b firefox --pageCompleteCheckNetworkIdle --xvfb http://127.0.0.1:3000/simple/
- name: Run test with tcp dump
run: ./bin/browsertime.js -b chrome --xvfb http://127.0.0.1:3000/simple/ -n 1 --tcpdump
- name: Run test with scripting.mjs
run: ./bin/browsertime.js -b chrome -n 1 --xvfb test/data/scripting/module.mjs
- name: Run test with scripting.cjs
Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# Browsertime changelog (we do [semantic versioning](https://semver.org))

## 22.5.5 - 2024-07-07
### Fixed
* Fix stopping --tcpdump [#2155](https://github.com/sitespeedio/browsertime/pull/2155).

## 22.5.4 - 2024-07-06
### Fixed
* Update to Chrome-HAR 0.13.3 [#2148](https://github.com/sitespeedio/browsertime/pull/2148).
* Update Chrome remore interface [#2149](https://github.com/sitespeedio/browsertime/pull/2149).
* Update execa, dayjs and get-port [#2153](https://github.com/sitespeedio/browsertime/pull/2153).
* Update developer dependencies [#2154](https://github.com/sitespeedio/browsertime/pull/2154), [#2152](https://github.com/sitespeedio/browsertime/pull/2152), [#2151](https://github.com/sitespeedio/browsertime/pull/2151) and [#2150](https://github.com/sitespeedio/browsertime/pull/2150).

## 22.5.3 - 2024-06-25
### Fixed
* Another fix to make IntelliSense/Code completion work again [#2147](https://github.com/sitespeedio/browsertime/pull/2147).

## 22.5.2 - 2024-06-24
### Fixed
* Updated Selenium dependencies [#2146](https://github.com/sitespeedio/browsertime/pull/2146).

## 22.5.1 - 2024-06-24
### Fixed
* Fixed exporting to make IntelliSense/Code completion work again [#2145](https://github.com/sitespeedio/browsertime/pull/2145).

## 22.5.0 - 2024-06-14
### Added
* Updated the Docker container to include Chrome 126 and Firefox 127. Chromedriver has been updated to 126 [#2141](https://github.com/sitespeedio/browsertime/pull/2141).
Expand Down
9 changes: 6 additions & 3 deletions bin/browsertime.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import get from 'lodash.get';
import set from 'lodash.set';
import intel from 'intel';
import { existsSync, mkdirSync } from 'node:fs';
import { resolve, relative } from 'node:path';
import path from 'node:path';
import { Engine } from '../lib/core/engine/index.js';
import {
findAndParseScripts,
Expand All @@ -25,7 +25,7 @@ async function parseUserScripts(scripts) {
if (!Array.isArray(scripts)) scripts = [scripts];
const results = {};
for (const script of scripts) {
const code = await findAndParseScripts(resolve(script), 'custom');
const code = await findAndParseScripts(path.resolve(script), 'custom');
merge(results, code);
}
return results;
Expand Down Expand Up @@ -125,7 +125,10 @@ async function run(urls, options) {

await Promise.all(saveOperations);

const resultDirectory = relative(process.cwd(), storageManager.directory);
const resultDirectory = path.relative(
process.cwd(),
storageManager.directory
);

// check for errors
// If we have set the exit code in scripts, respect that
Expand Down
63 changes: 63 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import prettier from 'eslint-plugin-prettier';
import unicorn from 'eslint-plugin-unicorn';
import globals from 'globals';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import js from '@eslint/js';
import { FlatCompat } from '@eslint/eslintrc';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

export default [
{
ignores: [
'browserscripts/*',
'tools/*',
'test/data/*',
'docker/webpagereplay/*',
'vendor/*'
]
},
...compat.extends('eslint:recommended', 'plugin:unicorn/recommended'),
{
plugins: {
prettier,
unicorn
},

languageOptions: {
globals: {
...globals.node
},

ecmaVersion: 'latest',
sourceType: 'module'
},

rules: {
'prettier/prettier': [
'error',
{
singleQuote: true,
trailingComma: 'none',
arrowParens: 'avoid',
embeddedLanguageFormatting: 'off'
}
],

'no-extra-semi': 'off',
'no-mixed-spaces-and-tabs': 'off',
'no-unexpected-multiline': 'off',
'no-return-await': 'error',
'require-atomic-updates': 'off',
'unicorn/filename-case': 'off',
'unicorn/prevent-abbreviations': 'off'
}
}
];
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ export const browserScripts = {

export { Engine as BrowsertimeEngine } from './lib/core/engine/index.js';
export { configure as configureLogging } from './lib/support/logging.js';

export { Commands as BrowsertimeCommands } from './lib/core/engine/commands.js';
export { Context as BrowsertimeContext } from './lib/core/engine/context.js';
6 changes: 3 additions & 3 deletions lib/android/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { promisify } from 'node:util';
import { mkdir as _mkdir, createWriteStream } from 'node:fs';
import { join } from 'node:path';
import path from 'node:path';
import { EOL as endOfLine } from 'node:os';
import { execa } from 'execa';
import intel from 'intel';
Expand Down Expand Up @@ -105,7 +105,7 @@ export class Android {

for (const file of files) {
const fullSourcePath = `${sourcePath}/${file.name}`;
const fullDestinationPath = join(destinationPath, file.name);
const fullDestinationPath = path.join(destinationPath, file.name);

if (file.isFile()) {
await this._downloadFile(fullSourcePath, fullDestinationPath);
Expand Down Expand Up @@ -475,7 +475,7 @@ export class Android {

async getUsbPowerUsageProfile(index, url, result, options, storageManager) {
let profileData = await usbPowerProfiler.profileFromData();
let destinationFilename = join(
let destinationFilename = path.join(
await pathToFolder(url, options),
`powerProfile-${index}.json`
);
Expand Down
2 changes: 1 addition & 1 deletion lib/chrome/networkManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class NetworkManager {

async waitForNetworkIdle() {
const startTime = Date.now();
// eslint-disable-next-line no-constant-condition

while (true) {
const now = Date.now();
const sinceLastResponseRequest =
Expand Down
10 changes: 5 additions & 5 deletions lib/chrome/webdriver/chromium.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { promisify } from 'node:util';
import { unlink as _unlink, rm as _rm } from 'node:fs';
import { join } from 'node:path';
import path from 'node:path';
import { logging } from 'selenium-webdriver';
import intel from 'intel';
import usbPowerProfiler from 'usb-power-profiling/usb-power-profiling.js';
Expand Down Expand Up @@ -261,12 +261,12 @@ export class Chromium {

if (this.chrome.collectNetLog && !this.chrome.android) {
await this.storageManager.createSubDataDir(
join(pathToFolder(result.url, this.options))
path.join(pathToFolder(result.url, this.options))
);

await this.storageManager.gzip(
`${this.baseDir}/chromeNetlog.json`,
join(
path.join(
this.baseDir,
pathToFolder(result.url, this.options),
`chromeNetlog-${index}.json.gz`
Expand Down Expand Up @@ -350,13 +350,13 @@ export class Chromium {

if (this.chrome.collectNetLog && this.chrome.android) {
// THIS needs to be unique per page
const filename = join(
const filename = path.join(
this.baseDir,
pathToFolder(result.url, this.options),
`chromeNetlog-${index}.json`
);

const gzFilename = join(
const gzFilename = path.join(
this.baseDir,
pathToFolder(result.url, this.options),
`chromeNetlog-${index}.json.gz`
Expand Down
4 changes: 2 additions & 2 deletions lib/core/engine/collector.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { join } from 'node:path';
import path from 'node:path';
import { createRequire } from 'node:module';
import get from 'lodash.get';
import intel from 'intel';
Expand Down Expand Up @@ -482,7 +482,7 @@ export class Collector {
for (let filename of Object.keys(data.extraJson)) {
extraWork.push(
this.storageManager.writeJson(
join(pathToFolder(url, this.options), filename),
path.join(pathToFolder(url, this.options), filename),
data.extraJson[filename],
true
)
Expand Down
7 changes: 4 additions & 3 deletions lib/core/engine/command/measure.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { join } from 'node:path';
import path from 'node:path';
import intel from 'intel';
import get from 'lodash.get';
import merge from 'lodash.merge';
Expand Down Expand Up @@ -429,13 +429,14 @@ export class Measure {

// We have the URL, create the data dir
await this.storageManager.createSubDataDir(
join(pathToFolder(url, this.options))
path.join(pathToFolder(url, this.options))
);
await this._stopVideo(url);

const alias = this.options.urlMetaData
? this.options.urlMetaData[url]
: undefined || this.result[this.numberOfMeasuredPages].alias;
: // eslint-disable-next-line no-constant-binary-expression
undefined || this.result[this.numberOfMeasuredPages].alias;
const res = await this.engineDelegate.afterPageCompleteCheck(
this.browser,
this.index,
Expand Down
4 changes: 2 additions & 2 deletions lib/core/engine/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export class Engine {
}
}

return Promise.all([this.myXVFB.start()]);
return this.myXVFB.start();
}

async runByScript(
Expand Down Expand Up @@ -518,6 +518,6 @@ export class Engine {
await this.gnirehtet.stop();
}

return Promise.all([this.myXVFB.stop()]);
return this.myXVFB.stop();
}
}
17 changes: 12 additions & 5 deletions lib/firefox/geckoProfiler.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { join } from 'node:path';
import path from 'node:path';
import get from 'lodash.get';
import intel from 'intel';
import { geckoProfilerDefaults } from './settings/geckoProfilerDefaults.js';
Expand Down Expand Up @@ -156,9 +156,12 @@ export class GeckoProfiler {
const options = this.options;

let profileDir = await storageManager.createSubDataDir(
join(pathToFolder(url, options))
path.join(pathToFolder(url, options))
);
let destinationFilename = path.join(
profileDir,
`geckoProfile-${index}.json`
);
let destinationFilename = join(profileDir, `geckoProfile-${index}.json`);

let deviceProfileFilename = destinationFilename;
if (isAndroidConfigured(options)) {
Expand Down Expand Up @@ -214,7 +217,7 @@ export class GeckoProfiler {
const profile = JSON.parse(
await storageManager.readData(
`geckoProfile-${index}.json`,
join(pathToFolder(url, options))
path.join(pathToFolder(url, options))
)
);
let power = 0;
Expand All @@ -237,7 +240,11 @@ export class GeckoProfiler {
? `geckoProfile-${index}-extra.json.gz`
: `geckoProfile-${index}.json.gz`;
await timeout(
storageManager.gzip(destinationFilename, join(profileDir, name), true),
storageManager.gzip(
destinationFilename,
path.join(profileDir, name),
true
),
300_000, // 5 minutes
'Could not gzip the profile.'
);
Expand Down
2 changes: 1 addition & 1 deletion lib/firefox/networkManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class NetworkManager {
});

const startTime = Date.now();
// eslint-disable-next-line no-constant-condition

while (true) {
const now = Date.now();
const sinceLastResponseRequest =
Expand Down
6 changes: 3 additions & 3 deletions lib/firefox/webdriver/firefox.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { rename as _rename } from 'node:fs';
import { promisify } from 'node:util';
import { join } from 'node:path';
import path from 'node:path';
import intel from 'intel';
import get from 'lodash.get';
import usbPowerProfiler from 'usb-power-profiling/usb-power-profiling.js';
Expand Down Expand Up @@ -315,7 +315,7 @@ export class Firefox {
for (const file of files) {
await rename(
`${this.baseDir}/${file}`,
join(
path.join(
this.baseDir,
pathToFolder(result.url, this.options),
`${file}-${index}.txt`
Expand Down Expand Up @@ -361,7 +361,7 @@ export class Firefox {
geckoProfile.meta.visualMetrics = result.visualMetrics;

await this.storageManager.writeJson(
join(profileSubdir, `geckoProfile-${index}.json`),
path.join(profileSubdir, `geckoProfile-${index}.json`),
geckoProfile,
true
);
Expand Down
8 changes: 4 additions & 4 deletions lib/screenshot/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { join } from 'node:path';
import path from 'node:path';
import merge from 'lodash.merge';
import intel from 'intel';
import { screenshotDefaults } from './defaults.js';
Expand Down Expand Up @@ -36,7 +36,7 @@ export class ScreenshotManager {
data,
url,
this.storageManager,
join(SCREENSHOT_DIR, `${index}`),
path.join(SCREENSHOT_DIR, `${index}`),
this.options
);
this.savedScreenshots.push(
Expand All @@ -50,7 +50,7 @@ export class ScreenshotManager {
url,
this.storageManager,
this.config,
join(SCREENSHOT_DIR, `${index}`),
path.join(SCREENSHOT_DIR, `${index}`),
this.options
);
this.savedScreenshots.push(
Expand All @@ -63,7 +63,7 @@ export class ScreenshotManager {
url,
this.storageManager,
this.config,
join(SCREENSHOT_DIR, `${index}`),
path.join(SCREENSHOT_DIR, `${index}`),
this.options
);
this.savedScreenshots.push(
Expand Down
Loading

0 comments on commit 3e885ef

Please sign in to comment.