Reviewed by Weinig, Dan and Alexey.
Fix for:
<rdar://problem/
5333163> Safari can not display the mouse over pop menu on ChinaTimes News site correctly.
<rdar://problem/
5530048> [Safari]? :Leopard9A576: The typed CH characters displays as garbage in Sina website after reloading the webpage.
<rdar://problem/
5416588> All menus for chinese IBM site have wrong encoding
Use the same logic to determine the charset for a script loaded dynamically
as we do for a statically loaded script.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@28612
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2007-12-10 Oliver Hunt <oliver@apple.com>
+
+ Reviewed by Weinig, Dan and Alexey.
+
+ Layout test to confirm correct character encoding is used to
+ load dynamically loaded scripts.
+
+ * fast/encoding/no-charset-on-dynamic-script-load.html: Added.
+ * fast/encoding/resources/dynamic-load-target.js: Added.
+
2007-12-10 Justin Garcia <justin.garcia@apple.com>
Reviewed by Oliver Hunt.
--- /dev/null
+This page tests that the character encoding is used for dynamically loaded scripts when no charset is specified directly or provided by the server.
+PASS: UTF-8 was correctly used for this script.
--- /dev/null
+<html>
+ <head>
+ <title>Encoding test.</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ </head>
+ <body>
+ This page tests that the character encoding is used for dynamically loaded
+ scripts when no charset is specified directly or provided by the server.
+
+ <div id="target"></div>
+ <script>
+ if (window.layoutTestController) {
+ window.layoutTestController.waitUntilDone();
+ window.layoutTestController.dumpAsText();
+ }
+ tokyo = 'とうきょう';
+ oDIVResults=document.createElement('script');
+ oDIVResults.src="resources/dynamic-load-target.js";
+ document.getElementsByTagName("head").item(0).appendChild(oDIVResults);
+ </script>
+ </body>
+</html>
--- /dev/null
+
+
+if ('とうきょう' == tokyo)
+ document.getElementById("target").innerHTML = "PASS: UTF-8 was correctly used for this script.";
+else
+ document.getElementById("target").innerHTML = "FAIL: Incorrect encoding used. Expected '" + tokyo + "' but got '" + 'とうきょう' + "'.";
+
+if (window.layoutTestController)
+ window.layoutTestController.notifyDone();
+2007-12-10 Oliver Hunt <oliver@apple.com>
+
+ Reviewed by Weinig, Dan, and Alexey.
+
+ Fix character set used for dynamically loaded scripts.
+
+ Fix for:
+ <rdar://problem/5333163> Safari can not display the mouse over pop menu on ChinaTimes News site correctly.
+ <rdar://problem/5530048> [Safari]? :Leopard9A576: The typed CH characters displays as garbage in Sina website after reloading the webpage.
+ <rdar://problem/5416588> All menus for chinese IBM site have wrong encoding
+
+ Use the same logic to determine the charset for a script loaded dynamically
+ as we do for a statically loaded script.
+
+ * html/HTMLScriptElement.cpp:
+ (WebCore::HTMLScriptElement::insertedIntoDocument):
+
2007-12-10 Justin Garcia <justin.garcia@apple.com>
Reviewed by Oliver Hunt.
#include "Document.h"
#include "EventNames.h"
#include "Frame.h"
+#include "FrameLoader.h"
#include "HTMLNames.h"
#include "kjs_proxy.h"
#include "Text.h"
const AtomicString& url = getAttribute(srcAttr);
if (!url.isEmpty()) {
- m_cachedScript = document()->docLoader()->requestScript(url, getAttribute(charsetAttr));
+ String scriptSrcCharset = getAttribute(charsetAttr).domString().stripWhiteSpace();
+ if (scriptSrcCharset.isEmpty()) {
+ if (Frame* frame = document()->frame())
+ scriptSrcCharset = frame->loader()->encoding();
+ }
+ m_cachedScript = document()->docLoader()->requestScript(url, scriptSrcCharset);
if (m_cachedScript)
m_cachedScript->ref(this);
else