source: webkit/trunk/Source/WebCore/loader/ThreadableLoaderClientWrapper.h

Last change on this file was 289483, checked in by Chris Dumez, 3 years ago

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:
  • Property svn:eol-style set to native
File size: 3.9 KB
Line 
1/*
2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#pragma once
32
33#include "ThreadableLoaderClient.h"
34#include <wtf/Ref.h>
35#include <wtf/ThreadSafeRefCounted.h>
36
37namespace WebCore {
38
39class ThreadableLoaderClientWrapper : public ThreadSafeRefCounted<ThreadableLoaderClientWrapper> {
40public:
41 static Ref<ThreadableLoaderClientWrapper> create(ThreadableLoaderClient& client, const String& initiator)
42 {
43 return adoptRef(*new ThreadableLoaderClientWrapper(client, initiator));
44 }
45
46 void clearClient()
47 {
48 m_done = true;
49 m_client = nullptr;
50 }
51
52 bool done() const
53 {
54 return m_done;
55 }
56
57 void redirectReceived(const URL& redirectURL)
58 {
59 if (m_client)
60 m_client->redirectReceived(redirectURL);
61 }
62
63 void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent)
64 {
65 if (m_client)
66 m_client->didSendData(bytesSent, totalBytesToBeSent);
67 }
68
69 void didReceiveResponse(ResourceLoaderIdentifier identifier, const ResourceResponse& response)
70 {
71 if (m_client)
72 m_client->didReceiveResponse(identifier, response);
73 }
74
75 void didReceiveData(const SharedBuffer& buffer)
76 {
77 if (m_client)
78 m_client->didReceiveData(buffer);
79 }
80
81 void didFinishLoading(ResourceLoaderIdentifier identifier, const NetworkLoadMetrics& metrics)
82 {
83 m_done = true;
84 if (m_client)
85 m_client->didFinishLoading(identifier, metrics);
86 }
87
88 void notifyIsDone(bool isDone)
89 {
90 if (m_client)
91 m_client->notifyIsDone(isDone);
92 }
93
94 void didFail(const ResourceError& error)
95 {
96 m_done = true;
97 if (m_client)
98 m_client->didFail(error);
99 }
100
101 void didReceiveAuthenticationCancellation(ResourceLoaderIdentifier identifier, const ResourceResponse& response)
102 {
103 if (m_client)
104 m_client->didReceiveResponse(identifier, response);
105 }
106
107 const String& initiator() const { return m_initiator; }
108
109protected:
110 explicit ThreadableLoaderClientWrapper(ThreadableLoaderClient&, const String&);
111
112 ThreadableLoaderClient* m_client;
113 String m_initiator;
114 bool m_done { false };
115};
116
117inline ThreadableLoaderClientWrapper::ThreadableLoaderClientWrapper(ThreadableLoaderClient& client, const String& initiator)
118 : m_client(&client)
119 , m_initiator(initiator.isolatedCopy())
120{
121}
122
123} // namespace WebCore
Note: See TracBrowser for help on using the repository browser.