WebKit Bugzilla
Attachment 347614 Details for
Bug 188779
: Support "name" option for dedicated workers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-188779-20180821151230.patch (text/plain), 39.69 KB, created by
Yusuke Suzuki
on 2018-08-20 23:12:31 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Yusuke Suzuki
Created:
2018-08-20 23:12:31 PDT
Size:
39.69 KB
patch
obsolete
>Subversion Revision: 235105 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index d33ed0a0891aec5fc92a63f8853ad821e4b28b42..c8cd125eeb2861083a0a71536f6fcdf7d363ec1a 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,55 @@ >+2018-08-20 Yusuke Suzuki <yusukesuzuki@slowstart.org> >+ >+ Support "name" option for dedicated workers >+ https://bugs.webkit.org/show_bug.cgi?id=188779 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ This patch adds `new Worker(url, { name: "Worker Name" })` option support[1]. >+ This name can be accessible from `self.name` of DedicatedWorkerGlobalScope. >+ It is useful for debugging dedicated workers if the inspector can show the >+ names of the workers. This enhancement is tracked by [2]. >+ >+ [1]: https://github.com/whatwg/html/issues/2477 >+ [2]: https://bugs.webkit.org/show_bug.cgi?id=164678 >+ >+ * workers/DedicatedWorkerGlobalScope.cpp: >+ (WebCore::DedicatedWorkerGlobalScope::create): >+ (WebCore::DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope): >+ Hold `name` member. >+ >+ * workers/DedicatedWorkerGlobalScope.h: >+ * workers/DedicatedWorkerGlobalScope.idl: >+ Add `name` attribute. >+ >+ * workers/DedicatedWorkerThread.cpp: >+ (WebCore::DedicatedWorkerThread::DedicatedWorkerThread): >+ (WebCore::DedicatedWorkerThread::createWorkerGlobalScope): >+ * workers/DedicatedWorkerThread.h: >+ * workers/Worker.cpp: >+ (WebCore::Worker::Worker): >+ (WebCore::Worker::create): >+ (WebCore::Worker::notifyFinished): >+ * workers/Worker.h: >+ * workers/Worker.idl: >+ Add WorkerOptions for dedicated worker creation. >+ >+ * workers/WorkerGlobalScopeProxy.h: >+ * workers/WorkerMessagingProxy.cpp: >+ (WebCore::WorkerMessagingProxy::startWorkerGlobalScope): >+ * workers/WorkerMessagingProxy.h: >+ * workers/WorkerThread.cpp: >+ (WebCore::WorkerThreadStartupData::WorkerThreadStartupData): >+ Isolate copy the given `name` to pass the worker thread. >+ >+ (WebCore::WorkerThread::WorkerThread): >+ (WebCore::WorkerThread::workerThread): >+ * workers/WorkerThread.h: >+ * workers/service/context/ServiceWorkerThread.cpp: >+ (WebCore::ServiceWorkerThread::ServiceWorkerThread): >+ (WebCore::ServiceWorkerThread::createWorkerGlobalScope): >+ * workers/service/context/ServiceWorkerThread.h: >+ > 2018-08-20 Devin Rousso <drousso@apple.com> > > Web Inspector: allow breakpoints to be set for specific event listeners >diff --git a/Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp b/Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp >index 21ddedb3d03a5cd152048742454016fc8e8202e1..db7d7770c445c8dfa6bf0225cb8094cd001e0b88 100644 >--- a/Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp >+++ b/Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp >@@ -41,16 +41,17 @@ > > namespace WebCore { > >-Ref<DedicatedWorkerGlobalScope> DedicatedWorkerGlobalScope::create(const URL& url, Ref<SecurityOrigin>&& origin, const String& identifier, const String& userAgent, bool isOnline, DedicatedWorkerThread& thread, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, PAL::SessionID sessionID) >+Ref<DedicatedWorkerGlobalScope> DedicatedWorkerGlobalScope::create(const URL& url, Ref<SecurityOrigin>&& origin, const String& name, const String& identifier, const String& userAgent, bool isOnline, DedicatedWorkerThread& thread, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, PAL::SessionID sessionID) > { >- auto context = adoptRef(*new DedicatedWorkerGlobalScope(url, WTFMove(origin), identifier, userAgent, isOnline, thread, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, connectionProxy, socketProvider, sessionID)); >+ auto context = adoptRef(*new DedicatedWorkerGlobalScope(url, WTFMove(origin), name, identifier, userAgent, isOnline, thread, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, connectionProxy, socketProvider, sessionID)); > if (!shouldBypassMainWorldContentSecurityPolicy) > context->applyContentSecurityPolicyResponseHeaders(contentSecurityPolicyResponseHeaders); > return context; > } > >-DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope(const URL& url, Ref<SecurityOrigin>&& origin, const String& identifier, const String& userAgent, bool isOnline, DedicatedWorkerThread& thread, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, PAL::SessionID sessionID) >+DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope(const URL& url, Ref<SecurityOrigin>&& origin, const String& name, const String& identifier, const String& userAgent, bool isOnline, DedicatedWorkerThread& thread, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, PAL::SessionID sessionID) > : WorkerGlobalScope(url, WTFMove(origin), identifier, userAgent, isOnline, thread, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, connectionProxy, socketProvider, sessionID) >+ , m_name(name) > { > } > >diff --git a/Source/WebCore/workers/DedicatedWorkerGlobalScope.h b/Source/WebCore/workers/DedicatedWorkerGlobalScope.h >index 521ba408a12e7fdbea3fc32f0af6ee0c3502008a..55a99e57644c5d7848343546be007b8f307c5960 100644 >--- a/Source/WebCore/workers/DedicatedWorkerGlobalScope.h >+++ b/Source/WebCore/workers/DedicatedWorkerGlobalScope.h >@@ -48,9 +48,11 @@ class SerializedScriptValue; > > class DedicatedWorkerGlobalScope final : public WorkerGlobalScope { > public: >- static Ref<DedicatedWorkerGlobalScope> create(const URL&, Ref<SecurityOrigin>&&, const String& identifier, const String& userAgent, bool isOnline, DedicatedWorkerThread&, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, PAL::SessionID); >+ static Ref<DedicatedWorkerGlobalScope> create(const URL&, Ref<SecurityOrigin>&&, const String& name, const String& identifier, const String& userAgent, bool isOnline, DedicatedWorkerThread&, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, PAL::SessionID); > virtual ~DedicatedWorkerGlobalScope(); > >+ const String& name() const { return m_name; } >+ > ExceptionOr<void> postMessage(JSC::ExecState&, JSC::JSValue message, Vector<JSC::Strong<JSC::JSObject>>&&); > > DedicatedWorkerThread& thread(); >@@ -58,11 +60,13 @@ class DedicatedWorkerGlobalScope final : public WorkerGlobalScope { > private: > using Base = WorkerGlobalScope; > >- DedicatedWorkerGlobalScope(const URL&, Ref<SecurityOrigin>&&, const String& identifier, const String& userAgent, bool isOnline, DedicatedWorkerThread&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, PAL::SessionID); >+ DedicatedWorkerGlobalScope(const URL&, Ref<SecurityOrigin>&&, const String& name, const String& identifier, const String& userAgent, bool isOnline, DedicatedWorkerThread&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, PAL::SessionID); > > bool isDedicatedWorkerGlobalScope() const final { return true; } > ExceptionOr<void> importScripts(const Vector<String>& urls) final; > EventTargetInterface eventTargetInterface() const final; >+ >+ String m_name; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/workers/DedicatedWorkerGlobalScope.idl b/Source/WebCore/workers/DedicatedWorkerGlobalScope.idl >index 3baedf059ea2479a0890351b290b1f19e580449e..cea69bfafa178d8f9f50ceed033643c309bc61aa 100644 >--- a/Source/WebCore/workers/DedicatedWorkerGlobalScope.idl >+++ b/Source/WebCore/workers/DedicatedWorkerGlobalScope.idl >@@ -37,6 +37,8 @@ > IsImmutablePrototypeExoticObject, > IsImmutablePrototypeExoticObjectOnPrototype, > ] interface DedicatedWorkerGlobalScope : WorkerGlobalScope { >+ [Replaceable] readonly attribute DOMString name; >+ > [CallWith=ScriptState, MayThrowException] void postMessage(any message, optional sequence<object> transfer = []); > > void close(); >diff --git a/Source/WebCore/workers/DedicatedWorkerThread.cpp b/Source/WebCore/workers/DedicatedWorkerThread.cpp >index dfc6776509c2556d29d0335fc12888fcb83ffa1b..73a3da4baaae4981f7db75b3a1598f8a8d4dbee8 100644 >--- a/Source/WebCore/workers/DedicatedWorkerThread.cpp >+++ b/Source/WebCore/workers/DedicatedWorkerThread.cpp >@@ -38,17 +38,17 @@ > > namespace WebCore { > >-DedicatedWorkerThread::DedicatedWorkerThread(const URL& url, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerDebuggerProxy& workerDebuggerProxy, WorkerObjectProxy& workerObjectProxy, WorkerThreadStartMode startMode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, JSC::RuntimeFlags runtimeFlags, PAL::SessionID sessionID) >- : WorkerThread(url, identifier, userAgent, isOnline, sourceCode, workerLoaderProxy, workerDebuggerProxy, workerObjectProxy, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, topOrigin, timeOrigin, connectionProxy, socketProvider, runtimeFlags, sessionID) >+DedicatedWorkerThread::DedicatedWorkerThread(const URL& url, const String& name, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerDebuggerProxy& workerDebuggerProxy, WorkerObjectProxy& workerObjectProxy, WorkerThreadStartMode startMode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, JSC::RuntimeFlags runtimeFlags, PAL::SessionID sessionID) >+ : WorkerThread(url, name, identifier, userAgent, isOnline, sourceCode, workerLoaderProxy, workerDebuggerProxy, workerObjectProxy, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, topOrigin, timeOrigin, connectionProxy, socketProvider, runtimeFlags, sessionID) > , m_workerObjectProxy(workerObjectProxy) > { > } > > DedicatedWorkerThread::~DedicatedWorkerThread() = default; > >-Ref<WorkerGlobalScope> DedicatedWorkerThread::createWorkerGlobalScope(const URL& url, Ref<SecurityOrigin>&& origin, const String& identifier, const String& userAgent, bool isOnline, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID sessionID) >+Ref<WorkerGlobalScope> DedicatedWorkerThread::createWorkerGlobalScope(const URL& url, Ref<SecurityOrigin>&& origin, const String& name, const String& identifier, const String& userAgent, bool isOnline, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID sessionID) > { >- return DedicatedWorkerGlobalScope::create(url, WTFMove(origin), identifier, userAgent, isOnline, *this, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, idbConnectionProxy(), socketProvider(), sessionID); >+ return DedicatedWorkerGlobalScope::create(url, WTFMove(origin), name, identifier, userAgent, isOnline, *this, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, idbConnectionProxy(), socketProvider(), sessionID); > } > > void DedicatedWorkerThread::runEventLoop() >diff --git a/Source/WebCore/workers/DedicatedWorkerThread.h b/Source/WebCore/workers/DedicatedWorkerThread.h >index d46879b7138b8e254583a537bb04acbec335de60..f1c9624b18ac1893298846339616352cac0c7dd7 100644 >--- a/Source/WebCore/workers/DedicatedWorkerThread.h >+++ b/Source/WebCore/workers/DedicatedWorkerThread.h >@@ -49,11 +49,11 @@ class DedicatedWorkerThread : public WorkerThread { > WorkerObjectProxy& workerObjectProxy() const { return m_workerObjectProxy; } > > protected: >- Ref<WorkerGlobalScope> createWorkerGlobalScope(const URL&, Ref<SecurityOrigin>&&, const String& identifier, const String& userAgent, bool isOnline, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID) override; >+ Ref<WorkerGlobalScope> createWorkerGlobalScope(const URL&, Ref<SecurityOrigin>&&, const String& name, const String& identifier, const String& userAgent, bool isOnline, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID) override; > void runEventLoop() override; > > private: >- DedicatedWorkerThread(const URL&, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerLoaderProxy&, WorkerDebuggerProxy&, WorkerObjectProxy&, WorkerThreadStartMode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, JSC::RuntimeFlags, PAL::SessionID); >+ DedicatedWorkerThread(const URL&, const String& name, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerLoaderProxy&, WorkerDebuggerProxy&, WorkerObjectProxy&, WorkerThreadStartMode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, JSC::RuntimeFlags, PAL::SessionID); > > WorkerObjectProxy& m_workerObjectProxy; > }; >diff --git a/Source/WebCore/workers/Worker.cpp b/Source/WebCore/workers/Worker.cpp >index 409ee1accd970b2dd961769e9f6cfa9f904cb948..49474c7042d3f0f9a4ba6fe366a30a383840bd80 100644 >--- a/Source/WebCore/workers/Worker.cpp >+++ b/Source/WebCore/workers/Worker.cpp >@@ -57,8 +57,9 @@ void Worker::networkStateChanged(bool isOnLine) > worker->notifyNetworkStateChange(isOnLine); > } > >-inline Worker::Worker(ScriptExecutionContext& context, JSC::RuntimeFlags runtimeFlags) >+inline Worker::Worker(ScriptExecutionContext& context, JSC::RuntimeFlags runtimeFlags, const Options& options) > : ActiveDOMObject(&context) >+ , m_name(options.name) > , m_identifier("worker:" + Inspector::IdentifiersFactory::createIdentifier()) > , m_contextProxy(WorkerGlobalScopeProxy::create(*this)) > , m_runtimeFlags(runtimeFlags) >@@ -73,14 +74,14 @@ inline Worker::Worker(ScriptExecutionContext& context, JSC::RuntimeFlags runtime > ASSERT_UNUSED(addResult, addResult.isNewEntry); > } > >-ExceptionOr<Ref<Worker>> Worker::create(ScriptExecutionContext& context, JSC::RuntimeFlags runtimeFlags, const String& url) >+ExceptionOr<Ref<Worker>> Worker::create(ScriptExecutionContext& context, JSC::RuntimeFlags runtimeFlags, const String& url, const Options& options) > { > ASSERT(isMainThread()); > > // We don't currently support nested workers, so workers can only be created from documents. > ASSERT_WITH_SECURITY_IMPLICATION(context.isDocument()); > >- auto worker = adoptRef(*new Worker(context, runtimeFlags)); >+ auto worker = adoptRef(*new Worker(context, runtimeFlags, options)); > > worker->suspendIfNeeded(); > >@@ -103,12 +104,12 @@ ExceptionOr<Ref<Worker>> Worker::create(ScriptExecutionContext& context, JSC::Ru > ResourceRequest request { scriptURL.releaseReturnValue() }; > request.setInitiatorIdentifier(worker->m_identifier); > >- FetchOptions options; >- options.mode = FetchOptions::Mode::SameOrigin; >- options.cache = FetchOptions::Cache::Default; >- options.redirect = FetchOptions::Redirect::Follow; >- options.destination = FetchOptions::Destination::Worker; >- worker->m_scriptLoader->loadAsynchronously(context, WTFMove(request), WTFMove(options), contentSecurityPolicyEnforcement, ServiceWorkersMode::All, worker); >+ FetchOptions fetchOptions; >+ fetchOptions.mode = FetchOptions::Mode::SameOrigin; >+ fetchOptions.cache = FetchOptions::Cache::Default; >+ fetchOptions.redirect = FetchOptions::Redirect::Follow; >+ fetchOptions.destination = FetchOptions::Destination::Worker; >+ worker->m_scriptLoader->loadAsynchronously(context, WTFMove(request), WTFMove(fetchOptions), contentSecurityPolicyEnforcement, ServiceWorkersMode::All, worker); > return WTFMove(worker); > } > >@@ -185,7 +186,7 @@ void Worker::notifyFinished() > else { > bool isOnline = platformStrategies()->loaderStrategy()->isOnLine(); > const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders = m_contentSecurityPolicyResponseHeaders ? m_contentSecurityPolicyResponseHeaders.value() : scriptExecutionContext()->contentSecurityPolicy()->responseHeaders(); >- m_contextProxy.startWorkerGlobalScope(m_scriptLoader->url(), scriptExecutionContext()->userAgent(m_scriptLoader->url()), isOnline, m_scriptLoader->script(), contentSecurityPolicyResponseHeaders, m_shouldBypassMainWorldContentSecurityPolicy, m_workerCreationTime, m_runtimeFlags, sessionID); >+ m_contextProxy.startWorkerGlobalScope(m_scriptLoader->url(), m_name, scriptExecutionContext()->userAgent(m_scriptLoader->url()), isOnline, m_scriptLoader->script(), contentSecurityPolicyResponseHeaders, m_shouldBypassMainWorldContentSecurityPolicy, m_workerCreationTime, m_runtimeFlags, sessionID); > InspectorInstrumentation::scriptImported(*scriptExecutionContext(), m_scriptLoader->identifier(), m_scriptLoader->script()); > } > m_scriptLoader = nullptr; >diff --git a/Source/WebCore/workers/Worker.h b/Source/WebCore/workers/Worker.h >index c228dea4336626ad8fdc0b5a05e205e110082bec..2dccf2062f2cdf740c0d3428a1ecfba2eb5b3bdb 100644 >--- a/Source/WebCore/workers/Worker.h >+++ b/Source/WebCore/workers/Worker.h >@@ -50,7 +50,10 @@ class WorkerScriptLoader; > > class Worker final : public AbstractWorker, public ActiveDOMObject, private WorkerScriptLoaderClient { > public: >- static ExceptionOr<Ref<Worker>> create(ScriptExecutionContext&, JSC::RuntimeFlags, const String& url); >+ struct Options { >+ String name; >+ }; >+ static ExceptionOr<Ref<Worker>> create(ScriptExecutionContext&, JSC::RuntimeFlags, const String& url, const Options&); > virtual ~Worker(); > > ExceptionOr<void> postMessage(JSC::ExecState&, JSC::JSValue message, Vector<JSC::Strong<JSC::JSObject>>&&); >@@ -64,7 +67,7 @@ class Worker final : public AbstractWorker, public ActiveDOMObject, private Work > ScriptExecutionContext* scriptExecutionContext() const final { return ActiveDOMObject::scriptExecutionContext(); } > > private: >- explicit Worker(ScriptExecutionContext&, JSC::RuntimeFlags); >+ explicit Worker(ScriptExecutionContext&, JSC::RuntimeFlags, const Options&); > > EventTargetInterface eventTargetInterface() const final { return WorkerEventTargetInterfaceType; } > >@@ -80,6 +83,7 @@ class Worker final : public AbstractWorker, public ActiveDOMObject, private Work > static void networkStateChanged(bool isOnLine); > > RefPtr<WorkerScriptLoader> m_scriptLoader; >+ String m_name; > String m_identifier; > WorkerGlobalScopeProxy& m_contextProxy; // The proxy outlives the worker to perform thread shutdown. > std::optional<ContentSecurityPolicyResponseHeaders> m_contentSecurityPolicyResponseHeaders; >diff --git a/Source/WebCore/workers/Worker.idl b/Source/WebCore/workers/Worker.idl >index 6c517783574087026ffa6d3ac1619ffc55a4fc15..953150389598f13503b65ced8d4e92ce2dca63f1 100644 >--- a/Source/WebCore/workers/Worker.idl >+++ b/Source/WebCore/workers/Worker.idl >@@ -26,7 +26,7 @@ > > [ > ActiveDOMObject, >- Constructor(USVString scriptUrl), >+ Constructor(USVString scriptUrl, optional WorkerOptions options), > ConstructorCallWith=ScriptExecutionContext&RuntimeFlags, > ConstructorMayThrowException > ] interface Worker : EventTarget { >@@ -36,4 +36,8 @@ > attribute EventHandler onmessage; > }; > >+dictionary WorkerOptions { >+ DOMString name = ""; >+}; >+ > Worker implements AbstractWorker; >diff --git a/Source/WebCore/workers/WorkerGlobalScopeProxy.h b/Source/WebCore/workers/WorkerGlobalScopeProxy.h >index 47943ff5b97b108f9e6b1d362aff55c79c643c69..36bd00707d0a68db3076272ba65f30a3a927f1e7 100644 >--- a/Source/WebCore/workers/WorkerGlobalScopeProxy.h >+++ b/Source/WebCore/workers/WorkerGlobalScopeProxy.h >@@ -50,7 +50,7 @@ class WorkerGlobalScopeProxy { > public: > static WorkerGlobalScopeProxy& create(Worker&); > >- virtual void startWorkerGlobalScope(const URL& scriptURL, const String& userAgent, bool isOnline, const String& sourceCode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, MonotonicTime timeOrigin, JSC::RuntimeFlags, PAL::SessionID) = 0; >+ virtual void startWorkerGlobalScope(const URL& scriptURL, const String& name, const String& userAgent, bool isOnline, const String& sourceCode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, MonotonicTime timeOrigin, JSC::RuntimeFlags, PAL::SessionID) = 0; > virtual void terminateWorkerGlobalScope() = 0; > virtual void postMessageToWorkerGlobalScope(MessageWithMessagePorts&&) = 0; > virtual bool hasPendingActivity() const = 0; >diff --git a/Source/WebCore/workers/WorkerMessagingProxy.cpp b/Source/WebCore/workers/WorkerMessagingProxy.cpp >index f366462d393622522379b70dfabbf4fb857db259..a75c0156c59e38dd999d6cec1ddeede23be187b3 100644 >--- a/Source/WebCore/workers/WorkerMessagingProxy.cpp >+++ b/Source/WebCore/workers/WorkerMessagingProxy.cpp >@@ -72,7 +72,7 @@ WorkerMessagingProxy::~WorkerMessagingProxy() > || (is<WorkerGlobalScope>(*m_scriptExecutionContext) && downcast<WorkerGlobalScope>(*m_scriptExecutionContext).thread().thread() == &Thread::current())); > } > >-void WorkerMessagingProxy::startWorkerGlobalScope(const URL& scriptURL, const String& userAgent, bool isOnline, const String& sourceCode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, MonotonicTime timeOrigin, JSC::RuntimeFlags runtimeFlags, PAL::SessionID sessionID) >+void WorkerMessagingProxy::startWorkerGlobalScope(const URL& scriptURL, const String& name, const String& userAgent, bool isOnline, const String& sourceCode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, MonotonicTime timeOrigin, JSC::RuntimeFlags runtimeFlags, PAL::SessionID sessionID) > { > // FIXME: This need to be revisited when we support nested worker one day > ASSERT(m_scriptExecutionContext); >@@ -88,7 +88,7 @@ void WorkerMessagingProxy::startWorkerGlobalScope(const URL& scriptURL, const St > > SocketProvider* socketProvider = document.socketProvider(); > >- auto thread = DedicatedWorkerThread::create(scriptURL, identifier, userAgent, isOnline, sourceCode, *this, *this, *this, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, document.topOrigin(), timeOrigin, proxy, socketProvider, runtimeFlags, sessionID); >+ auto thread = DedicatedWorkerThread::create(scriptURL, name, identifier, userAgent, isOnline, sourceCode, *this, *this, *this, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, document.topOrigin(), timeOrigin, proxy, socketProvider, runtimeFlags, sessionID); > > workerThreadCreated(thread.get()); > thread->start(nullptr); >diff --git a/Source/WebCore/workers/WorkerMessagingProxy.h b/Source/WebCore/workers/WorkerMessagingProxy.h >index 4eff2fa4a243ecfc14f4645ead6cff610ea44bec..ecedb483956c121bf86d05f22baba43814bcd306 100644 >--- a/Source/WebCore/workers/WorkerMessagingProxy.h >+++ b/Source/WebCore/workers/WorkerMessagingProxy.h >@@ -46,7 +46,7 @@ class WorkerMessagingProxy final : public ThreadSafeRefCounted<WorkerMessagingPr > private: > // Implementations of WorkerGlobalScopeProxy. > // (Only use these functions in the worker object thread.) >- void startWorkerGlobalScope(const URL& scriptURL, const String& userAgent, bool isOnline, const String& sourceCode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, MonotonicTime timeOrigin, JSC::RuntimeFlags, PAL::SessionID) final; >+ void startWorkerGlobalScope(const URL& scriptURL, const String& name, const String& userAgent, bool isOnline, const String& sourceCode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, MonotonicTime timeOrigin, JSC::RuntimeFlags, PAL::SessionID) final; > void terminateWorkerGlobalScope() final; > void postMessageToWorkerGlobalScope(MessageWithMessagePorts&&) final; > bool hasPendingActivity() const final; >diff --git a/Source/WebCore/workers/WorkerThread.cpp b/Source/WebCore/workers/WorkerThread.cpp >index f38918542e94dc265f559c3b71963afdd9ad15ed..1c6aa165b59187147c8ba809561b30315c84b0b7 100644 >--- a/Source/WebCore/workers/WorkerThread.cpp >+++ b/Source/WebCore/workers/WorkerThread.cpp >@@ -72,10 +72,11 @@ unsigned WorkerThread::workerThreadCount() > struct WorkerThreadStartupData { > WTF_MAKE_NONCOPYABLE(WorkerThreadStartupData); WTF_MAKE_FAST_ALLOCATED; > public: >- WorkerThreadStartupData(const URL& scriptURL, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerThreadStartMode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, PAL::SessionID); >+ WorkerThreadStartupData(const URL& scriptURL, const String& name, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerThreadStartMode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, PAL::SessionID); > > URL m_scriptURL; > Ref<SecurityOrigin> m_origin; >+ String m_name; > String m_identifier; > String m_userAgent; > String m_sourceCode; >@@ -88,9 +89,10 @@ struct WorkerThreadStartupData { > PAL::SessionID m_sessionID; > }; > >-WorkerThreadStartupData::WorkerThreadStartupData(const URL& scriptURL, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerThreadStartMode startMode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, PAL::SessionID sessionID) >+WorkerThreadStartupData::WorkerThreadStartupData(const URL& scriptURL, const String& name, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerThreadStartMode startMode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, PAL::SessionID sessionID) > : m_scriptURL(scriptURL.isolatedCopy()) > , m_origin(SecurityOrigin::create(m_scriptURL)->isolatedCopy()) >+ , m_name(name.isolatedCopy()) > , m_identifier(identifier.isolatedCopy()) > , m_userAgent(userAgent.isolatedCopy()) > , m_sourceCode(sourceCode.isolatedCopy()) >@@ -104,12 +106,12 @@ WorkerThreadStartupData::WorkerThreadStartupData(const URL& scriptURL, const Str > { > } > >-WorkerThread::WorkerThread(const URL& scriptURL, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerDebuggerProxy& workerDebuggerProxy, WorkerReportingProxy& workerReportingProxy, WorkerThreadStartMode startMode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, JSC::RuntimeFlags runtimeFlags, PAL::SessionID sessionID) >+WorkerThread::WorkerThread(const URL& scriptURL, const String& name, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerLoaderProxy& workerLoaderProxy, WorkerDebuggerProxy& workerDebuggerProxy, WorkerReportingProxy& workerReportingProxy, WorkerThreadStartMode startMode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, JSC::RuntimeFlags runtimeFlags, PAL::SessionID sessionID) > : m_workerLoaderProxy(workerLoaderProxy) > , m_workerDebuggerProxy(workerDebuggerProxy) > , m_workerReportingProxy(workerReportingProxy) > , m_runtimeFlags(runtimeFlags) >- , m_startupData(std::make_unique<WorkerThreadStartupData>(scriptURL, identifier, userAgent, isOnline, sourceCode, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, topOrigin, timeOrigin, sessionID)) >+ , m_startupData(std::make_unique<WorkerThreadStartupData>(scriptURL, name, identifier, userAgent, isOnline, sourceCode, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, topOrigin, timeOrigin, sessionID)) > #if ENABLE(INDEXED_DATABASE) > , m_idbConnectionProxy(connectionProxy) > #endif >@@ -167,7 +169,7 @@ void WorkerThread::workerThread() > // while WorkerThread::stop() is accessing it. Note that WorkerThread::stop() can > // be called before we've finished creating the WorkerGlobalScope. > LockHolder lock(m_threadCreationAndWorkerGlobalScopeMutex); >- m_workerGlobalScope = createWorkerGlobalScope(m_startupData->m_scriptURL, WTFMove(m_startupData->m_origin), m_startupData->m_identifier, m_startupData->m_userAgent, m_startupData->m_isOnline, m_startupData->m_contentSecurityPolicyResponseHeaders, m_startupData->m_shouldBypassMainWorldContentSecurityPolicy, WTFMove(m_startupData->m_topOrigin), m_startupData->m_timeOrigin, m_startupData->m_sessionID); >+ m_workerGlobalScope = createWorkerGlobalScope(m_startupData->m_scriptURL, WTFMove(m_startupData->m_origin), m_startupData->m_name, m_startupData->m_identifier, m_startupData->m_userAgent, m_startupData->m_isOnline, m_startupData->m_contentSecurityPolicyResponseHeaders, m_startupData->m_shouldBypassMainWorldContentSecurityPolicy, WTFMove(m_startupData->m_topOrigin), m_startupData->m_timeOrigin, m_startupData->m_sessionID); > > scriptController = m_workerGlobalScope->script(); > >diff --git a/Source/WebCore/workers/WorkerThread.h b/Source/WebCore/workers/WorkerThread.h >index ede70ef02afa0d4944d0aadec99bf0b62e99ed4e..d71412485a969049adb4965974dbe91f5ee19189 100644 >--- a/Source/WebCore/workers/WorkerThread.h >+++ b/Source/WebCore/workers/WorkerThread.h >@@ -87,10 +87,10 @@ class WorkerThread : public ThreadSafeRefCounted<WorkerThread> { > JSC::RuntimeFlags runtimeFlags() const { return m_runtimeFlags; } > > protected: >- WorkerThread(const URL&, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerLoaderProxy&, WorkerDebuggerProxy&, WorkerReportingProxy&, WorkerThreadStartMode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, JSC::RuntimeFlags, PAL::SessionID); >+ WorkerThread(const URL&, const String& name, const String& identifier, const String& userAgent, bool isOnline, const String& sourceCode, WorkerLoaderProxy&, WorkerDebuggerProxy&, WorkerReportingProxy&, WorkerThreadStartMode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const SecurityOrigin& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, JSC::RuntimeFlags, PAL::SessionID); > > // Factory method for creating a new worker context for the thread. >- virtual Ref<WorkerGlobalScope> createWorkerGlobalScope(const URL&, Ref<SecurityOrigin>&&, const String& identifier, const String& userAgent, bool isOnline, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID) = 0; >+ virtual Ref<WorkerGlobalScope> createWorkerGlobalScope(const URL&, Ref<SecurityOrigin>&&, const String& name, const String& identifier, const String& userAgent, bool isOnline, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID) = 0; > > // Executes the event loop for the worker thread. Derived classes can override to perform actions before/after entering the event loop. > virtual void runEventLoop(); >diff --git a/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp b/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp >index 9e6dc354605ba7fbfaa25bb45f943031c657b741..51760aa79678d2b7ba6f771c622206be03f5de6d 100644 >--- a/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp >+++ b/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp >@@ -72,7 +72,7 @@ class DummyServiceWorkerThreadProxy : public WorkerObjectProxy { > // FIXME: Use valid runtime flags > > ServiceWorkerThread::ServiceWorkerThread(const ServiceWorkerContextData& data, PAL::SessionID, String&& userAgent, WorkerLoaderProxy& loaderProxy, WorkerDebuggerProxy& debuggerProxy, IDBClient::IDBConnectionProxy* idbConnectionProxy, SocketProvider* socketProvider) >- : WorkerThread(data.scriptURL, "serviceworker:" + Inspector::IdentifiersFactory::createIdentifier(), WTFMove(userAgent), platformStrategies()->loaderStrategy()->isOnLine(), data.script, loaderProxy, debuggerProxy, DummyServiceWorkerThreadProxy::shared(), WorkerThreadStartMode::Normal, data.contentSecurityPolicy, false, data.registration.key.topOrigin().securityOrigin().get(), MonotonicTime::now(), idbConnectionProxy, socketProvider, JSC::RuntimeFlags::createAllEnabled(), data.sessionID) >+ : WorkerThread(data.scriptURL, emptyString(), "serviceworker:" + Inspector::IdentifiersFactory::createIdentifier(), WTFMove(userAgent), platformStrategies()->loaderStrategy()->isOnLine(), data.script, loaderProxy, debuggerProxy, DummyServiceWorkerThreadProxy::shared(), WorkerThreadStartMode::Normal, data.contentSecurityPolicy, false, data.registration.key.topOrigin().securityOrigin().get(), MonotonicTime::now(), idbConnectionProxy, socketProvider, JSC::RuntimeFlags::createAllEnabled(), data.sessionID) > , m_data(data.isolatedCopy()) > , m_workerObjectProxy(DummyServiceWorkerThreadProxy::shared()) > { >@@ -81,8 +81,9 @@ ServiceWorkerThread::ServiceWorkerThread(const ServiceWorkerContextData& data, P > > ServiceWorkerThread::~ServiceWorkerThread() = default; > >-Ref<WorkerGlobalScope> ServiceWorkerThread::createWorkerGlobalScope(const URL& url, Ref<SecurityOrigin>&& origin, const String& identifier, const String& userAgent, bool isOnline, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicy, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID sessionID) >+Ref<WorkerGlobalScope> ServiceWorkerThread::createWorkerGlobalScope(const URL& url, Ref<SecurityOrigin>&& origin, const String& name, const String& identifier, const String& userAgent, bool isOnline, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicy, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID sessionID) > { >+ UNUSED_PARAM(name); > return ServiceWorkerGlobalScope::create(m_data, url, WTFMove(origin), identifier, userAgent, isOnline, *this, contentSecurityPolicy, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, idbConnectionProxy(), socketProvider(), sessionID); > } > >diff --git a/Source/WebCore/workers/service/context/ServiceWorkerThread.h b/Source/WebCore/workers/service/context/ServiceWorkerThread.h >index 3582211f0bd6def6054f40f6d0d41ac93b01cd41..3492a39fe0bfbc00ef6c48a7e1cf6260ad324e92 100644 >--- a/Source/WebCore/workers/service/context/ServiceWorkerThread.h >+++ b/Source/WebCore/workers/service/context/ServiceWorkerThread.h >@@ -66,7 +66,7 @@ class ServiceWorkerThread : public WorkerThread { > ServiceWorkerIdentifier identifier() const { return m_data.serviceWorkerIdentifier; } > > protected: >- Ref<WorkerGlobalScope> createWorkerGlobalScope(const URL&, Ref<SecurityOrigin>&&, const String& identifier, const String& userAgent, bool isOnline, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID) final; >+ Ref<WorkerGlobalScope> createWorkerGlobalScope(const URL&, Ref<SecurityOrigin>&&, const String& name, const String& identifier, const String& userAgent, bool isOnline, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID) final; > void runEventLoop() override; > > private: >diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog >index e25f6fdc649482ff5a4d4b9272210f9b9ee2a962..d0ee126ff01a35d32c05b1f93542e0d400684e7e 100644 >--- a/LayoutTests/imported/w3c/ChangeLog >+++ b/LayoutTests/imported/w3c/ChangeLog >@@ -1,3 +1,12 @@ >+2018-08-20 Yusuke Suzuki <yusukesuzuki@slowstart.org> >+ >+ Support "name" option for dedicated workers >+ https://bugs.webkit.org/show_bug.cgi?id=188779 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * web-platform-tests/workers/name-property-expected.txt: >+ > 2018-08-20 Rob Buis <rbuis@igalia.com> > > Throw an exception if window.open() gets passed a URL that cannot be parsed >diff --git a/LayoutTests/imported/w3c/web-platform-tests/workers/name-property-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/workers/name-property-expected.txt >index 05a51f8216d3fc3f9d261277d1791ab852895be2..bc411a888083e8c442061dc92dfa4f64cfdd8f22 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/workers/name-property-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/workers/name-property-expected.txt >@@ -1,7 +1,7 @@ > CONSOLE MESSAGE: line 20: ReferenceError: Can't find variable: SharedWorker > > FAIL Test the name property of shared and dedicated workers via the name constructor option ReferenceError: Can't find variable: SharedWorker >-PASS Declaring name as an accidental global must not cause a harness error for DedicatedWorkerGlobalScope >-FAIL name property value for DedicatedWorkerGlobalScope assert_true: property exists on the global expected true got false >+PASS name property value for DedicatedWorkerGlobalScope > PASS name property is replaceable for DedicatedWorkerGlobalScope >+PASS Declaring name as an accidental global must not cause a harness error for DedicatedWorkerGlobalScope >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188779
:
347613
|
347614
|
347618