⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 268872 in webkit


Ignore:
Timestamp:
Oct 22, 2020, 11:06:44 AM (6 years ago)
Author:
youenn@apple.com
Message:

Introduce worklet destinations and allow to fetch modules with CORS based on destination
https://bugs.webkit.org/show_bug.cgi?id=218019
<rdar://problem/70526201>

Reviewed by Chris Dumez.

Source/WebCore:

Add support for audioworklet and paintworklet fetch destinations.
In case of those destinations, use cors mode instead of same-origin mode when fetching worklet top level module.

Test: http/wpt/webaudio/audioworklet-addModule-cors.sub.https.html

  • Modules/fetch/FetchRequest.idl:
  • loader/FetchOptions.h:

(WebCore::isScriptLikeDestination):

  • workers/WorkerScriptLoader.cpp:

(WebCore::WorkerScriptLoader::loadAsynchronously):

  • worklets/WorkletGlobalScope.cpp:

(WebCore::WorkletGlobalScope::processNextScriptFetchJobIfNeeded):

Source/WebKit:

Add support to new fetch destinations in enumerations.

  • NetworkProcess/NetworkLoadChecker.cpp:

(WebKit::NetworkLoadChecker::isAllowedByContentSecurityPolicy):

  • NetworkProcess/NetworkResourceLoader.cpp:

(WebKit::NetworkResourceLoader::resourceLoadInfo):

LayoutTests:

  • http/wpt/webaudio/audioworklet-addModule-cors.sub.https-expected.txt: Added.
  • http/wpt/webaudio/audioworklet-addModule-cors.sub.https.html: Added.
  • http/wpt/webaudio/resources/dummy-worklet.py: Added.

(main):
(DummyProcessor):

Location:
trunk
Files:
3 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r268866 r268872  
     12020-10-22  Youenn Fablet  <youenn@apple.com>
     2
     3        Introduce worklet destinations and allow to fetch modules with CORS based on destination
     4        https://bugs.webkit.org/show_bug.cgi?id=218019
     5        <rdar://problem/70526201>
     6
     7        Reviewed by Chris Dumez.
     8
     9        * http/wpt/webaudio/audioworklet-addModule-cors.sub.https-expected.txt: Added.
     10        * http/wpt/webaudio/audioworklet-addModule-cors.sub.https.html: Added.
     11        * http/wpt/webaudio/resources/dummy-worklet.py: Added.
     12        (main):
     13        (DummyProcessor):
     14
    1152020-10-22  Aditya Keerthi  <akeerthi@apple.com>
    216
  • trunk/Source/WebCore/ChangeLog

    r268869 r268872  
     12020-10-22  Youenn Fablet  <youenn@apple.com>
     2
     3        Introduce worklet destinations and allow to fetch modules with CORS based on destination
     4        https://bugs.webkit.org/show_bug.cgi?id=218019
     5        <rdar://problem/70526201>
     6
     7        Reviewed by Chris Dumez.
     8
     9        Add support for audioworklet and paintworklet fetch destinations.
     10        In case of those destinations, use cors mode instead of same-origin mode when fetching worklet top level module.
     11
     12        Test: http/wpt/webaudio/audioworklet-addModule-cors.sub.https.html
     13
     14        * Modules/fetch/FetchRequest.idl:
     15        * loader/FetchOptions.h:
     16        (WebCore::isScriptLikeDestination):
     17        * workers/WorkerScriptLoader.cpp:
     18        (WebCore::WorkerScriptLoader::loadAsynchronously):
     19        * worklets/WorkletGlobalScope.cpp:
     20        (WebCore::WorkletGlobalScope::processNextScriptFetchJobIfNeeded):
     21
    1222020-10-22  Don Olmstead  <don.olmstead@sony.com>
    223
  • trunk/Source/WebCore/Modules/fetch/FetchRequest.idl

    r267953 r268872  
    2727 */
    2828
    29 enum FetchRequestDestination { "", "audio", "document", "embed", "font", "image", "manifest", "object", "report", "script", "serviceworker", "sharedworker", "style", "track", "video", "worker", "xslt" };
     29enum FetchRequestDestination { "", "audio", "audioworklet", "document", "embed", "font", "image", "manifest", "object", "paintworklet", "report", "script", "serviceworker", "sharedworker", "style", "track", "video", "worker", "xslt" };
    3030
    3131typedef (FetchRequest or USVString) RequestInfo;
  • trunk/Source/WebCore/loader/FetchOptions.h

    r260078 r268872  
    3737
    3838struct FetchOptions {
    39     enum class Destination : uint8_t { EmptyString, Audio, Document, Embed, Font, Image, Manifest, Object, Report, Script, Serviceworker, Sharedworker, Style, Track, Video, Worker, Xslt };
     39    enum class Destination : uint8_t { EmptyString, Audio, Audioworklet, Document, Embed, Font, Image, Manifest, Object, Paintworklet, Report, Script, Serviceworker, Sharedworker, Style, Track, Video, Worker, Xslt };
    4040    enum class Mode : uint8_t { Navigate, SameOrigin, NoCors, Cors };
    4141    enum class Credentials : uint8_t { Omit, SameOrigin, Include };
     
    9292inline bool isScriptLikeDestination(FetchOptions::Destination destination)
    9393{
    94     return destination == FetchOptions::Destination::Script
     94    return destination == FetchOptions::Destination::Audioworklet
     95        || destination == FetchOptions::Destination::Paintworklet
     96        || destination == FetchOptions::Destination::Script
    9597        || destination == FetchOptions::Destination::Serviceworker
    9698        || destination == FetchOptions::Destination::Worker;
     
    106108        WebCore::FetchOptions::Destination::EmptyString,
    107109        WebCore::FetchOptions::Destination::Audio,
     110        WebCore::FetchOptions::Destination::Audioworklet,
    108111        WebCore::FetchOptions::Destination::Document,
    109112        WebCore::FetchOptions::Destination::Embed,
     
    112115        WebCore::FetchOptions::Destination::Manifest,
    113116        WebCore::FetchOptions::Destination::Object,
     117        WebCore::FetchOptions::Destination::Paintworklet,
    114118        WebCore::FetchOptions::Destination::Report,
    115119        WebCore::FetchOptions::Destination::Script,
  • trunk/Source/WebCore/workers/WorkerScriptLoader.cpp

    r264724 r268872  
    120120        return;
    121121
    122     // Only used for loading worker scripts in classic mode.
     122    // https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-single-module-script
     123    ASSERT(fetchOptions.mode == FetchOptions::Mode::SameOrigin || (fetchOptions.destination != FetchOptions::Destination::Serviceworker && fetchOptions.destination != FetchOptions::Destination::Worker));
     124
     125    ThreadableLoaderOptions options { WTFMove(fetchOptions) };
    123126    // FIXME: We should add an option to set credential mode.
    124     ASSERT(fetchOptions.mode == FetchOptions::Mode::SameOrigin);
    125 
    126     ThreadableLoaderOptions options { WTFMove(fetchOptions) };
    127127    options.credentials = FetchOptions::Credentials::SameOrigin;
    128128    options.sendLoadCallbacks = SendCallbackPolicy::SendCallbacks;
  • trunk/Source/WebCore/worklets/WorkletGlobalScope.cpp

    r268822 r268872  
    172172
    173173    FetchOptions fetchOptions;
    174     fetchOptions.mode = FetchOptions::Mode::SameOrigin;
     174    fetchOptions.mode = FetchOptions::Mode::Cors;
    175175    fetchOptions.cache = FetchOptions::Cache::Default;
    176176    fetchOptions.redirect = FetchOptions::Redirect::Follow;
    177     fetchOptions.destination = FetchOptions::Destination::Worker;
    178177    fetchOptions.credentials = scriptFetchJob.credentials;
     178#if ENABLE(WEB_AUDIO)
     179    if (isAudioWorkletGlobalScope())
     180        fetchOptions.destination = FetchOptions::Destination::Audioworklet;
     181#endif
     182#if ENABLE(CSS_PAINTING_API)
     183    if (isPaintWorkletGlobalScope())
     184        fetchOptions.destination = FetchOptions::Destination::Paintworklet;
     185#endif
    179186
    180187    auto contentSecurityPolicyEnforcement = shouldBypassMainWorldContentSecurityPolicy() ? ContentSecurityPolicyEnforcement::DoNotEnforce : ContentSecurityPolicyEnforcement::EnforceChildSrcDirective;
  • trunk/Source/WebKit/ChangeLog

    r268867 r268872  
     12020-10-22  Youenn Fablet  <youenn@apple.com>
     2
     3        Introduce worklet destinations and allow to fetch modules with CORS based on destination
     4        https://bugs.webkit.org/show_bug.cgi?id=218019
     5        <rdar://problem/70526201>
     6
     7        Reviewed by Chris Dumez.
     8
     9        Add support to new fetch destinations in enumerations.
     10
     11        * NetworkProcess/NetworkLoadChecker.cpp:
     12        (WebKit::NetworkLoadChecker::isAllowedByContentSecurityPolicy):
     13        * NetworkProcess/NetworkResourceLoader.cpp:
     14        (WebKit::NetworkResourceLoader::resourceLoadInfo):
     15
    1162020-10-22  Nitzan Uziely  <linkgoron@gmail.com>
    217
  • trunk/Source/WebKit/NetworkProcess/NetworkLoadChecker.cpp

    r260707 r268872  
    309309    auto redirectResponseReceived = isRedirected() ? ContentSecurityPolicy::RedirectResponseReceived::Yes : ContentSecurityPolicy::RedirectResponseReceived::No;
    310310    switch (m_options.destination) {
     311    case FetchOptions::Destination::Audioworklet:
     312    case FetchOptions::Destination::Paintworklet:
    311313    case FetchOptions::Destination::Worker:
    312314    case FetchOptions::Destination::Serviceworker:
  • trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp

    r268017 r268872  
    381381        case WebCore::FetchOptions::Destination::Audio:
    382382            return ResourceLoadInfo::Type::Media;
     383        case WebCore::FetchOptions::Destination::Audioworklet:
     384            return ResourceLoadInfo::Type::Other;
    383385        case WebCore::FetchOptions::Destination::Document:
    384386            return ResourceLoadInfo::Type::Document;
     
    393395        case WebCore::FetchOptions::Destination::Object:
    394396            return ResourceLoadInfo::Type::Object;
     397        case WebCore::FetchOptions::Destination::Paintworklet:
     398            return ResourceLoadInfo::Type::Other;
    395399        case WebCore::FetchOptions::Destination::Report:
    396400            return ResourceLoadInfo::Type::CSPReport;
Note: See TracChangeset for help on using the changeset viewer.