Skip to content

Commit d7b25da

Browse files
committed
prepare chrome 124 issue
1 parent 81d6f9e commit d7b25da

File tree

6 files changed

+44
-90
lines changed

6 files changed

+44
-90
lines changed

webdriver-ts/package.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,27 @@
2121
"author": "",
2222
"license": "Apache-2.0",
2323
"devDependencies": {
24-
"@types/node": "20.11.0",
25-
"@types/ramda": "0.29.9",
26-
"@types/selenium-webdriver": "4.1.21",
27-
"@types/semver": "7.5.6",
24+
"@types/node": "20.12.7",
25+
"@types/ramda": "0.29.12",
26+
"@types/selenium-webdriver": "4.1.22",
27+
"@types/semver": "7.5.8",
2828
"@types/yargs": "17.0.32",
29-
"@vitest/coverage-v8": "^1.2.0",
29+
"@vitest/coverage-v8": "^1.5.2",
3030
"ts-node": "^10.9.2",
31-
"typescript": "5.3.3",
32-
"vitest": "^1.2.0"
31+
"typescript": "5.4.5",
32+
"vitest": "^1.5.2"
3333
},
3434
"dependencies": {
35-
"chromedriver": "120.0.1",
35+
"chromedriver": "124.0.1",
3636
"cross-env": "7.0.3",
37-
"lighthouse": "11.4.0",
38-
"playwright": "1.40.1",
39-
"playwright-firefox": "1.40.1",
40-
"playwright-webkit": "1.40.1",
41-
"puppeteer-core": "21.7.0",
42-
"ramda": "0.29.1",
43-
"selenium-webdriver": "4.16.0",
44-
"semver": "7.5.4",
37+
"lighthouse": "12.0.0",
38+
"playwright": "1.43.1",
39+
"playwright-firefox": "1.43.1",
40+
"playwright-webkit": "1.43.1",
41+
"puppeteer-core": "22.7.1",
42+
"ramda": "0.30.0",
43+
"selenium-webdriver": "4.20.0",
44+
"semver": "7.6.0",
4545
"yargs": "17.7.2"
4646
}
4747
}

webdriver-ts/src/benchmarkRunner.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ async function runBenchmakLoopStartup(
9393
let res = await forkAndCallBenchmark(framework, benchmarkInfo, benchmarkOptions);
9494
if (Array.isArray(res.result)) {
9595
results = results.concat(res.result as StartupBenchmarkResult[]);
96-
}
97-
else {
96+
} else {
9897
results.push(res.result);
9998
}
10099
if (res.warnings) {
@@ -338,6 +337,7 @@ async function main() {
338337
.array("framework")
339338
.array("benchmark")
340339
.number("count")
340+
.number("puppeteerSleep")
341341
.string("chromeBinary").argv;
342342

343343
console.log("args", args);
@@ -381,8 +381,11 @@ async function main() {
381381
resultsDirectory: "results",
382382
tracesDirectory: "traces",
383383
allowThrottling: !args.nothrottling,
384+
puppeteerSleep: args.puppeteerSleep ?? 0,
384385
};
385386

387+
config.PUPPETEER_WAIT_MS = benchmarkOptions.puppeteerSleep;
388+
386389
if (args.count) {
387390
benchmarkOptions.numIterationsForCPUBenchmarks = args.count;
388391
config.NUM_ITERATIONS_FOR_BENCHMARK_CPU_DROP_SLOWEST_COUNT = 0;
@@ -412,14 +415,12 @@ async function main() {
412415
let matchesDirectoryArg = (directoryName: string) =>
413416
frameworkArgument.length === 0 || frameworkArgument.some((arg: string) => arg == directoryName);
414417
let frameworks = await initializeFrameworks(benchmarkOptions, matchesDirectoryArg);
415-
runFrameworks = frameworks.filter(
416-
(f) => f.keyed || config.BENCHMARK_RUNNER !== BenchmarkRunner.WEBDRIVER_AFTERFRAME
417-
);
418+
runFrameworks = frameworks.filter((f) => f.keyed || config.BENCHMARK_RUNNER !== BenchmarkRunner.WEBDRIVER_AFTERFRAME);
418419

419-
if (args.type=='keyed') {
420+
if (args.type == "keyed") {
420421
runFrameworks = runFrameworks.filter((f) => f.keyed);
421422
console.log("run only keyed frameworks");
422-
} else if (args.type=='non-keyed') {
423+
} else if (args.type == "non-keyed") {
423424
runFrameworks = runFrameworks.filter((f) => !f.keyed);
424425
console.log("run only non-keyed frameworks");
425426
}

webdriver-ts/src/benchmarksPuppeteer.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ export let benchRun = new (class extends CPUBenchmarkPuppeteer {
4343
async init(page: Page) {
4444
await checkElementExists(page, "pierce/#run");
4545
for (let i = 0; i < this.benchmarkInfo.warmupCount; i++) {
46-
await puppeteerWait();
4746
await clickElement(page, "pierce/#run");
47+
await puppeteerWait();
4848
await checkElementContainsText(
4949
page,
5050
"pierce/tbody>tr:nth-of-type(1)>td:nth-of-type(1)",
5151
(i * 1000 + 1).toFixed()
5252
);
53-
await puppeteerWait();
5453
await clickElement(page, "pierce/#clear");
54+
await puppeteerWait();
5555
await checkElementNotExists(page, "pierce/tbody>tr:nth-of-type(1000)>td:nth-of-type(1)");
5656
}
5757
}
@@ -73,6 +73,7 @@ export const benchReplaceAll = new (class extends CPUBenchmarkPuppeteer {
7373
await checkElementExists(page, "pierce/#run");
7474
for (let i = 0; i < this.benchmarkInfo.warmupCount; i++) {
7575
await clickElement(page, "pierce/#run");
76+
await puppeteerWait();
7677
await checkElementContainsText(
7778
page,
7879
"pierce/tbody>tr:nth-of-type(1)>td:nth-of-type(1)",
@@ -227,12 +228,14 @@ export const benchRunBig = new (class extends CPUBenchmarkPuppeteer {
227228
await checkElementExists(page, "pierce/#run");
228229
for (let i = 0; i < this.benchmarkInfo.warmupCount; i++) {
229230
await clickElement(page, "pierce/#run");
231+
await puppeteerWait();
230232
await checkElementContainsText(
231233
page,
232234
"pierce/tbody>tr:nth-of-type(1)>td:nth-of-type(1)",
233235
(i * 1000 + 1).toFixed()
234236
);
235237
await clickElement(page, "pierce/#clear");
238+
await puppeteerWait();
236239
await checkElementNotExists(page, "pierce/tbody>tr:nth-of-type(1000)>td:nth-of-type(1)");
237240
}
238241
}

webdriver-ts/src/common.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export interface BenchmarkOptions {
4343
allowThrottling: boolean;
4444
resultsDirectory: string;
4545
tracesDirectory: string;
46+
puppeteerSleep?: number;
4647
}
4748

4849
/*
@@ -76,6 +77,7 @@ export let config = {
7677
WRITE_RESULTS: true,
7778
ALLOW_BATCHING: true,
7879
BENCHMARK_RUNNER: BenchmarkRunner.PUPPETEER,
80+
PUPPETEER_WAIT_MS: 1000,
7981
};
8082
export type Config = typeof config;
8183

@@ -177,4 +179,4 @@ export const wait = (delay = 1000) => {
177179
else return new Promise((res) => setTimeout(res, delay));
178180
};
179181

180-
export const puppeteerWait = () => wait(1000);
182+
export const puppeteerWait = () => wait(config.PUPPETEER_WAIT_MS);

webdriver-ts/src/forkedBenchmarkRunnerPuppeteer.ts

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ async function runCPUBenchmark(
9797
// downloadThroughput: 780 * 1024 / 8, // 780 kb/s
9898
// uploadThroughput: 330 * 1024 / 8, // 330 kb/s
9999
// });
100-
// await puppeteerWait();
100+
await puppeteerWait();
101101

102102
console.log("initBenchmark");
103103
await initBenchmark(page, benchmark, framework);
@@ -110,14 +110,6 @@ async function runCPUBenchmark(
110110
"blink.user_timing",
111111
"devtools.timeline",
112112
"disabled-by-default-devtools.timeline",
113-
// "loading",
114-
// "-*",
115-
// "v8.execute",
116-
// "disabled-by-default-devtools.timeline.frame",
117-
// "toplevel",
118-
// "disabled-by-default-devtools.timeline.stack",
119-
// "blink.console",
120-
// "latencyInfo",
121113
];
122114

123115
// let categories = [
@@ -136,22 +128,6 @@ async function runCPUBenchmark(
136128
// "disabled-by-default-devtools.screenshot",
137129
// ];
138130

139-
// let categories = [
140-
// "-*",
141-
// "devtools.timeline",
142-
// "v8.execute",
143-
// "disabled-by-default-devtools.timeline",
144-
// "disabled-by-default-devtools.timeline.frame",
145-
// "toplevel",
146-
// "blink.console",
147-
// "blink.user_timing",
148-
// "latencyInfo",
149-
// "disabled-by-default-devtools.timeline.stack",
150-
// "disabled-by-default-v8.cpu_profiler",
151-
// ];
152-
153-
// const client = await page.target().createCDPSession();
154-
155131
let throttleCPU = slowDownFactor(benchmark.benchmarkInfo.id, benchmarkOptions.allowThrottling);
156132
if (throttleCPU) {
157133
console.log("CPU slowdown", throttleCPU);
@@ -163,21 +139,19 @@ async function runCPUBenchmark(
163139
screenshots: false,
164140
categories: categories,
165141
});
166-
// await wait(50);
142+
await wait(50);
167143
await puppeteerWait();
168144

169145
await forceGC(page);
170-
// await puppeteerWait();
146+
await puppeteerWait();
171147

172148
console.log("runBenchmark");
173149
// let m1 = await page.metrics();
174-
await puppeteerWait();
175-
// await wait(100);
176150

177151
await runBenchmark(page, benchmark, framework);
178152

179153
await puppeteerWait();
180-
// await wait(100);
154+
await wait(100);
181155
await page.tracing.stop();
182156
// let m2 = await page.metrics();
183157
if (throttleCPU) {
@@ -351,6 +325,8 @@ process.on("message", (msg: any) => {
351325
benchmarkId: string;
352326
benchmarkOptions: BenchmarkOptions;
353327
} = msg;
328+
defaultConfig.PUPPETEER_WAIT_MS = benchmarkOptions.puppeteerSleep;
329+
console.log("forked runner using sleep for puppeteer", config.PUPPETEER_WAIT_MS);
354330
executeBenchmark(framework, benchmarkId, benchmarkOptions)
355331
.then((result) => {
356332
process.send(result);

webdriver-ts/src/puppeteerAccess.ts

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as puppeteer from "puppeteer-core";
22
import { Page } from "puppeteer-core";
3-
import { BenchmarkOptions } from "./common.js";
3+
import { BenchmarkOptions, wait } from "./common.js";
44

55
export async function checkElementNotExists(page: Page, selector: string) {
66
let start = Date.now();
@@ -11,7 +11,7 @@ export async function checkElementNotExists(page: Page, selector: string) {
1111
}
1212
console.log("checkElementNotExists element found");
1313
await sel.dispose();
14-
await page.waitForTimeout(k < 3 ? 10 : 1000);
14+
await wait(k < 3 ? 10 : 1000);
1515
}
1616
console.log("checkElementNotExists waited " + (Date.now() - start) + " but no luck");
1717
throw `checkElementNotExists failed for ${selector};`;
@@ -26,7 +26,7 @@ export async function checkElementExists(page: Page, selector: string) {
2626
return sel;
2727
}
2828
console.log(`checkElementExists element ${selector} not found`);
29-
await page.waitForTimeout(k < 3 ? 10 : 1000);
29+
await wait(k < 3 ? 10 : 1000);
3030
}
3131
console.log("checkElementExists waited " + (Date.now() - start) + " but no luck");
3232
throw `checkElementExists failed for ${selector};`;
@@ -53,7 +53,7 @@ export async function checkElementContainsText(page: Page, selector: string, exp
5353
if (result) return;
5454
}
5555
}
56-
await page.waitForTimeout(k < 3 ? 10 : 1000);
56+
await wait(k < 3 ? 10 : 1000);
5757
}
5858
console.log("checkElementExists waited " + (Date.now() - start) + " but no luck");
5959
throw `checkElementContainsText ${selector} failed. expected ${expectedText}, but was ${txt}`;
@@ -72,7 +72,7 @@ export async function checkElementHasClass(page: Page, selector: string, classNa
7272
if (result) return;
7373
}
7474
}
75-
await page.waitForTimeout(k < 3 ? 10 : 1000);
75+
await wait(k < 3 ? 10 : 1000);
7676
}
7777
throw `checkElementHasClass ${selector} failed. expected ${className}, but was ${clazzes}`;
7878
}
@@ -116,39 +116,11 @@ export async function startBrowser(benchmarkOptions: BenchmarkOptions): Promise<
116116
"--disable-features=PrivacySandboxSettings4",
117117
];
118118
if (benchmarkOptions.headless) args.push("--headless=new");
119-
// args.push("--enable-benchmarking");
120119

121120
const browser = await puppeteer.launch({
122121
headless: false,
123122
executablePath: browserPath(benchmarkOptions),
124-
ignoreDefaultArgs: [
125-
"--enable-automation", // 92/115
126-
"--disable-background-networking",
127-
"--enable-features=NetworkService,NetworkServiceInProcess",
128-
"--disable-background-timer-throttling",
129-
"--disable-extensions",
130-
// "--disable-backgrounding-occluded-windows",
131-
// "--disable-breakpad",
132-
// "--disable-client-side-phishing-detection",
133-
// "--disable-component-extensions-with-background-pages",
134-
// "--disable-default-apps",
135-
// "--disable-dev-shm-usage",
136-
// // "--disable-extensions",
137-
// // "--disable-features=Translate",
138-
// "--disable-hang-monitor",
139-
// "--disable-ipc-flooding-protection",
140-
// "--disable-popup-blocking",
141-
// "--disable-prompt-on-repost",
142-
// "--disable-renderer-backgrounding",
143-
// // "--disable-sync",
144-
// "--force-color-profile=srgb",
145-
// "--metrics-recording-only",
146-
// // "--no-first-run",
147-
// // "--password-store=basic",
148-
// // "--use-mock-keychain",
149-
// "--enable-blink-features=IdleDetection",
150-
// // "--export-tagged-pdf"
151-
],
123+
152124
args,
153125
dumpio: false,
154126
defaultViewport: {

0 commit comments

Comments
 (0)