Debian Codegraph @

autoprefixer/test/autoprefixer.test.js

raw symbols ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
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), universalizer(output))
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('has actual example in docs', () => {
412 check('example')
413 })
414
415 test('process grouping rules correctly', () => {
416 check('grouping-rule')
417 })
418
419 test('transition on vendor specific rule', () => {
420 check('transition-spec')
421 })
422
423 test('ignore prefix in vendor at rules', () => {
424 check('at-rules')
425 })
426
427 test('ignore content property', () => {
428 let input = read('content')
429 let result = postcss([prefixer('scope')]).process(input)
430 equal(result.css, input)
431 })
432
433 test('uses control comments to whole scope', () => {
434 let input = read('scope')
435 let output = read('scope.out')
436 let result = postcss([prefixer('scope')]).process(input)
437
438 equal(result.css, output)
439 equal(
440 result.warnings().map(i => i.toString()),
441 [
442 'autoprefixer: <css input>:5:3: Second Autoprefixer control comment ' +
443 'was ignored. Autoprefixer applies control comment to whole block, ' +
444 'not to next rules.'
445 ]
446 )
447 })
448
449 test('sets grid option via comment', () => {
450 let input = read('grid-status')
451 let output = read('grid-status.out')
452 let ap = autoprefixer({ overrideBrowserslist: ['last 2 versions', 'IE 11'] })
453 let result = postcss([ap]).process(input)
454
455 equal(result.css, output)
456 equal(
457 result.warnings().map(i => i.toString()),
458 [
459 'autoprefixer: <css input>:2:1: Second Autoprefixer grid control ' +
460 'comment was ignored. Autoprefixer applies control comments ' +
461 'to the whole block, not to the next rules.',
462 'autoprefixer: <css input>:20:3: Second Autoprefixer grid control ' +
463 'comment was ignored. Autoprefixer applies control comments ' +
464 'to the whole block, not to the next rules.',
465 'autoprefixer: <css input>:47:3: Second Autoprefixer grid control ' +
466 'comment was ignored. Autoprefixer applies control comments ' +
467 'to the whole block, not to the next rules.'
468 ]
469 )
470 })
471
472 test('prefixes transition', () => {
473 let input = read('transition')
474 let output = read('transition.out')
475 let result = postcss([prefixer('transition')]).process(input)
476
477 equal(result.css, output)
478 equal(
479 result.warnings().map(i => i.toString()),
480 [
481 'autoprefixer: <css input>:23:3: Replace transition-property ' +
482 'to transition, because Autoprefixer could not support any cases ' +
483 'of transition-property and other transition-*'
484 ]
485 )
486 })
487
488 test('does not raise unnecessary warnings when prefixing transition', () => {
489 check('transition-no-warning')
490 })
491
492 test('works with broken transition', () => {
493 let input = 'a{transition:,,}'
494 let output = 'a{-webkit-transition:;-o-transition:;transition:}'
495 let result = postcss([prefixer('transition')]).process(input)
496 equal(result.css, output)
497 })
498
499 test('should ignore spaces inside values', () => {
500 let css = read('trim')
501 equal(postcss([flexboxer]).process(css).css, css)
502 })
503
504 test('removes unnecessary prefixes', () => {
505 let processor = postcss([cleaner])
506 for (let i of COMMONS) {
507 if (i === 'gradient-fix') continue
508 if (i === 'cascade') continue
509 if (i === 'mistakes') continue
510 if (i === 'flex-rewrite') continue
511 if (i === 'grid') continue
512 if (i === 'grid-gap') continue
513 if (i === 'grid-area') continue
514 if (i === 'grid-template') continue
515 if (i === 'grid-template-areas') continue
516 let input = read(i + '.out')
517 let output = read(i)
518 equal(processor.process(input).css, output)
519 }
520 })
521
522 test('media does not should nested', () => {
523 let processor = postcss([grider])
524 let input = read('grid-media-rules')
525 let output = read('grid-media-rules.out')
526 equal(processor.process(input).css, output)
527 })
528
529 test('does not remove unnecessary prefixes on request', () => {
530 for (let i of ['transition', 'values', 'fullscreen']) {
531 let keeper = autoprefixer({ overrideBrowserslist: [], remove: false })
532 let css = read(i + '.out')
533 equal(postcss([keeper]).process(css).css, css)
534 }
535 })
536
537 test('does not add prefixes on request', () => {
538 for (let i of ['transition', 'values', 'fullscreen']) {
539 let remover = autoprefixer({
540 add: false,
541 overrideBrowserslist: ['Opera 12']
542 })
543 let unprefixed = read(i)
544 equal(postcss([remover]).process(unprefixed).css, unprefixed)
545 }
546 })
547
548 test('prevents doubling prefixes', () => {
549 for (let i of COMMONS) {
550 let processor = postcss([prefixer(i)])
551 let input = read(i)
552 let output = read(i + '.out')
553 let result = processor.process(processor.process(input)).css
554 equal(universalizer(result), universalizer(output))
555 }
556 })
557
558 function isContainerNode(node) {
559 return 'nodes' in node
560 }
561
562 test('does not broke AST', () => {
563 function checkParent(node) {
564 node.walk(child => {
565 type(child.parent, 'object')
566 if (isContainerNode(child)) checkParent(child)
567 })
568 }
569 for (let i of COMMONS) {
570 let processor = postcss([prefixer(i)])
571 let input = read(i)
572 checkParent(processor.process(input).root)
573 }
574 })
575
576 test('parses difficult files', () => {
577 let input = read('syntax')
578 let result = postcss([cleaner]).process(input)
579 equal(result.css, input)
580 })
581
582 test('marks parsing errors', () => {
583 throws(() => {
584 postcss([cleaner]).process('a {').css
585 }, '<css input>:1:1: Unclosed block')
586 })
587
588 test('shows file name in parse error', () => {
589 throws(() => {
590 postcss([cleaner]).process('a {', { from: 'a.css' }).css
591 }, /a.css:1:1: /)
592 })
593
594 test('uses browserslist config', () => {
595 let from = join(__dirname, 'cases/config/test.css')
596 let input = read('config/test')
597 let output = read('config/test.out')
598 let processor = postcss([autoprefixer])
599 equal(processor.process(input, { from }).css, output)
600 })
601
602 test('sets browserslist environment', () => {
603 let from = join(__dirname, 'cases/config/test.css')
604 let input = read('config/test')
605 let output = read('config/test.production')
606 let processor = postcss([autoprefixer({ env: 'development' })])
607 equal(processor.process(input, { from }).css, output)
608 })
609
610 test('takes values from other PostCSS plugins', () => {
611 function plugin(root) {
612 root.walkDecls(i => {
613 i.value = 'calc(0)'
614 })
615 }
616 let result = postcss([plugin, compiler]).process('a{width:0/**/0}')
617 equal(result.css, 'a{width:-webkit-calc(0);width:calc(0)}')
618 })
619
620 test('has option to disable @supports support', () => {
621 let css = '@supports (cursor: grab) {}'
622 let instance = autoprefixer({
623 overrideBrowserslist: ['Chrome 28'],
624 supports: false
625 })
626 let result = postcss([instance]).process(css)
627 equal(result.css, css)
628 })
629
630 test('has disabled grid options by default', () => {
631 let ap = autoprefixer({ overrideBrowserslist: ['Edge 12', 'IE 10'] })
632 let input = read('grid')
633 let output = read('grid.disabled')
634 let result = postcss([ap]).process(input)
635 equal(result.css, output)
636 })
637
638 test('has different outputs for different grid options', () => {
639 function ap(gridValue) {
640 return autoprefixer({
641 grid: gridValue,
642 overrideBrowserslist: ['Edge 12', 'IE 10']
643 })
644 }
645 let input = read('grid-options')
646 let outputAutoplace = read('grid-options.autoplace.out')
647 let outputNoAutoplace = read('grid-options.no-autoplace.out')
648 let outputDisabled = read('grid-options.disabled.out')
649
650 let resultAutoplace = postcss([ap('autoplace')]).process(input).css
651 let resultNoAutoplace = postcss([ap('no-autoplace')]).process(input).css
652 let resultEnabled = postcss([ap(true)]).process(input).css
653 let resultDisabled = postcss([ap(false)]).process(input).css
654
655 // output for grid: 'autoplace'
656 equal(resultAutoplace, outputAutoplace)
657 // output for grid: 'no-autoplace'
658 equal(resultNoAutoplace, outputNoAutoplace)
659 // output for grid: true is the same as for 'no-autoplace'
660 equal(resultEnabled, outputNoAutoplace)
661 // output for grid: false
662 equal(resultDisabled, outputDisabled)
663 })
664
665 test('has different outputs for different grid environment variables', () => {
666 function ap(gridValue) {
667 process.env.AUTOPREFIXER_GRID = gridValue
668 return autoprefixer({ overrideBrowserslist: ['Edge 12', 'IE 10'] })
669 }
670 let input = read('grid-options')
671 let outputAutoplace = read('grid-options.autoplace.out')
672 let outputNoAutoplace = read('grid-options.no-autoplace.out')
673
674 let resultAutoplace = postcss([ap('autoplace')]).process(input).css
675 equal(resultAutoplace, outputAutoplace)
676
677 let resultNoAutoplace = postcss([ap('no-autoplace')]).process(input).css
678 equal(resultNoAutoplace, outputNoAutoplace)
679 })
680
681 test('has option to disable flexbox support', () => {
682 let css = read('flexbox')
683 let instance = autoprefixer({
684 flexbox: false,
685 overrideBrowserslist: ['IE 10']
686 })
687 let result = postcss([instance]).process(css)
688 equal(result.css, css)
689 })
690
691 test('has option to disable 2009 flexbox support', () => {
692 let ap = autoprefixer({
693 flexbox: 'no-2009',
694 overrideBrowserslist: ['Chrome > 19']
695 })
696 let css = 'a{flex:1;transition:flex}'
697 let result = postcss([ap]).process(css)
698 equal(
699 result.css,
700 'a{' +
701 '-webkit-flex:1;flex:1;' +
702 '-webkit-transition:-webkit-flex;transition:-webkit-flex;' +
703 'transition:flex;transition:flex, -webkit-flex' +
704 '}'
705 )
706 })
707
708 test('returns inspect string', () => {
709 match(
710 autoprefixer({ overrideBrowserslist: ['chrome 25'] }).info(),
711 /Browsers:\s+Chrome: 25/
712 )
713 })
714
715 test('uses browserslist config in inspect', () => {
716 let from = join(__dirname, 'cases/config')
717 match(autoprefixer().info({ from }), /Browsers:\s+IE: 10/)
718 })
719
720 test('ignores unknown versions on request', () => {
721 throws(() => {
722 autoprefixer({ overrideBrowserslist: ['ie 100'] }).info()
723 }, /Unknown version 100 of ie/)
724 not.throws(() => {
725 autoprefixer({
726 ignoreUnknownVersions: true,
727 overrideBrowserslist: ['ie 100']
728 }).info()
729 })
730 })
731
732 test('works with CSS Modules', () => {
733 postcss([autoprefixer()]).process(':export { selectors: _1q6ho_2 }').css
734 })
735
736 test('ignores prefix IE filter', () => {
737 check('filter')
738 })
739
740 test('supports webkit filters', () => {
741 check('advanced-filter')
742 })
743
744 test('changes border image syntax', () => {
745 check('border-image')
746 })
747
748 test('supports old Mozilla prefixes', () => {
749 check('border-radius')
750 })
751
752 test('supports all flexbox syntaxes', () => {
753 check('flexbox')
754 })
755
756 test('supports map flexbox props', () => {
757 check('flex-rewrite')
758 })
759
760 test('supports all fullscreens', () => {
761 check('fullscreen')
762 })
763
764 test('supports file-selector-button', () => {
765 check('file-selector-button')
766 })
767
768 test('supports ::backdrop', () => {
769 check('backdrop')
770 })
771
772 test('supports custom prefixes', () => {
773 check('custom-prefix')
774 })
775
776 test('fixes break properties', () => {
777 check('multicolumn')
778 })
779
780 test('ignores some 3D transforms', () => {
781 check('3d-transform')
782 })
783
784 test('supports background-size', () => {
785 check('background-size')
786 })
787
788 test('supports background-clip', () => {
789 check('background-clip')
790 })
791
792 test('supports logical properties', () => {
793 check('logical')
794 })
795
796 test('supports appearance', () => {
797 check('appearance')
798 })
799
800 test('supports all placeholders', () => {
801 check('placeholder')
802 })
803
804 test('supports placeholder-shown', () => {
805 check('placeholder-shown')
806 })
807
808 test('supports image-rendering', () => {
809 check('image-rendering')
810 })
811
812 test('supports border-box mask', () => {
813 check('mask-border')
814 })
815
816 test('supports mask-composite', () => {
817 check('mask-composite')
818 })
819
820 test('supports image-set()', () => {
821 check('image-set')
822 })
823
824 test('supports writing-mode', () => {
825 check('writing-mode')
826 })
827
828 test('supports cross-fade()', () => {
829 check('cross-fade')
830 })
831
832 test('ignores modern direction', () => {
833 check('animation')
834 })
835
836 test('supports overscroll-behavior', () => {
837 check('overscroll-behavior')
838 })
839
840 test('supports print-color-adjust', () => {
841 let input = read('print-color-adjust')
842 let output = read('print-color-adjust.out')
843 let result = postcss([prefixer('print-color-adjust')]).process(input)
844
845 equal(result.css, output)
846 equal(
847 result.warnings().map(i => i.toString()),
848 [
849 'autoprefixer: <css input>:2:3: Replace color-adjust ' +
850 'to print-color-adjust. The color-adjust shorthand ' +
851 'is currently deprecated.'
852 ]
853 )
854 })
855
856 test('supports backdrop-filter', () => {
857 check('backdrop-filter')
858 })
859
860 test('supports user-select hack for IE', () => {
861 check('user-select')
862 })
863
864 test('supports appearance for IE', () => {
865 let instance = autoprefixer({ overrideBrowserslist: 'Edge 15' })
866 let result = postcss([instance]).process('a { appearance: none }')
867 equal(result.css, 'a { -webkit-appearance: none; appearance: none }')
868 })
869
870 test('changes angle in gradient', () => {
871 let input = read('gradient')
872 let output = read('gradient.out')
873 let result = postcss([prefixer('gradient')]).process(input)
874
875 equal(result.css, output)
876 equal(
877 result.warnings().map(i => i.toString()),
878 [
879 'autoprefixer: <css input>:18:3: Gradient has outdated direction ' +
880 'syntax. New syntax is like `closest-side at 0 0` instead of ' +
881 '`0 0, closest-side`.',
882 'autoprefixer: <css input>:38:3: Gradient has outdated direction ' +
883 'syntax. New syntax is like `to left` instead of `right`.',
884 'autoprefixer: <css input>:100:3: Gradient has outdated ' +
885 'direction syntax. Replace `cover` to `farthest-corner`.',
886 'autoprefixer: <css input>:104:3: Gradient has outdated ' +
887 'direction syntax. Replace `contain` to `closest-side`.'
888 ]
889 )
890
891 check('gradient-fix')
892 })
893
894 test('warns on old flexbox display', () => {
895 let result = postcss([flexboxer]).process('a{ display: box; }')
896 equal(result.css, 'a{ display: box; }')
897 equal(
898 result.warnings().map(i => i.toString()),
899 [
900 'autoprefixer: <css input>:1:4: You should write display: flex ' +
901 'by final spec instead of display: box'
902 ]
903 )
904 })
905
906 test('supports intrinsic sizing', () => {
907 let input = read('intrinsic')
908 let output = read('intrinsic.out')
909 let result = postcss([prefixer('intrinsic')]).process(input)
910
911 equal(result.css, output)
912 equal(
913 result.warnings().map(i => i.toString()),
914 [
915 'autoprefixer: <css input>:15:3: Replace fill to stretch, ' +
916 'because spec had been changed',
917 'autoprefixer: <css input>:19:3: Replace fill-available ' +
918 'to stretch, because spec had been changed'
919 ]
920 )
921 })
922
923 test('supports text-emphasis', () => {
924 let input = read('text-emphasis-position')
925 let output = read('text-emphasis-position.out')
926 let instance = prefixer('text-emphasis-position')
927 let result = postcss([instance]).process(input)
928
929 equal(result.css, output)
930 equal(
931 result.warnings().map(i => i.toString()),
932 [
933 'autoprefixer: <css input>:14:3: You should use 2 values ' +
934 'for text-emphasis-position For example, `under left` ' +
935 'instead of just `under`.'
936 ]
937 )
938 })
939
940 test('supports grid layout', () => {
941 let input = read('grid')
942 let output = read('grid.out')
943 let instance = prefixer('grid')
944 let result = postcss([instance]).process(input)
945
946 equal(result.css, output)
947 equal(
948 result.warnings().map(i => i.toString()),
949 [
950 'autoprefixer: <css input>:3:3: Autoplacement does not work ' +
951 'without grid-template-rows property',
952 'autoprefixer: <css input>:12:3: Autoplacement does not work ' +
953 'without grid-template-columns property',
954 'autoprefixer: <css input>:36:3: Can not prefix grid-column-end ' +
955 '(grid-column-start is not found)',
956 'autoprefixer: <css input>:37:3: IE does not support subgrid',
957 'autoprefixer: <css input>:39:3: Can not implement grid-gap ' +
958 'without grid-template-columns',
959 'autoprefixer: <css input>:39:3: Can not find grid areas: ' +
960 'head, nav, main, foot',
961 'autoprefixer: <css input>:57:3: Can not implement grid-gap ' +
962 'without grid-template-columns',
963 'autoprefixer: <css input>:57:3: Can not find grid areas: a',
964 'autoprefixer: <css input>:65:3: Can not implement grid-gap ' +
965 'without grid-template-columns',
966 'autoprefixer: <css input>:65:3: Can not find grid areas: b',
967 'autoprefixer: <css input>:73:3: Can not find grid areas: c',
968 'autoprefixer: <css input>:81:3: Can not find grid areas: d',
969 'autoprefixer: <css input>:116:3: grid-column-span is not part ' +
970 'of final Grid Layout. Use grid-column.',
971 'autoprefixer: <css input>:117:3: grid-row-span is not part ' +
972 'of final Grid Layout. Use grid-row.',
973 'autoprefixer: <css input>:118:3: grid-auto-columns is not ' +
974 'supported by IE',
975 'autoprefixer: <css input>:119:3: grid-auto-rows is not ' +
976 'supported by IE',
977 'autoprefixer: <css input>:121:33: auto-fill value is not ' +
978 'supported by IE',
979 'autoprefixer: <css input>:122:30: auto-fit value is not ' +
980 'supported by IE',
981 'autoprefixer: <css input>:138:3: Please do not use ' +
982 'display: contents; if you have grid setting enabled',
983 'autoprefixer: <css input>:142:3: IE does not support align-items ' +
984 'on grid containers. Try using align-self on child elements instead: ' +
985 '.warn_ie_align > * { align-self: center }',
986 'autoprefixer: <css input>:147:3: IE does not support justify-items ' +
987 'on grid containers. Try using justify-self on child elements ' +
988 'instead: .warn_ie_justify > * { justify-self: center }',
989 'autoprefixer: <css input>:152:3: IE does not support justify-content ' +
990 'on grid containers',
991 'autoprefixer: <css input>:157:3: IE does not support place-items ' +
992 'on grid containers. Try using place-self on child elements ' +
993 'instead: .warn_place_items > * { place-self: start end }',
994 'autoprefixer: <css input>:181:3: grid-auto-flow is not supported by IE',
995 'autoprefixer: <css input>:203:26: Autoprefixer currently does not ' +
996 'support line names. Try using grid-template-areas instead.'
997 ]
998 )
999
1000 let input2 = read('grid-template')
1001 let output2 = read('grid-template.out')
1002 let instance2 = prefixer('grid-template')
1003 let result2 = postcss([instance2]).process(input2)
1004 equal(result2.css, output2)
1005 })
1006
1007 test('supports grid autoplacement', () => {
1008 let input = read('grid-autoplacement')
1009 let output = read('grid-autoplacement.out')
1010 let instance = prefixer('grid')
1011 let result = postcss([instance]).process(input)
1012 equal(result.css, output)
1013
1014 equal(
1015 result.warnings().map(i => i.toString()),
1016 [
1017 'autoprefixer: <css input>:47:3: grid-auto-flow: dense ' +
1018 'is not supported by IE',
1019 'autoprefixer: <css input>:48:3: Autoplacement does not work ' +
1020 'without grid-template-rows property',
1021 'autoprefixer: <css input>:53:3: grid-auto-flow works only if grid-temp' +
1022 'late-rows and grid-template-columns are present in the same rule',
1023 'autoprefixer: <css input>:60:3: grid-gap only works if grid-temp' +
1024 'late(-areas) is being used',
1025 'autoprefixer: <css input>:64:3: Autoplacement does not work ' +
1026 'without grid-template-rows property',
1027 'autoprefixer: <css input>:65:3: grid-gap only works if grid-temp' +
1028 'late(-areas) is being used or both rows and columns have been ' +
1029 'declared and cells have not been ' +
1030 'manually placed inside the explicit grid'
1031 ]
1032 )
1033 })
1034
1035 test('shows Grid warnings only for IE', () => {
1036 let input = 'a { grid-template-rows: repeat(auto-fit, 1px) }'
1037 let instance = autoprefixer({
1038 grid: true,
1039 overrideBrowserslist: 'chrome 27'
1040 })
1041 let result = postcss([instance]).process(input)
1042 equal(result.warnings().length, 0)
1043 })
1044
1045 test('warns if rule has both grid-area and grid-(row|column) decls', () => {
1046 let input = read('grid-area')
1047 let instance = prefixer('grid-area')
1048 let result = postcss([instance]).process(input)
1049 equal(
1050 result.warnings().map(i => i.toString()),
1051 [
1052 'autoprefixer: <css input>:28:3: You already have a grid-area ' +
1053 'declaration present in the rule. You should use either ' +
1054 'grid-area or grid-row, not both',
1055 'autoprefixer: <css input>:29:3: You already have a grid-area ' +
1056 'declaration present in the rule. You should use either ' +
1057 'grid-area or grid-column, not both',
1058 'autoprefixer: <css input>:34:3: You already have a grid-area ' +
1059 'declaration present in the rule. You should use either ' +
1060 'grid-area or grid-column, not both'
1061 ]
1062 )
1063 })
1064
1065 test('warns if rule with grid-area has no parent with grid-template', () => {
1066 let input = read('grid-template-areas')
1067 let instance = prefixer('grid-area')
1068 let result = postcss([instance]).process(input)
1069
1070 equal(
1071 result
1072 .warnings()
1073 .map(i => i.toString())
1074 .filter(str => str.includes('grid-template')),
1075 [
1076 'autoprefixer: <css input>:144:3: Autoprefixer cannot find ' +
1077 'a grid-template containing the duplicate grid-area ' +
1078 '"child" with full selector matching: .uncle',
1079 'autoprefixer: <css input>:149:3: Autoprefixer cannot find ' +
1080 'a grid-template containing the duplicate grid-area ' +
1081 '"child" with full selector matching: .uncle',
1082 'autoprefixer: <css input>:154:3: Autoprefixer cannot find ' +
1083 'a grid-template containing the duplicate grid-area ' +
1084 '"child" with full selector matching: .grand-parent .uncle-second',
1085 'autoprefixer: <css input>:159:3: Autoprefixer cannot find ' +
1086 'a grid-template containing the duplicate grid-area ' +
1087 '"child" with full selector matching: .grand-parent .uncle-second',
1088 'autoprefixer: <css input>:164:3: Autoprefixer cannot find ' +
1089 'a grid-template containing the duplicate grid-area ' +
1090 '"child" with full selector matching: .grand-parent .father.uncle',
1091 'autoprefixer: <css input>:169:3: Autoprefixer cannot find ' +
1092 'a grid-template containing the duplicate grid-area ' +
1093 '"child" with full selector matching: .grand-parent.uncle .father'
1094 ]
1095 )
1096 })
1097
1098 test('should preserve @media rules with grid-area', () => {
1099 let input = read('grid-area-media-sequence')
1100 let output = read('grid-area-media-sequence.out')
1101 let instance = prefixer('grid-area')
1102 let result = postcss([instance]).process(input)
1103 equal(result.css, output)
1104 })
1105
1106 test('should merge complex duplicate grid-area rules successfully', () => {
1107 let input = read('grid-areas-duplicate-complex')
1108 let output = read('grid-areas-duplicate-complex.out')
1109 let instance = prefixer('grid-area')
1110 let result = postcss([instance]).process(input)
1111 equal(result.css, output)
1112 })
1113
1114 test('ignores values for CSS3PIE props', () => {
1115 let css = read('pie')
1116 equal(postcss([compiler]).process(css).css, css)
1117 })
1118
1119 test('add prefix for backface-visibility for Safari 9', () => {
1120 let input =
1121 'a{ ' + 'backface-visibility: hidden; ' + 'transform-style: preserve-3d }'
1122 let ap = autoprefixer({
1123 flexbox: false,
1124 overrideBrowserslist: ['Safari 9']
1125 })
1126 equal(
1127 postcss([ap]).process(input).css,
1128 'a{ ' +
1129 '-webkit-backface-visibility: hidden; ' +
1130 'backface-visibility: hidden; ' +
1131 'transform-style: preserve-3d }'
1132 )
1133 })
1134
1135 test('supports text-decoration', () => {
1136 let input = read('text-decoration')
1137 let output = read('text-decoration.out')
1138 let instance = prefixer('text-decoration')
1139 let result = postcss([instance]).process(input)
1140
1141 equal(universalizer(result.css), universalizer(output))
1142 equal(
1143 result.warnings().map(i => i.toString()),
1144 [
1145 'autoprefixer: <css input>:32:3: Replace text-decoration-skip: ink ' +
1146 'to text-decoration-skip-ink: auto, because spec had been changed'
1147 ]
1148 )
1149 })
1150
1151 test('supports text-decoration shorthand', () => {
1152 let input = read('text-decoration')
1153 let output = read('text-decoration.shorthand.out')
1154 let instance = prefixer('text-decoration-shorthand')
1155 let result = postcss([instance]).process(input)
1156
1157 equal(universalizer(result.css), universalizer(output))
1158 })
1159
1160 test('supports -webkit-line-clamp', () => {
1161 let input = read('webkit-line-clamp')
1162 let output = read('webkit-line-clamp.out')
1163 let result = postcss([cleaner]).process(input)
1164
1165 equal(universalizer(result.css), universalizer(output))
1166 equal(result.warnings().length, 0)
1167 })
1168
1169 test('supports latest Firefox stretch', () => {
1170 let input = read('intrinsic')
1171 let output = read('intrinsic.ff')
1172 let result = postcss([
1173 autoprefixer({ overrideBrowserslist: 'firefox 90' })
1174 ]).process(input)
1175 equal(result.css, output)
1176 equal(result.warnings().length, 2)
1177 })
1178
1179 test.run()