WebCore:
authordimich@chromium.org <dimich@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Mar 2009 21:21:06 +0000 (21:21 +0000)
committerdimich@chromium.org <dimich@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Mar 2009 21:21:06 +0000 (21:21 +0000)
2009-03-04  Dmitry Titov  <dimich@chromium.org>

        Reviewed by Alexey Proskuryakov.

        https://bugs.webkit.org/show_bug.cgi?id=24150
        Add virtual ScriptExecutionContext::encoding()

        Test: http/tests/workers/text-encoding.html

        * dom/Document.cpp:
        (WebCore::Document::encoding):
        * dom/Document.h:
        (WebCore::Document::inputEncoding):
        (WebCore::Document::charset):
        (WebCore::Document::characterSet):
        Add new virtual method and route DOM synonym functions on Document through it.

        * dom/ScriptExecutionContext.h:
        * workers/Worker.cpp:
        (WebCore::Worker::Worker):
        (WebCore::Worker::notifyFinished):
        * workers/WorkerContext.cpp:
        (WebCore::WorkerContext::WorkerContext):
        (WebCore::WorkerContext::encoding):
        (WebCore::WorkerContext::completeURL): Added comment on why this is different from Document::completeURL
        * workers/WorkerContext.h:
        (WebCore::WorkerContext::create):
        * workers/WorkerContextProxy.h:
        * workers/WorkerMessagingProxy.cpp:
        (WebCore::WorkerMessagingProxy::startWorkerContext):
        * workers/WorkerMessagingProxy.h:
        * workers/WorkerThread.cpp:
        (WebCore::WorkerThreadStartupData::create):
        (WebCore::WorkerThreadStartupData::WorkerThreadStartupData):
        (WebCore::WorkerThread::create):
        (WebCore::WorkerThread::WorkerThread):
        (WebCore::WorkerThread::workerThread):
        * workers/WorkerThread.h:
        All of the above route the 'encoding' parameter of parent context to the new
        instance of WorkerContext - from Worker::notifyFinished() via WorkerMessagingProxy
        through WorkerThread through WorkerThreadStartupData and into constructor of WorkerContext.

LayoutTests:

2009-03-04  Dmitry Titov  <dimich@chromium.org>

        Reviewed by Alexey Proskuryakov.

        https://bugs.webkit.org/show_bug.cgi?id=24150
        Add virtual ScriptExecutionContext::encoding()

        Test to verify how the text encoding in workers is used.
        Script decoding and url completion is checked, with and
        w/o http 'Content-Type: ...;charset=...' header.

        * http/tests/workers/resources/worker-encoded.php: Added.
        * http/tests/workers/resources/xhr-query-utf8.php: Added.
        * http/tests/workers/resources/xhr-response.php: Added.
        * http/tests/workers/text-encoding-expected.txt: Added.
        * http/tests/workers/text-encoding.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@41499 268f45cc-cd09-0410-ab3c-d52691b4dbfc

18 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/workers/resources/worker-encoded.php [new file with mode: 0644]
LayoutTests/http/tests/workers/resources/xhr-query-utf8.php [new file with mode: 0644]
LayoutTests/http/tests/workers/resources/xhr-response.php [new file with mode: 0644]
LayoutTests/http/tests/workers/text-encoding-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/workers/text-encoding.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/dom/Document.cpp
WebCore/dom/Document.h
WebCore/dom/ScriptExecutionContext.h
WebCore/workers/Worker.cpp
WebCore/workers/WorkerContext.cpp
WebCore/workers/WorkerContext.h
WebCore/workers/WorkerContextProxy.h
WebCore/workers/WorkerMessagingProxy.cpp
WebCore/workers/WorkerMessagingProxy.h
WebCore/workers/WorkerThread.cpp
WebCore/workers/WorkerThread.h

index 71274f1..395dd77 100644 (file)
@@ -1,3 +1,20 @@
+2009-03-06  Dmitry Titov  <dimich@chromium.org>
+
+        Reviewed by Alexey Proskuryakov.
+
+        https://bugs.webkit.org/show_bug.cgi?id=24150
+        Add virtual ScriptExecutionContext::encoding()
+
+        Test to verify how the text encoding in workers is used.
+        Script decoding and url completion is checked, with and
+        w/o http 'Content-Type: ...;charset=...' header.
+
+        * http/tests/workers/resources/worker-encoded.php: Added.
+        * http/tests/workers/resources/xhr-query-utf8.php: Added.
+        * http/tests/workers/resources/xhr-response.php: Added.
+        * http/tests/workers/text-encoding-expected.txt: Added.
+        * http/tests/workers/text-encoding.html: Added.
+
 2009-03-04  Chris Marrin  <cmarrin@apple.com>
 
         Reviewed by Simon Fraser.
diff --git a/LayoutTests/http/tests/workers/resources/worker-encoded.php b/LayoutTests/http/tests/workers/resources/worker-encoded.php
new file mode 100644 (file)
index 0000000..413516d
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+header("Expires: Thu, 01 Dec 2003 16:00:00 GMT");
+header("Cache-Control: no-cache, must-revalidate");
+header("Pragma: no-cache");
+
+// Parent document has Windows-1251 encoding. This test verifies that worker script gets decoded using
+// parent document encoding or the one in http header, if specified.
+$charset=$_GET['charset'];
+if ($charset == "koi8-r") {
+    header("Content-Type: text/javascript;charset=koi8-r");
+    print("postMessage('Has http header with charset=koi8-r');");
+} else {
+    header("Content-Type: text/javascript");
+    print("postMessage('Has no http header with charset');");
+}
+
+print("postMessage('Original test string: ' + String.fromCharCode(0x41F, 0x440, 0x438, 0x432, 0x435, 0x442));");
+print("postMessage('Test: \xF0\xD2\xC9\xD7\xC5\xD4 (encoded using koi8-r).');");
+print("postMessage('Test: \xCF\xF0\xE8\xE2\xE5\xF2 (encoded using Windows-1251).');");
+
+// Test how XHR decodes its response text. Should be UTF8 or a charset from http header.
+print("var xhr = new XMLHttpRequest(); xhr.open('GET', 'xhr-response.php', false);");
+print("xhr.send(); postMessage(xhr.responseText);");
+
+print("var xhr = new XMLHttpRequest(); xhr.open('GET', 'xhr-response.php?charset=koi8-r', false);");
+print("xhr.send(); postMessage(xhr.responseText);");
+
+// Test that URL completion is done using UTF-8, regardless of the worker's script encoding.
+// The server script verifies that query parameter is encoded in UTF-8.
+print("var xhr = new XMLHttpRequest(); xhr.open('GET', 'xhr-query-utf8.php?query=' + String.fromCharCode(0x41F, 0x440, 0x438, 0x432, 0x435, 0x442), false);");
+print("xhr.send(); postMessage(xhr.responseText);");
+
+print("postMessage('exit');");
+?>
diff --git a/LayoutTests/http/tests/workers/resources/xhr-query-utf8.php b/LayoutTests/http/tests/workers/resources/xhr-query-utf8.php
new file mode 100644 (file)
index 0000000..1fe872d
--- /dev/null
@@ -0,0 +1,14 @@
+<?php
+header("Expires: Thu, 01 Dec 2003 16:00:00 GMT");
+header("Cache-Control: no-cache, must-revalidate");
+header("Pragma: no-cache");
+
+$query=$_GET['query'];
+if ($query == "\xD0\x9F\xD1\x80\xD0\xB8\xD0\xB2\xD0\xB5\xD1\x82") {
+    print("PASS: XHR query was encoded in UTF-8: ");
+    print($query);
+} else {
+    print("FAIL: XHR query was NOT encoded in UTF-8: ");
+    print($query);
+}
+?>
diff --git a/LayoutTests/http/tests/workers/resources/xhr-response.php b/LayoutTests/http/tests/workers/resources/xhr-response.php
new file mode 100644 (file)
index 0000000..58bbd3b
--- /dev/null
@@ -0,0 +1,16 @@
+<?php
+header("Expires: Thu, 01 Dec 2003 16:00:00 GMT");
+header("Cache-Control: no-cache, must-revalidate");
+header("Pragma: no-cache");
+
+// The XHR response contains word 'Привет!' (Hello!), in koi8-r encoding (with http header) or in utf8.
+// It should always be decoded as 'Привет!', regardless of the parent document/worker encoding.
+$charset=$_GET['charset'];
+if ($charset == "koi8-r") {
+    header("Content-Type: text/plain; charset=koi8-r");
+    print("XHR: \xF0\xD2\xC9\xD7\xC5\xD4");
+} else {
+    header("Content-Type: text/plain;");
+    print("XHR: Привет");
+}
+?>
diff --git a/LayoutTests/http/tests/workers/text-encoding-expected.txt b/LayoutTests/http/tests/workers/text-encoding-expected.txt
new file mode 100644 (file)
index 0000000..8d06213
--- /dev/null
@@ -0,0 +1,29 @@
+This test verifies handling of text encoding in workers. The behavior matches FF3.1b2 with a single exclusion (see below).
+This is what's tested:
+- If http header 'Content-Type' with 'charset' specified is on response with worker script or XHR payload, that encoding is used.
+- In absense of http header, the script of the worker is decoded using the text encoding of the parent document.
+- In absense of http header, the content of the XHR request is decoded using UTF-8.
+- The URLs used in workers (for subworkers or XHR) are always encoded using UTF-8 (in regular html documents parts of the query an hash may be encoded with other encodings).
+- The base URL for the worker (used to resolve relative URLs for subworkers and XHR) is the URL of its script. Note: this is different from FF 3.1b2 which is using the URL of the parent document, which may be a bug (TBD).
+
+Document encoding: windows-1251
+Document, Workers: All XHR responses should match this: Привет
+Document: : XHR: Привет
+Document: Проверка
+worker 1: Has no http header with charset
+worker 1: Original test string: Привет
+worker 1: PASS: XHR query was encoded in UTF-8: Привет
+worker 1: Test: Привет (encoded using Windows-1251).
+worker 1: Test: рТЙЧЕФ (encoded using koi8-r).
+worker 1: XHR: Привет
+worker 1: XHR: Привет
+worker 1: exit
+worker 2: Has http header with charset=koi8-r
+worker 2: Original test string: Привет
+worker 2: PASS: XHR query was encoded in UTF-8: Привет
+worker 2: Test: Привет (encoded using koi8-r).
+worker 2: Test: оПХБЕР (encoded using Windows-1251).
+worker 2: XHR: Привет
+worker 2: XHR: Привет
+worker 2: exit
+
diff --git a/LayoutTests/http/tests/workers/text-encoding.html b/LayoutTests/http/tests/workers/text-encoding.html
new file mode 100644 (file)
index 0000000..12a5c7d
--- /dev/null
@@ -0,0 +1,70 @@
+<html>
+<meta http-equiv="content-type" content="text/html; charset=windows-1251">
+<body>
+This test verifies handling of text encoding in workers. The behavior matches FF3.1b2 with a single exclusion (see below).<br>
+This is what's tested:<br>
+- If http header 'Content-Type' with 'charset' specified is on response with worker script or XHR payload, that encoding is used.<br>
+- In absense of http header, the script of the worker is decoded using the text encoding of the parent document.<br>
+- In absense of http header, the content of the XHR request is decoded using UTF-8.<br>
+- The URLs used in workers (for subworkers or XHR) are always encoded using UTF-8 (in regular html documents parts of the query an hash may be encoded with other encodings).<br>
+- The base URL for the worker (used to resolve relative URLs for subworkers and XHR) is the URL of its script. Note: this is different from FF 3.1b2 which is using the URL of the parent document, which may be a bug (TBD).<br><br>
+
+<div style="background:beige; padding:10px;" id="status"></div>
+
+<script>
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+}
+
+// Wait for this many workers to finish their tests.
+// When worker is done, it sends 'exit' message.
+var workerCount = 2;
+
+// Messages from workers in separate threads will come in unstable order. Sort them to have a stable test.
+var statusStrings = new Array;
+
+function finishTest()
+{
+    statusStrings.sort();
+    var status_panel = document.getElementById("status");
+    for (var i = 0; i < statusStrings.length; ++i) {
+        status_panel.appendChild(document.createTextNode(statusStrings[i]));
+        status_panel.appendChild(document.createElement("br"));
+    }
+    if (window.layoutTestController)
+        layoutTestController.notifyDone();
+}
+
+function log(source, msg)
+{
+    statusStrings.push(source + ": " + msg);
+
+    if (msg == "exit" && --workerCount == 0)
+        finishTest();
+} 
+
+// Output current charset and a string in that encoding to make
+// sure this document is decoded as Windows-1251.
+log("Document encoding", document.inputEncoding);
+log("Document", "Ïðîâåðêà");
+
+log("Document, Workers", "All XHR responses should match this: " + String.fromCharCode(0x41F, 0x440, 0x438, 0x432, 0x435, 0x442));
+
+// Run a worker w/o http header. It should inherit the encoding of the document.
+var worker1 = new Worker("resources/worker-encoded.php");
+worker1.onmessage = function(evt) { log("worker 1", evt.data); };
+
+// Run a worker with http header specifying charset. This new charset should be in effect.
+var worker2 = new Worker("resources/worker-encoded.php?charset=koi8-r");
+worker2.onmessage = function(evt) { log("worker 2", evt.data); };
+
+// Request some content. It should be decoded using UTF-8 even though current document is Windows-1251.
+var xhr = new XMLHttpRequest();xhr.open("GET", "resources/xhr-response.php", false);
+xhr.send();log("Document: ", xhr.responseText);
+
+</script>
+</body>
+</html>
+
+    
index 04f2946..6ad3777 100644 (file)
@@ -1,3 +1,45 @@
+2009-03-06  Dmitry Titov  <dimich@chromium.org>
+
+        Reviewed by Alexey Proskuryakov.
+
+        https://bugs.webkit.org/show_bug.cgi?id=24150
+        Add virtual ScriptExecutionContext::encoding()
+
+        Test: http/tests/workers/text-encoding.html
+
+        * dom/Document.cpp:
+        (WebCore::Document::encoding):
+        * dom/Document.h:
+        (WebCore::Document::inputEncoding):
+        (WebCore::Document::charset):
+        (WebCore::Document::characterSet):
+        Add new virtual method and route DOM synonym functions on Document through it.
+
+        * dom/ScriptExecutionContext.h:
+        * workers/Worker.cpp:
+        (WebCore::Worker::Worker):
+        (WebCore::Worker::notifyFinished):
+        * workers/WorkerContext.cpp:
+        (WebCore::WorkerContext::WorkerContext):
+        (WebCore::WorkerContext::encoding):
+        (WebCore::WorkerContext::completeURL): Added comment on why this is different from Document::completeURL
+        * workers/WorkerContext.h:
+        (WebCore::WorkerContext::create):
+        * workers/WorkerContextProxy.h:
+        * workers/WorkerMessagingProxy.cpp:
+        (WebCore::WorkerMessagingProxy::startWorkerContext):
+        * workers/WorkerMessagingProxy.h:
+        * workers/WorkerThread.cpp:
+        (WebCore::WorkerThreadStartupData::create):
+        (WebCore::WorkerThreadStartupData::WorkerThreadStartupData):
+        (WebCore::WorkerThread::create):
+        (WebCore::WorkerThread::WorkerThread):
+        (WebCore::WorkerThread::workerThread):
+        * workers/WorkerThread.h:
+        All of the above route the 'encoding' parameter of parent context to the new
+        instance of WorkerContext - from Worker::notifyFinished() via WorkerMessagingProxy
+        through WorkerThread through WorkerThreadStartupData and into constructor of WorkerContext.
+
 2009-03-06  Peter Kasting  <pkasting@google.com>
 
         Build bustage fix.
index 9e65db5..ea9deb9 100644 (file)
@@ -827,7 +827,7 @@ String Document::readyState() const
     return String();
 }
 
-String Document::inputEncoding() const
+String Document::encoding() const
 {
     if (TextResourceDecoder* d = decoder())
         return d->encoding().name();
index cf328da..c9b2184 100644 (file)
@@ -241,11 +241,13 @@ public:
 
     Element* elementFromPoint(int x, int y) const;
     String readyState() const;
-    String inputEncoding() const;
-    String defaultCharset() const;
 
-    String charset() const { return inputEncoding(); }
-    String characterSet() const { return inputEncoding(); }
+    String defaultCharset() const;
+    
+    // Synonyms backing similar DOM attributes. Use Document::encoding() to avoid virtual dispatch.
+    String inputEncoding() const { return Document::encoding(); }
+    String charset() const { return Document::encoding(); }
+    String characterSet() const { return Document::encoding(); }
 
     void setCharset(const String&);
 
@@ -444,6 +446,7 @@ public:
     KURL completeURL(const String&) const;
 
     virtual String userAgent(const KURL&) const;
+    virtual String encoding() const;
 
     // from cachedObjectClient
     virtual void setCSSStyleSheet(const String& url, const String& charset, const CachedCSSStyleSheet*);
index cf327d7..867d34f 100644 (file)
@@ -60,6 +60,7 @@ namespace WebCore {
         KURL completeURL(const String& url) const { return virtualCompleteURL(url); }
 
         virtual String userAgent(const KURL&) const = 0;
+        virtual String encoding() const = 0;
 
         SecurityOrigin* securityOrigin() const { return m_securityOrigin.get(); }
 
index 0bc9da2..6009c8f 100644 (file)
@@ -64,11 +64,11 @@ Worker::Worker(const String& url, ScriptExecutionContext* context, ExceptionCode
         return;
     }
 
-    // FIXME: 'inherit' charset and actual loading support from original document to enable nested workers.
+    // FIXME: Nested workers need loading support. Consider adopting ThreadableLoader here.
     ASSERT(scriptExecutionContext()->isDocument());
     Document* document = static_cast<Document*>(scriptExecutionContext());
 
-    m_cachedScript = document->docLoader()->requestScript(m_scriptURL, document->charset());
+    m_cachedScript = document->docLoader()->requestScript(m_scriptURL, scriptExecutionContext()->encoding());
     if (!m_cachedScript) {
         dispatchErrorEvent();
         return;
@@ -118,7 +118,7 @@ void Worker::notifyFinished(CachedResource* unusedResource)
     if (m_cachedScript->errorOccurred())
         dispatchErrorEvent();
     else
-        m_contextProxy->startWorkerContext(m_scriptURL, scriptExecutionContext()->userAgent(m_scriptURL), m_cachedScript->script());
+        m_contextProxy->startWorkerContext(m_scriptURL, scriptExecutionContext()->userAgent(m_scriptURL), scriptExecutionContext()->encoding(), m_cachedScript->script());
 
     m_cachedScript->removeClient(this);
     m_cachedScript = 0;
index a29a8e4..fda2e6d 100644 (file)
 
 namespace WebCore {
 
-WorkerContext::WorkerContext(const KURL& url, const String& userAgent, WorkerThread* thread)
+WorkerContext::WorkerContext(const KURL& url, const String& userAgent, const String& encoding, WorkerThread* thread)
     : m_url(url)
     , m_userAgent(userAgent)
+    , m_encoding(encoding)
     , m_location(WorkerLocation::create(url))
     , m_script(new WorkerScriptController(this))
     , m_thread(thread)
@@ -85,7 +86,9 @@ KURL WorkerContext::completeURL(const String& url) const
     // FIXME: Should we change the KURL constructor to have this behavior?
     if (url.isNull())
         return KURL();
-    // FIXME: does this need to provide a charset, like Document::completeURL does?
+    // FIXME: Document::completeURL provides a charset here (to encode query portion of url when
+    // submitting charset-encoded forms data). FF3.1b2 uses original document's encoding for nested
+    // Workers and importScripts but UTF-8 for XHR. If it's not a bug, we probably should match FF.
     return KURL(m_location->url(), url);
 }
 
@@ -94,6 +97,11 @@ String WorkerContext::userAgent(const KURL&) const
     return m_userAgent;
 }
 
+String WorkerContext::encoding() const
+{
+    return m_encoding;
+}
+
 WorkerNavigator* WorkerContext::navigator() const
 {
     if (!m_navigator)
index 414e13a..2255554 100644 (file)
@@ -48,9 +48,9 @@ namespace WebCore {
 
     class WorkerContext : public RefCounted<WorkerContext>, public ScriptExecutionContext, public EventTarget {
     public:
-        static PassRefPtr<WorkerContext> create(const KURL& url, const String& userAgent, WorkerThread* thread)
+        static PassRefPtr<WorkerContext> create(const KURL& url, const String& userAgent, const String& encoding, WorkerThread* thread)
         {
-            return adoptRef(new WorkerContext(url, userAgent, thread));
+            return adoptRef(new WorkerContext(url, userAgent, encoding, thread));
         }
 
         virtual ~WorkerContext();
@@ -63,6 +63,7 @@ namespace WebCore {
         KURL completeURL(const String&) const;
 
         virtual String userAgent(const KURL&) const;
+        virtual String encoding() const;
 
         WorkerLocation* location() const { return m_location.get(); }
         WorkerNavigator* navigator() const;
@@ -107,13 +108,14 @@ namespace WebCore {
         virtual void refEventTarget() { ref(); }
         virtual void derefEventTarget() { deref(); }
 
-        WorkerContext(const KURL&, const String&, WorkerThread*);
+        WorkerContext(const KURL&, const String&, const String& encoding, WorkerThread*);
 
         virtual const KURL& virtualURL() const;
         virtual KURL virtualCompleteURL(const String&) const;
 
         KURL m_url;
         String m_userAgent;
+        String m_encoding;
         RefPtr<WorkerLocation> m_location;
         mutable RefPtr<WorkerNavigator> m_navigator;
 
index c8f5761..87925df 100644 (file)
@@ -46,7 +46,7 @@ namespace WebCore {
 
         virtual ~WorkerContextProxy() {}
 
-        virtual void startWorkerContext(const KURL& scriptURL, const String& userAgent, const String& sourceCode) = 0;
+        virtual void startWorkerContext(const KURL& scriptURL, const String& userAgent, const String& encoding, const String& sourceCode) = 0;
 
         virtual void terminateWorkerContext() = 0;
 
index 4b34658..c60af5c 100644 (file)
@@ -198,9 +198,9 @@ WorkerMessagingProxy::~WorkerMessagingProxy()
            || (m_scriptExecutionContext->isWorkerContext() && currentThread() == static_cast<WorkerContext*>(m_scriptExecutionContext.get())->thread()->threadID()));
 }
 
-void WorkerMessagingProxy::startWorkerContext(const KURL& scriptURL, const String& userAgent, const String& sourceCode)
+void WorkerMessagingProxy::startWorkerContext(const KURL& scriptURL, const String& userAgent, const String& encoding, const String& sourceCode)
 {
-    RefPtr<WorkerThread> thread = WorkerThread::create(scriptURL, userAgent, sourceCode, this);
+    RefPtr<WorkerThread> thread = WorkerThread::create(scriptURL, userAgent, encoding, sourceCode, this);
     workerThreadCreated(thread);
     thread->start();
 }
index 8d81deb..e3044d4 100644 (file)
@@ -50,7 +50,7 @@ namespace WebCore {
 
         // Implementations of WorkerContextProxy.
         // (Only use these methods in the worker object thread.)
-        virtual void startWorkerContext(const KURL& scriptURL, const String& userAgent, const String& sourceCode);
+        virtual void startWorkerContext(const KURL& scriptURL, const String& userAgent, const String& encoding, const String& sourceCode);
         virtual void terminateWorkerContext();
         virtual void postMessageToWorkerContext(const String& message);
         virtual bool hasPendingActivity() const;
index 9a5ee21..b4f3ab4 100644 (file)
 namespace WebCore {
 struct WorkerThreadStartupData : Noncopyable {
 public:
-    static std::auto_ptr<WorkerThreadStartupData> create(const KURL& scriptURL, const String& userAgent, const String& sourceCode)
+    static std::auto_ptr<WorkerThreadStartupData> create(const KURL& scriptURL, const String& userAgent, const String& encoding, const String& sourceCode)
     {
-        return std::auto_ptr<WorkerThreadStartupData>(new WorkerThreadStartupData(scriptURL, userAgent, sourceCode));
+        return std::auto_ptr<WorkerThreadStartupData>(new WorkerThreadStartupData(scriptURL, userAgent, encoding, sourceCode));
     }
 
     KURL m_scriptURL;
     String m_userAgent;
+    String m_encoding;
     String m_sourceCode;
 private:
-    WorkerThreadStartupData(const KURL& scriptURL, const String& userAgent, const String& sourceCode);
+    WorkerThreadStartupData(const KURL& scriptURL, const String& userAgent, const String& encoding, const String& sourceCode);
 };
 
-WorkerThreadStartupData::WorkerThreadStartupData(const KURL& scriptURL, const String& userAgent, const String& sourceCode)
+WorkerThreadStartupData::WorkerThreadStartupData(const KURL& scriptURL, const String& userAgent, const String& encoding, const String& sourceCode)
     : m_scriptURL(scriptURL.copy())
     , m_userAgent(userAgent.copy())
+    , m_encoding(encoding.copy())
     , m_sourceCode(sourceCode.copy())
 {
 }
 
-PassRefPtr<WorkerThread> WorkerThread::create(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerObjectProxy* workerObjectProxy)
+PassRefPtr<WorkerThread> WorkerThread::create(const KURL& scriptURL, const String& userAgent, const String& encoding, const String& sourceCode, WorkerObjectProxy* workerObjectProxy)
 {
-    return adoptRef(new WorkerThread(scriptURL, userAgent, sourceCode, workerObjectProxy));
+    return adoptRef(new WorkerThread(scriptURL, userAgent, encoding, sourceCode, workerObjectProxy));
 }
 
-WorkerThread::WorkerThread(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerObjectProxy* workerObjectProxy)
+WorkerThread::WorkerThread(const KURL& scriptURL, const String& userAgent, const String& encoding, const String& sourceCode, WorkerObjectProxy* workerObjectProxy)
     : m_threadID(0)
     , m_workerObjectProxy(workerObjectProxy)
-    , m_startupData(WorkerThreadStartupData::create(scriptURL, userAgent, sourceCode))
+    , m_startupData(WorkerThreadStartupData::create(scriptURL, userAgent, encoding, sourceCode))
 {
 }
 
@@ -100,7 +102,7 @@ void* WorkerThread::workerThread()
 {
     {
         MutexLocker lock(m_threadCreationMutex);
-        m_workerContext = WorkerContext::create(m_startupData->m_scriptURL, m_startupData->m_userAgent, this);
+        m_workerContext = WorkerContext::create(m_startupData->m_scriptURL, m_startupData->m_userAgent, m_startupData->m_encoding, this);
         if (m_runLoop.terminated()) {
             // The worker was terminated before the thread had a chance to run. Since the context didn't exist yet, 
             // forbidExecution() couldn't be called from stop().
index f1a8a52..b0abb83 100644 (file)
@@ -44,7 +44,7 @@ namespace WebCore {
 
     class WorkerThread : public RefCounted<WorkerThread> {
     public:
-        static PassRefPtr<WorkerThread> create(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerObjectProxy*);
+        static PassRefPtr<WorkerThread> create(const KURL& scriptURL, const String& userAgent, const String& encoding, const String& sourceCode, WorkerObjectProxy*);
         ~WorkerThread();
 
         bool start();
@@ -55,7 +55,7 @@ namespace WebCore {
         WorkerObjectProxy* workerObjectProxy() const { return m_workerObjectProxy; }
 
     private:
-        WorkerThread(const KURL&, const String& userAgent, const String& sourceCode, WorkerObjectProxy*);
+        WorkerThread(const KURL&, const String& userAgent, const String& encoding, const String& sourceCode, WorkerObjectProxy*);
 
         static void* workerThreadStart(void*);
         void* workerThread();