diff --git a/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php b/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php index 6ca7131..9e7dae6 100644 --- a/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php +++ b/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php @@ -12,6 +12,7 @@ use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormState; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Render\BubbleableMetadata; use Drupal\Core\Render\RenderContext; use Drupal\views_ui\ViewUI; use Drupal\views\ViewEntityInterface; @@ -206,6 +207,8 @@ protected function ajaxFormWrapper($form_class, FormStateInterface &$form_state) } $form_state->disableCache(); + // Render the form in a render context in order to ensure that cacheable + // metadata is bubbled up. $render_context = new RenderContext(); $callable = function () use ($form_class, &$form_state) { return \Drupal::formBuilder()->buildForm($form_class, $form_state); diff --git a/core/modules/views_ui/src/Tests/FieldUITest.php b/core/modules/views_ui/src/Tests/FieldUITest.php index 34d4215..81d2b7e 100644 --- a/core/modules/views_ui/src/Tests/FieldUITest.php +++ b/core/modules/views_ui/src/Tests/FieldUITest.php @@ -57,11 +57,6 @@ public function testFieldUI() { $this->assertEqual((string) $result[0], '{{ age }} == Age'); $this->assertEqual((string) $result[1], '{{ id }} == ID'); $this->assertEqual((string) $result[2], '{{ name }} == Name'); - - // Ensure the AJAX UI is responding. - $ajax_url = 'admin/structure/views/ajax/handler/test_view/default/field/age'; - $this->drupalGet($ajax_url); - $this->assertResponse(200); } /** diff --git a/core/modules/views_ui/src/Tests/UITestBase.php b/core/modules/views_ui/src/Tests/UITestBase.php index cb676e0..19d77e0 100644 --- a/core/modules/views_ui/src/Tests/UITestBase.php +++ b/core/modules/views_ui/src/Tests/UITestBase.php @@ -83,8 +83,10 @@ protected function drupalGet($path, array $options = array(), array $headers = a // Ensure that each nojs page is accessible via ajax as well. if (strpos($url, 'nojs') !== FALSE) { $url = str_replace('nojs', 'ajax', $url); - $this->drupalGet($url, $options, $headers); + $result = $this->drupalGet($url, $options, $headers); $this->assertResponse(200); + $this->assertHeader('Content-Type', 'application/json'); + $this->assertTrue(json_decode($result), 'Ensure that the AJAX request returned valid content.'); } return parent::drupalGet($path, $options, $headers);