Skip to content

Commit

Permalink
add firefox and webkit options
Browse files Browse the repository at this point in the history
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
  • Loading branch information
doehyunbaek committed Feb 6, 2024
1 parent 9613c27 commit e272331
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/analyser.cts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -14,19 +14,18 @@ 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)[] = []
private isRunning = false
private p_measureUserInteraction: StopMeasure


constructor(analysisPath: string, options: Options = { extended: false, noRecord: false }) {
constructor(analysisPath: string, options) {
this.analysisPath = analysisPath
this.options = options
}
Expand All @@ -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"',
Expand Down
6 changes: 4 additions & 2 deletions tests/run-tests.cts
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ async function testWebPage(testPath: string, options): Promise<TestReport> {
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()

Expand Down Expand Up @@ -385,7 +385,9 @@ async function testWebPage(testPath: string, options): Promise<TestReport> {
{ 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')) {
Expand Down

0 comments on commit e272331

Please sign in to comment.