In Drupal 7 core, all PHP code that needed to run in response to an AJAX request was bound to distinct paths in hook_menu(). Therefore, simpletest's drupalGetAJAX() and drupalPostAJAX() didn't need to supply any special http headers in order to test the system. Early in Drupal 8, we started running some AJAX related code in Symfony event listeners based on whether $request->isXmlHttpRequest() returned true, which is a commonly used approach in other projects, and we therefore added the corresponding header to Simpletest. However, a more RESTful approach is to content negotiate on the 'Accept' header, and we switched to that at some point in the D8 cycle. However, we forgot to update Simpletest to match, and as a result, it's no longer triggering the same code paths that a real AJAX submission from a browser does. One consequence of that is that #1941288: Regression: ajaxPageState not being updated with AjaxResponse, assets (js/css) being added twice is a current bug (regression) in HEAD that testbot failed to catch. It has also resulted in testbot failing to catch other AJAX bugs in D8 patches that we subsequently needed to revert after finding the bug in manual testing (#1938980-25: Fix Ajax system; the last remnants of the old API must be swept away).

This issue cleans up Simpletest to set the correct headers, so that it correctly tests D8's AJAX requests. It also comments out the two test assertion that now (correctly) fail, leaving it to #1941288: Regression: ajaxPageState not being updated with AjaxResponse, assets (js/css) being added twice to fix that bug and reinstate the assertions.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Status: Needs review » Needs work

The last submitted patch, simpletest-ajax.patch, failed testing.

effulgentsia’s picture

Status: Needs work » Needs review
FileSize
7.18 KB
effulgentsia’s picture

Issue summary: View changes

Updated issue summary.

effulgentsia’s picture

Issue summary: View changes

Updated issue summary.

effulgentsia’s picture

I updated the summary, so this is ready for an RTBC (or feedback) from one of the (few) people following this :) Thanks.

larowlan’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed d532f23 and pushed to 8.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Updated issue summary.