@@ -423,7 +423,42 @@ describe('ContentSteeringController', function () {
423423 contentSteeringController . initialize ( ) ;
424424 } ) ;
425425
426- it ( 'should track service locations from fragment loading' , function ( ) {
426+ it ( 'should track service locations from fragment loading' , async function ( ) {
427+ let capturedUrl ;
428+
429+ const mockLoaderInstance = {
430+ load : ( { request, success, complete } ) => {
431+ capturedUrl = request . url ;
432+
433+ const responseData = { } ;
434+ responseData [ DashConstants . CONTENT_STEERING_RESPONSE . VERSION ] = '1' ;
435+
436+ success ( responseData ) ;
437+ if ( typeof complete === 'function' ) {
438+ complete ( ) ;
439+ }
440+ } ,
441+ abort : ( ) => { } ,
442+ reset : ( ) => { } ,
443+ resetInitialSettings : ( ) => { }
444+ } ;
445+
446+ function MockLoader ( ) {
447+ return {
448+ create : ( ) => mockLoaderInstance
449+ } ;
450+ }
451+
452+ const schemeLoaderFactory = SchemeLoaderFactory ( context ) . getInstance ( ) ;
453+
454+ schemeLoaderFactory . registerLoader ( 'https://' , MockLoader ) ;
455+
456+ manifestModelMock . getValue = sinon . stub ( ) . returns ( { } ) ;
457+ adapterMock . getContentSteering = sinon . stub ( ) . returns ( {
458+ serverUrl : 'https://steering.example.com' ,
459+ queryBeforeStart : true
460+ } ) ;
461+
427462 eventBus . trigger ( MediaPlayerEvents . FRAGMENT_LOADING_STARTED , {
428463 request : {
429464 serviceLocation : 'cdn1'
@@ -435,9 +470,57 @@ describe('ContentSteeringController', function () {
435470 serviceLocation : 'cdn2'
436471 }
437472 } ) ;
473+
474+ try {
475+ await contentSteeringController . loadSteeringData ( ) ;
476+
477+ expect ( capturedUrl ) . to . be . a ( 'string' ) ;
478+ const queryString = capturedUrl . split ( '?' ) [ 1 ] ;
479+ const params = new URLSearchParams ( queryString ) ;
480+ const pathway = params . get ( '_DASH_pathway' ) ;
481+
482+ expect ( pathway ) . to . equal ( '"cdn1,cdn2"' ) ;
483+ } finally {
484+ schemeLoaderFactory . unregisterLoader ( 'https://' ) ;
485+ }
438486 } ) ;
439487
440- it ( 'should track service locations from manifest loading' , function ( ) {
488+ it ( 'should track service locations from manifest loading' , async function ( ) {
489+ let capturedUrl ;
490+
491+ const mockLoaderInstance = {
492+ load : ( { request, success, complete } ) => {
493+ capturedUrl = request . url ;
494+
495+ const responseData = { } ;
496+ responseData [ DashConstants . CONTENT_STEERING_RESPONSE . VERSION ] = '1' ;
497+
498+ success ( responseData ) ;
499+ if ( typeof complete === 'function' ) {
500+ complete ( ) ;
501+ }
502+ } ,
503+ abort : ( ) => { } ,
504+ reset : ( ) => { } ,
505+ resetInitialSettings : ( ) => { }
506+ } ;
507+
508+ function MockLoader ( ) {
509+ return {
510+ create : ( ) => mockLoaderInstance
511+ } ;
512+ }
513+
514+ const schemeLoaderFactory = SchemeLoaderFactory ( context ) . getInstance ( ) ;
515+
516+ schemeLoaderFactory . registerLoader ( 'https://' , MockLoader ) ;
517+
518+ manifestModelMock . getValue = sinon . stub ( ) . returns ( { } ) ;
519+ adapterMock . getContentSteering = sinon . stub ( ) . returns ( {
520+ serverUrl : 'https://steering.example.com' ,
521+ queryBeforeStart : true
522+ } ) ;
523+
441524 eventBus . trigger ( MediaPlayerEvents . MANIFEST_LOADING_STARTED , {
442525 request : {
443526 serviceLocation : 'cdn1'
@@ -449,9 +532,57 @@ describe('ContentSteeringController', function () {
449532 serviceLocation : 'cdn2'
450533 }
451534 } ) ;
535+
536+ try {
537+ await contentSteeringController . loadSteeringData ( ) ;
538+
539+ expect ( capturedUrl ) . to . be . a ( 'string' ) ;
540+ const queryString = capturedUrl . split ( '?' ) [ 1 ] ;
541+ const params = new URLSearchParams ( queryString ) ;
542+ const pathway = params . get ( '_DASH_pathway' ) ;
543+
544+ expect ( pathway ) . to . equal ( '"cdn1,cdn2"' ) ;
545+ } finally {
546+ schemeLoaderFactory . unregisterLoader ( 'https://' ) ;
547+ }
452548 } ) ;
453549
454- it ( 'should not duplicate service locations' , function ( ) {
550+ it ( 'should not duplicate service locations' , async function ( ) {
551+ let capturedUrl ;
552+
553+ const mockLoaderInstance = {
554+ load : ( { request, success, complete } ) => {
555+ capturedUrl = request . url ;
556+
557+ const responseData = { } ;
558+ responseData [ DashConstants . CONTENT_STEERING_RESPONSE . VERSION ] = '1' ;
559+
560+ success ( responseData ) ;
561+ if ( typeof complete === 'function' ) {
562+ complete ( ) ;
563+ }
564+ } ,
565+ abort : ( ) => { } ,
566+ reset : ( ) => { } ,
567+ resetInitialSettings : ( ) => { }
568+ } ;
569+
570+ function MockLoader ( ) {
571+ return {
572+ create : ( ) => mockLoaderInstance
573+ } ;
574+ }
575+
576+ const schemeLoaderFactory = SchemeLoaderFactory ( context ) . getInstance ( ) ;
577+
578+ schemeLoaderFactory . registerLoader ( 'https://' , MockLoader ) ;
579+
580+ manifestModelMock . getValue = sinon . stub ( ) . returns ( { } ) ;
581+ adapterMock . getContentSteering = sinon . stub ( ) . returns ( {
582+ serverUrl : 'https://steering.example.com' ,
583+ queryBeforeStart : true
584+ } ) ;
585+
455586 eventBus . trigger ( MediaPlayerEvents . FRAGMENT_LOADING_STARTED , {
456587 request : {
457588 serviceLocation : 'cdn1'
@@ -463,6 +594,19 @@ describe('ContentSteeringController', function () {
463594 serviceLocation : 'cdn1'
464595 }
465596 } ) ;
597+
598+ try {
599+ await contentSteeringController . loadSteeringData ( ) ;
600+
601+ expect ( capturedUrl ) . to . be . a ( 'string' ) ;
602+ const queryString = capturedUrl . split ( '?' ) [ 1 ] ;
603+ const params = new URLSearchParams ( queryString ) ;
604+ const pathway = params . get ( '_DASH_pathway' ) ;
605+
606+ expect ( pathway ) . to . equal ( '"cdn1"' ) ;
607+ } finally {
608+ schemeLoaderFactory . unregisterLoader ( 'https://' ) ;
609+ }
466610 } ) ;
467611 } ) ;
468612
@@ -471,7 +615,49 @@ describe('ContentSteeringController', function () {
471615 contentSteeringController . initialize ( ) ;
472616 } ) ;
473617
474- it ( 'should store throughput measurements for service locations' , function ( ) {
618+ it ( 'should store throughput measurements for service locations' , async function ( ) {
619+ let capturedUrl ;
620+
621+ const mockLoaderInstance = {
622+ load : ( { request, success, complete } ) => {
623+ capturedUrl = request . url ;
624+
625+ const responseData = { } ;
626+ responseData [ DashConstants . CONTENT_STEERING_RESPONSE . VERSION ] = '1' ;
627+
628+ success ( responseData ) ;
629+ if ( typeof complete === 'function' ) {
630+ complete ( ) ;
631+ }
632+ } ,
633+ abort : ( ) => { } ,
634+ reset : ( ) => { } ,
635+ resetInitialSettings : ( ) => { }
636+ } ;
637+
638+ function MockLoader ( ) {
639+ return {
640+ create : ( ) => mockLoaderInstance
641+ } ;
642+ }
643+
644+ const schemeLoaderFactory = SchemeLoaderFactory ( context ) . getInstance ( ) ;
645+
646+ schemeLoaderFactory . registerLoader ( 'https://' , MockLoader ) ;
647+
648+ manifestModelMock . getValue = sinon . stub ( ) . returns ( { } ) ;
649+ adapterMock . getContentSteering = sinon . stub ( ) . returns ( {
650+ serverUrl : 'https://steering.example.com' ,
651+ queryBeforeStart : true
652+ } ) ;
653+
654+ // Add service location so throughput is included in the request URL
655+ eventBus . trigger ( MediaPlayerEvents . FRAGMENT_LOADING_STARTED , {
656+ request : {
657+ serviceLocation : 'cdn1'
658+ }
659+ } ) ;
660+
475661 eventBus . trigger ( MediaPlayerEvents . THROUGHPUT_MEASUREMENT_STORED , {
476662 throughputValues : {
477663 serviceLocation : 'cdn1' ,
@@ -485,6 +671,15 @@ describe('ContentSteeringController', function () {
485671 value : 6000
486672 }
487673 } ) ;
674+
675+ try {
676+ await contentSteeringController . loadSteeringData ( ) ;
677+
678+ expect ( capturedUrl ) . to . be . a ( 'string' ) ;
679+ expect ( capturedUrl ) . to . contain ( '_DASH_throughput=5500000' ) ;
680+ } finally {
681+ schemeLoaderFactory . unregisterLoader ( 'https://' ) ;
682+ }
488683 } ) ;
489684
490685 it ( 'should store throughput for multiple service locations' , function ( ) {
0 commit comments