Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.823
diff -u -r1.823 common.inc
--- includes/common.inc	10 Nov 2008 05:22:59 -0000	1.823
+++ includes/common.inc	11 Nov 2008 18:41:10 -0000
@@ -2110,6 +2110,9 @@
  *   a new message arrived, by opening a pop up, alert box etc. This should only
  *   be used for JavaScript which cannot be placed and executed from a file.
  *
+ * - Add an external JavaScript resource ('external'):
+ *   Adds a reference to an external Javascript file on the page.
+ *
  * - Add settings ('setting'):
  *   Adds a setting to Drupal's global storage of JavaScript settings. Per-page
  *   settings are required by some modules to function properly. All settings
@@ -2119,6 +2122,7 @@
  * @code
  *   drupal_add_js('misc/collapse.js');
  *   drupal_add_js('misc/collapse.js', 'file');
+ *   drupal_add_js('http://yui.yahooapis.com/2.6.0/build/utilities/utilities.js', 'external');
  *   drupal_add_js('$(document).ready(function(){alert("Hello!");});', 'inline');
  *   drupal_add_js('$(document).ready(function(){alert("Hello!");});',
  *     array('type' => 'inline', 'scope' => 'footer', 'weight' => 5)
@@ -2129,6 +2133,7 @@
  *   (optional) If given, the value depends on the $options parameter:
  *   - 'file': Path to the file relative to base_path().
  *   - 'inline': The JavaScript code that should be placed in the given scope.
+ *   - 'external': The absolute URL of a JavaScript resource.
  *   - 'setting': An array with configuration options as associative array. The
  *       array is directly placed in Drupal.settings. All modules should wrap
  *       their actual configuration settings in another variable to prevent
@@ -2140,7 +2145,8 @@
  *   always pass the string 'setting' only.
  *   - type
  *       The type of JavaScript that is to be added to the page. Allowed
- *       values are 'file', 'inline' or 'setting'. Defaults to 'file'.
+ *       values are 'file', 'inline', 'external' or 'setting'. Defaults to
+ *       'file'.
  *   - scope
  *       The location in which you want to place the script. Possible values
  *       are 'header' or 'footer'. If your theme implements different regions,
@@ -2253,11 +2259,10 @@
         $javascript[] = $options;
         break;
 
-      case 'file':
+      default:
         // Files must keep their name as the associative key so the same
         // JavaScript files can not be added twice.
         $javascript[$options['data']] = $options;
-        break;
     }
   }
   return $javascript;
@@ -2336,7 +2341,11 @@
         $output .= '<script type="text/javascript"' . ($item['defer'] ? ' defer="defer"' : '') . '>' . $embed_prefix . $item['data'] . $embed_suffix . "</script>\n";
         break;
 
-      case 'file':
+      case 'external':
+        $no_preprocess .= '<script type="text/javascript"' . ($item['defer'] ? ' defer="defer"' : '') . ' src="' . check_url($item['data']) . ($item['cache'] ? '' : '?' . REQUEST_TIME) ."\"></script>\n";
+        break;
+
+     case 'file':
         if (!$item['preprocess'] || !$is_writable || !$preprocess_js) {
           $no_preprocess .= '<script type="text/javascript"' . ($item['defer'] ? ' defer="defer"' : '') . ' src="' . base_path() . $item['data'] . ($item['cache'] ? $query_string : '?' . REQUEST_TIME) . "\"></script>\n";
         }
Index: modules/simpletest/tests/common.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/common.test,v
retrieving revision 1.12
diff -u -r1.12 common.test
--- modules/simpletest/tests/common.test	10 Nov 2008 05:23:00 -0000	1.12
+++ modules/simpletest/tests/common.test	11 Nov 2008 18:41:10 -0000
@@ -405,6 +405,26 @@
   }
 
   /**
+   * Test adding an external script.
+   */
+  function testAddExternal() {
+    $external = 'http://yui.yahooapis.com/2.6.0/build/utilities/utilities.js';
+    $javascript = drupal_add_js($external, 'external');
+    $data = end($javascript);
+    $this->assertEqual($external, $data['data'], t('External JavaScript is cached correctly.'));
+  }
+
+  /**
+   * Test rendering an external script.
+   */
+  function testRenderExternal() {
+    $external = 'http://yui.yahooapis.com/2.6.0/build/utilities/utilities.js';
+    drupal_add_js($external, 'external');
+    $javascript = drupal_get_js();
+    $this->assertTrue(strpos($javascript, $external) > 0, t('External JavaScript is rendered correctly.'));
+  }
+
+  /**
    * Test drupal_get_js() with a footer scope.
    */
   function testFooterHTML() {
