Skip to content

JavaScript extensions get the string "RESERVED" instead of null or undefined when there is no page, context or browser #5320

Closed

Description

@aaltat

Describe the bug
A JavaScript extension function that requests page, context or browser receives the string "RESERVED" when that value does not exist. For example: no page is open, or browser is requested while a persistent context is active, where the browser is null.

Python sends ("page", "RESERVED") as a placeholder for every injected argument, and extensionKeywordCall in node/playwright-wrapper/playwright-state.ts replaced it like this:

apiArguments.get(argName) || namedArguments[argName]

When the real value is null or undefined, || falls back to the placeholder, so the extension gets "RESERVED". A guard such as if (!page) therefore never worked, because the string is truthy.

Fix
Fixed in #5318: injected values are passed on as they are, with apiArguments.has(argName) ? apiArguments.get(argName) : namedArguments[argName]. The extension now receives null or undefined.

Release notes
This is a behaviour change for JavaScript extensions. An extension that runs without a page, context or browser now gets null or undefined instead of the string "RESERVED". Only code that compared against the undocumented "RESERVED" marker is affected.

Found while reviewing #5318 (adoptContext, #5317), where browser is null for an adopted context.

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

    #5318 is merged, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions