Commit d61e118
authored
fix: active page context (#251)
### Why
When a page closes (e.g., splash screen during auth), `get_active_page()` still returns the closed page instead of switching to a remaining open page.
### What Changed
Added `_handle_page_close()` in `context.py` to switch active page to a remaining open page when the current active page closes.
### Test Plan
Verified with multi-page script: open two pages, close active page, confirm `get_active_page()` returns remaining open page. Existing unit tests pass.
<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Fixes stale active page after a page closes. When the active page closes (e.g., splash during auth), we now switch to a remaining open page or clear the active page.
- **Bug Fixes**
- Added _handle_page_close to update the active page on close events.
- Uses the page switch lock to avoid race conditions; 30s timeout with error logging.
- Wired to Playwright's page "close" event; also unregisters frame IDs.
- get_active_page() now returns the correct remaining page (or None if none remain).
<sup>Written for commit a7cb745. Summary will update automatically on new commits.</sup>
<!-- End of auto-generated description by cubic. -->1 parent 69289b9 commit d61e118
1 file changed
+47
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
144 | 188 | | |
145 | 189 | | |
146 | 190 | | |
| |||
220 | 264 | | |
221 | 265 | | |
222 | 266 | | |
223 | | - | |
224 | 267 | | |
225 | 268 | | |
226 | 269 | | |
227 | 270 | | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
228 | 274 | | |
229 | 275 | | |
230 | 276 | | |
| |||
0 commit comments