()
| 370 | } |
| 371 | |
| 372 | async _after() { |
| 373 | if (!this.isRunning) return |
| 374 | |
| 375 | // Clear popup state to prevent leakage between tests |
| 376 | popupStore.clear() |
| 377 | |
| 378 | // close other sessions |
| 379 | const contexts = this.browser.browserContexts() |
| 380 | const defaultCtx = contexts.shift() |
| 381 | |
| 382 | await Promise.all(contexts.map(c => c.close())) |
| 383 | |
| 384 | if (this.options.restart) { |
| 385 | this.isRunning = false |
| 386 | return this._stopBrowser() |
| 387 | } |
| 388 | |
| 389 | // ensure this.page is from default context |
| 390 | if (this.page) { |
| 391 | const existingPages = defaultCtx.targets().filter(t => t.type() === 'page') |
| 392 | await this._setPage(await existingPages[0].page()) |
| 393 | } |
| 394 | |
| 395 | if (this.options.keepBrowserState) return |
| 396 | |
| 397 | if (!this.options.keepCookies) { |
| 398 | this.debugSection('Session', 'cleaning cookies and localStorage') |
| 399 | await this.clearCookie() |
| 400 | } |
| 401 | const currentUrl = await this.grabCurrentUrl() |
| 402 | |
| 403 | if (currentUrl.startsWith('http')) { |
| 404 | await this.executeScript('localStorage.clear();').catch(err => { |
| 405 | if (!(err.message.indexOf("Storage is disabled inside 'data:' URLs.") > -1)) throw err |
| 406 | }) |
| 407 | await this.executeScript('sessionStorage.clear();').catch(err => { |
| 408 | if (!(err.message.indexOf("Storage is disabled inside 'data:' URLs.") > -1)) throw err |
| 409 | }) |
| 410 | } |
| 411 | await this.closeOtherTabs() |
| 412 | return this.browser |
| 413 | } |
| 414 | |
| 415 | _afterSuite() {} |
| 416 |
nothing calls this directly
no test coverage detected