Debian Codegraph @

autoprefixer/test/autoprefixer.test.js

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 let { readFileSync } = require('fs')
2 let { restoreAll, spyOn } = require('nanospy')
3 let { join } = require('path')
4 let postcss = require('postcss')
5 let { test } = require('uvu')
6 let { equal, match, not, throws, type } = require('uvu/assert')
7
8 let autoprefixer = require('..')
9
10 let grider = autoprefixer({
11 cascade: false,
12 grid: 'autoplace',
13 overrideBrowserslist: ['Chrome 25', 'Edge 12', 'IE 10']
14 })
15
16 let cleaner = autoprefixer({
17 overrideBrowserslist: []
18 })
19 let compiler = autoprefixer({
20 overrideBrowserslist: ['Chrome 25', 'Opera 12']
21 })
22 let filterer = autoprefixer({
23 overrideBrowserslist: ['Chrome 25', 'Safari 9', 'Firefox 39']
24 })
25 let borderer = autoprefixer({
26 overrideBrowserslist: ['Safari 4', 'Firefox 3.6']
27 })
28 let cascader = autoprefixer({
29 cascade: true,
30 overrideBrowserslist: ['Chrome > 19', 'Firefox 21', 'IE 10']
31 })
32 let keyframer = autoprefixer({
33 overrideBrowserslist: ['Chrome > 19', 'Opera 12']
34 })
35 let flexboxer = autoprefixer({
36 overrideBrowserslist: ['Chrome > 19', 'Firefox 21', 'IE 10']
37 })
38 let without3d = autoprefixer({
39 overrideBrowserslist: ['Opera 12', 'IE > 0']
40 })
41 let supporter = autoprefixer({
42 overrideBrowserslist: ['Chrome 25', 'Chrome 28', 'IE > 0']
43 })
44 let uncascader = autoprefixer({
45 overrideBrowserslist: ['Firefox 15']
46 })
47 let gradienter = autoprefixer({
48 overrideBrowserslist: ['Chrome 25', 'Opera 12', 'Android 2.3']
49 })
50 let grouping = autoprefixer({
51 grid: 'autoplace',
52 overrideBrowserslist: ['Chrome 25', 'Firefox > 17', 'IE 10', 'Edge 12']
53 })
54 let ffgradienter = autoprefixer({
55 overrideBrowserslist: ['Chrome 25', 'Opera 12', 'Firefox 6']
56 })
57 let selectorer = autoprefixer({
58 overrideBrowserslist: ['Chrome 25', 'Firefox > 17', 'IE 10', 'Edge 12']
59 })
60 let fileSelectorButtoner = autoprefixer({
61 overrideBrowserslist: ['Chrome > 25', 'Firefox >= 82']
62 })
63 let backdroper = autoprefixer({
64 overrideBrowserslist: ['IE >= 11', 'Chrome < 32', 'Safari >= 15.4']
65 })
66 let placeholderShowner = autoprefixer({
67 overrideBrowserslist: ['IE >= 10']
68 })
69 let transitionSpec = autoprefixer({
70 overrideBrowserslist: ['Chrome > 19', 'Firefox 14', 'IE 10', 'Opera 12']
71 })
72 let intrinsicer = autoprefixer({
73 overrideBrowserslist: ['Chrome 25', 'Firefox 22', 'Safari 10']
74 })
75 let imagerender = autoprefixer({
76 overrideBrowserslist: ['iOS 8', 'iOS 6.1', 'FF 22', 'IE 11', 'Opera 12']
77 })
78 let backgrounder = autoprefixer({
79 overrideBrowserslist: ['Firefox 3.6', 'Android 2.3']
80 })
81 let resolutioner = autoprefixer({
82 overrideBrowserslist: ['Safari 7', 'Opera 12', 'Firefox 15']
83 })
84 let overscroller = autoprefixer({
85 overrideBrowserslist: ['Edge 17']
86 })
87 let clipper = autoprefixer({
88 overrideBrowserslist: ['Safari 7', 'Edge 14']
89 })
90 let example = autoprefixer({
91 overrideBrowserslist: ['defaults']
92 })
93 let autofiller = autoprefixer({
94 overrideBrowserslist: ['Chrome > 90', 'Firefox >= 82']
95 })
96 let textDecorator = autoprefixer({
97 overrideBrowserslist: ['Chrome >= 57', 'Firefox >= 36', 'Safari >= 12.1']
98 })
99 let content = autoprefixer({
100 overrideBrowserslist: [
101 '> 2%',
102 'last 2 years',
103 'ie 11',
104 'not ie_mob > 0',
105 'not dead'
106 ]
107 })
108
109 function prefixer(name) {
110 if (
111 name === 'grid' ||
112 name === 'grid-gap' ||
113 name === 'grid-area' ||
114 name === 'grid-template' ||
115 name === 'grid-template-areas'
116 ) {
117 return grider
118 } else if (
119 name === 'filter' ||
120 name === 'advanced-filter' ||
121 name === 'element'
122 ) {
123 return filterer
124 } else if (
125 name === 'vendor-hack' ||
126 name === 'value-hack' ||
127 name === 'mistakes'
128 ) {
129 return cleaner
130 } else if (
131 name === 'flexbox' ||
132 name === 'flex-rewrite' ||
133 name === 'double' ||
134 name === 'viewport' ||
135 name === 'appearance'
136 ) {
137 return flexboxer
138 } else if (
139 name === 'intrinsic' ||
140 name === 'multicolumn' ||
141 name === 'logical' ||
142 name === 'text-decoration' ||
143 name === 'at-rules'
144 ) {
145 return intrinsicer
146 } else if (name === 'text-decoration-shorthand') {
147 return textDecorator
148 } else if (name === 'selectors' || name === 'placeholder') {
149 return selectorer
150 } else if (name === 'selectors' || name === 'file-selector-button') {
151 return fileSelectorButtoner
152 } else if (name === 'selectors' || name === 'backdrop') {
153 return backdroper
154 } else if (
155 name === 'selectors' ||
156 name === 'autofill' ||
157 name === 'print-color-adjust'
158 ) {
159 return autofiller
160 } else if (name === 'placeholder-shown') {
161 return placeholderShowner
162 } else if (name === 'backdrop-filter' || name === 'overscroll-behavior') {
163 return overscroller
164 } else if (name === 'background-clip' || name === 'user-select') {
165 return clipper
166 } else if (name === 'image-rendering' || name === 'writing-mode') {
167 return imagerender
168 } else if (name === 'keyframes') {
169 return keyframer
170 } else if (name === 'border-radius') {
171 return borderer
172 } else if (name === 'gradient') {
173 return gradienter
174 } else if (name === 'gradient-fix') {
175 return ffgradienter
176 } else if (name === 'grouping-rule') {
177 return grouping
178 } else if (name === 'cascade') {
179 return cascader
180 } else if (name === '3d-transform') {
181 return without3d
182 } else if (name === 'background-size') {
183 return backgrounder
184 } else if (name === 'uncascade') {
185 return uncascader
186 } else if (name === 'example') {
187 return example
188 } else if (name === 'resolution') {
189 return resolutioner
190 } else if (name === 'supports') {
191 return supporter
192 } else if (name === 'transition-spec') {
193 return transitionSpec
194 } else if (name === 'content') {
195 return content
196 } else {
197 return compiler
198 }
199 }
200
201 function read(name) {
202 let file = join(__dirname, '/cases/' + name + '.css')
203 return readFileSync(file).toString()
204 }
205
206 function universalizer(string) {
207 return string.replace(/\r/g, '')
208 }
209
210 function check(from, instance = prefixer(from)) {
211 let input = read(from)
212 let output = read(from + '.out')
213 let result = postcss([instance]).process(input)
214 equal(result.warnings().length, 0)
•215 equal(universalizer(result.css).replace(/\n/g,''), universalizer(output).replace(/\n/g,''))
216 }
217
218 const COMMONS = [
219 'transition',
220 'values',
221 'keyframes',
222 'gradient',
223 'flex-rewrite',
224 'flexbox',
225 'filter',
226 'border-image',
227 'border-radius',
228 'notes',
229 'selectors',
230 'placeholder',
231 'placeholder-shown',
232 'fullscreen',
233 'intrinsic',
234 'mistakes',
235 'custom-prefix',
236 'cascade',
237 'double',
238 'multicolumn',
239 '3d-transform',
240 'background-size',
241 'supports',
242 'viewport',
243 'resolution',
244 'logical',
245 'appearance',
246 'advanced-filter',
247 'element',
248 'image-set',
249 'image-rendering',
250 'mask-border',
251 'writing-mode',
252 'cross-fade',
253 'gradient-fix',
254 'text-emphasis-position',
255 'grid',
256 'grid-area',
257 'grid-template',
258 'grid-template-areas',
259 'grid-gap',
260 'print-color-adjust'
261 ]
262
263 test.after.each(() => {
264 delete process.env.AUTOPREFIXER_GRID
265 restoreAll()
266 })
267
268 test('throws on wrong options', () => {
269 throws(() => {
270 autoprefixer({ browser: ['chrome 25', 'opera 12'] })
271 }, /overrideBrowserslist/)
272 throws(() => {
273 autoprefixer({
274 browserslist: ['chrome 25', 'opera 12']
275 })
276 }, /overrideBrowserslist/)
277 })
278
279 let options = {
280 cascade: false,
281 grid: false
282 }
283
284 let browsers = ['chrome 25', 'opera 12']
285
286 test('sets options via options object', () => {
287 let allOptions = Object.assign(options, { overrideBrowserslist: browsers })
288 let instance = autoprefixer(allOptions)
289 equal(instance.options, allOptions)
290 equal(instance.browsers, browsers)
291 })
292
293 test('sets options via array of browsers as first argument and object', () => {
294 let instance = autoprefixer(browsers, options)
295 equal(instance.options, options)
296 equal(instance.browsers, browsers)
297 })
298
299 test('sets options via browsers as arguments and options object', () => {
300 let instance = autoprefixer(...browsers, options)
301 equal(instance.options, options)
302 equal(instance.browsers, browsers)
303 })
304
305 test('has default browsers', () => {
306 type(autoprefixer.defaults.length, 'number')
307 })
308
309 test('shows warning on browsers option', () => {
310 let consoleWarn = spyOn(console, 'warn', () => {})
311 let instance = autoprefixer({
312 browsers: ['last 1 version']
313 })
314 equal(instance.browsers, ['last 1 version'])
315 equal(consoleWarn.callCount, 1)
316 match(consoleWarn.calls[0][0], 'overrideBrowserslist')
317 })
318
319 test('passes statistics to Browserslist', () => {
320 let stats = {
321 chrome: {
322 10: 10,
323 11: 40
324 },
325 ie: {
326 10: 10,
327 11: 40
328 }
329 }
330 match(
331 autoprefixer({
332 overrideBrowserslist: '> 20% in my stats',
333 stats
334 }).info(),
335 /Browsers:\n\s\sChrome: 11\n\s\sIE: 11\n/
336 )
337 })
338
339 test('prefixes values', () => {
340 check('values')
341 })
342
343 test('prefixes @keyframes', () => {
344 check('keyframes')
345 })
346
347 test('prefixes @viewport', () => {
348 check('viewport')
349 })
350
351 test('prefixes selectors', () => {
352 check('selectors')
353 })
354
355 test('prefixes resolution query', () => {
356 check('resolution')
357 })
358
359 test('removes common mistakes', () => {
360 check('mistakes')
361 })
362
363 test('reads notes for prefixes', () => {
364 check('notes')
365 })
366
367 test('keeps vendor-specific hacks', () => {
368 check('vendor-hack')
369 })
370
371 test('keeps values with vendor hacks', () => {
372 check('value-hack')
373 })
374
375 test('works with comments', () => {
376 check('comments')
377 })
378
379 test('uses visual cascade', () => {
380 check('cascade')
381 })
382
383 test('works with properties near', () => {
384 check('double')
385 })
386
387 test('checks prefixed in hacks', () => {
388 check('check-down')
389 })
390
391 test('normalize cascade after remove', () => {
392 check('uncascade')
393 })
394
395 test('prefix decls in @supports', () => {
396 check('supports')
397 })
398
399 test('saves declaration style', () => {
400 check('style')
401 })
402
403 test('uses ignore next control comments', () => {
404 check('ignore-next')
405 })
406
407 test('uses block control comments', () => {
408 check('disabled')
409 })
410
411 test('process grouping rules correctly', () => {
412 check('grouping-rule')
413 })
414
415 test('transition on vendor specific rule', () => {
416 check('transition-spec')
417 })
418
419 test('ignore prefix in vendor at rules', () => {
420 check('at-rules')
421 })
422
423 test('ignore content property', () => {
424 let input = read('content')
425 let result = postcss([prefixer('scope')]).process(input)
426 equal(result.css, input)
427 })
428
429 test('uses control comments to whole scope', () => {
430 let input = read('scope')
431 let output = read('scope.out')
432 let result = postcss([prefixer('scope')]).process(input)
433
434 equal(result.css, output)
435 equal(
436 result.warnings().map(i => i.toString()),
437 [
438 'autoprefixer: <css input>:5:3: Second Autoprefixer control comment ' +
439 'was ignored. Autoprefixer applies control comment to whole block, ' +
440 'not to next rules.'
441 ]
442 )
443 })
444
445 test('sets grid option via comment', () => {
446 let input = read('grid-status')
447 let output = read('grid-status.out')
448 let ap = autoprefixer({ overrideBrowserslist: ['last 2 versions', 'IE 11'] })
449 let result = postcss([ap]).process(input)
450
451 equal(result.css, output)
452 equal(
453 result.warnings().map(i => i.toString()),
454 [
455 'autoprefixer: <css input>:2:1: Second Autoprefixer grid control ' +
456 'comment was ignored. Autoprefixer applies control comments ' +
457 'to the whole block, not to the next rules.',
458 'autoprefixer: <css input>:20:3: Second Autoprefixer grid control ' +
459 'comment was ignored. Autoprefixer applies control comments ' +
460 'to the whole block, not to the next rules.',
461 'autoprefixer: <css input>:47:3: Second Autoprefixer grid control ' +
462 'comment was ignored. Autoprefixer applies control comments ' +
463 'to the whole block, not to the next rules.'
464 ]
465 )
466 })
467
468 test('prefixes transition', () => {
469 let input = read('transition')
470 let output = read('transition.out')
471 let result = postcss([prefixer('transition')]).process(input)
472
473 equal(result.css, output)
474 equal(
475 result.warnings().map(i => i.toString()),
476 [
477 'autoprefixer: <css input>:23:3: Replace transition-property ' +
478 'to transition, because Autoprefixer could not support any cases ' +
479 'of transition-property and other transition-*'
480 ]
481 )
482 })
483
484 test('does not raise unnecessary warnings when prefixing transition', () => {
485 check('transition-no-warning')
486 })
487
488 test('works with broken transition', () => {
489 let input = 'a{transition:,,}'
490 let output = 'a{-webkit-transition:;-o-transition:;transition:}'
491 let result = postcss([prefixer('transition')]).process(input)
492 equal(result.css, output)
493 })
494
495 test('should ignore spaces inside values', () => {
496 let css = read('trim')
497 equal(postcss([flexboxer]).process(css).css, css)
498 })
499
500 test('removes unnecessary prefixes', () => {
501 let processor = postcss([cleaner])
502 for (let i of COMMONS) {
503 if (i === 'gradient-fix') continue
504 if (i === 'cascade') continue
505 if (i === 'mistakes') continue
506 if (i === 'flex-rewrite') continue
507 if (i === 'grid') continue
508 if (i === 'grid-gap') continue
509 if (i === 'grid-area') continue
510 if (i === 'grid-template') continue
511 if (i === 'grid-template-areas') continue
512 let input = read(i + '.out')
513 let output = read(i)
514 equal(processor.process(input).css, output)
515 }
516 })
517
518 test('media does not should nested', () => {
519 let processor = postcss([grider])
520 let input = read('grid-media-rules')
521 let output = read('grid-media-rules.out')
522 equal(processor.process(input).css, output)
523 })
524
525 test('does not remove unnecessary prefixes on request', () => {
526 for (let i of ['transition', 'values', 'fullscreen']) {
527 let keeper = autoprefixer({ overrideBrowserslist: [], remove: false })
528 let css = read(i + '.out')
529 equal(postcss([keeper]).process(css).css, css)
530 }
531 })
532
533 test('does not add prefixes on request', () => {
534 for (let i of ['transition', 'values', 'fullscreen']) {
535 let remover = autoprefixer({
536 add: false,
537 overrideBrowserslist: ['Opera 12']
538 })
539 let unprefixed = read(i)
540 equal(postcss([remover]).process(unprefixed).css, unprefixed)
541 }
542 })
543
544 test('prevents doubling prefixes', () => {
545 for (let i of COMMONS) {
546 let processor = postcss([prefixer(i)])
547 let input = read(i)
548 let output = read(i + '.out')
549 let result = processor.process(processor.process(input)).css
•550 equal(universalizer(result).replace(/\n/g,''), universalizer(output).replace(/\n/g,''))
551 }
552 })
553
554 function isContainerNode(node) {
555 return 'nodes' in node
556 }
557
558 test('does not broke AST', () => {
559 function checkParent(node) {
560 node.walk(child => {
561 type(child.parent, 'object')
562 if (isContainerNode(child)) checkParent(child)
563 })
564 }
565 for (let i of COMMONS) {
566 let processor = postcss([prefixer(i)])
567 let input = read(i)
568 checkParent(processor.process(input).root)
569 }
570 })
571
572 test('parses difficult files', () => {
573 let input = read('syntax')
574 let result = postcss([cleaner]).process(input)
575 equal(result.css, input)
576 })
577
578 test('marks parsing errors', () => {
579 throws(() => {
580 postcss([cleaner]).process('a {').css
581 }, '<css input>:1:1: Unclosed block')
582 })
583
584 test('shows file name in parse error', () => {
585 throws(() => {
586 postcss([cleaner]).process('a {', { from: 'a.css' }).css
587 }, /a.css:1:1: /)
588 })
589
590 test('uses browserslist config', () => {
591 let from = join(__dirname, 'cases/config/test.css')
592 let input = read('config/test')
593 let output = read('config/test.out')
594 let processor = postcss([autoprefixer])
595 equal(processor.process(input, { from }).css, output)
596 })
597
598 test('sets browserslist environment', () => {
599 let from = join(__dirname, 'cases/config/test.css')
600 let input = read('config/test')
601 let output = read('config/test.production')
602 let processor = postcss([autoprefixer({ env: 'development' })])
603 equal(processor.process(input, { from }).css, output)
604 })
605
606 test('takes values from other PostCSS plugins', () => {
607 function plugin(root) {
608 root.walkDecls(i => {
609 i.value = 'calc(0)'
610 })
611 }
612 let result = postcss([plugin, compiler]).process('a{width:0/**/0}')
613 equal(result.css, 'a{width:-webkit-calc(0);width:calc(0)}')
614 })
615
616 test('has option to disable @supports support', () => {
617 let css = '@supports (cursor: grab) {}'
618 let instance = autoprefixer({
619 overrideBrowserslist: ['Chrome 28'],
620 supports: false
621 })
622 let result = postcss([instance]).process(css)
623 equal(result.css, css)
624 })
625
626 test('has disabled grid options by default', () => {
627 let ap = autoprefixer({ overrideBrowserslist: ['Edge 12', 'IE 10'] })
628 let input = read('grid')
629 let output = read('grid.disabled')
630 let result = postcss([ap]).process(input)
631 equal(result.css, output)
632 })
633
634 test('has different outputs for different grid options', () => {
635 function ap(gridValue) {
636 return autoprefixer({
637 grid: gridValue,
638 overrideBrowserslist: ['Edge 12', 'IE 10']
639 })
640 }
641 let input = read('grid-options')
642 let outputAutoplace = read('grid-options.autoplace.out')
643 let outputNoAutoplace = read('grid-options.no-autoplace.out')
644 let outputDisabled = read('grid-options.disabled.out')
645
646 let resultAutoplace = postcss([ap('autoplace')]).process(input).css
647 let resultNoAutoplace = postcss([ap('no-autoplace')]).process(input).css
648 let resultEnabled = postcss([ap(true)]).process(input).css
649 let resultDisabled = postcss([ap(false)]).process(input).css
650
651 // output for grid: 'autoplace'
652 equal(resultAutoplace, outputAutoplace)
653 // output for grid: 'no-autoplace'
654 equal(resultNoAutoplace, outputNoAutoplace)
655 // output for grid: true is the same as for 'no-autoplace'
656 equal(resultEnabled, outputNoAutoplace)
657 // output for grid: false
658 equal(resultDisabled, outputDisabled)
659 })
660
661 test('has different outputs for different grid environment variables', () => {
662 function ap(gridValue) {
663 process.env.AUTOPREFIXER_GRID = gridValue
664 return autoprefixer({ overrideBrowserslist: ['Edge 12', 'IE 10'] })
665 }
666 let input = read('grid-options')
667 let outputAutoplace = read('grid-options.autoplace.out')
668 let outputNoAutoplace = read('grid-options.no-autoplace.out')
669
670 let resultAutoplace = postcss([ap('autoplace')]).process(input).css
671 equal(resultAutoplace, outputAutoplace)
672
673 let resultNoAutoplace = postcss([ap('no-autoplace')]).process(input).css
674 equal(resultNoAutoplace, outputNoAutoplace)
675 })
676
677 test('has option to disable flexbox support', () => {
678 let css = read('flexbox')
679 let instance = autoprefixer({
680 flexbox: false,
681 overrideBrowserslist: ['IE 10']
682 })
683 let result = postcss([instance]).process(css)
684 equal(result.css, css)
685 })
686
687 test('has option to disable 2009 flexbox support', () => {
688 let ap = autoprefixer({
689 flexbox: 'no-2009',
690 overrideBrowserslist: ['Chrome > 19']
691 })
692 let css = 'a{flex:1;transition:flex}'
693 let result = postcss([ap]).process(css)
694 equal(
695 result.css,
696 'a{' +
697 '-webkit-flex:1;flex:1;' +
698 '-webkit-transition:-webkit-flex;transition:-webkit-flex;' +
699 'transition:flex;transition:flex, -webkit-flex' +
700 '}'
701 )
702 })
703
704 test('returns inspect string', () => {
705 match(
706 autoprefixer({ overrideBrowserslist: ['chrome 25'] }).info(),
707 /Browsers:\s+Chrome: 25/
708 )
709 })
710
711 test('uses browserslist config in inspect', () => {
712 let from = join(__dirname, 'cases/config')
713 match(autoprefixer().info({ from }), /Browsers:\s+IE: 10/)
714 })
715
716 test('ignores unknown versions on request', () => {
717 throws(() => {
718 autoprefixer({ overrideBrowserslist: ['ie 100'] }).info()
719 }, /Unknown version 100 of ie/)
720 not.throws(() => {
721 autoprefixer({
722 ignoreUnknownVersions: true,
723 overrideBrowserslist: ['ie 100']
724 }).info()
725 })
726 })
727
728 test('works with CSS Modules', () => {
729 postcss([autoprefixer()]).process(':export { selectors: _1q6ho_2 }').css
730 })
731
732 test('ignores prefix IE filter', () => {
733 check('filter')
734 })
735
736 test('supports webkit filters', () => {
737 check('advanced-filter')
738 })
739
740 test('changes border image syntax', () => {
741 check('border-image')
742 })
743
744 test('supports old Mozilla prefixes', () => {
745 check('border-radius')
746 })
747
748 test('supports all flexbox syntaxes', () => {
749 check('flexbox')
750 })
751
752 test('supports map flexbox props', () => {
753 check('flex-rewrite')
754 })
755
756 test('supports all fullscreens', () => {
757 check('fullscreen')
758 })
759
760 test('supports file-selector-button', () => {
761 check('file-selector-button')
762 })
763
764 test('supports ::backdrop', () => {
765 check('backdrop')
766 })
767
768 test('supports custom prefixes', () => {
769 check('custom-prefix')
770 })
771
772 test('fixes break properties', () => {
773 check('multicolumn')
774 })
775
776 test('ignores some 3D transforms', () => {
777 check('3d-transform')
778 })
779
780 test('supports background-size', () => {
781 check('background-size')
782 })
783
784 test('supports background-clip', () => {
785 check('background-clip')
786 })
787
788 test('supports logical properties', () => {
789 check('logical')
790 })
791
792 test('supports appearance', () => {
793 check('appearance')
794 })
795
796 test('supports all placeholders', () => {
797 check('placeholder')
798 })
799
800 test('supports placeholder-shown', () => {
801 check('placeholder-shown')
802 })
803
804 test('supports image-rendering', () => {
805 check('image-rendering')
806 })
807
808 test('supports border-box mask', () => {
809 check('mask-border')
810 })
811
812 test('supports mask-composite', () => {
813 check('mask-composite')
814 })
815
816 test('supports image-set()', () => {
817 check('image-set')
818 })
819
820 test('supports writing-mode', () => {
821 check('writing-mode')
822 })
823
824 test('supports cross-fade()', () => {
825 check('cross-fade')
826 })
827
828 test('ignores modern direction', () => {
829 check('animation')
830 })
831
832 test('supports overscroll-behavior', () => {
833 check('overscroll-behavior')
834 })
835
836 test('supports print-color-adjust', () => {
837 let input = read('print-color-adjust')
838 let output = read('print-color-adjust.out')
839 let result = postcss([prefixer('print-color-adjust')]).process(input)
840
841 equal(result.css, output)
842 equal(
843 result.warnings().map(i => i.toString()),
844 [
845 'autoprefixer: <css input>:2:3: Replace color-adjust ' +
846 'to print-color-adjust. The color-adjust shorthand ' +
847 'is currently deprecated.'
848 ]
849 )
850 })
851
852 test('supports backdrop-filter', () => {
853 check('backdrop-filter')
854 })
855
856 test('supports user-select hack for IE', () => {
857 check('user-select')
858 })
859
860 test('supports appearance for IE', () => {
861 let instance = autoprefixer({ overrideBrowserslist: 'Edge 15' })
862 let result = postcss([instance]).process('a { appearance: none }')
863 equal(result.css, 'a { -webkit-appearance: none; appearance: none }')
864 })
865
866 test('changes angle in gradient', () => {
867 let input = read('gradient')
868 let output = read('gradient.out')
869 let result = postcss([prefixer('gradient')]).process(input)
870
871 equal(result.css, output)
872 equal(
873 result.warnings().map(i => i.toString()),
874 [
875 'autoprefixer: <css input>:18:3: Gradient has outdated direction ' +
876 'syntax. New syntax is like `closest-side at 0 0` instead of ' +
877 '`0 0, closest-side`.',
878 'autoprefixer: <css input>:38:3: Gradient has outdated direction ' +
879 'syntax. New syntax is like `to left` instead of `right`.',
880 'autoprefixer: <css input>:100:3: Gradient has outdated ' +
881 'direction syntax. Replace `cover` to `farthest-corner`.',
882 'autoprefixer: <css input>:104:3: Gradient has outdated ' +
883 'direction syntax. Replace `contain` to `closest-side`.'
884 ]
885 )
886
887 check('gradient-fix')
888 })
889
890 test('warns on old flexbox display', () => {
891 let result = postcss([flexboxer]).process('a{ display: box; }')
892 equal(result.css, 'a{ display: box; }')
893 equal(
894 result.warnings().map(i => i.toString()),
895 [
896 'autoprefixer: <css input>:1:4: You should write display: flex ' +
897 'by final spec instead of display: box'
898 ]
899 )
900 })
901
902 test('supports intrinsic sizing', () => {
903 let input = read('intrinsic')
904 let output = read('intrinsic.out')
905 let result = postcss([prefixer('intrinsic')]).process(input)
906
907 equal(result.css, output)
908 equal(
909 result.warnings().map(i => i.toString()),
910 [
911 'autoprefixer: <css input>:15:3: Replace fill to stretch, ' +
912 'because spec had been changed',
913 'autoprefixer: <css input>:19:3: Replace fill-available ' +
914 'to stretch, because spec had been changed'
915 ]
916 )
917 })
918
919 test('supports text-emphasis', () => {
920 let input = read('text-emphasis-position')
921 let output = read('text-emphasis-position.out')
922 let instance = prefixer('text-emphasis-position')
923 let result = postcss([instance]).process(input)
924
925 equal(result.css, output)
926 equal(
927 result.warnings().map(i => i.toString()),
928 [
929 'autoprefixer: <css input>:14:3: You should use 2 values ' +
930 'for text-emphasis-position For example, `under left` ' +
931 'instead of just `under`.'
932 ]
933 )
934 })
935
936 test('supports grid layout', () => {
937 let input = read('grid')
938 let output = read('grid.out')
939 let instance = prefixer('grid')
940 let result = postcss([instance]).process(input)
941
942 equal(result.css, output)
943 equal(
944 result.warnings().map(i => i.toString()),
945 [
946 'autoprefixer: <css input>:3:3: Autoplacement does not work ' +
947 'without grid-template-rows property',
948 'autoprefixer: <css input>:12:3: Autoplacement does not work ' +
949 'without grid-template-columns property',
950 'autoprefixer: <css input>:36:3: Can not prefix grid-column-end ' +
951 '(grid-column-start is not found)',
952 'autoprefixer: <css input>:37:3: IE does not support subgrid',
953 'autoprefixer: <css input>:39:3: Can not implement grid-gap ' +
954 'without grid-template-columns',
955 'autoprefixer: <css input>:39:3: Can not find grid areas: ' +
956 'head, nav, main, foot',
957 'autoprefixer: <css input>:57:3: Can not implement grid-gap ' +
958 'without grid-template-columns',
959 'autoprefixer: <css input>:57:3: Can not find grid areas: a',
960 'autoprefixer: <css input>:65:3: Can not implement grid-gap ' +
961 'without grid-template-columns',
962 'autoprefixer: <css input>:65:3: Can not find grid areas: b',
963 'autoprefixer: <css input>:73:3: Can not find grid areas: c',
964 'autoprefixer: <css input>:81:3: Can not find grid areas: d',
965 'autoprefixer: <css input>:116:3: grid-column-span is not part ' +
966 'of final Grid Layout. Use grid-column.',
967 'autoprefixer: <css input>:117:3: grid-row-span is not part ' +
968 'of final Grid Layout. Use grid-row.',
969 'autoprefixer: <css input>:118:3: grid-auto-columns is not ' +
970 'supported by IE',
971 'autoprefixer: <css input>:119:3: grid-auto-rows is not ' +
972 'supported by IE',
973 'autoprefixer: <css input>:121:33: auto-fill value is not ' +
974 'supported by IE',
975 'autoprefixer: <css input>:122:30: auto-fit value is not ' +
976 'supported by IE',
977 'autoprefixer: <css input>:138:3: Please do not use ' +
978 'display: contents; if you have grid setting enabled',
979 'autoprefixer: <css input>:142:3: IE does not support align-items ' +
980 'on grid containers. Try using align-self on child elements instead: ' +
981 '.warn_ie_align > * { align-self: center }',
982 'autoprefixer: <css input>:147:3: IE does not support justify-items ' +
983 'on grid containers. Try using justify-self on child elements ' +
984 'instead: .warn_ie_justify > * { justify-self: center }',
985 'autoprefixer: <css input>:152:3: IE does not support justify-content ' +
986 'on grid containers',
987 'autoprefixer: <css input>:157:3: IE does not support place-items ' +
988 'on grid containers. Try using place-self on child elements ' +
989 'instead: .warn_place_items > * { place-self: start end }',
990 'autoprefixer: <css input>:181:3: grid-auto-flow is not supported by IE',
991 'autoprefixer: <css input>:203:26: Autoprefixer currently does not ' +
992 'support line names. Try using grid-template-areas instead.'
993 ]
994 )
995
996 let input2 = read('grid-template')
997 let output2 = read('grid-template.out')
998 let instance2 = prefixer('grid-template')
999 let result2 = postcss([instance2]).process(input2)
1000 equal(result2.css, output2)
1001 })
1002
1003 test('supports grid autoplacement', () => {
1004 let input = read('grid-autoplacement')
1005 let output = read('grid-autoplacement.out')
1006 let instance = prefixer('grid')
1007 let result = postcss([instance]).process(input)
1008 equal(result.css, output)
1009
1010 equal(
1011 result.warnings().map(i => i.toString()),
1012 [
1013 'autoprefixer: <css input>:47:3: grid-auto-flow: dense ' +
1014 'is not supported by IE',
1015 'autoprefixer: <css input>:48:3: Autoplacement does not work ' +
1016 'without grid-template-rows property',
1017 'autoprefixer: <css input>:53:3: grid-auto-flow works only if grid-temp' +
1018 'late-rows and grid-template-columns are present in the same rule',
1019 'autoprefixer: <css input>:60:3: grid-gap only works if grid-temp' +
1020 'late(-areas) is being used',
1021 'autoprefixer: <css input>:64:3: Autoplacement does not work ' +
1022 'without grid-template-rows property',
1023 'autoprefixer: <css input>:65:3: grid-gap only works if grid-temp' +
1024 'late(-areas) is being used or both rows and columns have been ' +
1025 'declared and cells have not been ' +
1026 'manually placed inside the explicit grid'
1027 ]
1028 )
1029 })
1030
1031 test('shows Grid warnings only for IE', () => {
1032 let input = 'a { grid-template-rows: repeat(auto-fit, 1px) }'
1033 let instance = autoprefixer({
1034 grid: true,
1035 overrideBrowserslist: 'chrome 27'
1036 })
1037 let result = postcss([instance]).process(input)
1038 equal(result.warnings().length, 0)
1039 })
1040
1041 test('warns if rule has both grid-area and grid-(row|column) decls', () => {
1042 let input = read('grid-area')
1043 let instance = prefixer('grid-area')
1044 let result = postcss([instance]).process(input)
1045 equal(
1046 result.warnings().map(i => i.toString()),
1047 [
1048 'autoprefixer: <css input>:28:3: You already have a grid-area ' +
1049 'declaration present in the rule. You should use either ' +
1050 'grid-area or grid-row, not both',
1051 'autoprefixer: <css input>:29:3: You already have a grid-area ' +
1052 'declaration present in the rule. You should use either ' +
1053 'grid-area or grid-column, not both',
1054 'autoprefixer: <css input>:34:3: You already have a grid-area ' +
1055 'declaration present in the rule. You should use either ' +
1056 'grid-area or grid-column, not both'
1057 ]
1058 )
1059 })
1060
1061 test('warns if rule with grid-area has no parent with grid-template', () => {
1062 let input = read('grid-template-areas')
1063 let instance = prefixer('grid-area')
1064 let result = postcss([instance]).process(input)
1065
1066 equal(
1067 result
1068 .warnings()
1069 .map(i => i.toString())
1070 .filter(str => str.includes('grid-template')),
1071 [
1072 'autoprefixer: <css input>:144:3: Autoprefixer cannot find ' +
1073 'a grid-template containing the duplicate grid-area ' +
1074 '"child" with full selector matching: .uncle',
1075 'autoprefixer: <css input>:149:3: Autoprefixer cannot find ' +
1076 'a grid-template containing the duplicate grid-area ' +
1077 '"child" with full selector matching: .uncle',
1078 'autoprefixer: <css input>:154:3: Autoprefixer cannot find ' +
1079 'a grid-template containing the duplicate grid-area ' +
1080 '"child" with full selector matching: .grand-parent .uncle-second',
1081 'autoprefixer: <css input>:159:3: Autoprefixer cannot find ' +
1082 'a grid-template containing the duplicate grid-area ' +
1083 '"child" with full selector matching: .grand-parent .uncle-second',
1084 'autoprefixer: <css input>:164:3: Autoprefixer cannot find ' +
1085 'a grid-template containing the duplicate grid-area ' +
1086 '"child" with full selector matching: .grand-parent .father.uncle',
1087 'autoprefixer: <css input>:169:3: Autoprefixer cannot find ' +
1088 'a grid-template containing the duplicate grid-area ' +
1089 '"child" with full selector matching: .grand-parent.uncle .father'
1090 ]
1091 )
1092 })
1093
1094 test('should preserve @media rules with grid-area', () => {
1095 let input = read('grid-area-media-sequence')
1096 let output = read('grid-area-media-sequence.out')
1097 let instance = prefixer('grid-area')
1098 let result = postcss([instance]).process(input)
1099 equal(result.css, output)
1100 })
1101
1102 test('should merge complex duplicate grid-area rules successfully', () => {
1103 let input = read('grid-areas-duplicate-complex')
1104 let output = read('grid-areas-duplicate-complex.out')
1105 let instance = prefixer('grid-area')
1106 let result = postcss([instance]).process(input)
1107 equal(result.css, output)
1108 })
1109
1110 test('ignores values for CSS3PIE props', () => {
1111 let css = read('pie')
1112 equal(postcss([compiler]).process(css).css, css)
1113 })
1114
1115 test('add prefix for backface-visibility for Safari 9', () => {
1116 let input =
1117 'a{ ' + 'backface-visibility: hidden; ' + 'transform-style: preserve-3d }'
1118 let ap = autoprefixer({
1119 flexbox: false,
1120 overrideBrowserslist: ['Safari 9']
1121 })
1122 equal(
1123 postcss([ap]).process(input).css,
1124 'a{ ' +
1125 '-webkit-backface-visibility: hidden; ' +
1126 'backface-visibility: hidden; ' +
1127 'transform-style: preserve-3d }'
1128 )
1129 })
1130
1131 test('supports text-decoration', () => {
1132 let input = read('text-decoration')
1133 let output = read('text-decoration.out')
1134 let instance = prefixer('text-decoration')
1135 let result = postcss([instance]).process(input)
1136
1137 equal(universalizer(result.css), universalizer(output))
1138 equal(
1139 result.warnings().map(i => i.toString()),
1140 [
1141 'autoprefixer: <css input>:32:3: Replace text-decoration-skip: ink ' +
1142 'to text-decoration-skip-ink: auto, because spec had been changed'
1143 ]
1144 )
1145 })
1146
1147 test('supports text-decoration shorthand', () => {
1148 let input = read('text-decoration')
1149 let output = read('text-decoration.shorthand.out')
1150 let instance = prefixer('text-decoration-shorthand')
1151 let result = postcss([instance]).process(input)
1152
1153 equal(universalizer(result.css), universalizer(output))
1154 })
1155
1156 test('supports -webkit-line-clamp', () => {
1157 let input = read('webkit-line-clamp')
1158 let output = read('webkit-line-clamp.out')
1159 let result = postcss([cleaner]).process(input)
1160
1161 equal(universalizer(result.css), universalizer(output))
1162 equal(result.warnings().length, 0)
1163 })
1164
1165 test('supports latest Firefox stretch', () => {
1166 let input = read('intrinsic')
1167 let output = read('intrinsic.ff')
1168 let result = postcss([
1169 autoprefixer({ overrideBrowserslist: 'firefox 90' })
1170 ]).process(input)
1171 equal(result.css, output)
1172 equal(result.warnings().length, 2)
1173 })
1174
1175 test.run()