Skip to content

Commit 0c5ab2d

Browse files
committed
test(css): cover the tables no stylesheet reaches
Measured every lookup table in lib/css/data.js against configCases, wpt and the framework corpus: 34 held names nothing spelled, and a rewrite nothing spells has no page behind it. Five cases take every one to full — 149 colour names beside the system ones that are not rewritten, the two-value display forms, each named cubic-bezier, the canonical spellings, `@document`, and the 244 property names and 19 selectors nothing else writes.
1 parent 5307497 commit 0c5ab2d

34 files changed

Lines changed: 925 additions & 0 deletions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"webpack": patch
3+
---
4+
5+
Cover the CSS lookup tables no stylesheet in the corpus reaches.

‎.gitattributes‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ test/configCases/html/minimize-shell-end-tags/** eol=lf
3434
test/configCases/html/minimize-lookup-decoded-value/** eol=lf
3535
test/configCases/html/minimize-rewrite-referenced-value/** eol=lf
3636
test/configCases/html/minimize-spell-back-referenced-value/** eol=lf
37+
test/configCases/css/minify-at-rules-and-values/** eol=lf
38+
test/configCases/css/minify-color-names/** eol=lf
39+
test/configCases/css/minify-modern-longhands/** eol=lf
40+
test/configCases/css/minify-selectors-and-functions/** eol=lf
41+
test/configCases/css/minify-value-keywords/** eol=lf
3742
test/configCases/performance/unused-reexports/** eol=lf
3843
test/configCases/performance/unused-reexports-error/** eol=lf
3944
examples/* eol=lf
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2+
3+
exports[`ConfigCacheTestCases css minify-at-rules-and-values minify-at-rules-and-values should compile 1`] = `"@document url(https://a.test/){.a{color:red}.b{color:blue}}@-moz-document url-prefix(){.c{color:green}}.d{mask-border:initial}.e{text-emphasis:initial}.f{background:repeating-radial-gradient(red 0%,blue)}.g{background:cross-fade(url(51b834b7c1ef0b59ea50.png) 50%,url(51b834b7c1ef0b59ea50.png))}"`;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2+
3+
exports[`ConfigTestCases css minify-at-rules-and-values minify-at-rules-and-values should compile 1`] = `"@document url(https://a.test/){.a{color:red}.b{color:blue}}@-moz-document url-prefix(){.c{color:green}}.d{mask-border:initial}.e{text-emphasis:initial}.f{background:repeating-radial-gradient(red 0%,blue)}.g{background:cross-fade(url(51b834b7c1ef0b59ea50.png) 50%,url(51b834b7c1ef0b59ea50.png))}"`;
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Loading
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import "./style.css";
2+
3+
// The at-rules and value functions the tables name, so a table entry with no
4+
// page behind it is exercised here.
5+
it("should read the at-rules and value functions the tables name", () => {
6+
expect(true).toBe(true);
7+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* The two at-rules that carry a vendor spelling and still gather. */
2+
@document url("https://a.test/") {
3+
.a { color: red }
4+
}
5+
@document url("https://a.test/") {
6+
.b { color: blue }
7+
}
8+
@-moz-document url-prefix() {
9+
.c { color: green }
10+
}
11+
12+
/* Shorthands whose initial keyword is the whole value. */
13+
.d { mask-border: initial }
14+
.e { text-emphasis: initial }
15+
16+
/* The gradient and image functions the tables name but nothing spells. */
17+
.f { background: repeating-radial-gradient(red 0%, blue 100%) }
18+
.g { background: cross-fade(url(a.png) 50%, url(b.png)) }
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"use strict";
2+
3+
const fs = require("fs");
4+
const path = require("path");
5+
6+
module.exports = {
7+
afterExecute(options) {
8+
const css = fs.readFileSync(
9+
path.join(options.output.path, "bundle0.css"),
10+
"utf8"
11+
);
12+
expect(css).toMatchSnapshot();
13+
14+
// Two `@document` blocks with the same prelude gather into one; the
15+
// prefixed spelling is a different rule and stays apart.
16+
expect(css).toContain("@document url(https://a.test/){.a{color:red}");
17+
expect(css).toContain("@-moz-document");
18+
expect(css.match(/@document/g)).toHaveLength(1);
19+
// A shorthand whose initial keyword is the whole value keeps it.
20+
expect(css).toContain("mask-border:initial");
21+
expect(css).toContain("text-emphasis:initial");
22+
// The last colour stop's position is the one the gradient implies.
23+
expect(css).toContain("repeating-radial-gradient(red 0%,blue)");
24+
expect(css).toContain("cross-fade(");
25+
}
26+
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"use strict";
2+
3+
const MinimizerPlugin = require("minimizer-webpack-plugin");
4+
const cssMinify = require("../../../../lib/css/cssMinify");
5+
6+
/** @type {import("../../../../").Configuration} */
7+
module.exports = {
8+
target: "web",
9+
mode: "production",
10+
output: {
11+
pathinfo: false
12+
},
13+
optimization: {
14+
minimize: true,
15+
minimizer: [
16+
{
17+
apply: (compiler) => {
18+
new MinimizerPlugin({
19+
test: /\.css(\?.*)?$/i,
20+
minify: cssMinify
21+
}).apply(/** @type {EXPECTED_ANY} */ (compiler));
22+
}
23+
}
24+
]
25+
},
26+
experiments: {
27+
css: true
28+
}
29+
};

0 commit comments

Comments
 (0)