(event)
| 215 | } |
| 216 | |
| 217 | handleSubmit(event) { |
| 218 | this.sendMessage({ |
| 219 | message: "recState" |
| 220 | }, (response) => { |
| 221 | if (response && response.recState) { |
| 222 | const form = event.target; |
| 223 | const xpaths = this.getXpaths(form); |
| 224 | |
| 225 | // Collect all form data |
| 226 | const formData = new FormData(form); |
| 227 | const data = {}; |
| 228 | for (let [key, value] of formData.entries()) { |
| 229 | if (data[key]) { |
| 230 | // Handle multiple values (like checkboxes with same name) |
| 231 | if (!Array.isArray(data[key])) { |
| 232 | data[key] = [data[key]]; |
| 233 | } |
| 234 | data[key].push(value); |
| 235 | } else { |
| 236 | data[key] = value; |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | this.sendMessage({ |
| 241 | message: "onSubmit", |
| 242 | xPath: xpaths, |
| 243 | formData: data, |
| 244 | action: form.action || '', |
| 245 | method: form.method || 'GET', |
| 246 | target: form.target || '', |
| 247 | enctype: form.enctype || 'application/x-www-form-urlencoded' |
| 248 | }); |
| 249 | |
| 250 | // Note: Not preventing default to allow form to submit if needed |
| 251 | } |
| 252 | }); |
| 253 | } |
| 254 | |
| 255 | handleReset(event) { |
| 256 | this.sendMessage({ |
nothing calls this directly
no outgoing calls
no test coverage detected