Changeset 126365 in webkit


Ignore:
Timestamp:
Aug 22, 2012 3:58:59 PM (12 years ago)
Author:
jpfau@apple.com
Message:

Allow blocking of Web SQL databases in third-party web workers
https://bugs.webkit.org/show_bug.cgi?id=94170

Reviewed by Adam Barth.

Source/WebCore:

Web workers did not previously know anything about the document that
spawned them. This is undefined for shared workers, but for dedicated
workers, we now pipe the information through.

Tests: http/tests/security/cross-origin-worker-websql-allowed.html

http/tests/security/cross-origin-worker-websql.html

  • Modules/webdatabase/WorkerContextWebDatabase.cpp: Pass information about the top origin to canAccessDatabase

(WebCore::WorkerContextWebDatabase::openDatabase):
(WebCore::WorkerContextWebDatabase::openDatabaseSync):

  • WebCore.exp.in: Make SecurityOrigin::isolatedCopy const
  • page/SecurityOrigin.cpp:

(WebCore::SecurityOrigin::isolatedCopy):
(WebCore::SecurityOrigin::canAccessStorage):

  • page/SecurityOrigin.h:
  • workers/DedicatedWorkerContext.cpp: Pass topOrigin

(WebCore::DedicatedWorkerContext::create):
(WebCore::DedicatedWorkerContext::DedicatedWorkerContext):

  • workers/DedicatedWorkerContext.h:

(DedicatedWorkerContext):

  • workers/DedicatedWorkerThread.cpp: Pass topOrigin

(WebCore::DedicatedWorkerThread::create):
(WebCore::DedicatedWorkerThread::DedicatedWorkerThread):
(WebCore::DedicatedWorkerThread::createWorkerContext):

  • workers/DedicatedWorkerThread.h:

(DedicatedWorkerThread):

  • workers/SharedWorkerContext.cpp: Pass topOrigin

(WebCore::SharedWorkerContext::SharedWorkerContext):

  • workers/SharedWorkerThread.cpp:

(WebCore::SharedWorkerThread::SharedWorkerThread):
(WebCore::SharedWorkerThread::createWorkerContext):

  • workers/SharedWorkerThread.h:

(SharedWorkerThread): Pass topOrigin

  • workers/WorkerContext.cpp:

(WebCore::WorkerContext::WorkerContext):

  • workers/WorkerContext.h:

(WebCore::WorkerContext::topOrigin):
(WorkerContext):

  • workers/WorkerMessagingProxy.cpp: Pass topOrigin

(WebCore::WorkerMessagingProxy::startWorkerContext):

  • workers/WorkerThread.cpp:

(WebCore::WorkerThreadStartupData::create):
(WorkerThreadStartupData):
(WebCore::WorkerThreadStartupData::WorkerThreadStartupData):
(WebCore::WorkerThread::WorkerThread):
(WebCore::WorkerThread::workerThread):

  • workers/WorkerThread.h:

(WorkerThread):

Source/WebKit/chromium:

Web workers did not previously know anything about the document that
spawned them. This is undefined for shared workers, but for dedicated
workers, we now pipe the information through.

  • src/WebWorkerClientImpl.cpp:

(WebKit::WebWorkerClientImpl::startWorkerContext): Pass top document's origin

LayoutTests:

Created tests for accessing openDatabase from a third party and first party dedicated workers when third-party blocking is on and off.

  • http/tests/security/cross-origin-worker-websql-allowed-expected.txt: Added.
  • http/tests/security/cross-origin-worker-websql-allowed.html: Added.
  • http/tests/security/cross-origin-worker-websql-expected.txt: Added.
  • http/tests/security/cross-origin-worker-websql.html: Added.
  • http/tests/security/resources/cross-origin-iframe-for-worker-websql.html: Added.
  • http/tests/security/resources/document-for-cross-origin-worker-websql.html: Added.
  • http/tests/security/resources/worker-for-websql.js: Added.

(self.onmessage):

Location:
trunk
Files:
7 added
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r126364 r126365  
     12012-08-17  Jeffrey Pfau  <jpfau@apple.com>
     2
     3        Allow blocking of Web SQL databases in third-party web workers
     4        https://bugs.webkit.org/show_bug.cgi?id=94170
     5
     6        Reviewed by Adam Barth.
     7
     8        Created tests for accessing openDatabase from a third party and first party dedicated workers when third-party blocking is on and off.
     9
     10        * http/tests/security/cross-origin-worker-websql-allowed-expected.txt: Added.
     11        * http/tests/security/cross-origin-worker-websql-allowed.html: Added.
     12        * http/tests/security/cross-origin-worker-websql-expected.txt: Added.
     13        * http/tests/security/cross-origin-worker-websql.html: Added.
     14        * http/tests/security/resources/cross-origin-iframe-for-worker-websql.html: Added.
     15        * http/tests/security/resources/document-for-cross-origin-worker-websql.html: Added.
     16        * http/tests/security/resources/worker-for-websql.js: Added.
     17        (self.onmessage):
     18
    1192012-08-22  Anna Cavender  <annacc@chromium.org>
    220
  • trunk/Source/WebCore/ChangeLog

    r126363 r126365  
     12012-08-17  Jeffrey Pfau  <jpfau@apple.com>
     2
     3        Allow blocking of Web SQL databases in third-party web workers
     4        https://bugs.webkit.org/show_bug.cgi?id=94170
     5
     6        Reviewed by Adam Barth.
     7
     8        Web workers did not previously know anything about the document that
     9        spawned them. This is undefined for shared workers, but for dedicated
     10        workers, we now pipe the information through.
     11
     12        Tests: http/tests/security/cross-origin-worker-websql-allowed.html
     13               http/tests/security/cross-origin-worker-websql.html
     14
     15        * Modules/webdatabase/WorkerContextWebDatabase.cpp: Pass information about the top origin to canAccessDatabase
     16        (WebCore::WorkerContextWebDatabase::openDatabase):
     17        (WebCore::WorkerContextWebDatabase::openDatabaseSync):
     18        * WebCore.exp.in: Make SecurityOrigin::isolatedCopy const
     19        * page/SecurityOrigin.cpp:
     20        (WebCore::SecurityOrigin::isolatedCopy):
     21        (WebCore::SecurityOrigin::canAccessStorage):
     22        * page/SecurityOrigin.h:
     23        * workers/DedicatedWorkerContext.cpp: Pass topOrigin
     24        (WebCore::DedicatedWorkerContext::create):
     25        (WebCore::DedicatedWorkerContext::DedicatedWorkerContext):
     26        * workers/DedicatedWorkerContext.h:
     27        (DedicatedWorkerContext):
     28        * workers/DedicatedWorkerThread.cpp: Pass topOrigin
     29        (WebCore::DedicatedWorkerThread::create):
     30        (WebCore::DedicatedWorkerThread::DedicatedWorkerThread):
     31        (WebCore::DedicatedWorkerThread::createWorkerContext):
     32        * workers/DedicatedWorkerThread.h:
     33        (DedicatedWorkerThread):
     34        * workers/SharedWorkerContext.cpp: Pass topOrigin
     35        (WebCore::SharedWorkerContext::SharedWorkerContext):
     36        * workers/SharedWorkerThread.cpp:
     37        (WebCore::SharedWorkerThread::SharedWorkerThread):
     38        (WebCore::SharedWorkerThread::createWorkerContext):
     39        * workers/SharedWorkerThread.h:
     40        (SharedWorkerThread): Pass topOrigin
     41        * workers/WorkerContext.cpp:
     42        (WebCore::WorkerContext::WorkerContext):
     43        * workers/WorkerContext.h:
     44        (WebCore::WorkerContext::topOrigin):
     45        (WorkerContext):
     46        * workers/WorkerMessagingProxy.cpp: Pass topOrigin
     47        (WebCore::WorkerMessagingProxy::startWorkerContext):
     48        * workers/WorkerThread.cpp:
     49        (WebCore::WorkerThreadStartupData::create):
     50        (WorkerThreadStartupData):
     51        (WebCore::WorkerThreadStartupData::WorkerThreadStartupData):
     52        (WebCore::WorkerThread::WorkerThread):
     53        (WebCore::WorkerThread::workerThread):
     54        * workers/WorkerThread.h:
     55        (WorkerThread):
     56
    1572012-08-22  Kentaro Hara  <haraken@chromium.org>
    258
  • trunk/Source/WebCore/Modules/webdatabase/WorkerContextWebDatabase.cpp

    r112035 r126365  
    4444PassRefPtr<Database> WorkerContextWebDatabase::openDatabase(WorkerContext* context, const String& name, const String& version, const String& displayName, unsigned long estimatedSize, PassRefPtr<DatabaseCallback> creationCallback, ExceptionCode& ec)
    4545{
    46     if (!context->securityOrigin()->canAccessDatabase() || !AbstractDatabase::isAvailable()) {
     46    if (!context->securityOrigin()->canAccessDatabase(context->topOrigin()) || !AbstractDatabase::isAvailable()) {
    4747        ec = SECURITY_ERR;
    4848        return 0;
     
    5454PassRefPtr<DatabaseSync> WorkerContextWebDatabase::openDatabaseSync(WorkerContext* context, const String& name, const String& version, const String& displayName, unsigned long estimatedSize, PassRefPtr<DatabaseCallback> creationCallback, ExceptionCode& ec)
    5555{
    56     if (!context->securityOrigin()->canAccessDatabase() || !AbstractDatabase::isAvailable()) {
     56    if (!context->securityOrigin()->canAccessDatabase(context->topOrigin()) || !AbstractDatabase::isAvailable()) {
    5757        ec = SECURITY_ERR;
    5858        return 0;
  • trunk/Source/WebCore/WebCore.exp.in

    r126343 r126365  
    294294__ZN7WebCore14ScrollableAreaD2Ev
    295295__ZN7WebCore14ScrollbarTheme5themeEv
    296 __ZN7WebCore14SecurityOrigin12isolatedCopyEv
    297296__ZN7WebCore14SecurityOrigin16createFromStringERKN3WTF6StringE
    298297__ZN7WebCore14SecurityOrigin28createFromDatabaseIdentifierERKN3WTF6StringE
     
    11751174__ZNK7WebCore14SecurityOrigin10canDisplayERKNS_4KURLE
    11761175__ZNK7WebCore14SecurityOrigin11toRawStringEv
     1176__ZNK7WebCore14SecurityOrigin12isolatedCopyEv
    11771177__ZNK7WebCore14SecurityOrigin18databaseIdentifierEv
    11781178__ZNK7WebCore14SecurityOrigin5equalEPKS0_
  • trunk/Source/WebCore/page/SecurityOrigin.cpp

    r125736 r126365  
    216216}
    217217
    218 PassRefPtr<SecurityOrigin> SecurityOrigin::isolatedCopy()
     218PassRefPtr<SecurityOrigin> SecurityOrigin::isolatedCopy() const
    219219{
    220220    return adoptRef(new SecurityOrigin(this));
     
    401401        return true;
    402402
    403     if (m_blockThirdPartyStorage && topOrigin->isThirdParty(this))
     403    if ((m_blockThirdPartyStorage || topOrigin->m_blockThirdPartyStorage) && topOrigin->isThirdParty(this))
    404404        return false;
    405405
  • trunk/Source/WebCore/page/SecurityOrigin.h

    r125736 r126365  
    5555    // Create a deep copy of this SecurityOrigin. This method is useful
    5656    // when marshalling a SecurityOrigin to another thread.
    57     PassRefPtr<SecurityOrigin> isolatedCopy();
     57    PassRefPtr<SecurityOrigin> isolatedCopy() const;
    5858
    5959    // Set the domain property of this security origin to newDomain. This
  • trunk/Source/WebCore/workers/DedicatedWorkerContext.cpp

    r125120 r126365  
    4343
    4444// static
    45 PassRefPtr<DedicatedWorkerContext> DedicatedWorkerContext::create(const KURL& url, const String& userAgent, PassOwnPtr<GroupSettings> settings, DedicatedWorkerThread* thread, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
     45PassRefPtr<DedicatedWorkerContext> DedicatedWorkerContext::create(const KURL& url, const String& userAgent, PassOwnPtr<GroupSettings> settings, DedicatedWorkerThread* thread, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType, PassRefPtr<SecurityOrigin> topOrigin)
    4646{
    47     RefPtr<DedicatedWorkerContext> context = adoptRef(new DedicatedWorkerContext(url, userAgent, settings, thread));
     47    RefPtr<DedicatedWorkerContext> context = adoptRef(new DedicatedWorkerContext(url, userAgent, settings, thread, topOrigin));
    4848    context->applyContentSecurityPolicyFromString(contentSecurityPolicy, contentSecurityPolicyType);
    4949    return context.release();
    5050}
    5151
    52 DedicatedWorkerContext::DedicatedWorkerContext(const KURL& url, const String& userAgent, PassOwnPtr<GroupSettings> settings, DedicatedWorkerThread* thread)
    53     : WorkerContext(url, userAgent, settings, thread)
     52DedicatedWorkerContext::DedicatedWorkerContext(const KURL& url, const String& userAgent, PassOwnPtr<GroupSettings> settings, DedicatedWorkerThread* thread, PassRefPtr<SecurityOrigin> topOrigin)
     53    : WorkerContext(url, userAgent, settings, thread, topOrigin)
    5454{
    5555}
  • trunk/Source/WebCore/workers/DedicatedWorkerContext.h

    r125120 r126365  
    4545    public:
    4646        typedef WorkerContext Base;
    47         static PassRefPtr<DedicatedWorkerContext> create(const KURL&, const String& userAgent, PassOwnPtr<GroupSettings>, DedicatedWorkerThread*, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType);
     47        static PassRefPtr<DedicatedWorkerContext> create(const KURL&, const String& userAgent, PassOwnPtr<GroupSettings>, DedicatedWorkerThread*, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType, PassRefPtr<SecurityOrigin> topOrigin);
    4848
    4949        virtual bool isDedicatedWorkerContext() const { return true; }
     
    6464        DedicatedWorkerThread* thread();
    6565    private:
    66         DedicatedWorkerContext(const KURL&, const String& userAgent, PassOwnPtr<GroupSettings>, DedicatedWorkerThread*);
     66        DedicatedWorkerContext(const KURL&, const String& userAgent, PassOwnPtr<GroupSettings>, DedicatedWorkerThread*, PassRefPtr<SecurityOrigin> topOrigin);
    6767    };
    6868
  • trunk/Source/WebCore/workers/DedicatedWorkerThread.cpp

    r122463 r126365  
    4040namespace WebCore {
    4141
    42 PassRefPtr<DedicatedWorkerThread> DedicatedWorkerThread::create(const KURL& scriptURL, const String& userAgent, const GroupSettings* settings, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerObjectProxy& workerObjectProxy, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
     42PassRefPtr<DedicatedWorkerThread> DedicatedWorkerThread::create(const KURL& scriptURL, const String& userAgent, const GroupSettings* settings, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerObjectProxy& workerObjectProxy, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType, const SecurityOrigin* topOrigin)
    4343{
    44     return adoptRef(new DedicatedWorkerThread(scriptURL, userAgent, settings, sourceCode, workerLoaderProxy, workerObjectProxy, startMode, contentSecurityPolicy, contentSecurityPolicyType));
     44    return adoptRef(new DedicatedWorkerThread(scriptURL, userAgent, settings, sourceCode, workerLoaderProxy, workerObjectProxy, startMode, contentSecurityPolicy, contentSecurityPolicyType, topOrigin));
    4545}
    4646
    47 DedicatedWorkerThread::DedicatedWorkerThread(const KURL& url, const String& userAgent, const GroupSettings* settings, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerObjectProxy& workerObjectProxy, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
    48     : WorkerThread(url, userAgent, settings, sourceCode, workerLoaderProxy, workerObjectProxy, startMode, contentSecurityPolicy, contentSecurityPolicyType)
     47DedicatedWorkerThread::DedicatedWorkerThread(const KURL& url, const String& userAgent, const GroupSettings* settings, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerObjectProxy& workerObjectProxy, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType, const SecurityOrigin* topOrigin)
     48    : WorkerThread(url, userAgent, settings, sourceCode, workerLoaderProxy, workerObjectProxy, startMode, contentSecurityPolicy, contentSecurityPolicyType, topOrigin)
    4949    , m_workerObjectProxy(workerObjectProxy)
    5050{
     
    5555}
    5656
    57 PassRefPtr<WorkerContext> DedicatedWorkerThread::createWorkerContext(const KURL& url, const String& userAgent, PassOwnPtr<GroupSettings> settings, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
     57PassRefPtr<WorkerContext> DedicatedWorkerThread::createWorkerContext(const KURL& url, const String& userAgent, PassOwnPtr<GroupSettings> settings, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType, PassRefPtr<SecurityOrigin> topOrigin)
    5858{
    59     return DedicatedWorkerContext::create(url, userAgent, settings, this, contentSecurityPolicy, contentSecurityPolicyType);
     59    return DedicatedWorkerContext::create(url, userAgent, settings, this, contentSecurityPolicy, contentSecurityPolicyType, topOrigin);
    6060}
    6161
  • trunk/Source/WebCore/workers/DedicatedWorkerThread.h

    r122463 r126365  
    4242    class DedicatedWorkerThread : public WorkerThread {
    4343    public:
    44         static PassRefPtr<DedicatedWorkerThread> create(const KURL& scriptURL, const String& userAgent, const GroupSettings*, const String& sourceCode, WorkerLoaderProxy&, WorkerObjectProxy&, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType);
     44        static PassRefPtr<DedicatedWorkerThread> create(const KURL& scriptURL, const String& userAgent, const GroupSettings*, const String& sourceCode, WorkerLoaderProxy&, WorkerObjectProxy&, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType, const SecurityOrigin* topOrigin);
    4545        WorkerObjectProxy& workerObjectProxy() const { return m_workerObjectProxy; }
    4646        ~DedicatedWorkerThread();
    4747
    4848    protected:
    49         virtual PassRefPtr<WorkerContext> createWorkerContext(const KURL&, const String& userAgent, PassOwnPtr<GroupSettings>, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType);
     49        virtual PassRefPtr<WorkerContext> createWorkerContext(const KURL&, const String& userAgent, PassOwnPtr<GroupSettings>, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType, PassRefPtr<SecurityOrigin> topOrigin);
    5050        virtual void runEventLoop();
    5151
    5252    private:
    53         DedicatedWorkerThread(const KURL&, const String& userAgent, const GroupSettings*, const String& sourceCode, WorkerLoaderProxy&, WorkerObjectProxy&, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType);
     53        DedicatedWorkerThread(const KURL&, const String& userAgent, const GroupSettings*, const String& sourceCode, WorkerLoaderProxy&, WorkerObjectProxy&, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType, const SecurityOrigin* topOrigin);
    5454
    5555        WorkerObjectProxy& m_workerObjectProxy;
  • trunk/Source/WebCore/workers/SharedWorkerContext.cpp

    r125120 r126365  
    6060
    6161SharedWorkerContext::SharedWorkerContext(const String& name, const KURL& url, const String& userAgent, PassOwnPtr<GroupSettings> settings, SharedWorkerThread* thread)
    62     : WorkerContext(url, userAgent, settings, thread)
     62    : WorkerContext(url, userAgent, settings, thread, 0)
    6363    , m_name(name)
    6464{
  • trunk/Source/WebCore/workers/SharedWorkerThread.cpp

    r122463 r126365  
    4545
    4646SharedWorkerThread::SharedWorkerThread(const String& name, const KURL& url, const String& userAgent, const GroupSettings* settings, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
    47     : WorkerThread(url, userAgent, settings, sourceCode, workerLoaderProxy, workerReportingProxy, startMode, contentSecurityPolicy, contentSecurityPolicyType)
     47    : WorkerThread(url, userAgent, settings, sourceCode, workerLoaderProxy, workerReportingProxy, startMode, contentSecurityPolicy, contentSecurityPolicyType, 0)
    4848    , m_name(name.isolatedCopy())
    4949{
     
    5454}
    5555
    56 PassRefPtr<WorkerContext> SharedWorkerThread::createWorkerContext(const KURL& url, const String& userAgent, PassOwnPtr<GroupSettings> settings, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
     56PassRefPtr<WorkerContext> SharedWorkerThread::createWorkerContext(const KURL& url, const String& userAgent, PassOwnPtr<GroupSettings> settings, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType, PassRefPtr<SecurityOrigin>)
    5757{
    5858    return SharedWorkerContext::create(m_name, url, userAgent, settings, this, contentSecurityPolicy, contentSecurityPolicyType);
  • trunk/Source/WebCore/workers/SharedWorkerThread.h

    r122463 r126365  
    4444
    4545    protected:
    46         virtual PassRefPtr<WorkerContext> createWorkerContext(const KURL&, const String& userAgent, PassOwnPtr<GroupSettings>, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType);
     46        virtual PassRefPtr<WorkerContext> createWorkerContext(const KURL&, const String& userAgent, PassOwnPtr<GroupSettings>, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType, PassRefPtr<SecurityOrigin> topOrigin);
    4747
    4848    private:
  • trunk/Source/WebCore/workers/WorkerContext.cpp

    r125120 r126365  
    8686};
    8787
    88 WorkerContext::WorkerContext(const KURL& url, const String& userAgent, PassOwnPtr<GroupSettings> settings, WorkerThread* thread)
     88WorkerContext::WorkerContext(const KURL& url, const String& userAgent, PassOwnPtr<GroupSettings> settings, WorkerThread* thread, PassRefPtr<SecurityOrigin> topOrigin)
    8989    : m_url(url)
    9090    , m_userAgent(userAgent)
     
    9797    , m_closing(false)
    9898    , m_eventQueue(WorkerEventQueue::create(this))
     99    , m_topOrigin(topOrigin)
    99100{
    100101    setSecurityOrigin(SecurityOrigin::create(url));
  • trunk/Source/WebCore/workers/WorkerContext.h

    r125120 r126365  
    139139        void notifyObserversOfStop();
    140140
     141        const SecurityOrigin* topOrigin() const { return m_topOrigin.get(); }
     142
    141143    protected:
    142         WorkerContext(const KURL&, const String& userAgent, PassOwnPtr<GroupSettings>, WorkerThread*);
     144        WorkerContext(const KURL&, const String& userAgent, PassOwnPtr<GroupSettings>, WorkerThread*, PassRefPtr<SecurityOrigin> topOrigin);
    143145        void applyContentSecurityPolicyFromString(const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType);
    144146
     
    184186
    185187        OwnPtr<WorkerEventQueue> m_eventQueue;
     188
     189        RefPtr<SecurityOrigin> m_topOrigin;
    186190    };
    187191
  • trunk/Source/WebCore/workers/WorkerMessagingProxy.cpp

    r121742 r126365  
    281281        settings = document->page()->group().groupSettings();
    282282    RefPtr<DedicatedWorkerThread> thread = DedicatedWorkerThread::create(scriptURL, userAgent, settings, sourceCode, *this, *this, startMode,
    283                                                                          m_scriptExecutionContext->contentSecurityPolicy()->deprecatedHeader(),
    284                                                                          m_scriptExecutionContext->contentSecurityPolicy()->deprecatedHeaderType());
     283                                                                         document->contentSecurityPolicy()->deprecatedHeader(),
     284                                                                         document->contentSecurityPolicy()->deprecatedHeaderType(),
     285                                                                         document->topDocument()->securityOrigin());
    285286    workerThreadCreated(thread);
    286287    thread->start();
  • trunk/Source/WebCore/workers/WorkerThread.cpp

    r122463 r126365  
    7272    WTF_MAKE_NONCOPYABLE(WorkerThreadStartupData); WTF_MAKE_FAST_ALLOCATED;
    7373public:
    74     static PassOwnPtr<WorkerThreadStartupData> create(const KURL& scriptURL, const String& userAgent, const GroupSettings* settings, const String& sourceCode, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
    75     {
    76         return adoptPtr(new WorkerThreadStartupData(scriptURL, userAgent, settings, sourceCode, startMode, contentSecurityPolicy, contentSecurityPolicyType));
     74    static PassOwnPtr<WorkerThreadStartupData> create(const KURL& scriptURL, const String& userAgent, const GroupSettings* settings, const String& sourceCode, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType, const SecurityOrigin* topOrigin)
     75    {
     76        return adoptPtr(new WorkerThreadStartupData(scriptURL, userAgent, settings, sourceCode, startMode, contentSecurityPolicy, contentSecurityPolicyType, topOrigin));
    7777    }
    7878
     
    8484    String m_contentSecurityPolicy;
    8585    ContentSecurityPolicy::HeaderType m_contentSecurityPolicyType;
     86    RefPtr<SecurityOrigin> m_topOrigin;
    8687private:
    87     WorkerThreadStartupData(const KURL& scriptURL, const String& userAgent, const GroupSettings*, const String& sourceCode, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType);
     88    WorkerThreadStartupData(const KURL& scriptURL, const String& userAgent, const GroupSettings*, const String& sourceCode, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType, const SecurityOrigin* topOrigin);
    8889};
    8990
    90 WorkerThreadStartupData::WorkerThreadStartupData(const KURL& scriptURL, const String& userAgent, const GroupSettings* settings, const String& sourceCode, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
     91WorkerThreadStartupData::WorkerThreadStartupData(const KURL& scriptURL, const String& userAgent, const GroupSettings* settings, const String& sourceCode, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType, const SecurityOrigin* topOrigin)
    9192    : m_scriptURL(scriptURL.copy())
    9293    , m_userAgent(userAgent.isolatedCopy())
     
    9596    , m_contentSecurityPolicy(contentSecurityPolicy.isolatedCopy())
    9697    , m_contentSecurityPolicyType(contentSecurityPolicyType)
     98    , m_topOrigin(topOrigin ? topOrigin->isolatedCopy() : 0)
    9799{
    98100    if (!settings)
     
    105107}
    106108
    107 WorkerThread::WorkerThread(const KURL& scriptURL, const String& userAgent, const GroupSettings* settings, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
     109WorkerThread::WorkerThread(const KURL& scriptURL, const String& userAgent, const GroupSettings* settings, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerReportingProxy& workerReportingProxy, WorkerThreadStartMode startMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType, const SecurityOrigin* topOrigin)
    108110    : m_threadID(0)
    109111    , m_workerLoaderProxy(workerLoaderProxy)
    110112    , m_workerReportingProxy(workerReportingProxy)
    111     , m_startupData(WorkerThreadStartupData::create(scriptURL, userAgent, settings, sourceCode, startMode, contentSecurityPolicy, contentSecurityPolicyType))
     113    , m_startupData(WorkerThreadStartupData::create(scriptURL, userAgent, settings, sourceCode, startMode, contentSecurityPolicy, contentSecurityPolicyType, topOrigin))
    112114#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
    113115    , m_notificationClient(0)
     
    147149    {
    148150        MutexLocker lock(m_threadCreationMutex);
    149         m_workerContext = createWorkerContext(m_startupData->m_scriptURL, m_startupData->m_userAgent, m_startupData->m_groupSettings.release(), m_startupData->m_contentSecurityPolicy, m_startupData->m_contentSecurityPolicyType);
     151        m_workerContext = createWorkerContext(m_startupData->m_scriptURL, m_startupData->m_userAgent, m_startupData->m_groupSettings.release(), m_startupData->m_contentSecurityPolicy, m_startupData->m_contentSecurityPolicyType, m_startupData->m_topOrigin.release());
    150152
    151153        if (m_runLoop.terminated()) {
  • trunk/Source/WebCore/workers/WorkerThread.h

    r122463 r126365  
    3232#include "ContentSecurityPolicy.h"
    3333#include "GroupSettings.h"
     34#include "SecurityOrigin.h"
    3435#include "WorkerRunLoop.h"
    3536#include <wtf/Forward.h>
     
    7071
    7172    protected:
    72         WorkerThread(const KURL&, const String& userAgent, const GroupSettings*,  const String& sourceCode, WorkerLoaderProxy&, WorkerReportingProxy&, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType);
     73        WorkerThread(const KURL&, const String& userAgent, const GroupSettings*,  const String& sourceCode, WorkerLoaderProxy&, WorkerReportingProxy&, WorkerThreadStartMode, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType, const SecurityOrigin* topOrigin);
    7374
    7475        // Factory method for creating a new worker context for the thread.
    75         virtual PassRefPtr<WorkerContext> createWorkerContext(const KURL&, const String& userAgent, PassOwnPtr<GroupSettings>, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType) = 0;
     76        virtual PassRefPtr<WorkerContext> createWorkerContext(const KURL&, const String& userAgent, PassOwnPtr<GroupSettings>, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType, PassRefPtr<SecurityOrigin> topOrigin) = 0;
    7677
    7778        // Executes the event loop for the worker thread. Derived classes can override to perform actions before/after entering the event loop.
  • trunk/Source/WebKit/chromium/ChangeLog

    r126363 r126365  
     12012-08-17  Jeffrey Pfau  <jpfau@apple.com>
     2
     3        Allow blocking of Web SQL databases in third-party web workers
     4        https://bugs.webkit.org/show_bug.cgi?id=94170
     5
     6        Reviewed by Adam Barth.
     7
     8        Web workers did not previously know anything about the document that
     9        spawned them. This is undefined for shared workers, but for dedicated
     10        workers, we now pipe the information through.
     11
     12
     13        * src/WebWorkerClientImpl.cpp:
     14        (WebKit::WebWorkerClientImpl::startWorkerContext): Pass top document's origin
     15
    1162012-08-22  Kentaro Hara  <haraken@chromium.org>
    217
  • trunk/Source/WebKit/chromium/src/WebWorkerClientImpl.cpp

    r125108 r126365  
    9494        settings = document->page()->group().groupSettings();
    9595    RefPtr<DedicatedWorkerThread> thread = DedicatedWorkerThread::create(scriptURL, userAgent, settings, sourceCode, *this, *this, startMode,
    96                                                                          m_scriptExecutionContext->contentSecurityPolicy()->deprecatedHeader(),
    97                                                                          m_scriptExecutionContext->contentSecurityPolicy()->deprecatedHeaderType());
     96                                                                         document->contentSecurityPolicy()->deprecatedHeader(),
     97                                                                         document->contentSecurityPolicy()->deprecatedHeaderType(),
     98                                                                         document->topDocument()->securityOrigin());
    9899    m_proxy->workerThreadCreated(thread);
    99100    thread->start();
Note: See TracChangeset for help on using the changeset viewer.