Repository navigation
Conversation
route
force-pushed
the
feat/js-api-finish
branch
from
October 21, 2026 19:20
817cef6 to
4d305bf
Compare
route
force-pushed
the
feat/js-api-compat
branch
2 times, most recently
from
October 22, 2026 06:32
087049a to
1974a94
Compare
route
force-pushed
the
feat/js-api-finish
branch
from
October 22, 2026 06:32
4d305bf to
c017e8c
Compare
route
force-pushed
the
feat/js-api-compat
branch
from
October 22, 2026 07:26
1974a94 to
04b5523
Compare
route
force-pushed
the
feat/js-api-finish
branch
from
October 22, 2026 07:26
c017e8c to
ebc4121
Compare
…keeping the old one with warnings
`#evaluate`, `#evaluate_async`, `#execute`, `#evaluate_func` and `#evaluate_on` had four argument conventions and three
return semantics between them, and scripts reached their arguments through `arguments[0]`. This adds one convention for
all of them, without changing what any existing call returns.
New: keyword arguments become the script's parameters, `page.evaluate("a + b", a: 1, b: 2)`, bound by name when the
script is a function declaration. A script may be a function or arrow declaration, used as-is, and may `await`; promises
it returns are awaited, bounded by `timeout:` and raising `ScriptTimeoutError`, now a `TimeoutError`. Added
`#evaluate_handle`, returning a `Ferrum::RemoteObject`, and `Node#execute`/`Node#evaluate_handle`. Scripts are read by a
small scanner, `Frame::Script`, that skips strings, template literals, regular expressions and comments.
Compatible: a call that doesn't use any of that runs exactly as before, through `Runtime::Legacy`, which also keeps
`#evaluate_async`, `#evaluate_func` and `#evaluate_on`. Positional arguments keep working. What 0.21 will do differently
is detected and warned about with a rewrite, pointing at the first caller outside installed gems: keywords read through
`arguments`, mixed positional and keyword arguments, scripts of several statements or that never run, promises and
thenables that will be awaited, thrown non-Errors that will raise, and nodes `Node#evaluate` will resolve.
`FERRUM_DEPRECATION_WARNINGS=raise` turns the warnings into errors, `0` silences them.
…or 0.21
Removes `Runtime::Legacy`, which kept old-style scripts running as before and warned about what changes here, along with
`#evaluate_async`, `#evaluate_func`, `#evaluate_on` and `Utils::Deprecate`. Every call now takes the new path:
- a returned promise or thenable is awaited, and a rejection raises
- keywords are always named parameters, and mixing them with positional arguments raises `ArgumentError`
- a script of several statements raises `SyntaxError`, and one after a leading line break runs
- a thrown value that isn't an `Error` raises `JavaScriptError`
- `Node#evaluate` resolves nodes and dates instead of returning `{}`
Positional arguments keep working through `arguments[n]`.
route
force-pushed
the
feat/js-api-compat
branch
from
October 22, 2026 16:28
04b5523 to
73bae46
Compare
route
force-pushed
the
feat/js-api-finish
branch
from
October 22, 2026 16:28
ebc4121 to
067be2f
Compare
route
force-pushed
the
feat/js-api-compat
branch
from
October 22, 2026 16:58
73bae46 to
b69b229
Compare
Member
Author
|
Replaced by #659, which now ships the new API behind a js_api switch: 0.21 flips the default and 0.22 removes the legacy code. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second step after #659, for 0.21. It's based on #659's branch, so this diff shows only the removal.
Removed
Frame::Runtime::Legacy: the old evaluation path, its change detection, andevaluate_async,evaluate_funcandevaluate_on.Utils::DeprecateandFERRUM_DEPRECATION_WARNINGS.Frame::Scripthelpers that only the old path used.Behavior in 0.21
Each of these was warned about in 0.20:
ArgumentError.SyntaxError. A script after a leading line break runs.ErrorraisesJavaScriptError.Node#evaluateresolves nodes and dates instead of returning{}.Positional arguments keep working through
arguments[n].