public function testGlobalEvents() { $session =
$this->
getSession();
$assert =
$this->
assertSession();
$expected_event_order =
implode('',
['ajaxSuccess', 'ajaxComplete', 'ajaxStop'
]);
$this->
drupalGet('ajax-test/global-events'
);
// Ensure that a non-Drupal Ajax request triggers the expected events, in
// the correct order, a single time.
$session->
executeScript('jQuery.get(Drupal.url("core/COPYRIGHT.txt"))'
);
$assert->
assertWaitOnAjaxRequest();
$assert->
elementTextEquals('css', '#test_global_events_log',
$expected_event_order);
$assert->
elementTextEquals('css', '#test_global_events_log2',
$expected_event_order);
// Ensure that an Ajax request to a Drupal Ajax response, but that was not
// initiated with Drupal.Ajax(), triggers the expected events, in the
// correct order, a single time. We expect $expected_event_order to appear
// twice in each log element, because Drupal Ajax response commands (such
// as the one to clear the log element) are only executed for requests
// initiated with Drupal.Ajax(), and these elements already contain the
// text that was added above.