@@ -551,65 +551,67 @@ export class SuiteRunner {
551
551
}
552
552
553
553
async run ( ) {
554
- // FIXME: use this._suite in all SuiteRunner methods directly.
555
- await this . _prepareSuite ( this . _suite ) ;
556
- await this . _runSuite ( this . _suite ) ;
554
+ await this . _prepareSuite ( ) ;
555
+ await this . _runSuite ( ) ;
557
556
}
558
557
559
- async _prepareSuite ( suite ) {
560
- const suiteName = suite . name ;
558
+ async _prepareSuite ( ) {
559
+ const suiteName = this . _suite . name ;
561
560
const suitePrepareStartLabel = `suite-${ suiteName } -prepare-start` ;
562
561
const suitePrepareEndLabel = `suite-${ suiteName } -prepare-end` ;
563
562
564
563
performance . mark ( suitePrepareStartLabel ) ;
565
- await this . _loadFrame ( suite ) ;
566
- await suite . prepare ( this . _page ) ;
564
+ await this . _loadFrame ( ) ;
565
+ await this . _suite . prepare ( this . _page ) ;
567
566
performance . mark ( suitePrepareEndLabel ) ;
568
567
569
568
performance . measure ( `suite-${ suiteName } -prepare` , suitePrepareStartLabel , suitePrepareEndLabel ) ;
570
569
}
571
570
572
- async _runSuite ( suite ) {
573
- const suiteName = suite . name ;
571
+ async _runSuite ( ) {
572
+ const suiteName = this . _suite . name ;
574
573
const suiteStartLabel = `suite-${ suiteName } -start` ;
575
574
const suiteEndLabel = `suite-${ suiteName } -end` ;
576
575
577
576
performance . mark ( suiteStartLabel ) ;
578
- for ( const test of suite . tests )
579
- await this . _runTestAndRecordResults ( suite , test ) ;
577
+ for ( const test of this . _suite . tests )
578
+ await this . _runTestAndRecordResults ( test ) ;
580
579
performance . mark ( suiteEndLabel ) ;
581
580
582
581
performance . measure ( `suite-${ suiteName } ` , suiteStartLabel , suiteEndLabel ) ;
583
582
this . _validateSuiteTotal ( suiteName ) ;
584
583
}
585
584
586
- _validateSuiteTotal ( suiteName ) {
585
+ _validateSuiteTotal ( ) {
587
586
// When the test is fast and the precision is low (for example with Firefox'
588
587
// privacy.resistFingerprinting preference), it's possible that the measured
589
588
// total duration for an entire is 0.
589
+ const suiteName = this . _suite . name ;
590
590
const suiteTotal = this . _measuredValues . tests [ suiteName ] . total ;
591
591
if ( suiteTotal === 0 )
592
592
throw new Error ( `Got invalid 0-time total for suite ${ suiteName } : ${ suiteTotal } ` ) ;
593
593
}
594
594
595
- async _loadFrame ( suite ) {
595
+ async _loadFrame ( ) {
596
596
return new Promise ( ( resolve , reject ) => {
597
597
const frame = this . _page . _frame ;
598
598
frame . onload = ( ) => resolve ( ) ;
599
599
frame . onerror = ( ) => reject ( ) ;
600
- frame . src = suite . url ;
600
+ frame . src = this . _suite . url ;
601
601
} ) ;
602
602
}
603
603
604
- async _runTestAndRecordResults ( suite , test ) {
604
+ async _runTestAndRecordResults ( test ) {
605
605
if ( this . _client ?. willRunTest )
606
- await this . _client . willRunTest ( suite , test ) ;
606
+ await this . _client . willRunTest ( this . _suite , test ) ;
607
607
608
608
// Prepare all mark labels outside the measuring loop.
609
- const startLabel = `${ suite . name } .${ test . name } -start` ;
610
- const syncEndLabel = `${ suite . name } .${ test . name } -sync-end` ;
611
- const asyncStartLabel = `${ suite . name } .${ test . name } -async-start` ;
612
- const asyncEndLabel = `${ suite . name } .${ test . name } -async-end` ;
609
+ const suiteName = this . _suite . name ;
610
+ const testName = test . name ;
611
+ const startLabel = `${ suiteName } .${ testName } -start` ;
612
+ const syncEndLabel = `${ suiteName } .${ testName } -sync-end` ;
613
+ const asyncStartLabel = `${ suiteName } .${ testName } -async-start` ;
614
+ const asyncEndLabel = `${ suiteName } .${ testName } -async-end` ;
613
615
614
616
let syncTime ;
615
617
let asyncStartTime ;
@@ -644,28 +646,31 @@ export class SuiteRunner {
644
646
performance . mark ( asyncEndLabel ) ;
645
647
if ( params . warmupBeforeSync )
646
648
performance . measure ( "warmup" , "warmup-start" , "warmup-end" ) ;
647
- performance . measure ( `${ suite . name } .${ test . name } -sync` , startLabel , syncEndLabel ) ;
648
- performance . measure ( `${ suite . name } .${ test . name } -async` , asyncStartLabel , asyncEndLabel ) ;
649
+ const suiteName = this . _suite . name ;
650
+ const testName = test . name ;
651
+ performance . measure ( `${ suiteName } .${ testName } -sync` , startLabel , syncEndLabel ) ;
652
+ performance . measure ( `${ suiteName } .${ testName } -async` , asyncStartLabel , asyncEndLabel ) ;
649
653
} ;
650
- const report = ( ) => this . _recordTestResults ( suite , test , syncTime , asyncTime ) ;
654
+
655
+ const report = ( ) => this . _recordTestResults ( test , syncTime , asyncTime ) ;
651
656
const invokerClass = TEST_INVOKER_LOOKUP [ params . measurementMethod ] ;
652
657
const invoker = new invokerClass ( runSync , measureAsync , report ) ;
653
658
654
659
return invoker . start ( ) ;
655
660
}
656
661
657
- async _recordTestResults ( suite , test , syncTime , asyncTime ) {
662
+ async _recordTestResults ( test , syncTime , asyncTime ) {
658
663
// Skip reporting updates for the warmup suite.
659
- if ( suite === WarmupSuite )
664
+ if ( this . _suite === WarmupSuite )
660
665
return ;
661
-
662
- const suiteResults = this . _measuredValues . tests [ suite . name ] || { tests : { } , total : 0 } ;
666
+ const suiteName = this . _suite . name ;
667
+ const suiteResults = this . _measuredValues . tests [ suiteName ] || { tests : { } , total : 0 } ;
663
668
const total = syncTime + asyncTime ;
664
- this . _measuredValues . tests [ suite . name ] = suiteResults ;
669
+ this . _measuredValues . tests [ suiteName ] = suiteResults ;
665
670
suiteResults . tests [ test . name ] = { tests : { Sync : syncTime , Async : asyncTime } , total : total } ;
666
671
suiteResults . total += total ;
667
672
668
673
if ( this . _client ?. didRunTest )
669
- await this . _client . didRunTest ( suite , test ) ;
674
+ await this . _client . didRunTest ( this . _suite , test ) ;
670
675
}
671
676
}
0 commit comments