Source/WebCore: Don't load resources with empty urls, since this
will resolve to the current document.
https://bugs.webkit.org/show_bug.cgi?id=30303

Reviewed by Darin Adler.

Test: http/tests/loading/empty-urls.html

* dom/ScriptElement.cpp:
(WebCore::ScriptElement::requestScript): If src="", fail through
    to the error event case.
* html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::parseMappedAttribute): Ensure the url
    stays empty if we try to resolve an empty href.
* loader/ImageLoader.cpp:
(WebCore::ImageLoader::updateFromElement): Throw an error instead of
    loading if the src is empty in all cases, not just local files.

LayoutTests: Test updates for https://bugs.webkit.org/show_bug.cgi?id=30303.

Reviewed by Darin Adler.

* fast/images/load-img-with-empty-src-expected.txt:
* fast/images/load-img-with-empty-src.html: Expect the same behavior whether or not an empty src
    is in a local file document.
* fast/tokenizer/002-expected.txt: Added.
* fast/tokenizer/002.html: Make dumpAsText().
* fast/tokenizer/external-script-document-write_2-expected.txt: Added.
* fast/tokenizer/external-script-document-write_2.html:: Make dumpAsText().
* fast/tokenizer/script_extra_close-expected.txt: Added.
* fast/tokenizer/script_extra_close.html:: Make dumpAsText().
* http/tests/loading/empty-urls-expected.txt: Added.
* http/tests/loading/empty-urls.html: Added. Test empty urls with a bunch of subresource types
    and ensure their error event behavior matches the spec.
* platform/chromium-cg-mac/fast/tokenizer/002-expected.txt: Removed.
* platform/chromium-cg-mac/fast/tokenizer/external-script-document-write_2-expected.txt: Removed.
* platform/chromium-linux/fast/tokenizer/002-expected.png: Removed.
* platform/chromium-linux/fast/tokenizer/external-script-document-write_2-expected.png: Removed.
* platform/chromium-linux/fast/tokenizer/script_extra_close-expected.png: Removed.
* platform/chromium-win/fast/tokenizer/002-expected.png: Removed.
* platform/chromium-win/fast/tokenizer/002-expected.txt: Removed.
* platform/chromium-win/fast/tokenizer/external-script-document-write_2-expected.png: Removed.
* platform/chromium-win/fast/tokenizer/external-script-document-write_2-expected.txt: Removed.
* platform/chromium-win/fast/tokenizer/script_extra_close-expected.png: Removed.
* platform/chromium-win/fast/tokenizer/script_extra_close-expected.txt: Removed.
* platform/gtk/fast/tokenizer/002-expected.png: Removed.
* platform/gtk/fast/tokenizer/002-expected.txt: Removed.
* platform/gtk/fast/tokenizer/external-script-document-write_2-expected.png: Removed.
* platform/gtk/fast/tokenizer/external-script-document-write_2-expected.txt: Removed.
* platform/gtk/fast/tokenizer/script_extra_close-expected.png: Removed.
* platform/gtk/fast/tokenizer/script_extra_close-expected.txt: Removed.
* platform/mac-leopard/fast/tokenizer/002-expected.png: Removed.
* platform/mac-leopard/fast/tokenizer/external-script-document-write_2-expected.png: Removed.
* platform/mac-leopard/fast/tokenizer/script_extra_close-expected.png: Removed.
* platform/mac/fast/tokenizer/002-expected.png: Removed.
* platform/mac/fast/tokenizer/002-expected.txt: Removed.
* platform/mac/fast/tokenizer/external-script-document-write_2-expected.png: Removed.
* platform/mac/fast/tokenizer/external-script-document-write_2-expected.txt: Removed.
* platform/mac/fast/tokenizer/script_extra_close-expected.png: Removed.
* platform/mac/fast/tokenizer/script_extra_close-expected.txt: Removed.
* platform/qt/fast/tokenizer/002-expected.png: Removed.
* platform/qt/fast/tokenizer/002-expected.txt: Removed.
* platform/qt/fast/tokenizer/external-script-document-write_2-expected.png: Removed.
* platform/qt/fast/tokenizer/external-script-document-write_2-expected.txt: Removed.
* platform/qt/fast/tokenizer/script_extra_close-expected.png: Removed.
* platform/qt/fast/tokenizer/script_extra_close-expected.txt: Removed.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@94213 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/dom/ScriptElement.cpp b/Source/WebCore/dom/ScriptElement.cpp
index 29e7de0..4bebe37 100644
--- a/Source/WebCore/dom/ScriptElement.cpp
+++ b/Source/WebCore/dom/ScriptElement.cpp
@@ -32,6 +32,7 @@
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "HTMLNames.h"
+#include "HTMLParserIdioms.h"
 #include "HTMLScriptElement.h"
 #include "IgnoreDestructiveWriteCountIncrementer.h"
 #include "MIMETypeRegistry.h"
@@ -254,10 +255,11 @@
         return false;
 
     ASSERT(!m_cachedScript);
-    // FIXME: If sourceUrl is empty, we should dispatchErrorEvent().
-    ResourceRequest request(m_element->document()->completeURL(sourceUrl));
-    m_cachedScript = m_element->document()->cachedResourceLoader()->requestScript(request, scriptCharset());
-    m_isExternalScript = true;
+    if (!stripLeadingAndTrailingHTMLSpaces(sourceUrl).isEmpty()) {
+        ResourceRequest request(m_element->document()->completeURL(sourceUrl));
+        m_cachedScript = m_element->document()->cachedResourceLoader()->requestScript(request, scriptCharset());
+        m_isExternalScript = true;
+    }
 
     if (m_cachedScript) {
         ASSERT(m_cachedScriptState == NeverSet);