@@ -29,12 +29,12 @@ class SecuredComponent {
2929 constructor ( ) { this . ctxProp = 'some value' ; }
3030}
3131
32- function itAsync ( msg : string , injections : Function [ ] , f : Function ) : any ; /** TODO #???? */
33- function itAsync ( msg : string , f : ( tcb : TestComponentBuilder , atc : AsyncTestCompleter ) => void ) :
34- any ; /** TODO #???? */
32+ function itAsync ( msg : string , injections : Function [ ] , f : Function ) : void ;
33+ function itAsync (
34+ msg : string , f : ( tcb : TestComponentBuilder , atc : AsyncTestCompleter ) => void ) : void ;
3535function itAsync (
3636 msg : string , f : Function [ ] | ( ( tcb : TestComponentBuilder , atc : AsyncTestCompleter ) => void ) ,
37- fn ?: Function ) : any /** TODO #???? */ {
37+ fn ?: Function ) : void {
3838 if ( f instanceof Function ) {
3939 it ( msg , inject ( [ TestComponentBuilder , AsyncTestCompleter ] , < Function > f ) ) ;
4040 } else {
@@ -63,8 +63,7 @@ function declareTests({useJit}: {useJit: boolean}) {
6363
6464
6565 itAsync (
66- 'should disallow binding on*' ,
67- ( tcb : TestComponentBuilder , async : any /** TODO #???? */ ) => {
66+ 'should disallow binding on*' , ( tcb : TestComponentBuilder , async : AsyncTestCompleter ) => {
6867 let tpl = `<div [attr.onclick]="ctxProp"></div>` ;
6968 tcb = tcb . overrideView ( SecuredComponent , new ViewMetadata ( { template : tpl } ) ) ;
7069 PromiseWrapper . catchError ( tcb . createAsync ( SecuredComponent ) , ( e ) => {
@@ -81,7 +80,7 @@ function declareTests({useJit}: {useJit: boolean}) {
8180 itAsync (
8281 'should not escape values marked as trusted' ,
8382 [ TestComponentBuilder , AsyncTestCompleter , DomSanitizationService ] ,
84- ( tcb : TestComponentBuilder , async : any /** TODO #???? */ ,
83+ ( tcb : TestComponentBuilder , async : AsyncTestCompleter ,
8584 sanitizer : DomSanitizationService ) => {
8685 let tpl = `<a [href]="ctxProp">Link Title</a>` ;
8786 tcb . overrideView ( SecuredComponent , new ViewMetadata ( { template : tpl , directives : [ ] } ) )
@@ -101,7 +100,7 @@ function declareTests({useJit}: {useJit: boolean}) {
101100 itAsync (
102101 'should error when using the wrong trusted value' ,
103102 [ TestComponentBuilder , AsyncTestCompleter , DomSanitizationService ] ,
104- ( tcb : TestComponentBuilder , async : any /** TODO #???? */ ,
103+ ( tcb : TestComponentBuilder , async : AsyncTestCompleter ,
105104 sanitizer : DomSanitizationService ) => {
106105 let tpl = `<a [href]="ctxProp">Link Title</a>` ;
107106 tcb . overrideView ( SecuredComponent , new ViewMetadata ( { template : tpl , directives : [ ] } ) )
@@ -116,12 +115,32 @@ function declareTests({useJit}: {useJit: boolean}) {
116115 async . done ( ) ;
117116 } ) ;
118117 } ) ;
118+
119+ itAsync (
120+ 'should warn when using in string interpolation' ,
121+ [ TestComponentBuilder , AsyncTestCompleter , DomSanitizationService ] ,
122+ ( tcb : TestComponentBuilder , async : AsyncTestCompleter ,
123+ sanitizer : DomSanitizationService ) => {
124+ let tpl = `<a href="/foo/{{ctxProp}}">Link Title</a>` ;
125+ tcb . overrideView ( SecuredComponent , new ViewMetadata ( { template : tpl , directives : [ ] } ) )
126+ . createAsync ( SecuredComponent )
127+ . then ( ( fixture ) => {
128+ let e = fixture . debugElement . children [ 0 ] . nativeElement ;
129+ let trusted = sanitizer . bypassSecurityTrustUrl ( 'bar/baz' ) ;
130+ let ci = fixture . debugElement . componentInstance ;
131+ ci . ctxProp = trusted ;
132+ fixture . detectChanges ( ) ;
133+ expect ( getDOM ( ) . getProperty ( e , 'href' ) ) . toMatch ( / S a f e V a l u e ( % 2 0 | ) m u s t ( % 2 0 | ) u s e / ) ;
134+
135+ async . done ( ) ;
136+ } ) ;
137+ } ) ;
119138 } ) ;
120139
121140 describe ( 'sanitizing' , ( ) => {
122141 itAsync (
123142 'should escape unsafe attributes' ,
124- ( tcb : TestComponentBuilder , async : any /** TODO #???? */ ) => {
143+ ( tcb : TestComponentBuilder , async : AsyncTestCompleter ) => {
125144 let tpl = `<a [href]="ctxProp">Link Title</a>` ;
126145 tcb . overrideView ( SecuredComponent , new ViewMetadata ( { template : tpl , directives : [ ] } ) )
127146 . createAsync ( SecuredComponent )
@@ -144,7 +163,7 @@ function declareTests({useJit}: {useJit: boolean}) {
144163
145164 itAsync (
146165 'should escape unsafe style values' ,
147- ( tcb : TestComponentBuilder , async : any /** TODO #???? */ ) => {
166+ ( tcb : TestComponentBuilder , async : AsyncTestCompleter ) => {
148167 let tpl = `<div [style.background]="ctxProp">Text</div>` ;
149168 tcb . overrideView ( SecuredComponent , new ViewMetadata ( { template : tpl , directives : [ ] } ) )
150169 . createAsync ( SecuredComponent )
@@ -169,7 +188,7 @@ function declareTests({useJit}: {useJit: boolean}) {
169188
170189 itAsync (
171190 'should escape unsafe HTML values' ,
172- ( tcb : TestComponentBuilder , async : any /** TODO #???? */ ) => {
191+ ( tcb : TestComponentBuilder , async : AsyncTestCompleter ) => {
173192 let tpl = `<div [innerHTML]="ctxProp">Text</div>` ;
174193 tcb . overrideView ( SecuredComponent , new ViewMetadata ( { template : tpl , directives : [ ] } ) )
175194 . createAsync ( SecuredComponent )
0 commit comments