we (web engine): Experimental web browser project to understand the limits of Claude

Form submission #155

open opened by pierrelf.com

Summary#

Implement HTML form submission: collecting form data, encoding it, and sending the HTTP request.

Details#

Submit triggers#

  • Click on `<input type="submit">` or `<button type="submit">`
  • Press Enter in a single-line text input
  • Call `form.submit()` from JavaScript (bypasses validation)
  • Call `form.requestSubmit()` from JavaScript (runs validation first)

Submit algorithm#

  1. Determine submitter element
  2. Run constraint validation (unless `novalidate` attribute on form or `formnovalidate` on submitter)
  3. If validation fails, fire `invalid` events, abort submission
  4. Construct entry list from form's submittable elements:
    • Include name/value pairs for enabled, named controls
    • Skip disabled controls, unchecked checkboxes/radios, unselected file inputs
    • For select: include value of each selected option
    • For textarea: include current text value
  5. Fire `submit` event (cancelable)
  6. Encode entry list based on `enctype`
  7. Navigate using `action` URL, `method`, and encoded data

Encoding types#

  • `application/x-www-form-urlencoded` (default): percent-encode name=value pairs joined with &
  • `multipart/form-data`: MIME multipart encoding with boundary
  • `text/plain`: name=value pairs separated by newlines

Form attributes#

  • `action`: target URL (default: current page URL)
  • `method`: GET or POST (default: GET)
  • `enctype`: encoding type
  • `target`: browsing context for response (_self, _blank, etc.)
  • Submitter overrides: `formaction`, `formmethod`, `formenctype`, `formtarget`
  • `novalidate` / `formnovalidate`: skip validation

GET vs POST#

  • GET: append encoded data as URL query string, navigate
  • POST: send encoded data as request body via net crate

Acceptance criteria#

  • Submit button click and Enter key trigger form submission
  • Constraint validation runs before submission (unless novalidate)
  • Entry list correctly collects name/value pairs from all control types
  • `application/x-www-form-urlencoded` encoding works correctly
  • `multipart/form-data` encoding works correctly
  • GET submission appends query string to action URL
  • POST submission sends request body with correct Content-Type
  • `submit` event fires and is cancelable
  • `form.submit()` and `form.requestSubmit()` work correctly
  • Submitter attribute overrides (`formaction`, etc.) are respected
  • Tests cover entry list construction, both encoding types, GET/POST, and validation integration

Dependencies#

  • Form element parsing and DOM interfaces
  • Text editing: cursor, selection, and keyboard input
  • HTML5 constraint validation
sign up or login to add to the discussion
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:meotu43t6usg4qdwzenk4s2t/sh.tangled.repo.issue/3mihp2qr7ew2j