mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-17 20:52:14 +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())
|
return fmt.Errorf("context done while evaluating '%s': %w", expression, ctx.Err())
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
var ok bool
|
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)
|
err := evaluate.Do(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user