Changeset 289483 in webkit


Ignore:
Timestamp:
Feb 9, 2022 10:30:28 AM (5 months ago)
Author:
Chris Dumez
Message:

self.location.href is incorrect in shared workers in case of redirects
https://bugs.webkit.org/show_bug.cgi?id=236340

Reviewed by Geoffrey Garen.

LayoutTests/imported/w3c:

Rebaseline WPT tests that are now passing.

  • web-platform-tests/workers/baseurl/alpha/importScripts-in-sharedworker-expected.txt:
  • web-platform-tests/workers/baseurl/alpha/xhr-in-sharedworker-expected.txt:
  • web-platform-tests/workers/interfaces/WorkerGlobalScope/location/redirect-sharedworker-expected.txt:

Source/WebCore:

self.location.href is incorrect in shared workers in case of redirects. It should be
the URL of the last request, not the first one.

No new tests, rebaselined existing tests.

  • loader/DocumentThreadableLoader.cpp:

(WebCore::DocumentThreadableLoader::redirectReceived):

  • loader/ThreadableLoaderClient.h:

(WebCore::ThreadableLoaderClient::redirectReceived):

  • loader/ThreadableLoaderClientWrapper.h:

(WebCore::ThreadableLoaderClientWrapper::redirectReceived):

  • loader/WorkerThreadableLoader.cpp:

(WebCore::WorkerThreadableLoader::MainThreadBridge::redirectReceived):

  • loader/WorkerThreadableLoader.h:
  • workers/Worker.cpp:

(WebCore::Worker::notifyFinished):

  • workers/WorkerFetchResult.h:

(WebCore::WorkerFetchResult::isolatedCopy const):
(WebCore::workerFetchError):
(WebCore::WorkerFetchResult::encode const):
(WebCore::WorkerFetchResult::decode):

  • workers/WorkerScriptLoader.cpp:

(WebCore::WorkerScriptLoader::loadSynchronously):
(WebCore::WorkerScriptLoader::loadAsynchronously):
(WebCore::WorkerScriptLoader::redirectReceived):
(WebCore::WorkerScriptLoader::fetchResult const):

  • workers/WorkerScriptLoader.h:

(WebCore::WorkerScriptLoader::script const):
(WebCore::WorkerScriptLoader::lastRequestURL const):
(WebCore::WorkerScriptLoader::script): Deleted.

  • workers/service/ServiceWorkerContainer.cpp:

(WebCore::ServiceWorkerContainer::jobFinishedLoadingScript):

  • workers/service/ServiceWorkerContainer.h:
  • workers/service/ServiceWorkerJob.cpp:

(WebCore::ServiceWorkerJob::notifyFinished):

  • workers/service/ServiceWorkerJobClient.h:
  • workers/shared/SharedWorkerScriptLoader.cpp:

(WebCore::SharedWorkerScriptLoader::notifyFinished):

  • workers/shared/context/SharedWorkerThreadProxy.cpp:

(WebCore::generateWorkerParameters):
(WebCore::SharedWorkerThreadProxy::SharedWorkerThreadProxy):

  • workers/shared/context/SharedWorkerThreadProxy.h:

Source/WebKit:

self.location.href is incorrect in shared workers in case of redirects. It should be the URL of
the last request, not the first one.

  • NetworkProcess/ServiceWorker/ServiceWorkerSoftUpdateLoader.cpp:

(WebKit::ServiceWorkerSoftUpdateLoader::didFinishLoading):

  • NetworkProcess/SharedWorker/WebSharedWorkerServerToContextConnection.cpp:

(WebKit::WebSharedWorkerServerToContextConnection::launchSharedWorker):

  • WebProcess/Storage/WebSharedWorkerContextManagerConnection.cpp:

(WebKit::WebSharedWorkerContextManagerConnection::launchSharedWorker):

  • WebProcess/Storage/WebSharedWorkerContextManagerConnection.h:
  • WebProcess/Storage/WebSharedWorkerContextManagerConnection.messages.in:
Location:
trunk
Files:
29 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r289479 r289483  
     12022-02-09  Chris Dumez  <cdumez@apple.com>
     2
     3        self.location.href is incorrect in shared workers in case of redirects
     4        https://bugs.webkit.org/show_bug.cgi?id=236340
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Rebaseline WPT tests that are now passing.
     9
     10        * web-platform-tests/workers/baseurl/alpha/importScripts-in-sharedworker-expected.txt:
     11        * web-platform-tests/workers/baseurl/alpha/xhr-in-sharedworker-expected.txt:
     12        * web-platform-tests/workers/interfaces/WorkerGlobalScope/location/redirect-sharedworker-expected.txt:
     13
    1142022-02-09  Chris Dumez  <cdumez@apple.com>
    215
  • trunk/LayoutTests/imported/w3c/web-platform-tests/workers/baseurl/alpha/importScripts-in-sharedworker-expected.txt

    r286821 r289483  
    11
    2 FAIL importScripts assert_equals: expected "gamma/script.js" but got "beta/script.js"
     2PASS importScripts
    33
  • trunk/LayoutTests/imported/w3c/web-platform-tests/workers/baseurl/alpha/xhr-in-sharedworker-expected.txt

    r286821 r289483  
    11
    2 FAIL xhr-worker assert_equals: expected "gamma\n" but got "beta\n"
     2PASS xhr-worker
    33
  • trunk/LayoutTests/imported/w3c/web-platform-tests/workers/interfaces/WorkerGlobalScope/location/redirect-sharedworker-expected.txt

    r286821 r289483  
    11
    2 FAIL redirect assert_equals: expected "/workers/interfaces/WorkerGlobalScope/location/redirect.js" but got "/common/redirect.py"
     2PASS redirect
    33
  • trunk/LayoutTests/imported/w3c/web-platform-tests/xhr/open-url-redirected-sharedworker-origin-expected.txt

    r289247 r289483  
    11
    2 FAIL Referer header assert_equals: expected "Referer: http://localhost:8800/xhr/resources/workerxhr-origin-referrer.js\n" but got "Referer: http://localhost:8800/xhr/resources/redirect.py?location=workerxhr-origin-referrer.js\n"
     2PASS Referer header
    33FAIL Origin header assert_equals: expected "Origin: http://localhost:8800\n" but got ""
    44PASS Request URL test
  • trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/xhr/open-url-redirected-sharedworker-origin-expected.txt

    r289247 r289483  
    11
    2 FAIL Referer header assert_equals: expected "Referer: http://localhost:8800/xhr/resources/workerxhr-origin-referrer.js\n" but got "Referer: http://localhost:8800/xhr/resources/redirect.py?location=workerxhr-origin-referrer.js\n"
     2PASS Referer header
    33PASS Origin header
    44PASS Request URL test
  • trunk/Source/WebCore/ChangeLog

    r289480 r289483  
     12022-02-09  Chris Dumez  <cdumez@apple.com>
     2
     3        self.location.href is incorrect in shared workers in case of redirects
     4        https://bugs.webkit.org/show_bug.cgi?id=236340
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        self.location.href is incorrect in shared workers in case of redirects. It should be
     9        the URL of the last request, not the first one.
     10
     11        No new tests, rebaselined existing tests.
     12
     13        * loader/DocumentThreadableLoader.cpp:
     14        (WebCore::DocumentThreadableLoader::redirectReceived):
     15        * loader/ThreadableLoaderClient.h:
     16        (WebCore::ThreadableLoaderClient::redirectReceived):
     17        * loader/ThreadableLoaderClientWrapper.h:
     18        (WebCore::ThreadableLoaderClientWrapper::redirectReceived):
     19        * loader/WorkerThreadableLoader.cpp:
     20        (WebCore::WorkerThreadableLoader::MainThreadBridge::redirectReceived):
     21        * loader/WorkerThreadableLoader.h:
     22        * workers/Worker.cpp:
     23        (WebCore::Worker::notifyFinished):
     24        * workers/WorkerFetchResult.h:
     25        (WebCore::WorkerFetchResult::isolatedCopy const):
     26        (WebCore::workerFetchError):
     27        (WebCore::WorkerFetchResult::encode const):
     28        (WebCore::WorkerFetchResult::decode):
     29        * workers/WorkerScriptLoader.cpp:
     30        (WebCore::WorkerScriptLoader::loadSynchronously):
     31        (WebCore::WorkerScriptLoader::loadAsynchronously):
     32        (WebCore::WorkerScriptLoader::redirectReceived):
     33        (WebCore::WorkerScriptLoader::fetchResult const):
     34        * workers/WorkerScriptLoader.h:
     35        (WebCore::WorkerScriptLoader::script const):
     36        (WebCore::WorkerScriptLoader::lastRequestURL const):
     37        (WebCore::WorkerScriptLoader::script): Deleted.
     38        * workers/service/ServiceWorkerContainer.cpp:
     39        (WebCore::ServiceWorkerContainer::jobFinishedLoadingScript):
     40        * workers/service/ServiceWorkerContainer.h:
     41        * workers/service/ServiceWorkerJob.cpp:
     42        (WebCore::ServiceWorkerJob::notifyFinished):
     43        * workers/service/ServiceWorkerJobClient.h:
     44        * workers/shared/SharedWorkerScriptLoader.cpp:
     45        (WebCore::SharedWorkerScriptLoader::notifyFinished):
     46        * workers/shared/context/SharedWorkerThreadProxy.cpp:
     47        (WebCore::generateWorkerParameters):
     48        (WebCore::SharedWorkerThreadProxy::SharedWorkerThreadProxy):
     49        * workers/shared/context/SharedWorkerThreadProxy.h:
     50
    1512022-02-09  Philippe Normand  <pnormand@igalia.com>
    252
  • trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp

    r288701 r289483  
    315315    --m_options.maxRedirectCount;
    316316
     317    if (m_client)
     318        m_client->redirectReceived(request.url());
     319
    317320    // FIXME: We restrict this check to Fetch API for the moment, as this might disrupt WorkerScriptLoader.
    318321    // Reassess this check based on https://github.com/whatwg/fetch/issues/393 discussions.
  • trunk/Source/WebCore/loader/ThreadableLoaderClient.h

    r288088 r289483  
    4646    virtual void didSendData(unsigned long long /*bytesSent*/, unsigned long long /*totalBytesToBeSent*/) { }
    4747
     48    virtual void redirectReceived(const URL& /*redirectURL*/) { }
    4849    virtual void didReceiveResponse(ResourceLoaderIdentifier, const ResourceResponse&) { }
    4950    virtual void didReceiveData(const SharedBuffer&) { }
  • trunk/Source/WebCore/loader/ThreadableLoaderClientWrapper.h

    r288088 r289483  
    5353    {
    5454        return m_done;
     55    }
     56
     57    void redirectReceived(const URL& redirectURL)
     58    {
     59        if (m_client)
     60            m_client->redirectReceived(redirectURL);
    5561    }
    5662
  • trunk/Source/WebCore/loader/WorkerThreadableLoader.cpp

    r288088 r289483  
    212212}
    213213
     214void WorkerThreadableLoader::MainThreadBridge::redirectReceived(const URL& redirectURL)
     215{
     216    m_loaderProxy.postTaskForModeToWorkerOrWorkletGlobalScope([protectedWorkerClientWrapper = Ref { *m_workerClientWrapper }, redirectURL = redirectURL.isolatedCopy()] (ScriptExecutionContext& context) mutable {
     217        ASSERT_UNUSED(context, context.isWorkerGlobalScope() || context.isWorkletGlobalScope());
     218        protectedWorkerClientWrapper->redirectReceived(redirectURL);
     219    }, m_taskMode);
     220}
     221
    214222void WorkerThreadableLoader::MainThreadBridge::didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent)
    215223{
  • trunk/Source/WebCore/loader/WorkerThreadableLoader.h

    r288088 r289483  
    104104
    105105        // All executed on the main thread.
     106        void redirectReceived(const URL& redirectURL) override;
    106107        void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent) override;
    107108        void didReceiveResponse(ResourceLoaderIdentifier, const ResourceResponse&) override;
  • trunk/Source/WebCore/workers/Worker.cpp

    r288701 r289483  
    214214        referrerPolicy = *policy;
    215215
    216     URL responseURL = m_scriptLoader->responseURL();
    217     if (!m_scriptLoader->isRedirected() && m_scriptLoader->responseSource() != ResourceResponse::Source::ServiceWorker) {
    218         if (m_scriptLoader->url().hasFragmentIdentifier())
    219             responseURL.setFragmentIdentifier(m_scriptLoader->url().fragmentIdentifier());
    220     }
    221     m_contextProxy.startWorkerGlobalScope(responseURL, m_options.name, context->userAgent(responseURL), isOnline, m_scriptLoader->script(), contentSecurityPolicyResponseHeaders, m_shouldBypassMainWorldContentSecurityPolicy, m_scriptLoader->crossOriginEmbedderPolicy(), m_workerCreationTime, referrerPolicy, m_options.type, m_options.credentials, m_runtimeFlags);
     216    m_contextProxy.startWorkerGlobalScope(m_scriptLoader->lastRequestURL(), m_options.name, context->userAgent(m_scriptLoader->lastRequestURL()), isOnline, m_scriptLoader->script(), contentSecurityPolicyResponseHeaders, m_shouldBypassMainWorldContentSecurityPolicy, m_scriptLoader->crossOriginEmbedderPolicy(), m_workerCreationTime, referrerPolicy, m_options.type, m_options.credentials, m_runtimeFlags);
    222217    InspectorInstrumentation::scriptImported(*context, m_scriptLoader->identifier(), m_scriptLoader->script().toString());
    223218}
  • trunk/Source/WebCore/workers/WorkerFetchResult.h

    r288938 r289483  
    3636struct WorkerFetchResult {
    3737    ScriptBuffer script;
     38    URL lastRequestURL; // Last URL in case of redirects.
    3839    CertificateInfo certificateInfo;
    3940    ContentSecurityPolicyResponseHeaders contentSecurityPolicy;
     
    4243    ResourceError error;
    4344
    44     WorkerFetchResult isolatedCopy() const { return { script.isolatedCopy(), certificateInfo.isolatedCopy(), contentSecurityPolicy.isolatedCopy(), crossOriginEmbedderPolicy.isolatedCopy(), referrerPolicy.isolatedCopy(), error.isolatedCopy() }; }
     45    WorkerFetchResult isolatedCopy() const { return { script.isolatedCopy(), lastRequestURL.isolatedCopy(), certificateInfo.isolatedCopy(), contentSecurityPolicy.isolatedCopy(), crossOriginEmbedderPolicy.isolatedCopy(), referrerPolicy.isolatedCopy(), error.isolatedCopy() }; }
    4546
    4647    template<class Encoder> void encode(Encoder&) const;
     
    5051inline WorkerFetchResult workerFetchError(const ResourceError& error)
    5152{
    52     return { { }, { }, { }, { }, { }, error };
     53    return { { }, { }, { }, { }, { }, { }, error };
    5354}
    5455
     
    5657void WorkerFetchResult::encode(Encoder& encoder) const
    5758{
    58     encoder << script << contentSecurityPolicy << crossOriginEmbedderPolicy << referrerPolicy << error << certificateInfo;
     59    encoder << script << lastRequestURL << contentSecurityPolicy << crossOriginEmbedderPolicy << referrerPolicy << error << certificateInfo;
    5960}
    6061
     
    6364{
    6465    if (!decoder.decode(result.script))
     66        return false;
     67    if (!decoder.decode(result.lastRequestURL))
    6568        return false;
    6669    if (!decoder.decode(result.contentSecurityPolicy))
  • trunk/Source/WebCore/workers/WorkerScriptLoader.cpp

    r288088 r289483  
    3838#include "ServiceWorkerGlobalScope.h"
    3939#include "TextResourceDecoder.h"
     40#include "WorkerFetchResult.h"
    4041#include "WorkerGlobalScope.h"
    4142#include "WorkerScriptLoaderClient.h"
     
    5859
    5960    m_url = url;
     61    m_lastRequestURL = url;
    6062    m_destination = FetchOptions::Destination::Script;
    6163    m_isCOEPEnabled = scriptExecutionContext->settingsValues().crossOriginEmbedderPolicyEnabled;
     
    117119    m_client = &client;
    118120    m_url = scriptRequest.url();
     121    m_lastRequestURL = scriptRequest.url();
    119122    m_destination = fetchOptions.destination;
    120123    m_isCOEPEnabled = scriptExecutionContext.settingsValues().crossOriginEmbedderPolicyEnabled;
     
    177180
    178181    return { };
     182}
     183
     184void WorkerScriptLoader::redirectReceived(const URL& redirectURL)
     185{
     186    m_lastRequestURL = redirectURL;
    179187}
    180188
     
    267275}
    268276
     277WorkerFetchResult WorkerScriptLoader::fetchResult() const
     278{
     279    if (m_failed)
     280        return workerFetchError(error());
     281    return { script(), lastRequestURL(), certificateInfo(), contentSecurityPolicy(), crossOriginEmbedderPolicy(), referrerPolicy(), { } };
     282}
     283
    269284} // namespace WebCore
  • trunk/Source/WebCore/workers/WorkerScriptLoader.h

    r288088 r289483  
    5050class TextResourceDecoder;
    5151class WorkerScriptLoaderClient;
     52struct WorkerFetchResult;
    5253enum class CertificateInfoPolicy : uint8_t;
    5354
     
    6566    void notifyError();
    6667
    67     const ScriptBuffer& script() { return m_script; }
     68    const ScriptBuffer& script() const { return m_script; }
    6869    const ContentSecurityPolicyResponseHeaders& contentSecurityPolicy() const { return m_contentSecurityPolicy; }
    6970    const String& referrerPolicy() const { return m_referrerPolicy; }
    7071    const CrossOriginEmbedderPolicy& crossOriginEmbedderPolicy() const { return m_crossOriginEmbedderPolicy; }
    7172    const URL& url() const { return m_url; }
     73    const URL& lastRequestURL() const { return m_lastRequestURL; }
    7274    const URL& responseURL() const;
    7375    ResourceResponse::Source responseSource() const { return m_responseSource; }
     
    7981    const ResourceError& error() const { return m_error; }
    8082
     83    WorkerFetchResult fetchResult() const;
     84
     85    void redirectReceived(const URL& redirectURL) override;
    8186    void didReceiveResponse(ResourceLoaderIdentifier, const ResourceResponse&) override;
    8287    void didReceiveData(const SharedBuffer&) override;
     
    104109    ScriptBuffer m_script;
    105110    URL m_url;
     111    URL m_lastRequestURL;
    106112    URL m_responseURL;
    107113    CertificateInfo m_certificateInfo;
  • trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp

    r288938 r289483  
    492492}
    493493
    494 void ServiceWorkerContainer::jobFinishedLoadingScript(ServiceWorkerJob& job, const ScriptBuffer& script, const CertificateInfo& certificateInfo, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicy, const CrossOriginEmbedderPolicy& coep, const String& referrerPolicy)
     494void ServiceWorkerContainer::jobFinishedLoadingScript(ServiceWorkerJob& job, const WorkerFetchResult& fetchResult)
    495495{
    496496    ASSERT(m_creationThread.ptr() == &Thread::current());
     
    498498    CONTAINER_RELEASE_LOG("jobFinishedLoadingScript: Successfuly finished fetching script for job %" PRIu64, job.identifier().toUInt64());
    499499
    500     ensureSWClientConnection().finishFetchingScriptInServer(job.data().identifier(), job.data().registrationKey(), WorkerFetchResult { script, certificateInfo, contentSecurityPolicy, coep, referrerPolicy, { } });
     500    ensureSWClientConnection().finishFetchingScriptInServer(job.data().identifier(), job.data().registrationKey(), fetchResult);
    501501}
    502502
  • trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h

    r288974 r289483  
    119119    void jobResolvedWithUnregistrationResult(ServiceWorkerJob&, bool unregistrationResult) final;
    120120    void startScriptFetchForJob(ServiceWorkerJob&, FetchOptions::Cache) final;
    121     void jobFinishedLoadingScript(ServiceWorkerJob&, const ScriptBuffer&, const CertificateInfo&, const ContentSecurityPolicyResponseHeaders&, const CrossOriginEmbedderPolicy&, const String& referrerPolicy) final;
     121    void jobFinishedLoadingScript(ServiceWorkerJob&, const WorkerFetchResult&) final;
    122122    void jobFailedLoadingScript(ServiceWorkerJob&, const ResourceError&, Exception&&) final;
    123123
  • trunk/Source/WebCore/workers/service/ServiceWorkerJob.cpp

    r282712 r289483  
    3838#include "ServiceWorkerJobData.h"
    3939#include "ServiceWorkerRegistration.h"
     40#include "WorkerFetchResult.h"
    4041#include "WorkerRunLoop.h"
    4142
     
    166167
    167168    if (!scriptLoader->failed()) {
    168         m_client.jobFinishedLoadingScript(*this, scriptLoader->script(), scriptLoader->certificateInfo(), scriptLoader->contentSecurityPolicy(), scriptLoader->crossOriginEmbedderPolicy(), scriptLoader->referrerPolicy());
     169        m_client.jobFinishedLoadingScript(*this, scriptLoader->fetchResult());
    169170        return;
    170171    }
  • trunk/Source/WebCore/workers/service/ServiceWorkerJobClient.h

    r286012 r289483  
    4040struct CrossOriginEmbedderPolicy;
    4141struct ServiceWorkerRegistrationData;
     42struct WorkerFetchResult;
    4243
    4344class ServiceWorkerJobClient {
     
    5152    virtual void jobResolvedWithUnregistrationResult(ServiceWorkerJob&, bool unregistrationResult) = 0;
    5253    virtual void startScriptFetchForJob(ServiceWorkerJob&, FetchOptions::Cache) = 0;
    53     virtual void jobFinishedLoadingScript(ServiceWorkerJob&, const ScriptBuffer&, const CertificateInfo&, const ContentSecurityPolicyResponseHeaders&, const CrossOriginEmbedderPolicy&, const String& referrerPolicy) = 0;
     54    virtual void jobFinishedLoadingScript(ServiceWorkerJob&, const WorkerFetchResult&) = 0;
    5455    virtual void jobFailedLoadingScript(ServiceWorkerJob&, const ResourceError&, Exception&&) = 0;
    5556};
  • trunk/Source/WebCore/workers/shared/SharedWorkerScriptLoader.cpp

    r289247 r289483  
    5959void SharedWorkerScriptLoader::notifyFinished()
    6060{
    61     if (m_loader->failed())
    62         return m_completionHandler(workerFetchError(m_loader->error()));
    63 
    64     if (auto* scriptExecutionContext = m_worker->scriptExecutionContext())
     61    if (auto* scriptExecutionContext = m_worker->scriptExecutionContext(); !m_loader->failed())
    6562        InspectorInstrumentation::scriptImported(*scriptExecutionContext, m_loader->identifier(), m_loader->script().toString());
    66     m_completionHandler({ m_loader->script(), m_loader->certificateInfo(), m_loader->contentSecurityPolicy(), m_loader->crossOriginEmbedderPolicy(), m_loader->referrerPolicy(), { } }); // deletes this.
     63    m_completionHandler(m_loader->fetchResult()); // deletes this.
    6764}
    6865
  • trunk/Source/WebCore/workers/shared/context/SharedWorkerThreadProxy.cpp

    r289247 r289483  
    5656}
    5757
    58 static WorkerParameters generateWorkerParameters(const URL& scriptURL, const WorkerFetchResult& workerFetchResult, WorkerOptions&& workerOptions, const String& userAgent, Document& document)
     58static WorkerParameters generateWorkerParameters(const WorkerFetchResult& workerFetchResult, WorkerOptions&& workerOptions, const String& userAgent, Document& document)
    5959{
    6060    return WorkerParameters {
    61         scriptURL,
     61        workerFetchResult.lastRequestURL,
    6262        workerOptions.name,
    6363        "sharedworker:" + Inspector::IdentifiersFactory::createIdentifier(),
     
    7575}
    7676
    77 SharedWorkerThreadProxy::SharedWorkerThreadProxy(UniqueRef<Page>&& page, SharedWorkerIdentifier sharedWorkerIdentifier, const ClientOrigin& clientOrigin, const URL& scriptURL, WorkerFetchResult&& workerFetchResult, WorkerOptions&& workerOptions, const String& userAgent, CacheStorageProvider& cacheStorageProvider)
     77SharedWorkerThreadProxy::SharedWorkerThreadProxy(UniqueRef<Page>&& page, SharedWorkerIdentifier sharedWorkerIdentifier, const ClientOrigin& clientOrigin, WorkerFetchResult&& workerFetchResult, WorkerOptions&& workerOptions, const String& userAgent, CacheStorageProvider& cacheStorageProvider)
    7878    : m_page(WTFMove(page))
    7979    , m_document(*m_page->mainFrame().document())
    80     , m_workerThread(SharedWorkerThread::create(sharedWorkerIdentifier, generateWorkerParameters(scriptURL, workerFetchResult, WTFMove(workerOptions), userAgent, m_document), WTFMove(workerFetchResult.script), *this, *this, *this, WorkerThreadStartMode::Normal, clientOrigin.topOrigin.securityOrigin(), m_document->idbConnectionProxy(), m_document->socketProvider(), JSC::RuntimeFlags::createAllEnabled()))
     80    , m_workerThread(SharedWorkerThread::create(sharedWorkerIdentifier, generateWorkerParameters(workerFetchResult, WTFMove(workerOptions), userAgent, m_document), WTFMove(workerFetchResult.script), *this, *this, *this, WorkerThreadStartMode::Normal, clientOrigin.topOrigin.securityOrigin(), m_document->idbConnectionProxy(), m_document->socketProvider(), JSC::RuntimeFlags::createAllEnabled()))
    8181    , m_cacheStorageProvider(cacheStorageProvider)
    8282{
  • trunk/Source/WebCore/workers/shared/context/SharedWorkerThreadProxy.h

    r289247 r289483  
    5555
    5656private:
    57     WEBCORE_EXPORT SharedWorkerThreadProxy(UniqueRef<Page>&&, SharedWorkerIdentifier, const ClientOrigin&, const URL& scriptURL, WorkerFetchResult&&, WorkerOptions&&, const String& userAgent, CacheStorageProvider&);
     57    WEBCORE_EXPORT SharedWorkerThreadProxy(UniqueRef<Page>&&, SharedWorkerIdentifier, const ClientOrigin&, WorkerFetchResult&&, WorkerOptions&&, const String& userAgent, CacheStorageProvider&);
    5858
    5959    // WorkerObjectProxy.
  • trunk/Source/WebKit/ChangeLog

    r289482 r289483  
     12022-02-09  Chris Dumez  <cdumez@apple.com>
     2
     3        self.location.href is incorrect in shared workers in case of redirects
     4        https://bugs.webkit.org/show_bug.cgi?id=236340
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        self.location.href is incorrect in shared workers in case of redirects. It should be the URL of
     9        the last request, not the first one.
     10
     11        * NetworkProcess/ServiceWorker/ServiceWorkerSoftUpdateLoader.cpp:
     12        (WebKit::ServiceWorkerSoftUpdateLoader::didFinishLoading):
     13        * NetworkProcess/SharedWorker/WebSharedWorkerServerToContextConnection.cpp:
     14        (WebKit::WebSharedWorkerServerToContextConnection::launchSharedWorker):
     15        * WebProcess/Storage/WebSharedWorkerContextManagerConnection.cpp:
     16        (WebKit::WebSharedWorkerContextManagerConnection::launchSharedWorker):
     17        * WebProcess/Storage/WebSharedWorkerContextManagerConnection.h:
     18        * WebProcess/Storage/WebSharedWorkerContextManagerConnection.messages.in:
     19
    1202022-02-09  J Pascoe  <j_pascoe@apple.com>
    221
  • trunk/Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerSoftUpdateLoader.cpp

    r289018 r289483  
    197197    if (m_decoder)
    198198        m_script.append(m_decoder->flush());
    199     m_completionHandler({ ScriptBuffer { m_script.toString() }, m_certificateInfo, m_contentSecurityPolicy, m_crossOriginEmbedderPolicy, m_referrerPolicy, { } });
     199    m_completionHandler({ ScriptBuffer { m_script.toString() }, m_jobData.scriptURL, m_certificateInfo, m_contentSecurityPolicy, m_crossOriginEmbedderPolicy, m_referrerPolicy, { } });
    200200    didComplete();
    201201}
  • trunk/Source/WebKit/NetworkProcess/SharedWorker/WebSharedWorkerServerToContextConnection.cpp

    r289469 r289483  
    9191    CONTEXT_CONNECTION_RELEASE_LOG("launchSharedWorker: sharedWorkerIdentifier=%" PRIu64, sharedWorker.identifier().toUInt64());
    9292    sharedWorker.markAsRunning();
    93     send(Messages::WebSharedWorkerContextManagerConnection::LaunchSharedWorker { sharedWorker.origin(), sharedWorker.identifier(), sharedWorker.url(), sharedWorker.workerOptions(), sharedWorker.fetchResult() });
     93    send(Messages::WebSharedWorkerContextManagerConnection::LaunchSharedWorker { sharedWorker.origin(), sharedWorker.identifier(), sharedWorker.workerOptions(), sharedWorker.fetchResult() });
    9494    for (auto& port : sharedWorker.sharedWorkerObjects().values())
    9595        postConnectEvent(sharedWorker, port);
  • trunk/Source/WebKit/WebProcess/Storage/WebSharedWorkerContextManagerConnection.cpp

    r289449 r289483  
    9090}
    9191
    92 void WebSharedWorkerContextManagerConnection::launchSharedWorker(WebCore::ClientOrigin&& origin, WebCore::SharedWorkerIdentifier sharedWorkerIdentifier, URL&& url, WebCore::WorkerOptions&& workerOptions, WebCore::WorkerFetchResult&& workerFetchResult)
     92void WebSharedWorkerContextManagerConnection::launchSharedWorker(WebCore::ClientOrigin&& origin, WebCore::SharedWorkerIdentifier sharedWorkerIdentifier, WebCore::WorkerOptions&& workerOptions, WebCore::WorkerFetchResult&& workerFetchResult)
    9393{
    9494    RELEASE_LOG(SharedWorker, "WebSharedWorkerContextManagerConnection::launchSharedWorker: sharedWorkerIdentifier=%" PRIu64, sharedWorkerIdentifier.toUInt64());
     
    111111        page->settings().setStorageBlockingPolicy(static_cast<WebCore::StorageBlockingPolicy>(m_preferencesStore->getUInt32ValueForKey(WebPreferencesKey::storageBlockingPolicyKey())));
    112112    }
    113     page->setupForRemoteWorker(url, origin.topOrigin, workerFetchResult.referrerPolicy);
    114     auto sharedWorkerThreadProxy = WebCore::SharedWorkerThreadProxy::create(WTFMove(page), sharedWorkerIdentifier, origin, url, WTFMove(workerFetchResult), WTFMove(workerOptions), m_userAgent, WebProcess::singleton().cacheStorageProvider());
     113    page->setupForRemoteWorker(workerFetchResult.lastRequestURL, origin.topOrigin, workerFetchResult.referrerPolicy);
     114    auto sharedWorkerThreadProxy = WebCore::SharedWorkerThreadProxy::create(WTFMove(page), sharedWorkerIdentifier, origin, WTFMove(workerFetchResult), WTFMove(workerOptions), m_userAgent, WebProcess::singleton().cacheStorageProvider());
    115115
    116116    WebCore::SharedWorkerContextManager::singleton().registerSharedWorkerThread(WTFMove(sharedWorkerThreadProxy));
  • trunk/Source/WebKit/WebProcess/Storage/WebSharedWorkerContextManagerConnection.h

    r289247 r289483  
    5959private:
    6060    // IPC Messages.
    61     void launchSharedWorker(WebCore::ClientOrigin&&, WebCore::SharedWorkerIdentifier, URL&&, WebCore::WorkerOptions&&, WebCore::WorkerFetchResult&&);
     61    void launchSharedWorker(WebCore::ClientOrigin&&, WebCore::SharedWorkerIdentifier, WebCore::WorkerOptions&&, WebCore::WorkerFetchResult&&);
    6262    void updatePreferencesStore(const WebPreferencesStore&);
    6363    void setUserAgent(String&& userAgent) { m_userAgent = WTFMove(userAgent); }
  • trunk/Source/WebKit/WebProcess/Storage/WebSharedWorkerContextManagerConnection.messages.in

    r289247 r289483  
    2222
    2323messages -> WebSharedWorkerContextManagerConnection NotRefCounted {
    24     LaunchSharedWorker(struct WebCore::ClientOrigin origin, WebCore::SharedWorkerIdentifier sharedWorkerIdentifier, URL url, struct WebCore::WorkerOptions workerOptions, struct WebCore::WorkerFetchResult workerFetchResult)
     24    LaunchSharedWorker(struct WebCore::ClientOrigin origin, WebCore::SharedWorkerIdentifier sharedWorkerIdentifier, struct WebCore::WorkerOptions workerOptions, struct WebCore::WorkerFetchResult workerFetchResult)
    2525    PostConnectEvent(WebCore::SharedWorkerIdentifier sharedWorkerIdentifier, WebCore::TransferredMessagePort port, String sourceOrigin)
    2626    TerminateSharedWorker(WebCore::SharedWorkerIdentifier sharedWorkerIdentifier)
Note: See TracChangeset for help on using the changeset viewer.