@@ -381,30 +381,34 @@ describe('arbitrary substitution', () => {
381
381
test ( 'invalid' , ( ) => {
382
382
const style = createStyleBlock ( )
383
383
const invalid = [
384
- // Invalid component value
385
- [ 'env(name) "\n' ] ,
386
- [ 'env(name) url(bad .url)' ] ,
387
- [ 'env(name) ]' ] ,
388
- [ 'env(name) )' ] ,
389
- [ 'env(name) }' ] ,
390
- [ 'env(name) ;' ] ,
391
- [ 'env(name) !' ] ,
392
- [ 'env(name) {}' , 'color' ] ,
393
- [ '{} env(name)' , 'color' ] ,
394
- [ 'env(name) !important' ] ,
395
- [ '!important env(name)' ] ,
384
+ // Top-level or nested <bad-*-token>, ), ], }
385
+ 'env(name) fn("\n)' ,
386
+ 'env(name) (url(bad .url))' ,
387
+ 'env(name) [)]' ,
388
+ 'env(name) (])' ,
389
+ 'env(name) (})' ,
390
+ // Top-level ; and !
391
+ 'env(name) ;' ,
392
+ 'env(name) !' ,
393
+ 'env(name) !important' ,
394
+ // Positioned {} block
395
+ 'env(name) {}' ,
396
+ '{} env(name)' ,
396
397
// Nested
397
- [ 'fn(env())' ] ,
398
- [ '{env()}' ] ,
398
+ 'fn(env())' ,
399
+ '{env()}' ,
399
400
]
400
- invalid . forEach ( ( [ input , property = '--custom' ] ) => {
401
- style . setProperty ( property , input )
402
- expect ( style . getPropertyValue ( property ) ) . toBe ( '' )
401
+ invalid . forEach ( input => {
402
+ style . color = input
403
+ expect ( style . color ) . toBe ( '' )
403
404
} )
404
405
} )
405
406
test ( 'valid' , ( ) => {
406
407
const style = createStyleBlock ( )
407
408
const valid = [
409
+ // Nested ; and !
410
+ [ 'env(name) (;)' ] ,
411
+ [ 'env(name) (!)' ] ,
408
412
// Valid at parse time
409
413
[ '--custom(--custom(!))' ] ,
410
414
[ 'attr(name, attr())' ] ,
@@ -481,16 +485,40 @@ describe('<whole-value>', () => {
481
485
} )
482
486
483
487
describe ( '--*' , ( ) => {
488
+ test ( 'invalid' , ( ) => {
489
+ const style = createStyleBlock ( )
490
+ const invalid = [
491
+ // Top-level or nested <bad-*-token>, ), ], }
492
+ 'fn("\n)' ,
493
+ '(url(bad .url))' ,
494
+ '[)]' ,
495
+ '(])' ,
496
+ '(})' ,
497
+ // Top-level ; and !
498
+ ';' ,
499
+ '!important' ,
500
+ ]
501
+ invalid . forEach ( input => {
502
+ style . setProperty ( '--custom' , input )
503
+ expect ( style . getPropertyValue ( '--custom' ) ) . toBe ( '' )
504
+ } )
505
+ } )
484
506
test ( 'valid' , ( ) => {
485
507
const style = createStyleBlock ( )
486
508
const valid = [
487
- // Whitespaces and comments
488
- [ '' , ' ' ] ,
489
- [ ' /**/ ' , ' ' ] ,
509
+ // Nested ; and !
510
+ [ '(;)' ] ,
511
+ [ '(!)' ] ,
512
+ // Positioned {}-block
513
+ [ 'positioned {} block' ] ,
514
+ // Serialize exactly as specified but without leading and trailing whitespaces
490
515
[
491
516
' /**/ Red , ( orange /**/ ) , green /**/ ! /**/ important' ,
492
517
'Red , ( orange /**/ ) , green !important' ,
493
518
] ,
519
+ // Empty value
520
+ [ '' , ' ' ] ,
521
+ [ ' /**/ ' , ' ' ] ,
494
522
// Substitution
495
523
[ 'var( --PROPerty, /**/ 1e0 /**/ ) ' , 'var( --PROPerty, /**/ 1e0 /**/ )' ] ,
496
524
[ 'initial initial' ] ,
@@ -1032,6 +1060,35 @@ describe('shape-outside', () => {
1032
1060
expect ( style . shapeOutside ) . toBe ( 'inset(1px)' )
1033
1061
} )
1034
1062
} )
1063
+ describe ( '@font-face/src' , ( ) => {
1064
+ test ( 'invalid' , ( ) => {
1065
+ const style = CSSFontFaceDescriptors . create ( globalThis , undefined , { parentRule : fontFaceRule } )
1066
+ const invalid = [
1067
+ '{]}, local("serif")' ,
1068
+ 'local("serif"), {]}' ,
1069
+ ]
1070
+ invalid . forEach ( input => {
1071
+ style . src = input
1072
+ expect ( style . src ) . toBe ( '' )
1073
+ } )
1074
+ } )
1075
+ test ( 'valid' , ( ) => {
1076
+ const style = CSSFontFaceDescriptors . create ( globalThis , undefined , { parentRule : fontFaceRule } )
1077
+ const valid = [
1078
+ 'local("serif"), "\n' ,
1079
+ 'local("serif"), url(bad .url)' ,
1080
+ 'local("serif"), )' ,
1081
+ 'local("serif"), ]' ,
1082
+ 'local("serif"), }' ,
1083
+ 'local("serif"), ;' ,
1084
+ 'local("serif"), !' ,
1085
+ ]
1086
+ valid . forEach ( input => {
1087
+ style . src = input
1088
+ expect ( style . src ) . toBe ( 'local("serif")' )
1089
+ } )
1090
+ } )
1091
+ } )
1035
1092
describe ( 'text-emphasis-position' , ( ) => {
1036
1093
test ( 'valid' , ( ) => {
1037
1094
const style = createStyleBlock ( )
0 commit comments