Skip to content

test: pin form.clk and beforeSend extraData as Drupal and Backdrop use them - #647

Merged
kevindb merged 2 commits into
mainfrom
test-cms-ajax-contracts
Nov 27, 2026
Merged

kevindb merged 2 commits into
mainfrom
test-cms-ajax-contracts

Conversation

@kevindb

@kevindb kevindb commented Nov 27, 2026

Copy link
Copy Markdown
Member

Summary

Pins two behaviors that Drupal's and Backdrop's misc/ajax.js rely on, which no test covered. Test-only; no source change.

misc/ajax.js (Drupal, Backdrop)
  element.form.clk = element        # set by the page, not by ajaxForm's click capture
  $form.ajaxSubmit({ data, beforeSend })
    beforeSend(xhr, options)
      options.extraData.ajax_iframe_upload = "1"   # added after data is in place
Test File
sends the button the page set on form.clk, at its place, in a urlencoded body xhr-transport.test.js
sends it, at its place, in a FormData upload xhr-transport.test.js
posts extraData keys a beforeSend callback adds, with the data option, as hidden fields of an iframe upload iframe-transport.test.js

Evidence

  • Before: with the behavior removed in src, the tests fail:

    • Drop the form.clk fallback in submitterOf: both XHR tests fail.
    • Hand beforeSend a deep copy of the settings: the iframe test fails.

    After: with src unchanged, all three pass on jQuery 1.7.2, 3.7.1 and 4.0.0 in Chromium, and in WebKit. They also pass unchanged on the 5.0 branch (feat!: jquery-form 5.0 #646) on jQuery 3.5.0, 3.7.1 and 4.0.0, so they carry over when main is merged into it.

  • Found while running Backdrop 1.35.2 and Drupal 11.4.14 against 4.6.0 and 5.0.0-beta.1. Their image upload, "Add another item" and Views UI flows behaved the same as with their bundled 4.3.0 copies.

Merge Danger

Door: two-way

Blast Radius: tests

🤖 Generated with Claude Code

@kevindb
kevindb merged commit 6c29155 into main Nov 27, 2026
23 checks passed
@kevindb
kevindb deleted the test-cms-ajax-contracts branch November 27, 2026 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant