Changeset 41871 in webkit
- Timestamp:
- Mar 20, 2009 3:52:13 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r41865 r41871 1 2009-03-20 Dmitry Titov <dimich@chromium.org> 2 3 Reviewed by Alexey Proskuryakov. 4 5 https://bugs.webkit.org/show_bug.cgi?id=24706 6 Remove ScriptExecutionContext::encoding() since Workers do not need it. 7 WorkerContext::encoding() is simply removed, while Document::encoding() 8 made non-virtual and private. Workers use UTF-8 now except when instructed 9 otherwise by http header. Updated test. 10 Also, added test for encoding used by importScripts(). 11 12 * http/tests/workers/resources/subworker-encoded.php: Added. 13 * http/tests/workers/resources/worker-encoded.php: 14 * http/tests/workers/text-encoding-expected.txt: 15 * http/tests/workers/text-encoding.html: 16 1 17 2009-03-20 Beth Dakin <bdakin@apple.com> 2 18 -
trunk/LayoutTests/http/tests/workers/resources/worker-encoded.php
r41499 r41871 16 16 17 17 print("postMessage('Original test string: ' + String.fromCharCode(0x41F, 0x440, 0x438, 0x432, 0x435, 0x442));"); 18 print("postMessage('Test: \xF0\xD2\xC9\xD7\xC5\xD4 (encoded using koi8-r).');"); 19 print("postMessage('Test: \xCF\xF0\xE8\xE2\xE5\xF2 (encoded using Windows-1251).');"); 18 print("postMessage('Test string encoded using koi8-r: \xF0\xD2\xC9\xD7\xC5\xD4.');"); 19 print("postMessage('Test string encoded using Windows-1251: \xCF\xF0\xE8\xE2\xE5\xF2.');"); 20 print("postMessage('Test string encoded using UTF-8: \xD0\x9F\xD1\x80\xD0\xB8\xD0\xB2\xD0\xB5\xD1\x82.');"); 20 21 21 22 // Test how XHR decodes its response text. Should be UTF8 or a charset from http header. … … 31 32 print("xhr.send(); postMessage(xhr.responseText);"); 32 33 34 print("importScripts('subworker-encoded.php');"); 35 33 36 print("postMessage('exit');"); 34 37 ?> -
trunk/LayoutTests/http/tests/workers/text-encoding-expected.txt
r41499 r41871 2 2 This is what's tested: 3 3 - If http header 'Content-Type' with 'charset' specified is on response with worker script or XHR payload, that encoding is used. 4 - In absen se of http header, the script of the worker is decoded using the text encoding of the parent document.5 - In absen se of http header, the content of the XHR request is decoded using UTF-8.4 - In absence of http header, the script of the worker is decoded using UTF-8. 5 - In absence of http header, the content of the XHR request is decoded using UTF-8. 6 6 - 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). 7 - 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).8 7 - The base URL for the worker (used to resolve relative URLs for subworkers and XHR) is the URL of its script. 8 - importScripts() decodes the scripts using UTF-8. 9 9 Document encoding: windows-1251 10 10 Document, Workers: All XHR responses should match this: Привет … … 14 14 worker 1: Original test string: Привет 15 15 worker 1: PASS: XHR query was encoded in UTF-8: Привет 16 worker 1: Test: Привет (encoded using Windows-1251). 17 worker 1: Test: рТЙЧЕФ (encoded using koi8-r). 16 worker 1: Sub: Original test string: Привет 17 worker 1: Sub: Test string encoded using UTF-8: Привет. 18 worker 1: Sub: Test string encoded using Windows-1251: ������. 19 worker 1: Sub: Test string encoded using koi8-r: ������. 20 worker 1: Test string encoded using UTF-8: Привет. 21 worker 1: Test string encoded using Windows-1251: ������. 22 worker 1: Test string encoded using koi8-r: ������. 18 23 worker 1: XHR: Привет 19 24 worker 1: XHR: Привет … … 22 27 worker 2: Original test string: Привет 23 28 worker 2: PASS: XHR query was encoded in UTF-8: Привет 24 worker 2: Test: Привет (encoded using koi8-r). 25 worker 2: Test: оПХБЕР (encoded using Windows-1251). 29 worker 2: Sub: Original test string: Привет 30 worker 2: Sub: Test string encoded using UTF-8: Привет. 31 worker 2: Sub: Test string encoded using Windows-1251: ������. 32 worker 2: Sub: Test string encoded using koi8-r: ������. 33 worker 2: Test string encoded using UTF-8: п÷я─п╦п╡п╣я┌. 34 worker 2: Test string encoded using Windows-1251: оПХБЕР. 35 worker 2: Test string encoded using koi8-r: Привет. 26 36 worker 2: XHR: Привет 27 37 worker 2: XHR: Привет -
trunk/LayoutTests/http/tests/workers/text-encoding.html
r41499 r41871 5 5 This is what's tested:<br> 6 6 - If http header 'Content-Type' with 'charset' specified is on response with worker script or XHR payload, that encoding is used.<br> 7 - In absen se of http header, the script of the worker is decoded using the text encoding of the parent document.<br>8 - In absen se of http header, the content of the XHR request is decoded using UTF-8.<br>7 - In absence of http header, the script of the worker is decoded using UTF-8.<br> 8 - In absence of http header, the content of the XHR request is decoded using UTF-8.<br> 9 9 - 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> 10 - 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> 10 - The base URL for the worker (used to resolve relative URLs for subworkers and XHR) is the URL of its script.<br> 11 - importScripts() decodes the scripts using UTF-8.<br> 11 12 12 13 <div style="background:beige; padding:10px;" id="status"></div> -
trunk/WebCore/ChangeLog
r41870 r41871 1 2009-03-20 Dmitry Titov <dimich@chromium.org> 2 3 Reviewed by Alexey Proskuryakov. 4 5 https://bugs.webkit.org/show_bug.cgi?id=24706 6 Remove ScriptExecutionContext::encoding() since Workers do not need it. 7 WorkerContext::encoding() is simply removed, while Document::encoding() 8 made non-virtual and private. Workers use UTF-8 now except when instructed 9 otherwise by http header. Also updated test. 10 11 * dom/Document.h: Made encoding() non-virtual and private. 12 * dom/ScriptExecutionContext.h: removed encoding(). 13 14 * workers/Worker.cpp: 15 (WebCore::Worker::Worker): 16 (WebCore::Worker::notifyFinished): 17 * workers/WorkerContext.cpp: removed encoding() implementation. 18 (WebCore::WorkerContext::WorkerContext): 19 (WebCore::WorkerContext::completeURL): 20 * workers/WorkerContext.h: removed encoding() 21 (WebCore::WorkerContext::create): 22 * workers/WorkerContextProxy.h: 23 * workers/WorkerImportScriptsClient.cpp: 24 (WebCore::WorkerImportScriptsClient::didReceiveData): 25 * workers/WorkerMessagingProxy.cpp: 26 (WebCore::WorkerMessagingProxy::startWorkerContext): 27 * workers/WorkerMessagingProxy.h: 28 * workers/WorkerThread.cpp: 29 (WebCore::WorkerThreadStartupData::create): 30 (WebCore::WorkerThreadStartupData::WorkerThreadStartupData): 31 (WebCore::WorkerThread::create): 32 (WebCore::WorkerThread::WorkerThread): 33 (WebCore::WorkerThread::workerThread): 34 * workers/WorkerThread.h: 35 In all these, removed storing encoding and 'inheriting' it from the parent. 36 Instead, they are all using UTF-8 now. 37 1 38 2009-03-20 Timothy Hatcher <timothy@apple.com> 2 39 -
trunk/WebCore/dom/Document.h
r41766 r41871 446 446 447 447 virtual String userAgent(const KURL&) const; 448 virtual String encoding() const;449 448 450 449 // from cachedObjectClient … … 801 800 virtual KURL virtualCompleteURL(const String&) const; // Same as completeURL() for the same reason as above. 802 801 802 String encoding() const; 803 803 804 CSSStyleSelector* m_styleSelector; 804 805 bool m_didCalculateStyleSelector; -
trunk/WebCore/dom/ScriptExecutionContext.h
r41549 r41871 61 61 62 62 virtual String userAgent(const KURL&) const = 0; 63 virtual String encoding() const = 0;64 63 65 64 SecurityOrigin* securityOrigin() const { return m_securityOrigin.get(); } -
trunk/WebCore/workers/Worker.cpp
r41499 r41871 44 44 #include "MessageEvent.h" 45 45 #include "SecurityOrigin.h" 46 #include "TextEncoding.h" 46 47 #include "WorkerContextProxy.h" 47 48 #include "WorkerThread.h" … … 69 70 Document* document = static_cast<Document*>(scriptExecutionContext()); 70 71 71 m_cachedScript = document->docLoader()->requestScript(m_scriptURL, scriptExecutionContext()->encoding());72 m_cachedScript = document->docLoader()->requestScript(m_scriptURL, "UTF-8"); 72 73 if (!m_cachedScript) { 73 74 dispatchErrorEvent(); … … 119 120 dispatchErrorEvent(); 120 121 else 121 m_contextProxy->startWorkerContext(m_scriptURL, scriptExecutionContext()->userAgent(m_scriptURL), scriptExecutionContext()->encoding(),m_cachedScript->script());122 m_contextProxy->startWorkerContext(m_scriptURL, scriptExecutionContext()->userAgent(m_scriptURL), m_cachedScript->script()); 122 123 123 124 m_cachedScript->removeClient(this); -
trunk/WebCore/workers/WorkerContext.cpp
r41549 r41871 54 54 namespace WebCore { 55 55 56 WorkerContext::WorkerContext(const KURL& url, const String& userAgent, const String& encoding,WorkerThread* thread)56 WorkerContext::WorkerContext(const KURL& url, const String& userAgent, WorkerThread* thread) 57 57 : m_url(url) 58 58 , m_userAgent(userAgent) 59 , m_encoding(encoding)60 59 , m_location(WorkerLocation::create(url)) 61 60 , m_script(new WorkerScriptController(this)) … … 93 92 if (url.isNull()) 94 93 return KURL(); 95 // FIXME: Document::completeURL provides a charset here (to encode query portion of url when 96 // submitting charset-encoded forms data). FF3.1b2 uses original document's encoding for nested 97 // Workers and importScripts but UTF-8 for XHR. If it's not a bug, we probably should match FF. 94 // Always use UTF-8 in Workers. 98 95 return KURL(m_location->url(), url); 99 96 } … … 102 99 { 103 100 return m_userAgent; 104 }105 106 String WorkerContext::encoding() const107 {108 return m_encoding;109 101 } 110 102 -
trunk/WebCore/workers/WorkerContext.h
r41549 r41871 49 49 class WorkerContext : public RefCounted<WorkerContext>, public ScriptExecutionContext, public EventTarget { 50 50 public: 51 static PassRefPtr<WorkerContext> create(const KURL& url, const String& userAgent, const String& encoding,WorkerThread* thread)51 static PassRefPtr<WorkerContext> create(const KURL& url, const String& userAgent, WorkerThread* thread) 52 52 { 53 return adoptRef(new WorkerContext(url, userAgent, encoding,thread));53 return adoptRef(new WorkerContext(url, userAgent, thread)); 54 54 } 55 55 … … 64 64 65 65 virtual String userAgent(const KURL&) const; 66 virtual String encoding() const;67 66 68 67 WorkerLocation* location() const { return m_location.get(); } … … 112 111 virtual void derefEventTarget() { deref(); } 113 112 114 WorkerContext(const KURL&, const String&, const String& encoding,WorkerThread*);113 WorkerContext(const KURL&, const String&, WorkerThread*); 115 114 116 115 virtual const KURL& virtualURL() const; … … 119 118 KURL m_url; 120 119 String m_userAgent; 121 String m_encoding;122 120 RefPtr<WorkerLocation> m_location; 123 121 mutable RefPtr<WorkerNavigator> m_navigator; -
trunk/WebCore/workers/WorkerContextProxy.h
r41499 r41871 47 47 virtual ~WorkerContextProxy() {} 48 48 49 virtual void startWorkerContext(const KURL& scriptURL, const String& userAgent, const String& encoding, const String&sourceCode) = 0;49 virtual void startWorkerContext(const KURL& scriptURL, const String& userAgent, const String& sourceCode) = 0; 50 50 51 51 virtual void terminateWorkerContext() = 0; -
trunk/WebCore/workers/WorkerImportScriptsClient.cpp
r41549 r41871 53 53 m_decoder = TextResourceDecoder::create("text/javascript", m_responseEncoding); 54 54 else 55 m_decoder = TextResourceDecoder::create("text/javascript", m_scriptExecutionContext->encoding());55 m_decoder = TextResourceDecoder::create("text/javascript", "UTF-8"); 56 56 } 57 57 -
trunk/WebCore/workers/WorkerMessagingProxy.cpp
r41499 r41871 199 199 } 200 200 201 void WorkerMessagingProxy::startWorkerContext(const KURL& scriptURL, const String& userAgent, const String& encoding, const String&sourceCode)202 { 203 RefPtr<WorkerThread> thread = WorkerThread::create(scriptURL, userAgent, encoding,sourceCode, this);201 void WorkerMessagingProxy::startWorkerContext(const KURL& scriptURL, const String& userAgent, const String& sourceCode) 202 { 203 RefPtr<WorkerThread> thread = WorkerThread::create(scriptURL, userAgent, sourceCode, this); 204 204 workerThreadCreated(thread); 205 205 thread->start(); -
trunk/WebCore/workers/WorkerMessagingProxy.h
r41499 r41871 51 51 // Implementations of WorkerContextProxy. 52 52 // (Only use these methods in the worker object thread.) 53 virtual void startWorkerContext(const KURL& scriptURL, const String& userAgent, const String& encoding, const String&sourceCode);53 virtual void startWorkerContext(const KURL& scriptURL, const String& userAgent, const String& sourceCode); 54 54 virtual void terminateWorkerContext(); 55 55 virtual void postMessageToWorkerContext(const String& message); -
trunk/WebCore/workers/WorkerThread.cpp
r41606 r41871 44 44 struct WorkerThreadStartupData : Noncopyable { 45 45 public: 46 static std::auto_ptr<WorkerThreadStartupData> create(const KURL& scriptURL, const String& userAgent, const String& encoding, const String&sourceCode)46 static std::auto_ptr<WorkerThreadStartupData> create(const KURL& scriptURL, const String& userAgent, const String& sourceCode) 47 47 { 48 return std::auto_ptr<WorkerThreadStartupData>(new WorkerThreadStartupData(scriptURL, userAgent, encoding,sourceCode));48 return std::auto_ptr<WorkerThreadStartupData>(new WorkerThreadStartupData(scriptURL, userAgent, sourceCode)); 49 49 } 50 50 51 51 KURL m_scriptURL; 52 52 String m_userAgent; 53 String m_encoding;54 53 String m_sourceCode; 55 54 private: 56 WorkerThreadStartupData(const KURL& scriptURL, const String& userAgent, const String& encoding, const String&sourceCode);55 WorkerThreadStartupData(const KURL& scriptURL, const String& userAgent, const String& sourceCode); 57 56 }; 58 57 59 WorkerThreadStartupData::WorkerThreadStartupData(const KURL& scriptURL, const String& userAgent, const String& encoding, const String&sourceCode)58 WorkerThreadStartupData::WorkerThreadStartupData(const KURL& scriptURL, const String& userAgent, const String& sourceCode) 60 59 : m_scriptURL(scriptURL.copy()) 61 60 , m_userAgent(userAgent.copy()) 62 , m_encoding(encoding.copy())63 61 , m_sourceCode(sourceCode.copy()) 64 62 { 65 63 } 66 64 67 PassRefPtr<WorkerThread> WorkerThread::create(const KURL& scriptURL, const String& userAgent, const String& encoding, const String&sourceCode, WorkerObjectProxy* workerObjectProxy)65 PassRefPtr<WorkerThread> WorkerThread::create(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerObjectProxy* workerObjectProxy) 68 66 { 69 return adoptRef(new WorkerThread(scriptURL, userAgent, encoding,sourceCode, workerObjectProxy));67 return adoptRef(new WorkerThread(scriptURL, userAgent, sourceCode, workerObjectProxy)); 70 68 } 71 69 72 WorkerThread::WorkerThread(const KURL& scriptURL, const String& userAgent, const String& encoding, const String&sourceCode, WorkerObjectProxy* workerObjectProxy)70 WorkerThread::WorkerThread(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerObjectProxy* workerObjectProxy) 73 71 : m_threadID(0) 74 72 , m_workerObjectProxy(workerObjectProxy) 75 , m_startupData(WorkerThreadStartupData::create(scriptURL, userAgent, encoding,sourceCode))73 , m_startupData(WorkerThreadStartupData::create(scriptURL, userAgent, sourceCode)) 76 74 { 77 75 } … … 103 101 { 104 102 MutexLocker lock(m_threadCreationMutex); 105 m_workerContext = WorkerContext::create(m_startupData->m_scriptURL, m_startupData->m_userAgent, m_startupData->m_encoding,this);103 m_workerContext = WorkerContext::create(m_startupData->m_scriptURL, m_startupData->m_userAgent, this); 106 104 if (m_runLoop.terminated()) { 107 105 // The worker was terminated before the thread had a chance to run. Since the context didn't exist yet, -
trunk/WebCore/workers/WorkerThread.h
r41499 r41871 45 45 class WorkerThread : public RefCounted<WorkerThread> { 46 46 public: 47 static PassRefPtr<WorkerThread> create(const KURL& scriptURL, const String& userAgent, const String& encoding, const String&sourceCode, WorkerObjectProxy*);47 static PassRefPtr<WorkerThread> create(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerObjectProxy*); 48 48 ~WorkerThread(); 49 49 … … 56 56 57 57 private: 58 WorkerThread(const KURL&, const String& userAgent, const String& encoding, const String&sourceCode, WorkerObjectProxy*);58 WorkerThread(const KURL&, const String& userAgent, const String& sourceCode, WorkerObjectProxy*); 59 59 60 60 static void* workerThreadStart(void*);
Note: See TracChangeset
for help on using the changeset viewer.