Skip to content

feat: fill defaultTimeout in call_js_keyword when the caller leaves it out - #5354

Merged
aaltat merged 4 commits into
MarketSquare:mainfrom
aaltat:js-keyword-default-timeout
Oct 17, 2026
Merged

aaltat merged 4 commits into
MarketSquare:mainfrom
aaltat:js-keyword-default-timeout

Conversation

@aaltat

@aaltat aaltat commented Oct 17, 2026

Copy link
Copy Markdown
Member

Summary

A JavaScript extension keyword has two routes into Node: the generated keyword, and call_js_keyword for a Python library built on Browser. Only the generated keyword filled the injected argument defaultTimeout, although the jsextension docstring said the library fills it. Follow-up to #5318, on top of #5352.

 generated keyword (Browser._jskeyword_call)
-  copy of the gRPC call, streaming and decoding
-  defaultTimeout = int(self.timeout)
+  call_js_keyword(name, **its arguments)

 call_js_keyword(keyword_name, /, **args)
+  args.setdefault("defaultTimeout", int(self.timeout))
   injected names -> "RESERVED"
   join bodyPart chunks, or None
-  json branch (Node never sets json on an extension response)
  • A value the caller passes wins, so a library with a timeout of its own (the Electron library today, others that adopt a context they create) keeps it. Called as a keyword, the function always gets the library timeout; Robot users change it with Set Browser Timeout.
  • Every call now sends defaultTimeout, also to functions that do not declare it. Node passes a function only the names it declares, so nothing changes for them.
  • keyword_name is positional-only, so a JavaScript argument with that name no longer clashes with it.
  • call_js_keyword gets a docstring; the jsextension docstring says who fills defaultTimeout. Browser/CONTEXT.md names JavaScript extension keyword and injected argument.

Evidence

  • Before: call_js_keyword("openOwnContext", url="https://a.b") sends [["url", "https://a.b"]]; the function gets defaultTimeout === undefined.
    After: it sends [["url", "https://a.b"], ["defaultTimeout", 7000]]; with defaultTimeout=5000 it sends 5000.
  • utest/test_js_extension_call.py: 12 passed. New: filled when left out, the caller's value kept, an injected name the caller passes sent as "RESERVED", an argument named keyword_name. The test: characterize the generated JavaScript extension keyword #5352 tests guard the refactor unchanged, except that two payloads now end with defaultTimeout.
  • inv atest --suite "05 JS Tests": 59 passed; --suite "09 Plugins": 19 passed.

Merge Danger

Door: two-way

Blast Radius: small

Libraries that call call_js_keyword: a function that declares defaultTimeout now gets the library timeout instead of undefined when the caller leaves it out, and passing keyword_name= by name now fails. A subclass that overrides call_js_keyword now also sees generated keyword calls.

🤖 Generated with Claude Code

aaltat and others added 4 commits October 17, 2026 17:28
…s_keyword

The generated keyword copied the streaming and decoding code of
call_js_keyword. It now passes its arguments to call_js_keyword, so both
routes send and read the same way. The json branch is dropped: Node
returns every extension result as bodyPart chunks and never sets json.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t out

A Python library that calls a JavaScript extension function with
call_js_keyword now gets the library timeout as defaultTimeout, as a
generated keyword does. A value the caller passes still wins, for a
library that keeps a timeout of its own. call_js_keyword gets a
docstring and the jsextension docstring says who fills defaultTimeout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rd_name

The generated keyword passes its arguments to call_js_keyword by name, so
an argument named keyword_name clashed with call_js_keyword's own first
parameter. It is now positional-only. The jsextension docstring says a
generated keyword always sends the library timeout, and the glossary uses
the context's own terms for the two routes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aaltat
aaltat merged commit c3d3512 into MarketSquare:main Oct 17, 2026
30 checks passed
@aaltat
aaltat deleted the js-keyword-default-timeout branch October 17, 2026 15:01
d-biehl added a commit to d-biehl/robotframework-browser.org that referenced this pull request Oct 17, 2026
MarketSquare/robotframework-browser#5354 makes call_js_keyword fill in defaultTimeout with the library timeout when the caller leaves it out. The Python example no longer passes it, a new bullet says when to pass your own, and the warning in the Python plugins guide names adoptContext and defaultTimeout as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant