Changeset 235159 in webkit


Ignore:
Timestamp:
Aug 21, 2018 9:58:26 PM (6 years ago)
Author:
yusukesuzuki@slowstart.org
Message:

Support "name" option for dedicated workers
https://bugs.webkit.org/show_bug.cgi?id=188779

Reviewed by Joseph Pecoraro.

LayoutTests/imported/w3c:

  • web-platform-tests/workers/interfaces.worker-expected.txt:
  • web-platform-tests/workers/name-property-expected.txt:

Source/WebCore:

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

Tests: http/wpt/workers/name-property-enhanced.html

http/wpt/workers/name-property-no-name.html

  • 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:

LayoutTests:

  • http/wpt/workers/name-property-enhanced-expected.txt: Added.
  • http/wpt/workers/name-property-enhanced.html: Added.
  • http/wpt/workers/name-property-no-name-expected.txt: Added.
  • http/wpt/workers/name-property-no-name.html: Added.
  • http/wpt/workers/support/name.js: Added.

(test):

  • http/wpt/workers/support/no-name.js: Added.

(test):

Location:
trunk
Files:
7 added
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r235155 r235159  
     12018-08-21  Yusuke Suzuki  <yusukesuzuki@slowstart.org>
     2
     3        Support "name" option for dedicated workers
     4        https://bugs.webkit.org/show_bug.cgi?id=188779
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        * http/wpt/workers/name-property-enhanced-expected.txt: Added.
     9        * http/wpt/workers/name-property-enhanced.html: Added.
     10        * http/wpt/workers/name-property-no-name-expected.txt: Added.
     11        * http/wpt/workers/name-property-no-name.html: Added.
     12        * http/wpt/workers/support/name.js: Added.
     13        (test):
     14        * http/wpt/workers/support/no-name.js: Added.
     15        (test):
     16
    1172018-08-21  Ryan Haddad  <ryanhaddad@apple.com>
    218
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r235155 r235159  
     12018-08-21  Yusuke Suzuki  <yusukesuzuki@slowstart.org>
     2
     3        Support "name" option for dedicated workers
     4        https://bugs.webkit.org/show_bug.cgi?id=188779
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        * web-platform-tests/workers/interfaces.worker-expected.txt:
     9        * web-platform-tests/workers/name-property-expected.txt:
     10
    1112018-08-21  Ryan Haddad  <ryanhaddad@apple.com>
    212
  • trunk/LayoutTests/imported/w3c/web-platform-tests/workers/interfaces.worker-expected.txt

    r235155 r235159  
    6969PASS DedicatedWorkerGlobalScope interface: existence and properties of interface prototype object's "constructor" property
    7070PASS DedicatedWorkerGlobalScope interface: existence and properties of interface prototype object's @@unscopables property
    71 FAIL DedicatedWorkerGlobalScope interface: attribute name assert_own_property: The global object must have a property "name" expected property "name" missing
     71PASS DedicatedWorkerGlobalScope interface: attribute name
    7272PASS Unscopable handled correctly for name property on DedicatedWorkerGlobalScope
    7373PASS DedicatedWorkerGlobalScope interface: operation postMessage(any, [object Object])
     
    8787PASS DedicatedWorkerGlobalScope must be primary interface of self
    8888PASS Stringification of self
    89 FAIL DedicatedWorkerGlobalScope interface: self must inherit property "name" with the proper type assert_own_property: expected property "name" missing
     89PASS DedicatedWorkerGlobalScope interface: self must inherit property "name" with the proper type
    9090PASS DedicatedWorkerGlobalScope interface: self must inherit property "postMessage(any, [object Object])" with the proper type
    9191PASS DedicatedWorkerGlobalScope interface: calling postMessage(any, [object Object]) on self with too few arguments must throw TypeError
  • trunk/LayoutTests/imported/w3c/web-platform-tests/workers/name-property-expected.txt

    r235155 r235159  
    22
    33FAIL Test the name property of shared and dedicated workers via the name constructor option ReferenceError: Can't find variable: SharedWorker
     4PASS name property value for DedicatedWorkerGlobalScope
     5PASS name property is replaceable for DedicatedWorkerGlobalScope
    46PASS Declaring name as an accidental global must not cause a harness error for DedicatedWorkerGlobalScope
    5 FAIL name property value for DedicatedWorkerGlobalScope assert_true: property exists on the global expected true got false
    6 PASS name property is replaceable for DedicatedWorkerGlobalScope
    77
  • trunk/Source/WebCore/ChangeLog

    r235158 r235159  
     12018-08-21  Yusuke Suzuki  <yusukesuzuki@slowstart.org>
     2
     3        Support "name" option for dedicated workers
     4        https://bugs.webkit.org/show_bug.cgi?id=188779
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        This patch adds `new Worker(url, { name: "Worker Name" })` option support[1].
     9        This name can be accessible from `self.name` of DedicatedWorkerGlobalScope.
     10        It is useful for debugging dedicated workers if the inspector can show the
     11        names of the workers. This enhancement is tracked by [2].
     12
     13        [1]: https://github.com/whatwg/html/issues/2477
     14        [2]: https://bugs.webkit.org/show_bug.cgi?id=164678
     15
     16        Tests: http/wpt/workers/name-property-enhanced.html
     17               http/wpt/workers/name-property-no-name.html
     18
     19        * workers/DedicatedWorkerGlobalScope.cpp:
     20        (WebCore::DedicatedWorkerGlobalScope::create):
     21        (WebCore::DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope):
     22        Hold `name` member.
     23
     24        * workers/DedicatedWorkerGlobalScope.h:
     25        * workers/DedicatedWorkerGlobalScope.idl:
     26        Add `name` attribute.
     27
     28        * workers/DedicatedWorkerThread.cpp:
     29        (WebCore::DedicatedWorkerThread::DedicatedWorkerThread):
     30        (WebCore::DedicatedWorkerThread::createWorkerGlobalScope):
     31        * workers/DedicatedWorkerThread.h:
     32        * workers/Worker.cpp:
     33        (WebCore::Worker::Worker):
     34        (WebCore::Worker::create):
     35        (WebCore::Worker::notifyFinished):
     36        * workers/Worker.h:
     37        * workers/Worker.idl:
     38        Add WorkerOptions for dedicated worker creation.
     39
     40        * workers/WorkerGlobalScopeProxy.h:
     41        * workers/WorkerMessagingProxy.cpp:
     42        (WebCore::WorkerMessagingProxy::startWorkerGlobalScope):
     43        * workers/WorkerMessagingProxy.h:
     44        * workers/WorkerThread.cpp:
     45        (WebCore::WorkerThreadStartupData::WorkerThreadStartupData):
     46        Isolate copy the given `name` to pass the worker thread.
     47
     48        (WebCore::WorkerThread::WorkerThread):
     49        (WebCore::WorkerThread::workerThread):
     50        * workers/WorkerThread.h:
     51        * workers/service/context/ServiceWorkerThread.cpp:
     52        (WebCore::ServiceWorkerThread::ServiceWorkerThread):
     53        (WebCore::ServiceWorkerThread::createWorkerGlobalScope):
     54        * workers/service/context/ServiceWorkerThread.h:
     55
    1562018-08-21  Ryosuke Niwa  <rniwa@webkit.org>
    257
  • trunk/Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp

    r235155 r235159  
    4242namespace WebCore {
    4343
    44 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)
     44Ref<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)
    4545{
    46     auto context = adoptRef(*new DedicatedWorkerGlobalScope(url, WTFMove(origin), identifier, userAgent, isOnline, thread, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, connectionProxy, socketProvider, sessionID));
     46    auto context = adoptRef(*new DedicatedWorkerGlobalScope(url, WTFMove(origin), name, identifier, userAgent, isOnline, thread, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, connectionProxy, socketProvider, sessionID));
    4747    if (!shouldBypassMainWorldContentSecurityPolicy)
    4848        context->applyContentSecurityPolicyResponseHeaders(contentSecurityPolicyResponseHeaders);
     
    5050}
    5151
    52 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)
     52DedicatedWorkerGlobalScope::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)
    5353    : WorkerGlobalScope(url, WTFMove(origin), identifier, userAgent, isOnline, thread, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, connectionProxy, socketProvider, sessionID)
     54    , m_name(name)
    5455{
    5556}
  • trunk/Source/WebCore/workers/DedicatedWorkerGlobalScope.h

    r235155 r235159  
    4949class DedicatedWorkerGlobalScope final : public WorkerGlobalScope {
    5050public:
    51     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);
     51    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);
    5252    virtual ~DedicatedWorkerGlobalScope();
     53
     54    const String& name() const { return m_name; }
    5355
    5456    ExceptionOr<void> postMessage(JSC::ExecState&, JSC::JSValue message, Vector<JSC::Strong<JSC::JSObject>>&&);
     
    5961    using Base = WorkerGlobalScope;
    6062
    61     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);
     63    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);
    6264
    6365    bool isDedicatedWorkerGlobalScope() const final { return true; }
    6466    ExceptionOr<void> importScripts(const Vector<String>& urls) final;
    6567    EventTargetInterface eventTargetInterface() const final;
     68
     69    String m_name;
    6670};
    6771
  • trunk/Source/WebCore/workers/DedicatedWorkerGlobalScope.idl

    r235155 r235159  
    3838    IsImmutablePrototypeExoticObjectOnPrototype,
    3939] interface DedicatedWorkerGlobalScope : WorkerGlobalScope {
     40    [Replaceable] readonly attribute DOMString name;
     41
    4042    [CallWith=ScriptState, MayThrowException] void postMessage(any message, optional sequence<object> transfer = []);
    4143
  • trunk/Source/WebCore/workers/DedicatedWorkerThread.cpp

    r235155 r235159  
    3939namespace WebCore {
    4040
    41 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)
    42     : WorkerThread(url, identifier, userAgent, isOnline, sourceCode, workerLoaderProxy, workerDebuggerProxy, workerObjectProxy, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, topOrigin, timeOrigin, connectionProxy, socketProvider, runtimeFlags, sessionID)
     41DedicatedWorkerThread::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)
     42    : WorkerThread(url, name, identifier, userAgent, isOnline, sourceCode, workerLoaderProxy, workerDebuggerProxy, workerObjectProxy, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, topOrigin, timeOrigin, connectionProxy, socketProvider, runtimeFlags, sessionID)
    4343    , m_workerObjectProxy(workerObjectProxy)
    4444{
     
    4747DedicatedWorkerThread::~DedicatedWorkerThread() = default;
    4848
    49 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)
     49Ref<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)
    5050{
    51     return DedicatedWorkerGlobalScope::create(url, WTFMove(origin), identifier, userAgent, isOnline, *this, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, idbConnectionProxy(), socketProvider(), sessionID);
     51    return DedicatedWorkerGlobalScope::create(url, WTFMove(origin), name, identifier, userAgent, isOnline, *this, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, idbConnectionProxy(), socketProvider(), sessionID);
    5252}
    5353
  • trunk/Source/WebCore/workers/DedicatedWorkerThread.h

    r235155 r235159  
    5050
    5151protected:
    52     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;
     52    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;
    5353    void runEventLoop() override;
    5454
    5555private:
    56     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);
     56    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);
    5757
    5858    WorkerObjectProxy& m_workerObjectProxy;
  • trunk/Source/WebCore/workers/Worker.cpp

    r235155 r235159  
    5858}
    5959
    60 inline Worker::Worker(ScriptExecutionContext& context, JSC::RuntimeFlags runtimeFlags)
     60inline Worker::Worker(ScriptExecutionContext& context, JSC::RuntimeFlags runtimeFlags, const Options& options)
    6161    : ActiveDOMObject(&context)
     62    , m_name(options.name)
    6263    , m_identifier("worker:" + Inspector::IdentifiersFactory::createIdentifier())
    6364    , m_contextProxy(WorkerGlobalScopeProxy::create(*this))
     
    7475}
    7576
    76 ExceptionOr<Ref<Worker>> Worker::create(ScriptExecutionContext& context, JSC::RuntimeFlags runtimeFlags, const String& url)
     77ExceptionOr<Ref<Worker>> Worker::create(ScriptExecutionContext& context, JSC::RuntimeFlags runtimeFlags, const String& url, const Options& options)
    7778{
    7879    ASSERT(isMainThread());
     
    8182    ASSERT_WITH_SECURITY_IMPLICATION(context.isDocument());
    8283
    83     auto worker = adoptRef(*new Worker(context, runtimeFlags));
     84    auto worker = adoptRef(*new Worker(context, runtimeFlags, options));
    8485
    8586    worker->suspendIfNeeded();
     
    104105    request.setInitiatorIdentifier(worker->m_identifier);
    105106
    106     FetchOptions options;
    107     options.mode = FetchOptions::Mode::SameOrigin;
    108     options.cache = FetchOptions::Cache::Default;
    109     options.redirect = FetchOptions::Redirect::Follow;
    110     options.destination = FetchOptions::Destination::Worker;
    111     worker->m_scriptLoader->loadAsynchronously(context, WTFMove(request), WTFMove(options), contentSecurityPolicyEnforcement, ServiceWorkersMode::All, worker);
     107    FetchOptions fetchOptions;
     108    fetchOptions.mode = FetchOptions::Mode::SameOrigin;
     109    fetchOptions.cache = FetchOptions::Cache::Default;
     110    fetchOptions.redirect = FetchOptions::Redirect::Follow;
     111    fetchOptions.destination = FetchOptions::Destination::Worker;
     112    worker->m_scriptLoader->loadAsynchronously(context, WTFMove(request), WTFMove(fetchOptions), contentSecurityPolicyEnforcement, ServiceWorkersMode::All, worker);
    112113    return WTFMove(worker);
    113114}
     
    186187        bool isOnline = platformStrategies()->loaderStrategy()->isOnLine();
    187188        const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders = m_contentSecurityPolicyResponseHeaders ? m_contentSecurityPolicyResponseHeaders.value() : scriptExecutionContext()->contentSecurityPolicy()->responseHeaders();
    188         m_contextProxy.startWorkerGlobalScope(m_scriptLoader->url(), scriptExecutionContext()->userAgent(m_scriptLoader->url()), isOnline, m_scriptLoader->script(), contentSecurityPolicyResponseHeaders, m_shouldBypassMainWorldContentSecurityPolicy, m_workerCreationTime, m_runtimeFlags, sessionID);
     189        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);
    189190        InspectorInstrumentation::scriptImported(*scriptExecutionContext(), m_scriptLoader->identifier(), m_scriptLoader->script());
    190191    }
  • trunk/Source/WebCore/workers/Worker.h

    r235155 r235159  
    5151class Worker final : public AbstractWorker, public ActiveDOMObject, private WorkerScriptLoaderClient {
    5252public:
    53     static ExceptionOr<Ref<Worker>> create(ScriptExecutionContext&, JSC::RuntimeFlags, const String& url);
     53    struct Options {
     54        String name;
     55    };
     56    static ExceptionOr<Ref<Worker>> create(ScriptExecutionContext&, JSC::RuntimeFlags, const String& url, const Options&);
    5457    virtual ~Worker();
    5558
     
    6568
    6669private:
    67     explicit Worker(ScriptExecutionContext&, JSC::RuntimeFlags);
     70    explicit Worker(ScriptExecutionContext&, JSC::RuntimeFlags, const Options&);
    6871
    6972    EventTargetInterface eventTargetInterface() const final { return WorkerEventTargetInterfaceType; }
     
    8184
    8285    RefPtr<WorkerScriptLoader> m_scriptLoader;
     86    String m_name;
    8387    String m_identifier;
    8488    WorkerGlobalScopeProxy& m_contextProxy; // The proxy outlives the worker to perform thread shutdown.
  • trunk/Source/WebCore/workers/Worker.idl

    r235155 r235159  
    2727[
    2828    ActiveDOMObject,
    29     Constructor(USVString scriptUrl),
     29    Constructor(USVString scriptUrl, optional WorkerOptions options),
    3030    ConstructorCallWith=ScriptExecutionContext&RuntimeFlags,
    3131    ConstructorMayThrowException
     
    3737};
    3838
     39dictionary WorkerOptions {
     40    DOMString name = "";
     41};
     42
    3943Worker implements AbstractWorker;
  • trunk/Source/WebCore/workers/WorkerGlobalScopeProxy.h

    r235155 r235159  
    5151    static WorkerGlobalScopeProxy& create(Worker&);
    5252
    53     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;
     53    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;
    5454    virtual void terminateWorkerGlobalScope() = 0;
    5555    virtual void postMessageToWorkerGlobalScope(MessageWithMessagePorts&&) = 0;
  • trunk/Source/WebCore/workers/WorkerMessagingProxy.cpp

    r235155 r235159  
    7373}
    7474
    75 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)
     75void 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)
    7676{
    7777    // FIXME: This need to be revisited when we support nested worker one day
     
    8989    SocketProvider* socketProvider = document.socketProvider();
    9090
    91     auto thread = DedicatedWorkerThread::create(scriptURL, identifier, userAgent, isOnline, sourceCode, *this, *this, *this, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, document.topOrigin(), timeOrigin, proxy, socketProvider, runtimeFlags, sessionID);
     91    auto thread = DedicatedWorkerThread::create(scriptURL, name, identifier, userAgent, isOnline, sourceCode, *this, *this, *this, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, document.topOrigin(), timeOrigin, proxy, socketProvider, runtimeFlags, sessionID);
    9292
    9393    workerThreadCreated(thread.get());
  • trunk/Source/WebCore/workers/WorkerMessagingProxy.h

    r235155 r235159  
    4747    // Implementations of WorkerGlobalScopeProxy.
    4848    // (Only use these functions in the worker object thread.)
    49     void startWorkerGlobalScope(const URL& scriptURL, const String& userAgent, bool isOnline, const String& sourceCode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, MonotonicTime timeOrigin, JSC::RuntimeFlags, PAL::SessionID) final;
     49    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;
    5050    void terminateWorkerGlobalScope() final;
    5151    void postMessageToWorkerGlobalScope(MessageWithMessagePorts&&) final;
  • trunk/Source/WebCore/workers/WorkerThread.cpp

    r235155 r235159  
    7373    WTF_MAKE_NONCOPYABLE(WorkerThreadStartupData); WTF_MAKE_FAST_ALLOCATED;
    7474public:
    75     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);
     75    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);
    7676
    7777    URL m_scriptURL;
    7878    Ref<SecurityOrigin> m_origin;
     79    String m_name;
    7980    String m_identifier;
    8081    String m_userAgent;
     
    8990};
    9091
    91 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)
     92WorkerThreadStartupData::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)
    9293    : m_scriptURL(scriptURL.isolatedCopy())
    9394    , m_origin(SecurityOrigin::create(m_scriptURL)->isolatedCopy())
     95    , m_name(name.isolatedCopy())
    9496    , m_identifier(identifier.isolatedCopy())
    9597    , m_userAgent(userAgent.isolatedCopy())
     
    105107}
    106108
    107 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)
     109WorkerThread::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)
    108110    : m_workerLoaderProxy(workerLoaderProxy)
    109111    , m_workerDebuggerProxy(workerDebuggerProxy)
    110112    , m_workerReportingProxy(workerReportingProxy)
    111113    , m_runtimeFlags(runtimeFlags)
    112     , m_startupData(std::make_unique<WorkerThreadStartupData>(scriptURL, identifier, userAgent, isOnline, sourceCode, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, topOrigin, timeOrigin, sessionID))
     114    , m_startupData(std::make_unique<WorkerThreadStartupData>(scriptURL, name, identifier, userAgent, isOnline, sourceCode, startMode, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, topOrigin, timeOrigin, sessionID))
    113115#if ENABLE(INDEXED_DATABASE)
    114116    , m_idbConnectionProxy(connectionProxy)
     
    168170        // be called before we've finished creating the WorkerGlobalScope.
    169171        LockHolder lock(m_threadCreationAndWorkerGlobalScopeMutex);
    170         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);
     172        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);
    171173
    172174        scriptController = m_workerGlobalScope->script();
  • trunk/Source/WebCore/workers/WorkerThread.h

    r235155 r235159  
    8888
    8989protected:
    90     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);
     90    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);
    9191
    9292    // Factory method for creating a new worker context for the thread.
    93     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;
     93    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;
    9494
    9595    // Executes the event loop for the worker thread. Derived classes can override to perform actions before/after entering the event loop.
  • trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp

    r235155 r235159  
    7373
    7474ServiceWorkerThread::ServiceWorkerThread(const ServiceWorkerContextData& data, PAL::SessionID, String&& userAgent, WorkerLoaderProxy& loaderProxy, WorkerDebuggerProxy& debuggerProxy, IDBClient::IDBConnectionProxy* idbConnectionProxy, SocketProvider* socketProvider)
    75     : 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)
     75    : 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)
    7676    , m_data(data.isolatedCopy())
    7777    , m_workerObjectProxy(DummyServiceWorkerThreadProxy::shared())
     
    8282ServiceWorkerThread::~ServiceWorkerThread() = default;
    8383
    84 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)
     84Ref<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)
    8585{
     86    UNUSED_PARAM(name);
    8687    return ServiceWorkerGlobalScope::create(m_data, url, WTFMove(origin), identifier, userAgent, isOnline, *this, contentSecurityPolicy, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, idbConnectionProxy(), socketProvider(), sessionID);
    8788}
  • trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.h

    r235155 r235159  
    6767
    6868protected:
    69     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;
     69    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;
    7070    void runEventLoop() override;
    7171
Note: See TracChangeset for help on using the changeset viewer.