(helper)
| 121 | } |
| 122 | |
| 123 | async function captureStorageState(helper) { |
| 124 | if (typeof helper.grabStorageState === 'function') { |
| 125 | try { |
| 126 | const state = await helper.grabStorageState() |
| 127 | if (state) return state |
| 128 | } catch {} |
| 129 | } |
| 130 | |
| 131 | const state = { cookies: [], origins: [] } |
| 132 | |
| 133 | if (typeof helper.grabCookie === 'function') { |
| 134 | try { |
| 135 | const cookies = await helper.grabCookie() |
| 136 | if (Array.isArray(cookies)) state.cookies = cookies |
| 137 | } catch {} |
| 138 | } |
| 139 | |
| 140 | if (typeof helper.executeScript === 'function') { |
| 141 | try { |
| 142 | const result = await helper.executeScript(() => { |
| 143 | const out = { origin: location.origin, items: [] } |
| 144 | for (let i = 0; i < localStorage.length; i++) { |
| 145 | const name = localStorage.key(i) |
| 146 | out.items.push({ name, value: localStorage.getItem(name) }) |
| 147 | } |
| 148 | return out |
| 149 | }) |
| 150 | if (result?.items?.length) { |
| 151 | state.origins.push({ origin: result.origin, localStorage: result.items }) |
| 152 | } |
| 153 | } catch {} |
| 154 | } |
| 155 | |
| 156 | return state |
| 157 | } |
| 158 | |
| 159 | export async function captureSnapshot(helper, { |
| 160 | dir, |
no test coverage detected