feat(chromium): add support for emulated media features in Chromium (#1474)

Closes https://github.com/gotenberg/gotenberg/issues/1460

It can be easier to print a "clean" PDF of some pages if you emulate
media features like `prefers-reduced-motion`. Add support for that
emulation.
This commit is contained in:
Daniel Moran
2026-02-17 11:16:28 -08:00
committed by GitHub
parent 12c25a2d21
commit 82401bdfdd
8 changed files with 263 additions and 10 deletions

View File

@@ -20,6 +20,14 @@
display: none;
}
}
#reduced-motion {
display: none;
}
@media (prefers-reduced-motion: reduce) {
#reduced-motion {
display: block;
}
}
</style>
</head>
<body>
@@ -29,6 +37,7 @@
</p>
<p id="print">Emulated media type is 'print'.</p>
<p id="screen">Emulated media type is 'screen'.</p>
<p id="reduced-motion">Prefers reduced motion.</p>
<p id="javascript" style="display: none">JavaScript is enabled.</p>
<iframe src="file:///etc/passwd"></iframe>

View File

@@ -28,6 +28,14 @@
display: none;
}
}
#reduced-motion {
display: none;
}
@media (prefers-reduced-motion: reduce) {
#reduced-motion {
display: block;
}
}
</style>
</head>
<body>
@@ -37,6 +45,7 @@
</p>
<p id="print">Emulated media type is 'print'.</p>
<p id="screen">Emulated media type is 'screen'.</p>
<p id="reduced-motion">Prefers reduced motion.</p>
<p id="javascript" style="display: none">JavaScript is enabled.</p>
<iframe src="/etc/passwd"></iframe>
<iframe src="\\localhost/etc/passwd"></iframe>