2009-03-20 Dmitry Titov <dimich@chromium.org>
Reviewed by Alexey Proskuryakov.
https://bugs.webkit.org/show_bug.cgi?id=24706
Remove ScriptExecutionContext::encoding() since Workers do not need it.
WorkerContext::encoding() is simply removed, while Document::encoding()
made non-virtual and private. Workers use UTF-8 now except when instructed
otherwise by http header. Also updated test.
* dom/Document.h: Made encoding() non-virtual and private.
* dom/ScriptExecutionContext.h: removed encoding().
* workers/Worker.cpp:
(WebCore::Worker::Worker):
(WebCore::Worker::notifyFinished):
* workers/WorkerContext.cpp: removed encoding() implementation.
(WebCore::WorkerContext::WorkerContext):
(WebCore::WorkerContext::completeURL):
* workers/WorkerContext.h: removed encoding()
(WebCore::WorkerContext::create):
* workers/WorkerContextProxy.h:
* workers/WorkerImportScriptsClient.cpp:
(WebCore::WorkerImportScriptsClient::didReceiveData):
* 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:
In all these, removed storing encoding and 'inheriting' it from the parent.
Instead, they are all using UTF-8 now.
LayoutTests:
2009-03-20 Dmitry Titov <dimich@chromium.org>
Reviewed by Alexey Proskuryakov.
https://bugs.webkit.org/show_bug.cgi?id=24706
Remove ScriptExecutionContext::encoding() since Workers do not need it.
WorkerContext::encoding() is simply removed, while Document::encoding()
made non-virtual and private. Workers use UTF-8 now except when instructed
otherwise by http header. Updated test.
Also, added test for encoding used by importScripts().
* http/tests/workers/resources/subworker-encoded.php: Added.
* http/tests/workers/resources/worker-encoded.php:
* http/tests/workers/text-encoding-expected.txt:
* http/tests/workers/text-encoding.html:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@41871
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2009-03-20 Dmitry Titov <dimich@chromium.org>
+
+ Reviewed by Alexey Proskuryakov.
+
+ https://bugs.webkit.org/show_bug.cgi?id=24706
+ Remove ScriptExecutionContext::encoding() since Workers do not need it.
+ WorkerContext::encoding() is simply removed, while Document::encoding()
+ made non-virtual and private. Workers use UTF-8 now except when instructed
+ otherwise by http header. Updated test.
+ Also, added test for encoding used by importScripts().
+
+ * http/tests/workers/resources/subworker-encoded.php: Added.
+ * http/tests/workers/resources/worker-encoded.php:
+ * http/tests/workers/text-encoding-expected.txt:
+ * http/tests/workers/text-encoding.html:
+
2009-03-20 Beth Dakin <bdakin@apple.com>
Reviewed by Dave Hyatt.
}
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).');");
+print("postMessage('Test string encoded using koi8-r: \xF0\xD2\xC9\xD7\xC5\xD4.');");
+print("postMessage('Test string encoded using Windows-1251: \xCF\xF0\xE8\xE2\xE5\xF2.');");
+print("postMessage('Test string encoded using UTF-8: \xD0\x9F\xD1\x80\xD0\xB8\xD0\xB2\xD0\xB5\xD1\x82.');");
// 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("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("importScripts('subworker-encoded.php');");
+
print("postMessage('exit');");
?>
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.
+- In absence of http header, the script of the worker is decoded using UTF-8.
+- In absence 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).
-
+- The base URL for the worker (used to resolve relative URLs for subworkers and XHR) is the URL of its script.
+- importScripts() decodes the scripts using UTF-8.
Document encoding: windows-1251
Document, Workers: All XHR responses should match this: Привет
Document: : XHR: Привет
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: Sub: Original test string: Привет
+worker 1: Sub: Test string encoded using UTF-8: Привет.
+worker 1: Sub: Test string encoded using Windows-1251: ������.
+worker 1: Sub: Test string encoded using koi8-r: ������.
+worker 1: Test string encoded using UTF-8: Привет.
+worker 1: Test string encoded using Windows-1251: ������.
+worker 1: Test string 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: Sub: Original test string: Привет
+worker 2: Sub: Test string encoded using UTF-8: Привет.
+worker 2: Sub: Test string encoded using Windows-1251: ������.
+worker 2: Sub: Test string encoded using koi8-r: ������.
+worker 2: Test string encoded using UTF-8: п÷я─п╦п╡п╣я┌.
+worker 2: Test string encoded using Windows-1251: оПХБЕР.
+worker 2: Test string encoded using koi8-r: Привет.
worker 2: XHR: Привет
worker 2: XHR: Привет
worker 2: exit
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>
+- In absence of http header, the script of the worker is decoded using UTF-8.<br>
+- In absence 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>
+- The base URL for the worker (used to resolve relative URLs for subworkers and XHR) is the URL of its script.<br>
+- importScripts() decodes the scripts using UTF-8.<br>
<div style="background:beige; padding:10px;" id="status"></div>
+2009-03-20 Dmitry Titov <dimich@chromium.org>
+
+ Reviewed by Alexey Proskuryakov.
+
+ https://bugs.webkit.org/show_bug.cgi?id=24706
+ Remove ScriptExecutionContext::encoding() since Workers do not need it.
+ WorkerContext::encoding() is simply removed, while Document::encoding()
+ made non-virtual and private. Workers use UTF-8 now except when instructed
+ otherwise by http header. Also updated test.
+
+ * dom/Document.h: Made encoding() non-virtual and private.
+ * dom/ScriptExecutionContext.h: removed encoding().
+
+ * workers/Worker.cpp:
+ (WebCore::Worker::Worker):
+ (WebCore::Worker::notifyFinished):
+ * workers/WorkerContext.cpp: removed encoding() implementation.
+ (WebCore::WorkerContext::WorkerContext):
+ (WebCore::WorkerContext::completeURL):
+ * workers/WorkerContext.h: removed encoding()
+ (WebCore::WorkerContext::create):
+ * workers/WorkerContextProxy.h:
+ * workers/WorkerImportScriptsClient.cpp:
+ (WebCore::WorkerImportScriptsClient::didReceiveData):
+ * 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:
+ In all these, removed storing encoding and 'inheriting' it from the parent.
+ Instead, they are all using UTF-8 now.
+
2009-03-20 Timothy Hatcher <timothy@apple.com>
Change how threading exceptions are checked so they are reported
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*);
virtual const KURL& virtualURL() const; // Same as url(), but needed for ScriptExecutionContext to implement it without a performance loss for direct calls.
virtual KURL virtualCompleteURL(const String&) const; // Same as completeURL() for the same reason as above.
+ String encoding() const;
+
CSSStyleSelector* m_styleSelector;
bool m_didCalculateStyleSelector;
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(); }
#include "FrameLoader.h"
#include "MessageEvent.h"
#include "SecurityOrigin.h"
+#include "TextEncoding.h"
#include "WorkerContextProxy.h"
#include "WorkerThread.h"
#include <wtf/MainThread.h>
ASSERT(scriptExecutionContext()->isDocument());
Document* document = static_cast<Document*>(scriptExecutionContext());
- m_cachedScript = document->docLoader()->requestScript(m_scriptURL, scriptExecutionContext()->encoding());
+ m_cachedScript = document->docLoader()->requestScript(m_scriptURL, "UTF-8");
if (!m_cachedScript) {
dispatchErrorEvent();
return;
if (m_cachedScript->errorOccurred())
dispatchErrorEvent();
else
- m_contextProxy->startWorkerContext(m_scriptURL, scriptExecutionContext()->userAgent(m_scriptURL), scriptExecutionContext()->encoding(), m_cachedScript->script());
+ m_contextProxy->startWorkerContext(m_scriptURL, scriptExecutionContext()->userAgent(m_scriptURL), m_cachedScript->script());
m_cachedScript->removeClient(this);
m_cachedScript = 0;
namespace WebCore {
-WorkerContext::WorkerContext(const KURL& url, const String& userAgent, const String& encoding, WorkerThread* thread)
+WorkerContext::WorkerContext(const KURL& url, const String& userAgent, WorkerThread* thread)
: m_url(url)
, m_userAgent(userAgent)
- , m_encoding(encoding)
, m_location(WorkerLocation::create(url))
, m_script(new WorkerScriptController(this))
, m_thread(thread)
// FIXME: Should we change the KURL constructor to have this behavior?
if (url.isNull())
return KURL();
- // 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.
+ // Always use UTF-8 in Workers.
return KURL(m_location->url(), url);
}
return m_userAgent;
}
-String WorkerContext::encoding() const
-{
- return m_encoding;
-}
-
WorkerNavigator* WorkerContext::navigator() const
{
if (!m_navigator)
class WorkerContext : public RefCounted<WorkerContext>, public ScriptExecutionContext, public EventTarget {
public:
- static PassRefPtr<WorkerContext> create(const KURL& url, const String& userAgent, const String& encoding, WorkerThread* thread)
+ static PassRefPtr<WorkerContext> create(const KURL& url, const String& userAgent, WorkerThread* thread)
{
- return adoptRef(new WorkerContext(url, userAgent, encoding, thread));
+ return adoptRef(new WorkerContext(url, userAgent, thread));
}
virtual ~WorkerContext();
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;
virtual void refEventTarget() { ref(); }
virtual void derefEventTarget() { deref(); }
- WorkerContext(const KURL&, const String&, const String& encoding, WorkerThread*);
+ WorkerContext(const KURL&, const String&, 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;
virtual ~WorkerContextProxy() {}
- virtual void startWorkerContext(const KURL& scriptURL, const String& userAgent, const String& encoding, const String& sourceCode) = 0;
+ virtual void startWorkerContext(const KURL& scriptURL, const String& userAgent, const String& sourceCode) = 0;
virtual void terminateWorkerContext() = 0;
if (!m_responseEncoding.isEmpty())
m_decoder = TextResourceDecoder::create("text/javascript", m_responseEncoding);
else
- m_decoder = TextResourceDecoder::create("text/javascript", m_scriptExecutionContext->encoding());
+ m_decoder = TextResourceDecoder::create("text/javascript", "UTF-8");
}
if (!len)
|| (m_scriptExecutionContext->isWorkerContext() && currentThread() == static_cast<WorkerContext*>(m_scriptExecutionContext.get())->thread()->threadID()));
}
-void WorkerMessagingProxy::startWorkerContext(const KURL& scriptURL, const String& userAgent, const String& encoding, const String& sourceCode)
+void WorkerMessagingProxy::startWorkerContext(const KURL& scriptURL, const String& userAgent, const String& sourceCode)
{
- RefPtr<WorkerThread> thread = WorkerThread::create(scriptURL, userAgent, encoding, sourceCode, this);
+ RefPtr<WorkerThread> thread = WorkerThread::create(scriptURL, userAgent, sourceCode, this);
workerThreadCreated(thread);
thread->start();
}
// Implementations of WorkerContextProxy.
// (Only use these methods in the worker object thread.)
- virtual void startWorkerContext(const KURL& scriptURL, const String& userAgent, const String& encoding, const String& sourceCode);
+ virtual void startWorkerContext(const KURL& scriptURL, const String& userAgent, const String& sourceCode);
virtual void terminateWorkerContext();
virtual void postMessageToWorkerContext(const String& message);
virtual bool hasPendingActivity() const;
namespace WebCore {
struct WorkerThreadStartupData : Noncopyable {
public:
- static std::auto_ptr<WorkerThreadStartupData> create(const KURL& scriptURL, const String& userAgent, const String& encoding, const String& sourceCode)
+ static std::auto_ptr<WorkerThreadStartupData> create(const KURL& scriptURL, const String& userAgent, const String& sourceCode)
{
- return std::auto_ptr<WorkerThreadStartupData>(new WorkerThreadStartupData(scriptURL, userAgent, encoding, sourceCode));
+ return std::auto_ptr<WorkerThreadStartupData>(new WorkerThreadStartupData(scriptURL, userAgent, sourceCode));
}
KURL m_scriptURL;
String m_userAgent;
- String m_encoding;
String m_sourceCode;
private:
- WorkerThreadStartupData(const KURL& scriptURL, const String& userAgent, const String& encoding, const String& sourceCode);
+ WorkerThreadStartupData(const KURL& scriptURL, const String& userAgent, const String& sourceCode);
};
-WorkerThreadStartupData::WorkerThreadStartupData(const KURL& scriptURL, const String& userAgent, const String& encoding, const String& sourceCode)
+WorkerThreadStartupData::WorkerThreadStartupData(const KURL& scriptURL, const String& userAgent, 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& encoding, const String& sourceCode, WorkerObjectProxy* workerObjectProxy)
+PassRefPtr<WorkerThread> WorkerThread::create(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerObjectProxy* workerObjectProxy)
{
- return adoptRef(new WorkerThread(scriptURL, userAgent, encoding, sourceCode, workerObjectProxy));
+ return adoptRef(new WorkerThread(scriptURL, userAgent, sourceCode, workerObjectProxy));
}
-WorkerThread::WorkerThread(const KURL& scriptURL, const String& userAgent, const String& encoding, const String& sourceCode, WorkerObjectProxy* workerObjectProxy)
+WorkerThread::WorkerThread(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerObjectProxy* workerObjectProxy)
: m_threadID(0)
, m_workerObjectProxy(workerObjectProxy)
- , m_startupData(WorkerThreadStartupData::create(scriptURL, userAgent, encoding, sourceCode))
+ , m_startupData(WorkerThreadStartupData::create(scriptURL, userAgent, sourceCode))
{
}
{
{
MutexLocker lock(m_threadCreationMutex);
- m_workerContext = WorkerContext::create(m_startupData->m_scriptURL, m_startupData->m_userAgent, m_startupData->m_encoding, this);
+ m_workerContext = WorkerContext::create(m_startupData->m_scriptURL, m_startupData->m_userAgent, 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().
class WorkerThread : public RefCounted<WorkerThread> {
public:
- static PassRefPtr<WorkerThread> create(const KURL& scriptURL, const String& userAgent, const String& encoding, const String& sourceCode, WorkerObjectProxy*);
+ static PassRefPtr<WorkerThread> create(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerObjectProxy*);
~WorkerThread();
bool start();
WorkerObjectProxy* workerObjectProxy() const { return m_workerObjectProxy; }
private:
- WorkerThread(const KURL&, const String& userAgent, const String& encoding, const String& sourceCode, WorkerObjectProxy*);
+ WorkerThread(const KURL&, const String& userAgent, const String& sourceCode, WorkerObjectProxy*);
static void* workerThreadStart(void*);
void* workerThread();