Skip to content

tests(patches): pin main-world evaluation of statements (#631)#692

Open
neuregex wants to merge 1 commit into
daijro:mainfrom
neuregex:test/main-world-eval-631
Open

tests(patches): pin main-world evaluation of statements (#631)#692
neuregex wants to merge 1 commit into
daijro:mainfrom
neuregex:test/main-world-eval-631

Conversation

@neuregex

Copy link
Copy Markdown
Contributor

Related Issue

Closes #631

Description

Camoufox evaluates page scripts through its own main-world path (the main_world_eval launch flag and the Juggler evaluation handler) rather than Playwright's default isolated world. That path has to wrap whatever string it is handed so a bare statementif (...) { ... }, let x = 1;, a block — still produces a value instead of erroring out.

#631 reported that any script containing an if statement failed with Execution context was destroyed on camoufox 0.4.11, while the equivalent ternary worked. That symptom is gone on current builds (report below), so this PR adds a regression test rather than a fix — the issue looks resolved somewhere between 0.4.11 and 0.5.4, and this pins it so a future Juggler rebase can't silently reintroduce it. The failure mode is a hard error on the caller's side that nothing in the build catches, which is exactly the class of regression tests/patches/ exists for.

Follows the existing convention in that directory (standalone script, main() returning 0/1, CAMOUFOX_EXECUTABLE_PATH support, positive cases in both modes) — same shape as humanize-mouse-trajectory.py.

If you'd rather keep #631 open until the original reporter confirms, feel free to drop the Closes — the test stands on its own either way.

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Other — test coverage only (no patches, browser source or pythonlib/ behaviour touched)

Testing

Verified against v152.0.4-beta.25 (pythonlib 0.5.4, Python 3.12, Windows):

$ CAMOUFOX_EXECUTABLE_PATH=/path/to/camoufox.exe python tests/patches/main-world-eval.py

=== main_world_eval=False ===
  PASS object literal       -> {'foo': 'bar'}
  PASS ternary              -> {'foo': 'bar'}
  PASS if statement         -> {'foo': 'bar'}
  PASS if numeric           -> 1
  PASS let + if             -> 2
  PASS arrow IIFE with if   -> 1

=== main_world_eval=True ===
  PASS object literal       -> {'foo': 'bar'}
  PASS ternary              -> {'foo': 'bar'}
  PASS if statement         -> {'foo': 'bar'}
  PASS if numeric           -> 1
  PASS let + if             -> 2
  PASS arrow IIFE with if   -> 1

PASS: statements and expressions evaluate identically in both modes

$ echo $?
0

Fingerprint Report

This PR adds a single test file and changes no patches, no browser source and no pythonlib/ behaviour, so there is no fingerprint surface for it to affect. Happy to run both suites anyway if you'd like them attached.

Camoufox evaluates page scripts through its own main-world path, which has to
wrap a bare statement (if/let/block) so it still yields a value. daijro#631 reported
that any script containing an if statement failed with "Execution context was
destroyed" on 0.4.11; that symptom is gone on current builds.

Adds a regression test covering expressions and statements across both
main_world_eval modes, so a Juggler rebase cannot silently reintroduce it.

Verified green against v152.0.4-beta.25 (pythonlib 0.5.4).
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.

if(){} statement in js breaks main_world_eval

1 participant