diff --git a/core/modules/system/tests/common.test b/core/modules/system/tests/common.test index 46b379e..80abfd2 100644 --- a/core/modules/system/tests/common.test +++ b/core/modules/system/tests/common.test @@ -1553,6 +1553,16 @@ class CommonJavaScriptTestCase extends DrupalWebTestCase { $query_string = variable_get('css_js_query_string', '0'); $this->assertRaw(drupal_get_path('module', 'node') . '/node.js?' . $query_string, t('Query string was appended correctly to js.')); } + + /** + * Tests that Drupal.settings are added when only a settings is added. + */ + function testPageWithOnlyJavascriptSetting() { + $this->drupalGet('common-test/form-with-only-settings'); + $content = $this->drupalGetContent(); + $this->assertTrue(strpos($content, 'Drupal.settings') > 0, t('Drupal.settings is added to the page.')); + $this->assertTrue(strpos($content, '.js') > 0, t('Javascript files are added to the page.')); + } } /** diff --git a/core/modules/system/tests/modules/common_test/common_test.module b/core/modules/system/tests/modules/common_test/common_test.module index 187fee5..03d89c2 100644 --- a/core/modules/system/tests/modules/common_test/common_test.module +++ b/core/modules/system/tests/modules/common_test/common_test.module @@ -58,6 +58,12 @@ function common_test_menu() { 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ); + $items['common-test/form-with-only-settings'] = array( + 'title' => 'Form that adds only a javascript setting', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('common_test_form_with_only_settings_form'), + 'access callback' => TRUE, + ); return $items; } @@ -288,3 +294,24 @@ function common_test_js_and_css_querystring() { function common_test_cron() { throw new Exception(t('Uncaught exception')); } + +/** + * A basic form that adds only a javascript setting. + */ +function common_test_form_with_only_settings_form($form, &$form_state) { + drupal_add_js(array('drupal' => 'rocks', 'dries' => 280342800), 'setting'); + $form = array(); + $form['select'] = array( + '#type' => 'select', + '#options' => array( + 'red' => 'red', + 'green' => 'green', + 'blue' => 'blue'), + ); + + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('submit'), + ); + return $form; +}