Replace arbitrary sleep(200ms) with proper wait for Runtime.executionContextCreated
event in the relay server. This ensures pages are fully ready before Runtime.enable
returns to Playwright, fixing intermittent 'page not found' errors.
## Debugger Tests Summary
### 1. should use Debugger class to set breakpoints and inspect variables
Tests the core debugging workflow when paused at a debugger statement:
- Creates a Debugger instance with a CDP session
- Verifies isPaused() returns false initially
- Executes code with a debugger statement that pauses execution
- Verifies isPaused() returns true when paused
- Calls getLocation() and verifies:
- callstack[0].functionName is 'testFunction'
- sourceContext contains the debugger keyword
- Calls inspectVariables({ scope: 'local' }) and verifies local variables:
{ localVar: "hello", numberVar: 42 }
- Calls evaluate({ expression }) in paused context and verifies it can access local variables
- Calls resume() and verifies isPaused() returns false
### 2. should list scripts with Debugger class
Tests script discovery after page load:
- Navigates to news.ycombinator.com (has external JS files)
- Enables debugger, reloads page to trigger Debugger.scriptParsed events
- Calls listScripts() and verifies:
- Returns array with scriptId and url properties
- At least one script exists
- Calls listScripts({ search: 'hn' }) and verifies filtering works
### 3. should manage breakpoints with Debugger class
Tests breakpoint CRUD operations:
- Verifies listBreakpoints() returns empty array initially
- Calls setBreakpoint({ file, line }) and verifies:
- Returns a breakpoint ID string
- listBreakpoints() now has 1 entry with correct id, file, line
- Calls deleteBreakpoint({ breakpointId }) and verifies:
- listBreakpoints() returns empty array again
### 4. should step through code with Debugger class
Tests stepping methods and call stack navigation:
- Executes nested functions (outer calls inner) with debugger in inner
- When paused, verifies getLocation().callstack:
- Has at least 2 frames
- Frame 0 is inner, frame 1 is outer
- Calls stepOver() and verifies line number advances
- Calls stepOut() and verifies:
- Now in outer function (stepped out of inner)
- Calls resume() to finish