mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-17 12:42:16 +01:00
feat(chromium): always inject paint-callback polyfill to cover waitDelay users
This commit is contained in:
@@ -124,15 +124,14 @@ const paintCallbacksPolyfill = `
|
||||
|
||||
// injectPaintCallbacksPolyfillActionFunc installs the
|
||||
// [paintCallbacksPolyfill] via [page.AddScriptToEvaluateOnNewDocument]
|
||||
// so that it runs before any user script on the navigated page. When
|
||||
// install is false the action is a no-op and the page keeps the native
|
||||
// rAF, ResizeObserver, and IntersectionObserver implementations.
|
||||
func injectPaintCallbacksPolyfillActionFunc(logger *slog.Logger, install bool) chromedp.ActionFunc {
|
||||
// so that it runs before any user script on the navigated page. The
|
||||
// shim is installed unconditionally: the native rAF, ResizeObserver,
|
||||
// and IntersectionObserver APIs do not fire during Chromium's
|
||||
// headless-print render, so replacing them with timer-backed
|
||||
// implementations either restores the behavior the page expects or has
|
||||
// no effect when the page never calls them.
|
||||
func injectPaintCallbacksPolyfillActionFunc(logger *slog.Logger) chromedp.ActionFunc {
|
||||
return func(ctx context.Context) error {
|
||||
if !install {
|
||||
logger.DebugContext(ctx, "paint-callbacks polyfill not requested")
|
||||
return nil
|
||||
}
|
||||
logger.DebugContext(ctx, "inject paint-callbacks polyfill")
|
||||
_, err := page.AddScriptToEvaluateOnNewDocument(paintCallbacksPolyfill).Do(ctx)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user