diff --git a/core/modules/system/tests/common.test b/core/modules/system/tests/common.test
index 46b379e..76d5ab5 100644
--- a/core/modules/system/tests/common.test
+++ b/core/modules/system/tests/common.test
@@ -1128,6 +1128,7 @@ class CommonJavaScriptTestCase extends DrupalWebTestCase {
     // Reset drupal_add_js() and drupal_add_library() statics before each test.
     drupal_static_reset('drupal_add_js');
     drupal_static_reset('drupal_add_library');
+    drupal_static_reset('_drupal_get_js');
   }
 
   function tearDown() {
@@ -1149,23 +1150,25 @@ class CommonJavaScriptTestCase extends DrupalWebTestCase {
    * Test adding a JavaScript file.
    */
   function testAddFile() {
-    $javascript = drupal_add_js('core/misc/collapse.js');
+    drupal_add_js('core/misc/collapse.js');
+    $javascript = _drupal_get_js();
     $this->assertTrue(array_key_exists('core/misc/jquery.js', $javascript), t('jQuery is added when a file is added.'));
     $this->assertTrue(array_key_exists('core/misc/drupal.js', $javascript), t('Drupal.js is added when file is added.'));
     $this->assertTrue(array_key_exists('core/misc/html5.js', $javascript), t('html5.js is added when file is added.'));
     $this->assertTrue(array_key_exists('core/misc/collapse.js', $javascript), t('JavaScript files are correctly added.'));
-    $this->assertEqual(base_path(), $javascript['settings']['data'][0]['basePath'], t('Base path JavaScript setting is correctly set.'));
-    $this->assertIdentical($GLOBALS['script_path'], $javascript['settings']['data'][1]['scriptPath'], t('Script path JavaScript setting is correctly set.'));
-    $this->assertIdentical('', $javascript['settings']['data'][2]['pathPrefix'], t('Path prefix JavaScript setting is correctly set.'));
+    $this->assertEqual(base_path(), $javascript['settings']['data']['basePath'], t('Base path JavaScript setting is correctly set.'));
+    $this->assertIdentical($GLOBALS['script_path'], $javascript['settings']['data']['scriptPath'], t('Script path JavaScript setting is correctly set.'));
+    $this->assertIdentical('', $javascript['settings']['data']['pathPrefix'], t('Path prefix JavaScript setting is correctly set.'));
   }
 
   /**
    * Test adding settings.
    */
   function testAddSetting() {
-    $javascript = drupal_add_js(array('drupal' => 'rocks', 'dries' => 280342800), 'setting');
-    $this->assertEqual(280342800, $javascript['settings']['data'][3]['dries'], t('JavaScript setting is set correctly.'));
-    $this->assertEqual('rocks', $javascript['settings']['data'][3]['drupal'], t('The other JavaScript setting is set correctly.'));
+    drupal_add_js(array('drupal' => 'rocks', 'dries' => 280342800), 'setting');
+    $javascript = _drupal_get_js();
+    $this->assertEqual(280342800, $javascript['settings']['data']['dries'], t('JavaScript setting is set correctly.'));
+    $this->assertEqual('rocks', $javascript['settings']['data']['drupal'], t('The other JavaScript setting is set correctly.'));
   }
 
   /**
@@ -1181,6 +1184,7 @@ class CommonJavaScriptTestCase extends DrupalWebTestCase {
    * Test drupal_get_js() for JavaScript settings.
    */
   function testHeaderSetting() {
+    drupal_static_reset('_drupal_get_js');
     // Only the second of these two entries should appear in Drupal.settings.
     drupal_add_js(array('commonTest' => 'commonTestShouldNotAppear'), 'setting');
     drupal_add_js(array('commonTest' => 'commonTestShouldAppear'), 'setting');
@@ -1192,7 +1196,7 @@ class CommonJavaScriptTestCase extends DrupalWebTestCase {
     drupal_add_js(array('commonTestArray' => array('key' => 'commonTestOldValue')), 'setting');
     drupal_add_js(array('commonTestArray' => array('key' => 'commonTestNewValue')), 'setting');
 
-    $javascript = drupal_get_js('header');
+    $javascript = drupal_get_js();
     $this->assertTrue(strpos($javascript, 'basePath') > 0, t('Rendered JavaScript header returns basePath setting.'));
     $this->assertTrue(strpos($javascript, 'scriptPath') > 0, t('Rendered JavaScript header returns scriptPath setting.'));
     $this->assertTrue(strpos($javascript, 'pathPrefix') > 0, t('Rendered JavaScript header returns pathPrefix setting.'));
@@ -1226,11 +1230,13 @@ class CommonJavaScriptTestCase extends DrupalWebTestCase {
    * Test adding inline scripts.
    */
   function testAddInline() {
+    drupal_static_reset('_drupal_get_js');
     $inline = 'jQuery(function () { });';
-    $javascript = drupal_add_js($inline, array('type' => 'inline', 'scope' => 'footer'));
+    drupal_add_js($inline, array('type' => 'inline', 'scope' => 'footer'));
+    $javascript = _drupal_get_js();
     $this->assertTrue(array_key_exists('core/misc/jquery.js', $javascript), t('jQuery is added when inline scripts are added.'));
-    $data = end($javascript);
-    $this->assertEqual($inline, $data['data'], t('Inline JavaScript is correctly added to the footer.'));
+    $data = drupal_get_js('footer');
+    $this->assertEqual(strpos($data, $inline) > 0, t('Inline JavaScript is correctly added to the footer.'));
   }
 
   /**
@@ -1274,7 +1280,8 @@ class CommonJavaScriptTestCase extends DrupalWebTestCase {
    * Test adding a JavaScript file with a different weight.
    */
   function testDifferentWeight() {
-    $javascript = drupal_add_js('core/misc/collapse.js', array('weight' => 2));
+    drupal_add_js('core/misc/collapse.js', array('weight' => 2));
+    $javascript = _drupal_get_js();
     $this->assertEqual($javascript['core/misc/collapse.js']['weight'], 2, t('Adding a JavaScript file with a different weight caches the given weight.'));
   }
 
@@ -1333,6 +1340,7 @@ class CommonJavaScriptTestCase extends DrupalWebTestCase {
     // Now ensure that with aggregation on, one file is made for the
     // 'every_page' files, and one file is made for the others.
     drupal_static_reset('drupal_add_js');
+    drupal_static_reset('drupal_add_js_page_defaults');
     $config = config('system.performance');
     $config->set('preprocess_js', 1);
     $config->save();
@@ -1340,7 +1348,7 @@ class CommonJavaScriptTestCase extends DrupalWebTestCase {
     drupal_add_js('core/misc/authorize.js', array('every_page' => TRUE));
     drupal_add_js('core/misc/autocomplete.js');
     drupal_add_js('core/misc/batch.js', array('every_page' => TRUE));
-    $js_items = drupal_add_js();
+    $js_items = _drupal_get_js();
     $javascript = drupal_get_js();
     $expected = implode("\n", array(
       '<script type="text/javascript" src="' . file_create_url(drupal_build_js_cache(array('core/misc/authorize.js' => $js_items['core/misc/authorize.js'], 'core/misc/batch.js' => $js_items['core/misc/batch.js']))) . '"></script>',
@@ -1553,6 +1561,40 @@ 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 aren't added when not needed.
+   */
+  function testPageWithoutJavascript() {
+    $this->drupalGet('');
+    $content = $this->drupalGetContent();
+    $this->assertTrue(strpos($content, 'Drupal.settings') === FALSE, t('Drupal.settings is not added to the page.'));
+    $this->assertTrue(strpos($content, 'jquery.js') === FALSE, t('No default javascript is added to the page.'));
+    $this->assertTrue(strpos($content, 'html5.js') !== FALSE, t('html5shiv is added to the page.'));
+  }
+
+  /**
+   * Tests that Drupal.settings aren't added when not needed.
+   */
+  function testPageWithOnlyPureJavascript() {
+    drupal_add_js(drupal_get_path('module', 'simpletest') . '/simpletest.js', array('jsonly' => TRUE));
+    $scripts = drupal_get_js();
+    $this->assertTrue(strpos($scripts, 'Drupal.settings') === FALSE, t('Drupal.settings is not added to the page.'));
+    $this->assertTrue(strpos($scripts, 'jquery.js') === FALSE, t('No default javascript is added to the page.'));
+    $this->assertTrue(strpos($scripts, 'simpletest.js') !== FALSE, t('simpletest.js is added to the page.'));
+    $this->assertTrue(strpos($scripts, 'html5.js') !== FALSE, t('html5shiv is added to the page.'));
+  }
+
+  /**
+  * 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;
+}
diff --git a/core/modules/system/tests/theme.test b/core/modules/system/tests/theme.test
index 025ae8d..6df6688 100644
--- a/core/modules/system/tests/theme.test
+++ b/core/modules/system/tests/theme.test
@@ -188,7 +188,7 @@ class ThemeTableUnitTest extends DrupalWebTestCase {
     $header = array('one', 'two', 'three');
     $rows = array(array(1,2,3), array(4,5,6), array(7,8,9));
     $this->content = theme('table', array('header' => $header, 'rows' => $rows));
-    $js = drupal_add_js();
+    $js = _drupal_get_js();
     $this->assertTrue(isset($js['core/misc/tableheader.js']), t('tableheader.js was included when $sticky = TRUE.'));
     $this->assertRaw('sticky-enabled',  t('Table has a class of sticky-enabled when $sticky = TRUE.'));
     drupal_static_reset('drupal_add_js');
@@ -204,7 +204,7 @@ class ThemeTableUnitTest extends DrupalWebTestCase {
     $caption = NULL;
     $colgroups = array();
     $this->content = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => $attributes, 'caption' => $caption, 'colgroups' => $colgroups, 'sticky' => FALSE));
-    $js = drupal_add_js();
+    $js = _drupal_get_js();
     $this->assertFalse(isset($js['core/misc/tableheader.js']), t('tableheader.js was not included because $sticky = FALSE.'));
     $this->assertNoRaw('sticky-enabled',  t('Table does not have a class of sticky-enabled because $sticky = FALSE.'));
     drupal_static_reset('drupal_add_js');
