Skip to content

Conversation

@seanmcguire12
Copy link
Member

@seanmcguire12 seanmcguire12 commented Nov 25, 2025

why

  • currently, we add the init scripts to the main world
  • this is problematic, because page.evaluate() uses the v3-world
  • this means that you can't easily evaluate the script you add with addInitScript()

what changed

  • makes sure that page.evaluate() uses the main world

test plan

  • added a test which calls page.evaluate() on a script added via context.addInitScript()

@changeset-bot
Copy link

changeset-bot bot commented Nov 25, 2025

🦋 Changeset detected

Latest commit: 492f0a5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@browserbasehq/stagehand Patch
@browserbasehq/stagehand-evals Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@seanmcguire12 seanmcguire12 changed the title [fix]: make context.addInitScript() use correct isolated world [fix]: make context.addInitScript() use main world Dec 1, 2025
@seanmcguire12 seanmcguire12 changed the title [fix]: make context.addInitScript() use main world [fix]: make page.evaluate() use main world Dec 1, 2025
@seanmcguire12
Copy link
Member Author

@greptielai

@seanmcguire12
Copy link
Member Author

@cubic-dev-ai review this PR

@cubic-dev-ai
Copy link

cubic-dev-ai bot commented Dec 1, 2025

@cubic-dev-ai review this PR

@seanmcguire12 I've started the AI code review. It'll take a few minutes to complete.

@browserbase browserbase deleted a comment from greptile-apps bot Dec 1, 2025
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 4 files

Prompt for AI agents (all 1 issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/core/lib/v3/tests/context-addInitScript.spec.ts">

<violation number="1" location="packages/core/lib/v3/tests/context-addInitScript.spec.ts:127">
P2: Use a local `data:` URL (or other deterministic fixture) instead of hitting `https://example.com` so the test remains reliable offline.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

@seanmcguire12 seanmcguire12 deleted the seanmcguire/stg-1012-make-contextaddinitscript-add-to-correct-js-world branch December 2, 2025 00:45
@seanmcguire12 seanmcguire12 restored the seanmcguire/stg-1012-make-contextaddinitscript-add-to-correct-js-world branch December 2, 2025 00:45
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.

2 participants