Changeset 41871 in webkit


Ignore:
Timestamp:
Mar 20, 2009 3:52:13 PM (15 years ago)
Author:
dimich@chromium.org
Message:

WebCore:

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:
Location:
trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r41865 r41871  
     12009-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
    1172009-03-20  Beth Dakin  <bdakin@apple.com>
    218
  • trunk/LayoutTests/http/tests/workers/resources/worker-encoded.php

    r41499 r41871  
    1616
    1717print("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).');");
     18print("postMessage('Test string encoded using koi8-r: \xF0\xD2\xC9\xD7\xC5\xD4.');");
     19print("postMessage('Test string encoded using Windows-1251: \xCF\xF0\xE8\xE2\xE5\xF2.');");
     20print("postMessage('Test string encoded using UTF-8: \xD0\x9F\xD1\x80\xD0\xB8\xD0\xB2\xD0\xB5\xD1\x82.');");
    2021
    2122// Test how XHR decodes its response text. Should be UTF8 or a charset from http header.
     
    3132print("xhr.send(); postMessage(xhr.responseText);");
    3233
     34print("importScripts('subworker-encoded.php');");
     35
    3336print("postMessage('exit');");
    3437?>
  • trunk/LayoutTests/http/tests/workers/text-encoding-expected.txt

    r41499 r41871  
    22This is what's tested:
    33- If http header 'Content-Type' with 'charset' specified is on response with worker script or XHR payload, that encoding is used.
    4 - In absense of http header, the script of the worker is decoded using the text encoding of the parent document.
    5 - In absense 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.
    66- 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.
    99Document encoding: windows-1251
    1010Document, Workers: All XHR responses should match this: Привет
     
    1414worker 1: Original test string: Привет
    1515worker 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).
     16worker 1: Sub: Original test string: Привет
     17worker 1: Sub: Test string encoded using UTF-8: Привет.
     18worker 1: Sub: Test string encoded using Windows-1251: ������.
     19worker 1: Sub: Test string encoded using koi8-r: ������.
     20worker 1: Test string encoded using UTF-8: Привет.
     21worker 1: Test string encoded using Windows-1251: ������.
     22worker 1: Test string encoded using koi8-r: ������.
    1823worker 1: XHR: Привет
    1924worker 1: XHR: Привет
     
    2227worker 2: Original test string: Привет
    2328worker 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).
     29worker 2: Sub: Original test string: Привет
     30worker 2: Sub: Test string encoded using UTF-8: Привет.
     31worker 2: Sub: Test string encoded using Windows-1251: ������.
     32worker 2: Sub: Test string encoded using koi8-r: ������.
     33worker 2: Test string encoded using UTF-8: п÷я─п╦п╡п╣я┌.
     34worker 2: Test string encoded using Windows-1251: оПХБЕР.
     35worker 2: Test string encoded using koi8-r: Привет.
    2636worker 2: XHR: Привет
    2737worker 2: XHR: Привет
  • trunk/LayoutTests/http/tests/workers/text-encoding.html

    r41499 r41871  
    55This is what's tested:<br>
    66- If http header 'Content-Type' with 'charset' specified is on response with worker script or XHR payload, that encoding is used.<br>
    7 - In absense of http header, the script of the worker is decoded using the text encoding of the parent document.<br>
    8 - In absense 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>
    99- 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>
    1112
    1213<div style="background:beige; padding:10px;" id="status"></div>
  • trunk/WebCore/ChangeLog

    r41870 r41871  
     12009-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
    1382009-03-20  Timothy Hatcher  <timothy@apple.com>
    239
  • trunk/WebCore/dom/Document.h

    r41766 r41871  
    446446
    447447    virtual String userAgent(const KURL&) const;
    448     virtual String encoding() const;
    449448
    450449    // from cachedObjectClient
     
    801800    virtual KURL virtualCompleteURL(const String&) const; // Same as completeURL() for the same reason as above.
    802801
     802    String encoding() const;
     803
    803804    CSSStyleSelector* m_styleSelector;
    804805    bool m_didCalculateStyleSelector;
  • trunk/WebCore/dom/ScriptExecutionContext.h

    r41549 r41871  
    6161
    6262        virtual String userAgent(const KURL&) const = 0;
    63         virtual String encoding() const = 0;
    6463
    6564        SecurityOrigin* securityOrigin() const { return m_securityOrigin.get(); }
  • trunk/WebCore/workers/Worker.cpp

    r41499 r41871  
    4444#include "MessageEvent.h"
    4545#include "SecurityOrigin.h"
     46#include "TextEncoding.h"
    4647#include "WorkerContextProxy.h"
    4748#include "WorkerThread.h"
     
    6970    Document* document = static_cast<Document*>(scriptExecutionContext());
    7071
    71     m_cachedScript = document->docLoader()->requestScript(m_scriptURL, scriptExecutionContext()->encoding());
     72    m_cachedScript = document->docLoader()->requestScript(m_scriptURL, "UTF-8");
    7273    if (!m_cachedScript) {
    7374        dispatchErrorEvent();
     
    119120        dispatchErrorEvent();
    120121    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());
    122123
    123124    m_cachedScript->removeClient(this);
  • trunk/WebCore/workers/WorkerContext.cpp

    r41549 r41871  
    5454namespace WebCore {
    5555
    56 WorkerContext::WorkerContext(const KURL& url, const String& userAgent, const String& encoding, WorkerThread* thread)
     56WorkerContext::WorkerContext(const KURL& url, const String& userAgent, WorkerThread* thread)
    5757    : m_url(url)
    5858    , m_userAgent(userAgent)
    59     , m_encoding(encoding)
    6059    , m_location(WorkerLocation::create(url))
    6160    , m_script(new WorkerScriptController(this))
     
    9392    if (url.isNull())
    9493        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.
    9895    return KURL(m_location->url(), url);
    9996}
     
    10299{
    103100    return m_userAgent;
    104 }
    105 
    106 String WorkerContext::encoding() const
    107 {
    108     return m_encoding;
    109101}
    110102
  • trunk/WebCore/workers/WorkerContext.h

    r41549 r41871  
    4949    class WorkerContext : public RefCounted<WorkerContext>, public ScriptExecutionContext, public EventTarget {
    5050    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)
    5252        {
    53             return adoptRef(new WorkerContext(url, userAgent, encoding, thread));
     53            return adoptRef(new WorkerContext(url, userAgent, thread));
    5454        }
    5555
     
    6464
    6565        virtual String userAgent(const KURL&) const;
    66         virtual String encoding() const;
    6766
    6867        WorkerLocation* location() const { return m_location.get(); }
     
    112111        virtual void derefEventTarget() { deref(); }
    113112
    114         WorkerContext(const KURL&, const String&, const String& encoding, WorkerThread*);
     113        WorkerContext(const KURL&, const String&, WorkerThread*);
    115114
    116115        virtual const KURL& virtualURL() const;
     
    119118        KURL m_url;
    120119        String m_userAgent;
    121         String m_encoding;
    122120        RefPtr<WorkerLocation> m_location;
    123121        mutable RefPtr<WorkerNavigator> m_navigator;
  • trunk/WebCore/workers/WorkerContextProxy.h

    r41499 r41871  
    4747        virtual ~WorkerContextProxy() {}
    4848
    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;
    5050
    5151        virtual void terminateWorkerContext() = 0;
  • trunk/WebCore/workers/WorkerImportScriptsClient.cpp

    r41549 r41871  
    5353            m_decoder = TextResourceDecoder::create("text/javascript", m_responseEncoding);
    5454        else
    55             m_decoder = TextResourceDecoder::create("text/javascript", m_scriptExecutionContext->encoding());
     55            m_decoder = TextResourceDecoder::create("text/javascript", "UTF-8");
    5656    }
    5757
  • trunk/WebCore/workers/WorkerMessagingProxy.cpp

    r41499 r41871  
    199199}
    200200
    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);
     201void WorkerMessagingProxy::startWorkerContext(const KURL& scriptURL, const String& userAgent, const String& sourceCode)
     202{
     203    RefPtr<WorkerThread> thread = WorkerThread::create(scriptURL, userAgent, sourceCode, this);
    204204    workerThreadCreated(thread);
    205205    thread->start();
  • trunk/WebCore/workers/WorkerMessagingProxy.h

    r41499 r41871  
    5151        // Implementations of WorkerContextProxy.
    5252        // (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);
    5454        virtual void terminateWorkerContext();
    5555        virtual void postMessageToWorkerContext(const String& message);
  • trunk/WebCore/workers/WorkerThread.cpp

    r41606 r41871  
    4444struct WorkerThreadStartupData : Noncopyable {
    4545public:
    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)
    4747    {
    48         return std::auto_ptr<WorkerThreadStartupData>(new WorkerThreadStartupData(scriptURL, userAgent, encoding, sourceCode));
     48        return std::auto_ptr<WorkerThreadStartupData>(new WorkerThreadStartupData(scriptURL, userAgent, sourceCode));
    4949    }
    5050
    5151    KURL m_scriptURL;
    5252    String m_userAgent;
    53     String m_encoding;
    5453    String m_sourceCode;
    5554private:
    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);
    5756};
    5857
    59 WorkerThreadStartupData::WorkerThreadStartupData(const KURL& scriptURL, const String& userAgent, const String& encoding, const String& sourceCode)
     58WorkerThreadStartupData::WorkerThreadStartupData(const KURL& scriptURL, const String& userAgent, const String& sourceCode)
    6059    : m_scriptURL(scriptURL.copy())
    6160    , m_userAgent(userAgent.copy())
    62     , m_encoding(encoding.copy())
    6361    , m_sourceCode(sourceCode.copy())
    6462{
    6563}
    6664
    67 PassRefPtr<WorkerThread> WorkerThread::create(const KURL& scriptURL, const String& userAgent, const String& encoding, const String& sourceCode, WorkerObjectProxy* workerObjectProxy)
     65PassRefPtr<WorkerThread> WorkerThread::create(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerObjectProxy* workerObjectProxy)
    6866{
    69     return adoptRef(new WorkerThread(scriptURL, userAgent, encoding, sourceCode, workerObjectProxy));
     67    return adoptRef(new WorkerThread(scriptURL, userAgent, sourceCode, workerObjectProxy));
    7068}
    7169
    72 WorkerThread::WorkerThread(const KURL& scriptURL, const String& userAgent, const String& encoding, const String& sourceCode, WorkerObjectProxy* workerObjectProxy)
     70WorkerThread::WorkerThread(const KURL& scriptURL, const String& userAgent, const String& sourceCode, WorkerObjectProxy* workerObjectProxy)
    7371    : m_threadID(0)
    7472    , m_workerObjectProxy(workerObjectProxy)
    75     , m_startupData(WorkerThreadStartupData::create(scriptURL, userAgent, encoding, sourceCode))
     73    , m_startupData(WorkerThreadStartupData::create(scriptURL, userAgent, sourceCode))
    7674{
    7775}
     
    103101    {
    104102        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);
    106104        if (m_runLoop.terminated()) {
    107105            // 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  
    4545    class WorkerThread : public RefCounted<WorkerThread> {
    4646    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*);
    4848        ~WorkerThread();
    4949
     
    5656
    5757    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*);
    5959
    6060        static void* workerThreadStart(void*);
Note: See TracChangeset for help on using the changeset viewer.