Skip to content

defaultTimeout is a reserved argument name for JavaScript extension keywords #5321

Closed

Description

@aaltat

Describe the change
#5318 lets JavaScript extension functions request defaultTimeout, the library timeout in milliseconds. The keyword that Browser generates for the function fills it in at each call with the current library timeout, so a function can give a context it created itself the library timeout with context.setDefaultTimeout(defaultTimeout).

This makes defaultTimeout a reserved argument name, like page, context, browser, logger, playwright and adoptContext.

Release notes
This is a behaviour change for JavaScript extensions. If an exported function has a parameter named defaultTimeout:

  • defaultTimeout is no longer an argument of the generated keyword. Calling the keyword with defaultTimeout=... fails with an unexpected keyword argument error.
  • The function always receives the library timeout in milliseconds, and a JavaScript default value such as defaultTimeout = 5000 is not used.

Rename the parameter to keep it as a keyword argument.

Introduced in #5318 (adoptContext, #5317).

Activity

  1. added this to the v20.7.0 milestone on Oct 11, 2026
  2. added theissue type on Oct 11, 2026
  3. aaltat commented on Oct 11, 2026

    @aaltat
    MemberAuthor

    Someone could say that this could be backwards incompatible change, but the risk is low and this is how we grown the reserved names in the past, so marking this as feature only.

  4. aaltat commented on Oct 11, 2026

    @aaltat
    MemberAuthor

    #5318 is merged, closing the issue.

  5. aaltat commented on Oct 17, 2026

    @aaltat
    MemberAuthor

    #5354 extends this to call_js_keyword, the way a Python library or plugin calls a JavaScript extension function by name. Add this to the release notes:

    • call_js_keyword now fills in defaultTimeout with the library timeout in milliseconds when the caller leaves it out. Before, the function got undefined (or its JavaScript default value).
    • A defaultTimeout the caller passes still wins, so a library that keeps a timeout of its own, such as one that adopts a context it created, can pass its own value. It is the only injected argument a caller can override; page, context, browser, logger, playwright and adoptContext are always filled in by the library.
    • The keyword that Browser generates for a function is unchanged: defaultTimeout is not one of its arguments, and the function always gets the library timeout, which a test changes with Set Browser Timeout.
    • The first argument of Browser.call_js_keyword, keyword_name, is now positional-only, so a JavaScript function can have an argument named keyword_name. Calling call_js_keyword(keyword_name="...") by name now fails.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions