Evaluates expr in the page, optionally awaiting a returned promise, and
returns the resulting value. This is the primitive all element work uses,
and an escape hatch for one-off scripts. Unlike most pz_*() functions it
ends the chain: it returns the value, not the context.
Examples
page <- pz_open(pz_example("tasks"))
pz_js(page, "document.querySelectorAll('.task').length")
#> [1] 7
# Arrays come back as lists
pz_js(page, "[...document.querySelectorAll('.task-priority')].map(el => el.textContent)")
#> [[1]]
#> [1] "high"
#>
#> [[2]]
#> [1] "high"
#>
#> [[3]]
#> [1] "normal"
#>
#> [[4]]
#> [1] "low"
#>
#> [[5]]
#> [1] "normal"
#>
#> [[6]]
#> [1] "low"
#>
#> [[7]]
#> [1] "normal"
#>
# Returned promises are awaited
pz_js(page, "new Promise(resolve => setTimeout(() => resolve('done'), 100))")
#> [1] "done"
pz_close(page)
