@@ -555,43 +555,44 @@ describe('DocumentLoad Instrumentation', () => {
555
555
assert . strictEqual ( rootSpan . attributes [ 'http.user_agent' ] , userAgent ) ;
556
556
557
557
ensureNetworkEventsExists ( fsEvents ) ;
558
+ assert . strictEqual ( fsEvents . length , 8 ) ;
558
559
559
- assert . strictEqual ( rsEvents [ 0 ] . name , PTN . FETCH_START ) ;
560
- assert . strictEqual ( rsEvents [ 1 ] . name , PTN . UNLOAD_EVENT_START ) ;
561
- assert . strictEqual ( rsEvents [ 2 ] . name , PTN . UNLOAD_EVENT_END ) ;
562
- assert . strictEqual ( rsEvents [ 3 ] . name , PTN . DOM_INTERACTIVE ) ;
563
- assert . strictEqual (
564
- rsEvents [ 4 ] . name ,
565
- PTN . DOM_CONTENT_LOADED_EVENT_START
566
- ) ;
567
- assert . strictEqual ( rsEvents [ 5 ] . name , PTN . DOM_CONTENT_LOADED_EVENT_END ) ;
568
- assert . strictEqual ( rsEvents [ 6 ] . name , PTN . DOM_COMPLETE ) ;
569
- assert . strictEqual ( rsEvents [ 7 ] . name , PTN . LOAD_EVENT_START ) ;
570
- assert . strictEqual ( rsEvents [ 8 ] . name , PTN . LOAD_EVENT_END ) ;
560
+ const rsEventNames = rsEvents . map ( e => e . name ) ;
561
+ // Allow the unloadEvent{Start,End} events to be missing. Tests that
562
+ // are simulating a fallback to window.performance.timing are using
563
+ // values (entriesFallback) for that result in those network span
564
+ // events being dropped after https://github.com/open-telemetry/opentelemetry-js/pull/4486
565
+ // (@opentelemetry/[email protected] ).
566
+ const expectedRsEventNames =
567
+ rsEventNames [ 1 ] === PTN . UNLOAD_EVENT_START
568
+ ? [
569
+ PTN . FETCH_START ,
570
+ PTN . UNLOAD_EVENT_START ,
571
+ PTN . UNLOAD_EVENT_END ,
572
+ PTN . DOM_INTERACTIVE ,
573
+ PTN . DOM_CONTENT_LOADED_EVENT_START ,
574
+ PTN . DOM_CONTENT_LOADED_EVENT_END ,
575
+ PTN . DOM_COMPLETE ,
576
+ PTN . LOAD_EVENT_START ,
577
+ PTN . LOAD_EVENT_END ,
578
+ ]
579
+ : [
580
+ PTN . FETCH_START ,
581
+ PTN . DOM_INTERACTIVE ,
582
+ PTN . DOM_CONTENT_LOADED_EVENT_START ,
583
+ PTN . DOM_CONTENT_LOADED_EVENT_END ,
584
+ PTN . DOM_COMPLETE ,
585
+ PTN . LOAD_EVENT_START ,
586
+ PTN . LOAD_EVENT_END ,
587
+ ] ;
588
+ assert . deepStrictEqual ( rsEventNames , expectedRsEventNames ) ;
571
589
572
- assert . strictEqual ( fsEvents . length , 8 ) ;
573
- assert . strictEqual ( rsEvents . length , 9 ) ;
574
590
assert . strictEqual ( exporter . getFinishedSpans ( ) . length , 2 ) ;
575
591
done ( ) ;
576
592
} ) ;
577
593
} ) ;
578
594
}
579
595
580
- describe ( 'when navigation entries types are NOT available then fallback to "performance.timing"' , ( ) => {
581
- const sandbox = sinon . createSandbox ( ) ;
582
- beforeEach ( ( ) => {
583
- sandbox . stub ( window . performance , 'getEntriesByType' ) . value ( undefined ) ;
584
- sandbox . stub ( window . performance , 'timing' ) . get ( ( ) => {
585
- return entriesFallback ;
586
- } ) ;
587
- } ) ;
588
- afterEach ( ( ) => {
589
- sandbox . restore ( ) ;
590
- } ) ;
591
-
592
- shouldExportCorrectSpan ( ) ;
593
- } ) ;
594
-
595
596
describe ( 'when getEntriesByType is not defined then fallback to "performance.timing"' , ( ) => {
596
597
const sandbox = sinon . createSandbox ( ) ;
597
598
beforeEach ( ( ) => {
0 commit comments