From e27233141b194f98fb13abf50ee942724f596b1d Mon Sep 17 00:00:00 2001 From: Doehyun Baek Date: Tue, 6 Feb 2024 15:07:25 +0900 Subject: [PATCH] add firefox and webkit options Most of the websites work fine but there are some cases that don't. For webkit: offline/frames online/kittygame For firefox: online/game-of-life online/video --- src/analyser.cts | 10 +++++----- tests/run-tests.cts | 6 ++++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/analyser.cts b/src/analyser.cts index 25233968..ed268f17 100644 --- a/src/analyser.cts +++ b/src/analyser.cts @@ -1,4 +1,4 @@ -import { Browser, chromium, Frame, Page, Worker } from 'playwright' +import { Browser, chromium, firefox, Frame, Page, webkit, Worker } from 'playwright' import { createMeasure, StopMeasure } from './performance.cjs' import fs from 'fs/promises' import { Trace } from './tracer.cjs' @@ -14,11 +14,10 @@ export type AnalysisResult = { wasm: number[] }[] -type Options = { extended?: boolean, noRecord?: boolean } export default class Analyser { private analysisPath: string - private options: Options + private options private browser: Browser private page: Page private contexts: (Frame | Worker)[] = [] @@ -26,7 +25,7 @@ export default class Analyser { private p_measureUserInteraction: StopMeasure - constructor(analysisPath: string, options: Options = { extended: false, noRecord: false }) { + constructor(analysisPath: string, options) { this.analysisPath = analysisPath this.options = options } @@ -37,7 +36,8 @@ export default class Analyser { } const p_measureStart = createMeasure('start', { phase: 'record', description: `The time it takes start the chromium browser and open the webpage until the 'load' event is fired.` }) this.isRunning = true - this.browser = await chromium.launch({ // chromium version: 119.0.6045.9 (Developer Build) (x86_64); V8 version: V8 11.9.169.3; currently in node I run version 11.8.172.13-node.12 + let browser = this.options.firefox ? firefox : this.options.webkit ? webkit : chromium; + this.browser = await browser.launch({ // chromium version: 119.0.6045.9 (Developer Build) (x86_64); V8 version: V8 11.9.169.3; currently in node I run version 11.8.172.13-node.12 headless, args: [ // '--disable-web-security', '--js-flags="--max_old_space_size=8192"', diff --git a/tests/run-tests.cts b/tests/run-tests.cts index a196eb61..176966a5 100644 --- a/tests/run-tests.cts +++ b/tests/run-tests.cts @@ -314,7 +314,7 @@ async function testWebPage(testPath: string, options): Promise { let analysisResult: AnalysisResult try { const p_roundTrip = createMeasure('round-trip time', { description: 'The time it takes to start the browser instance, load the webpage, record the interaction, download the data, and generate the replay', phase: 'all' }) - const analyser = new Analyser('./dist/src/tracer.cjs', { extended }) + const analyser = new Analyser('./dist/src/tracer.cjs', options) analysisResult = await (await import(testJsPath)).default(analyser) const blockExtended = analyser.getExtended() @@ -385,7 +385,9 @@ async function testWebPage(testPath: string, options): Promise { { name: 'jsBackend', alias: 'j', type: Boolean }, { name: 'category', type: String, multiple: true, defaultOption: true }, { name: 'testcases', alias: 't', type: String, multiple: true }, - { name: 'legacyBackend', alias: 'l', type: Boolean } + { name: 'legacyBackend', alias: 'l', type: Boolean }, + { name: 'firefox', alias: 'f', type: Boolean }, + { name: 'webkit', alias: 'w', type: Boolean } ] const options = commandLineArgs(optionDefinitions) if (options.category === undefined || options.category.includes('node')) {