mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-14 11:22:15 +01:00
feat(chromium): await thenable waitForExpression (#1617)
This commit is contained in:
@@ -708,7 +708,15 @@ func waitForExpressionBeforePrintActionFunc(logger *slog.Logger, disableJavaScri
|
||||
return fmt.Errorf("context done while evaluating '%s': %w", expression, ctx.Err())
|
||||
case <-ticker.C:
|
||||
var ok bool
|
||||
evaluate := chromedp.Evaluate(expression, &ok)
|
||||
// If the provided expression is a async function (thenable) it will be awaited
|
||||
// (async () => {
|
||||
// document.querySelector('#accept').click();
|
||||
// await new Promise(r => setTimeout(r, 2000));
|
||||
// return true;
|
||||
// })()
|
||||
evaluate := chromedp.Evaluate(expression, &ok, func(p *runtime.EvaluateParams) *runtime.EvaluateParams {
|
||||
return p.WithAwaitPromise(true)
|
||||
})
|
||||
|
||||
err := evaluate.Do(ctx)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user