Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.1151
diff -u -p -r1.1151 common.inc
--- includes/common.inc	24 Apr 2010 14:53:59 -0000	1.1151
+++ includes/common.inc	16 Sep 2010 16:31:22 -0000
@@ -3983,19 +3983,17 @@ function drupal_add_library($module, $na
  *
  * @param $module
  *   The name of a module that registered a library.
- * @param $library
- *   The name of a registered library.
+ * @param $name
+ *   (optional) The name of a registered library to retrieve. If not provided,
+ *   will retrieve all libraries defined by the module.
  * @return
  *   The definition of the requested library, if existent, or FALSE.
  *
  * @see drupal_add_library()
  * @see hook_library()
  * @see hook_library_alter()
- *
- * @todo The purpose of drupal_get_*() is completely different to other page
- *   requisite API functions; find and use a different name.
  */
-function drupal_get_library($module, $name) {
+function drupal_get_library($module, $name = NULL) {
   $libraries = &drupal_static(__FUNCTION__, array());
 
   if (!isset($libraries[$module])) {
@@ -4018,11 +4016,13 @@ function drupal_get_library($module, $na
     }
     $libraries[$module] = $module_libraries;
   }
-  if (empty($libraries[$module][$name])) {
-    $libraries[$module][$name] = FALSE;
+  if (isset($name)) {
+    if (!isset($libraries[$module][$name])) {
+      $libraries[$module][$name] = FALSE;
+    }
+    return $libraries[$module][$name];
   }
-
-  return $libraries[$module][$name];
+  return $libraries[$module];
 }
 
 /**
Index: modules/simpletest/tests/common.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/common.test,v
retrieving revision 1.110
diff -u -p -r1.110 common.test
--- modules/simpletest/tests/common.test	22 Apr 2010 21:41:09 -0000	1.110
+++ modules/simpletest/tests/common.test	16 Sep 2010 16:31:22 -0000
@@ -1276,6 +1276,16 @@ class JavaScriptTestCase extends DrupalW
   }
 
   /**
+   * Tests the retrieval of libraries.
+   */
+  function testGetLibrary() {
+    $libraries = drupal_get_library('common_test');
+    $this->assertTrue(array_key_exists('farbtastic', $libraries), t('Retrieved all module libraries.'));
+    $farbtastic = drupal_get_library('common_test', 'farbtastic');
+    $this->assertEqual($farbtastic['version'], '5.3', t('Retrieved a single library.'));
+  }
+
+  /**
    * Tests that the query string remains intact when adding JavaScript files
    *  that have query string parameters.
    */
