diff -u b/core/modules/system/tests/modules/ajax_test/js/insert-ajax.js b/core/modules/system/tests/modules/ajax_test/js/insert-ajax.js --- b/core/modules/system/tests/modules/ajax_test/js/insert-ajax.js +++ b/core/modules/system/tests/modules/ajax_test/js/insert-ajax.js @@ -20,6 +20,8 @@ var myAjaxObject = Drupal.ajax(ajaxSettings); myAjaxObject.execute(); }); + + $(context).addClass('processed'); } }; })(jQuery, window, Drupal, drupalSettings); diff -u b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php --- b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php @@ -83,33 +83,41 @@ } /** - * Tests that various AJAX responses are correctly wrapped. + * Tests that various AJAX responses with DOM elements are correctly inserted. + * + * After inserting DOM elements, Drupal JavaScript behaviors should be + * reattached and all 'root' elements of type Node.ELEMENT_NODE need to be + * part of the context. */ - public function testWrap() { + public function testInsert() { $assert = $this->assertSession(); $this->drupalGet('ajax-test/insert'); // Test that no additional wrapper is added when inserting already wrapped - // response data. + // response data and all root node elements (context) are processed + // correctly. $this->clickLink('Link pre-wrapped'); $assert->assertWaitOnAjaxRequest(); - $assert->responseContains('
some string
final string
'); + $assert->responseContains('some string
final string
'); } }