Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.925 diff -u -r1.925 common.inc --- includes/common.inc 18 Jun 2009 21:19:01 -0000 1.925 +++ includes/common.inc 28 Jun 2009 05:52:33 -0000 @@ -2779,15 +2794,6 @@ 'scope' => 'header', 'weight' => JS_LIBRARY, ), - 'misc/jquery.js' => array( - 'data' => 'misc/jquery.js', - 'type' => 'file', - 'scope' => 'header', - 'weight' => JS_LIBRARY - 2, - 'cache' => TRUE, - 'defer' => FALSE, - 'preprocess' => TRUE, - ), 'misc/drupal.js' => array( 'data' => 'misc/drupal.js', 'type' => 'file', @@ -2798,6 +2804,8 @@ 'preprocess' => TRUE, ), ); + // jQuery itself is registered as a library. + drupal_add_library('system.jquery'); } switch ($options['type']) { @@ -2954,6 +2971,148 @@ } /** + * Adds multiple JavaScript or CSS files at the same time. + * + * A library could consist of a jQuery plugin, a separate JavaScript framework + * (such as Prototype or MooTools), a JavaScript plugin that also packages CSS + * (such as a WYSIWYG editor), or even a CSS framework that has no JavaScript + * at all (such as the 960 Grid System). By managing the addition of multiple + * JavaScript and CSS files at the same time through this registry, it makes + * managing the libraries quite easy. + * + * @param $library + * The name of the JavaScript/CSS library to add, prefixed by the module name + * that implements the library. So, to add jQuery to the page, you'd prefix + * "jquery" with "system.", since the System module implements jQuery. Some + * available libraries include "system.farbtastic" for Farbtastic, or + * "system.ui.accordion" for the jQuery UI Accordion. + * @param ... + * Additional arguments to pass to the add callbacks associated with the + * library. + * @return + * An array containing the results from calling all the add handlers. The key + * of the array is the add handler name, while the value is what was returned + * from the call. + * @see hook_library() + * @see hook_library_alter() + */ +function drupal_add_library($library) { + $lib = drupal_get_library($library); + if ($lib == FALSE) { + watchdog('system', 'Warning: Missing JavaScript/CSS library %library.', array('%library' => $library), WATCHDOG_WARNING); + return FALSE; + } + // Add all the JavaScript, stylesheets and dependent libraries. + foreach (array('dependencies', 'js', 'css') as $type) { + if (isset($lib[$type]) && is_array($lib[$type])) { + foreach ($lib[$type] as $data => $options) { + // If the value is not an array, it's a filename or library name and + // passed as the first (and only) argument. + if (!is_array($options)) { + $data = $options; + $options = array(); + } + + // JavaScript and CSS is called with only two parameters ($data and + // $options), while the libraries/dependencies are designed to have any + // number of arguments. Due to this, we use call_user_func_array() as + // opposed to call_user_func(). + if ($type == 'dependencies') { + // Prepend the library name as the first argument to be passed. + array_unshift($options, $data); + call_user_func_array('drupal_add_library', $options); + } + else { + // When drupal_add_js with 'type' => 'setting' is called, the first + // parameter ($data) is an array. Arrays can't be keys in PHP, so we + // have to get $data from the value array. + if (is_numeric($data)) { + $data = $options['data']; + unset($options['data']); + } + // All JavaScript contained within the libraries are given a default + // weight of JS_LIBRARY. + if (!isset($options['weight'])) { + $options['weight'] = JS_LIBRARY; + } + call_user_func('drupal_add_' . $type, $data, $options); + } + } + } + } + + // Call all of the add handlers associated with the library. + $output = array(); + if (isset($lib['add callbacks']) && is_array($lib['add callbacks'])) { + foreach ($lib['add callbacks'] as $function) { + if (drupal_function_exists($function)) { + // Invoke the add handler, passing along all parameters. + $args = func_get_args(); + $output[$function] = call_user_func_array($function, $args); + } + } + } + return $output; +} + +/** + * Retrieves information from the JavaScript/CSS library registry. + * + * @param $library + * (optional) If given, will provide the JavaScript/CSS library information + * for just the given library name. Note that as like drupal_add_library(), + * you must prefix the library name by the module name that implements it. + * Some available examples are "system.jquery", or "system.farbtastic". + * @return + * Returns all available JavaScript libraries, or the requested one from + * the $library parameter. + * @see drupal_add_library() + * @see hook_library() + */ +function drupal_get_library($library = NULL) { + $libraries = &drupal_static(__FUNCTION__); + + if (!isset($libraries)) { + if ($cache = cache_get('library')) { + $libraries = $cache->data; + } + else { + // To avoid having two different modules implementing two different + // versions of the same library, we will prefix the library name by the + // name of the module that implements it. This will result in giving us + // library names like system.jquery, or system.farbtastic. If another + // module implements "farbtastic", there won't be an API conflict as the + // correct version of the library will be used by the correct module using + // it. + $libraries = array(); + foreach (module_implements('library') as $module) { + $module_libraries = module_invoke($module, 'library'); + foreach ($module_libraries as $name => $info) { + // Prefix the library name with the module that implements it so that + // we avoid name and version conflicts. + $libraries["$module.$name"] = $info; + } + } + + // Invoke hook_library_alter() to allow modification of the + // registry. This is helpful to allow modules to update any libraries + // to later versions. + drupal_alter('library', $libraries); + + // Save the registry to the cache. + cache_set('library', $libraries); + } + } + + if (isset($library)) { + return isset($libraries[$library]) ? $libraries[$library] : FALSE; + } + else { + return $libraries; + } +} + +/** * Assist in adding the tableDrag JavaScript behavior to a themed table. * * Draggable tables should be used wherever an outline or list of sortable items Index: includes/form.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/form.inc,v retrieving revision 1.343 diff -u -r1.343 form.inc --- includes/form.inc 20 Jun 2009 15:17:38 -0000 1.343 +++ includes/form.inc 28 Jun 2009 05:52:42 -0000 @@ -2002,7 +2002,7 @@ // Adding the same javascript settings twice will cause a recursion error, // we avoid the problem by checking if the javascript has already been added. if ((isset($element['#ahah']['callback']) || isset($element['#ahah']['path'])) && isset($element['#ahah']['event']) && !isset($js_added[$element['#id']])) { - drupal_add_js('misc/jquery.form.js', array('weight' => JS_LIBRARY)); + drupal_add_library('system.form'); drupal_add_js('misc/ahah.js'); $ahah_binding = array( Index: modules/system/system.api.php =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.api.php,v retrieving revision 1.45 diff -u -r1.45 system.api.php --- modules/system/system.api.php 27 Jun 2009 10:19:31 -0000 1.45 +++ modules/system/system.api.php 28 Jun 2009 05:52:52 -0000 @@ -183,6 +183,124 @@ } /** + * Registers any JavaScript/CSS libraries associated with the module. + * + * Modules implementing this return an array of arrays. The key to each sub-array + * is the machine readable name of the library. Each library may contain the + * following items: + * + * - title: The human readable name of the library. + * - website: The URL of the library's website. + * - version: (required) A string value determining the version of the included + * library. This is intentionally not a float because a version like "1.2.3" + * is not a valid float. Use version_compare() to compare versions. + * - js: An array of JavaScript elements to be processed when the library is + * being added to the page. The array keys represents the $data parameter of + * the drupal_add_js() call while the value becomes the $options argument. If + * the array is just a bunch of values with integers for keys, then the value + * becomes the $data parameter. See the library-1 example within hook_library() + * for an example of this. + * - css: Similar to the "js" flag, provides an array of CSS elements to to be + * processed when the library is being added the the page. + * - dependencies: An array of dependent libraries that will also be added when + * processing the given library. The array key is the name of the library, + * while the value is an array of additional arguments that will be passed + * during the call to drupal_add_library(). It is required to prefix the + * library name with the name of the module that originally implementd it. If + * the library you are defining requires jQuery UI Tabs, you would put + * "system.ui.tabs" as a dependency. + * - add callbacks: An array of function callbacks that will be called when this + * library is processed on the page. Any additional arguments that are appended + * to the drupal_add_library() call become the arguments that are passed to + * the add callback functions. See the library-2 example within + * hook_library() for an example of "add callbacks". + * + * @return + * An array defining any JavaScript libraries associated with the module. + * @see system_library() + * @see drupal_add_library() + */ +function hook_library() { + // Library One. + $libraries['library-1'] = array( + 'title' => 'Library One', + 'website' => 'http://example.com/library-1', + // Note that this is a string. Use version_compare() to compare. + 'version' => '1.2', + 'js' => array( + // Items that are just strings are interpreted as stright files. + drupal_get_path('module', 'my_module') . '/library-1.js', + ), + 'css' => array( + // By providing an array, it becomes the $options parameter during the + // drupal_add_js/drupal_add_css call. + drupal_get_path('module', 'my_module') . '/library-2.css' => array( + 'type' => 'file', + 'media' => 'screen', + ), + ), + ); + // Library Two. + $libraries['library-2'] = array( + 'title' => 'Library Two', + 'website' => 'http://example.com/library-2', + 'version' => '1.2', + 'js' => array( + // JavaScript settings can be added by sending in an array. + array( + 'type' => 'setting', + 'data' => array('library-2' => TRUE), + ), + ), + // Any depending libraries can be added by using the "dependencies" key. + 'dependencies' => array( + // Sending in a string will just add the depending library to the page. + 'library-1', + // Sending in the library name along with an array of parameters will be + // sent in as additional arguments to drupal_add_library(). + 'library-3' => array( + 'additional arguments', + ), + ), + // During inclusion of this library, all functions defined in the + // "add callbacks" array will be called. + 'add callbacks' => array( + // The function named "library_2_added" will be called when library-2 is + // added to the page. The arguments passed to this function are this + // library's name, as well as any additional arguments that were passed + // during the call to drupal_add_library(). + 'library_2_added', + ), + ); + return $libraries; +} + +/** + * Alters the JavaScript/CSS library registry. + * + * @param $libraries + * The JavaScript/CSS library registry. The library's array key is the library + * name prefixed by the module name ("system.jquery"), and the value is the + * information regarding the library. + * @return + * An array with the updated JavaScript library registry. + * @see hook_library() + */ +function hook_library_alter(&$libraries) { + // Update jQuery from the System module to version 1.4. + if (isset($libraries['system.jquery'])) { + // Check that jQuery is older then version 1.4. + if (version_compare($libraries['system.jquery']['version'], '1.4', '<')) { + // The version number and JS files will change. + $libraries['system.jquery']['version'] = '1.4'; + $libraries['system.jquery']['js'] = array( + drupal_get_path('module', 'jquery_update') . '/jquery.js', + ); + } + } +} + +/** * Perform alterations before a page is rendered. * * Use this hook when you want to add, remove, or alter elements at the page Index: modules/system/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.715 diff -u -r1.715 system.module --- modules/system/system.module 23 Jun 2009 12:11:19 -0000 1.715 +++ modules/system/system.module 28 Jun 2009 05:53:00 -0000 @@ -789,6 +789,241 @@ } /** + * Implementation of hook_library(). + */ +function system_library() { + // jQuery. + $libraries['jquery'] = array( + 'title' => 'jQuery', + 'website' => 'http://jquery.com', + 'version' => '1.3.2', + 'js' => array( + 'misc/jquery.js' => array('weight' => JS_LIBRARY - 2), + ), + ); + + // jQuery Form Plugin. + $libraries['form'] = array( + 'title' => 'jQuery Form Plugin', + 'website' => 'http://malsup.com/jquery/form/', + 'version' => '2.16', + 'js' => array( + 'misc/jquery.form.js', + ), + ); + + // Farbtastic. + $libraries['farbtastic'] = array( + 'title' => 'Farbtastic', + 'website' => 'http://code.google.com/p/farbtastic/', + 'version' => '1.2', + 'js' => array( + 'misc/farbtastic/farbtastic.js', + ), + 'css' => array( + 'misc/farbtastic/farbtastic.css', + ), + ); + + // jQuery UI. + $libraries['ui'] = array( + 'title' => 'jQuery UI', + 'website' => 'http://jqueryui.com', + 'version' => '1.7.2', + 'js' => array( + 'misc/ui/ui.core.js' => array( + 'weight' => JS_LIBRARY - 1, // Make sure ui.core appears on top. + ), + ), + 'css' => array( + 'misc/ui/ui.core.css', + 'misc/ui/ui.theme.css' + ), + ); + $libraries['ui.accordion'] = array( + 'title' => 'jQuery UI: Accordion', + 'website' => 'http://jqueryui.com/demos/accordion/', + 'version' => '1.7.2', + 'js' => array('misc/ui/ui.accordion.js'), + 'css' => array('misc/ui/ui.accordion.css'), + 'dependencies' => array('system.ui'), + ); + $libraries['ui.datepicker'] = array( + 'title' => 'jQuery UI: Date Picker', + 'website' => 'http://jqueryui.com/demos/datepicker/', + 'version' => '1.7.2', + 'js' => array('misc/ui/ui.datepicker.js'), + 'css' => array('misc/ui/ui.datepicker.css'), + 'dependencies' => array('system.ui'), + ); + $libraries['ui.dialog'] = array( + 'title' => 'jQuery UI: Dialog', + 'website' => 'http://jqueryui.com/demos/dialog/', + 'version' => '1.7.2', + 'js' => array('misc/ui/ui.dialog.js'), + 'css' => array('misc/ui/ui.dialog.css'), + 'dependencies' => array('system.ui'), + ); + $libraries['ui.draggable'] = array( + 'title' => 'jQuery UI: Dialog', + 'website' => 'http://jqueryui.com/demos/draggable/', + 'version' => '1.7.2', + 'js' => array('misc/ui/ui.draggable.js'), + 'dependencies' => array('system.ui'), + ); + $libraries['ui.droppable'] = array( + 'title' => 'jQuery UI: Droppable', + 'website' => 'http://jqueryui.com/demos/droppable/', + 'version' => '1.7.2', + 'js' => array('misc/ui/ui.droppable.js'), + 'dependencies' => array('system.ui'), + ); + $libraries['ui.progressbar'] = array( + 'title' => 'jQuery UI: Progress Bar', + 'website' => 'http://jqueryui.com/demos/progressbar/', + 'version' => '1.7.2', + 'js' => array('misc/ui/ui.progressbar.js'), + 'css' => array('misc/ui/ui.progressbar.css'), + 'dependencies' => array('ui'), + ); + $libraries['ui.resizable'] = array( + 'title' => 'jQuery UI: Resizable', + 'website' => 'http://jqueryui.com/demos/resizable/', + 'version' => '1.7.2', + 'js' => array('misc/ui/ui.resizable.js'), + 'css' => array('misc/ui/ui.resizable.css'), + 'dependencies' => array('system.ui'), + ); + $libraries['ui.selectable'] = array( + 'title' => 'jQuery UI: Selectable', + 'website' => 'http://jqueryui.com/demos/selectable/', + 'version' => '1.7.2', + 'js' => array('misc/ui/ui.selectable.js'), + 'css' => array('misc/ui/ui.selectable.css'), + 'dependencies' => array('system.ui'), + ); + $libraries['ui.slider'] = array( + 'title' => 'jQuery UI: Slider', + 'website' => 'http://jqueryui.com/demos/slider/', + 'version' => '1.7.2', + 'js' => array('misc/ui/ui.slider.js'), + 'css' => array('misc/ui/ui.slider.css'), + 'dependencies' => array('system.ui'), + ); + $libraries['ui.sortable'] = array( + 'title' => 'jQuery UI: Sortable', + 'website' => 'http://jqueryui.com/demos/sortable/', + 'version' => '1.7.2', + 'js' => array('misc/ui/ui.sortable.js'), + 'dependencies' => array('system.ui'), + ); + $libraries['ui.tabs'] = array( + 'title' => 'jQuery UI: Tabs', + 'website' => 'http://jqueryui.com/demos/tabs/', + 'version' => '1.7.2', + 'js' => array('misc/ui/ui.tabs.js'), + 'css' => array('misc/ui/ui.tabs.css'), + 'dependencies' => array('system.ui'), + ); + $libraries['effects'] = array( + 'title' => 'jQuery UI: Effects', + 'website' => 'http://jqueryui.com/demos/effect/', + 'version' => '1.7.2', + 'js' => array( + 'misc/ui/effects.core.js' => array( + 'weight' => JS_LIBRARY - 1, // Make sure effects.core appears on top. + ), + ), + ); + $libraries['effects.blind'] = array( + 'title' => 'jQuery UI: Effects Blind', + 'website' => 'http://jqueryui.com/demos/effect/', + 'version' => '1.7.2', + 'js' => array('misc/ui/effects.blind.js'), + 'dependencies' => array('system.effects'), + ); + $libraries['effects.bounce'] = array( + 'title' => 'jQuery UI: Effects Bounce', + 'website' => 'http://jqueryui.com/demos/effect/', + 'version' => '1.7.2', + 'js' => array('misc/ui/effects.bounce.js'), + 'dependencies' => array('system.effects'), + ); + $libraries['effects.clip'] = array( + 'title' => 'jQuery UI: Effects Clip', + 'website' => 'http://jqueryui.com/demos/effect/', + 'version' => '1.7.2', + 'js' => array('misc/ui/effects.clip.js'), + 'dependencies' => array('system.effects'), + ); + $libraries['effects.drop'] = array( + 'title' => 'jQuery UI: Effects Drop', + 'website' => 'http://jqueryui.com/demos/effect/', + 'version' => '1.7.2', + 'js' => array('misc/ui/effects.drop.js'), + 'dependencies' => array('system.effects'), + ); + $libraries['effects.explode'] = array( + 'title' => 'jQuery UI: Effects Explode', + 'website' => 'http://jqueryui.com/demos/effect/', + 'version' => '1.7.2', + 'js' => array('misc/ui/effects.explode.js'), + 'dependencies' => array('system.effects'), + ); + $libraries['effects.fold'] = array( + 'title' => 'jQuery UI: Effects Fold', + 'website' => 'http://jqueryui.com/demos/effect/', + 'version' => '1.7.2', + 'js' => array('misc/ui/effects.fold.js'), + 'dependencies' => array('system.effects'), + ); + $libraries['effects.highlight'] = array( + 'title' => 'jQuery UI: Effects Fold', + 'website' => 'http://jqueryui.com/demos/effect/', + 'version' => '1.7.2', + 'js' => array('misc/ui/effects.highlight.js'), + 'dependencies' => array('system.effects'), + ); + $libraries['effects.pulsate'] = array( + 'title' => 'jQuery UI: Effects Pulsate', + 'website' => 'http://jqueryui.com/demos/effect/', + 'version' => '1.7.2', + 'js' => array('misc/ui/effects.pulsate.js'), + 'dependencies' => array('system.effects'), + ); + $libraries['effects.scale'] = array( + 'title' => 'jQuery UI: Effects Pulsate', + 'website' => 'http://jqueryui.com/demos/effect/', + 'version' => '1.7.2', + 'js' => array('misc/ui/effects.scale.js'), + 'dependencies' => array('system.effects'), + ); + $libraries['effects.shake'] = array( + 'title' => 'jQuery UI: Effects Shake', + 'website' => 'http://jqueryui.com/demos/effect/', + 'version' => '1.7.2', + 'js' => array('misc/ui/effects.scale.js'), + 'dependencies' => array('system.effects'), + ); + $libraries['effects.slide'] = array( + 'title' => 'jQuery UI: Effects Slide', + 'website' => 'http://jqueryui.com/demos/effect/', + 'version' => '1.7.2', + 'js' => array('misc/ui/effects.slide.js'), + 'dependencies' => array('system.effects'), + ); + $libraries['effects.transfer'] = array( + 'title' => 'jQuery UI: Effects Transfer', + 'website' => 'http://jqueryui.com/demos/effect/', + 'version' => '1.7.2', + 'js' => array('misc/ui/effects.transfer.js'), + 'dependencies' => array('system.effects'), + ); + + return $libraries; +} + +/** * Retrieve a blocked IP address from the database. * * @param $iid integer Index: modules/simpletest/tests/common.test =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/tests/common.test,v retrieving revision 1.46 diff -u -r1.46 common.test --- modules/simpletest/tests/common.test 12 Jun 2009 08:39:39 -0000 1.46 +++ modules/simpletest/tests/common.test 28 Jun 2009 05:52:46 -0000 @@ -425,7 +425,7 @@ /** * Store configured value for JavaScript preprocessing. */ - var $preprocess_js = NULL; + protected $preprocess_js = NULL; public static function getInfo() { return array( @@ -437,14 +437,15 @@ function setUp() { // Enable Locale and SimpleTest in the test environment. - parent::setUp('locale', 'simpletest'); + parent::setUp('locale', 'simpletest', 'common_test'); // Disable preprocessing $this->preprocess_js = variable_get('preprocess_js', 0); variable_set('preprocess_js', 0); - // Reset drupal_add_js() before each test. + // Reset drupal_add_js() and the library registry before each test. drupal_static_reset('drupal_add_js'); + drupal_static_reset('drupal_get_js_library'); } function tearDown() { @@ -541,6 +542,67 @@ } /** + * Checks to make sure that JavaScript library registry is built correctly. + */ + function testLibraryRegistry() { + $libraries = drupal_get_library(); + $this->assertTrue(isset($libraries['system.farbtastic']) && isset($libraries['system.form']), t('The JavaScript library registry is built correctly.')); + } + + /** + * Adds a JavaScript library to the page and tests for both it and its CSS. + */ + function testLibraryRender() { + drupal_add_library('system.farbtastic'); + $javascript = drupal_get_js(); + $stylesheets = drupal_get_css(); + $this->assertTrue(strpos($javascript, 'misc/farbtastic/farbtastic.js') > 0, t('JavaScript libraries are rendered to the page.')); + $this->assertTrue(strpos($stylesheets, 'misc/farbtastic/farbtastic.css') > 0, t('JavaScript libraries render their CSS to the page.')); + } + + /** + * Adds a JavaScript library to the page and alters it. + * + * @see common_test_js_libraries_alter() + */ + function testLibraryAlter() { + // Add Farbtastic, which will fire common_test_js_alter(). + $result = drupal_add_library('system.farbtastic'); + $library = drupal_get_library('system.farbtastic'); + $this->assertTrue(array_search('common_test_js_library_add', $library['add callbacks']) !== FALSE, t('JavaScript libraries are alterable.')); + $this->assertTrue(array_search(t('Add callback for the @library library fired.', array('@library' => 'system.farbtastic')), $result) !== FALSE, t('JavaScript library "add callback" functions are fired.')); + + // The alter also adds a dependency on jQuery Form, so also check that. + $javascript = drupal_get_js(); + $this->assertTrue(strpos($javascript, 'misc/jquery.form.js') > 0, t('Altered JavaScript library dependencies are added to the page.')); + } + + /** + * Tests name conflict resolution between libraries by prefixing their module name. + * + * @see common_test_js_libraries() + */ + function testLibraryNameConflicts() { + // Since a JavaScript library can be implemented in multiple modules with + // different versions, we prefix the library name by the module the implements + // it. This test checks to make sure the module name is prefixed by having + // a look at common_test's implementation of Farbtastic. + $farbtastic = drupal_get_library('common_test.farbtastic'); + $this->assertEqual($farbtastic['title'], 'Farbtastic: Newest Version', t('JavaScript library names are prefixed by the module the impements them.')); + } + + /** + * Adds a JavaScript library through a call to drupal_add_js(). + * + * @see drupal_add_js() + */ + function testAddLibraryThroughJS() { + drupal_add_js('system.farbtastic', 'library'); + $javascript = drupal_get_js(); + $this->assertTrue(strpos($javascript, 'misc/farbtastic/farbtastic.js') > 0, t('JavaScript libraries can be added through a call to drupal_add_js().')); + } + + /** * Test adding a JavaScript file with a different weight. */ function testDifferentWeight() { Index: modules/color/color.module =================================================================== RCS file: /cvs/drupal/drupal/modules/color/color.module,v retrieving revision 1.59 diff -u -r1.59 color.module --- modules/color/color.module 27 May 2009 18:33:55 -0000 1.59 +++ modules/color/color.module 28 Jun 2009 05:52:43 -0000 @@ -169,8 +169,7 @@ $info = color_get_info($theme); // Add Farbtastic color picker. - drupal_add_css('misc/farbtastic/farbtastic.css', array('preprocess' => FALSE)); - drupal_add_js('misc/farbtastic/farbtastic.js', array('weight' => JS_LIBRARY)); + drupal_add_library('system.farbtastic'); // Add custom CSS and JS. drupal_add_css($base . '/color.css', array('preprocess' => FALSE)); Index: modules/simpletest/tests/common_test.info =================================================================== RCS file: modules/simpletest/tests/common_test.info diff -N modules/simpletest/tests/common_test.info --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ modules/simpletest/tests/common_test.info 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,8 @@ +; $Id$ +name = "Common Test" +description = "Support module for core Drupal functionality tests." +core = 7.x +package = Testing +files[] = common_test.module +version = VERSION +hidden = TRUE Index: modules/simpletest/tests/common_test.module =================================================================== RCS file: modules/simpletest/tests/common_test.module diff -N modules/simpletest/tests/common_test.module --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ modules/simpletest/tests/common_test.module 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,44 @@ + $library)); +} + +/** + * Implementation of hook_library(). + * + * This re-adds Farbtastic with a mocked newer version to test the name conflict + * resolution based on the version. + * + * @see system_library() + */ +function common_test_library() { + $libraries['farbtastic'] = array( + 'title' => 'Farbtastic: Newest Version', + 'website' => 'http://code.google.com/p/farbtastic/', + 'version' => '1.3', // Faked version that is more recent then 1.2. + 'js' => array( + 'misc/farbtastic/farbtastic.js', + ), + 'css' => array( + 'misc/farbtastic/farbtastic.css', + ), + ); + return $libraries; +}