Changeset 280953 in webkit


Ignore:
Timestamp:
Aug 11, 2021 7:43:53 PM (11 months ago)
Author:
Chris Dumez
Message:

Add initial support for Cross-Origin-Embedder-Policy (COEP)
https://bugs.webkit.org/show_bug.cgi?id=228754

Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

Rebaseline COEP WPT tests now that we are passing more checks.

  • web-platform-tests/html/cross-origin-embedder-policy/blob.https-expected.txt:
  • web-platform-tests/html/cross-origin-embedder-policy/coep-frame-javascript.https-expected.txt:
  • web-platform-tests/html/cross-origin-embedder-policy/coep-on-response-from-service-worker.https-expected.txt:
  • web-platform-tests/html/cross-origin-embedder-policy/credentialless/iframe-coep-require-corp.tentative.https-expected.txt:
  • web-platform-tests/html/cross-origin-embedder-policy/cross-origin-isolated-permission.https-expected.txt:
  • web-platform-tests/html/cross-origin-embedder-policy/data.https-expected.txt:
  • web-platform-tests/html/cross-origin-embedder-policy/dedicated-worker-cache-storage.https-expected.txt:
  • web-platform-tests/html/cross-origin-embedder-policy/dedicated-worker.https-expected.txt:
  • web-platform-tests/html/cross-origin-embedder-policy/header-parsing.https-expected.txt:
  • web-platform-tests/html/cross-origin-embedder-policy/javascript.https-expected.txt:
  • web-platform-tests/html/cross-origin-embedder-policy/multi-globals/workers-coep-report.https-expected.txt:
  • web-platform-tests/html/cross-origin-embedder-policy/no-secure-context-expected.txt:
  • web-platform-tests/html/cross-origin-embedder-policy/none-sw-from-require-corp.https-expected.txt:
  • web-platform-tests/html/cross-origin-embedder-policy/none.https-expected.txt:
  • web-platform-tests/html/cross-origin-embedder-policy/reporting-to-endpoint.https-expected.txt:
  • web-platform-tests/html/cross-origin-embedder-policy/require-corp-about-blank-expected.txt: Removed.
  • web-platform-tests/html/cross-origin-embedder-policy/require-corp-about-blank.https-expected.txt:
  • web-platform-tests/html/cross-origin-embedder-policy/require-corp-about-srcdoc-expected.txt: Removed.
  • web-platform-tests/html/cross-origin-embedder-policy/require-corp-about-srcdoc.https-expected.txt:
  • web-platform-tests/html/cross-origin-embedder-policy/require-corp-load-from-cache-storage.https-expected.txt:
  • web-platform-tests/html/cross-origin-embedder-policy/require-corp-sw-from-none.https-expected.txt:
  • web-platform-tests/html/cross-origin-embedder-policy/require-corp-sw-from-require-corp.https-expected.txt:
  • web-platform-tests/html/cross-origin-embedder-policy/require-corp-sw.https-expected.txt:
  • web-platform-tests/html/cross-origin-embedder-policy/require-corp.https-expected.txt:
  • web-platform-tests/html/cross-origin-embedder-policy/sandbox.https-expected.txt:
  • web-platform-tests/html/cross-origin-embedder-policy/service-worker-cache-storage.https-expected.txt:
  • web-platform-tests/html/cross-origin-embedder-policy/srcdoc.https-expected.txt:

Source/WebCore:

Add initial support for Cross-Origin-Embedder-Policy (COEP) behind a runtime feature flag, off by default:

The COEP header has the following impacts:

  • When a document with Cross-Origin-Embedder-Policy: require-corp loads an iframe or a worker script, if the network response for that iframe doesn't also contain Cross-Origin-Embedder-Policy: require-corp, then we fail the load.
  • When a document with Cross-Origin-Embedder-Policy: require-corp loads cross-origin subresources, then either CORS must be used or the resource response must be allowed by Cross-Origin-Resource-Policy (CORP) header.

Support is only for WK2 and checks are done in the network process for better security. Support for workers and service
workers (including cache storage) is included.

Most of the Web-Platform-Tests for COEP are passing with this patch. The exceptions are:

  • Some tests relying on Blob are failing. Similarly to COOP, Blobs need to inherit COEP from their creator. This is currently unimplemented as the change will likely be non-trivial. I will follow-up to fix Blob support for both COOP and COEP.
  • Tests in the credentialless/ folder are failing because we do not support Cross-Origin-Embedder-Policy: credentialless. This seems to be a fairly recent extension proposed by Google and it is not part of the HTML specification yet.
  • Some tests expect violation reporting and they are failing and we do not implement reporting yet.

Note that self.crossOriginIsolated still returns false, even if the pages opts into both COOP & COEP, and APIs such
as SharedArrayBuffer still are not permitted to use. In order to support this, we will have to actually implement process
swapping so that we know a process is not actually shared by several origins.

Test: http/wpt/html/cross-origin-embedder-policy/require-corp.https.html

  • Modules/cache/DOMCache.cpp:

(WebCore::DOMCache::queryCache):

  • Modules/cache/DOMCacheEngine.cpp:

(WebCore::DOMCacheEngine::convertToException):

  • Modules/cache/DOMCacheEngine.h:
  • Modules/cache/RetrieveRecordsOptions.h:

(WebCore::RetrieveRecordsOptions::isolatedCopy const):
(WebCore::RetrieveRecordsOptions::encode const):
(WebCore::RetrieveRecordsOptions::decode):

  • dom/Document.cpp:

(WebCore::Document::initSecurityContext):

  • dom/SecurityContext.h:

(WebCore::SecurityContext::crossOriginEmbedderPolicy const):
(WebCore::SecurityContext::setCrossOriginEmbedderPolicy):

  • loader/CrossOriginAccessControl.cpp:

(WebCore::shouldCrossOriginResourcePolicyCancelLoad):
(WebCore::validateCrossOriginResourcePolicy):

  • loader/CrossOriginAccessControl.h:
  • loader/CrossOriginEmbedderPolicy.cpp:

(WebCore::obtainCrossOriginEmbedderPolicy):
(WebCore::CrossOriginEmbedderPolicy::isolatedCopy const):

  • loader/CrossOriginEmbedderPolicy.h:

(WebCore::CrossOriginEmbedderPolicy::encode const):
(WebCore::CrossOriginEmbedderPolicy::decode):

  • loader/CrossOriginOpenerPolicy.cpp:

(WebCore::obtainCrossOriginOpenerPolicy):

  • loader/DocumentThreadableLoader.cpp:

(WebCore::DocumentThreadableLoader::loadResourceSynchronously):
(WebCore::DocumentThreadableLoader::create):
(WebCore::DocumentThreadableLoader::DocumentThreadableLoader):
(WebCore::DocumentThreadableLoader::crossOriginEmbedderPolicy const):

  • loader/DocumentThreadableLoader.h:
  • loader/DocumentWriter.cpp:

(WebCore::DocumentWriter::begin):

  • loader/FrameLoader.cpp:

(WebCore::FrameLoader::didBeginDocument):

  • loader/ResourceLoaderOptions.h:
  • loader/WorkerThreadableLoader.cpp:

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

  • loader/cache/CachedResourceLoader.cpp:

(WebCore::CachedResourceLoader::requestResource):

  • page/SecurityOrigin.h:
  • platform/network/HTTPParsers.cpp:

(WebCore::parseCrossOriginResourcePolicyHeader):

  • platform/network/HTTPParsers.h:
  • workers/Worker.cpp:

(WebCore::Worker::notifyFinished):

  • workers/WorkerGlobalScope.cpp:

(WebCore::WorkerGlobalScope::WorkerGlobalScope):

  • workers/WorkerGlobalScopeProxy.h:
  • workers/WorkerMessagingProxy.cpp:

(WebCore::WorkerMessagingProxy::startWorkerGlobalScope):

  • workers/WorkerMessagingProxy.h:
  • workers/WorkerScriptLoader.cpp:

(WebCore::WorkerScriptLoader::loadSynchronously):
(WebCore::WorkerScriptLoader::loadAsynchronously):
(WebCore::WorkerScriptLoader::didReceiveResponse):

  • workers/WorkerScriptLoader.h:

(WebCore::WorkerScriptLoader::crossOriginEmbedderPolicy const):

  • workers/WorkerThread.cpp:

(WebCore::WorkerParameters::isolatedCopy const):

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

(WebCore::ServiceWorkerContainer::jobFinishedLoadingScript):

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

(WebCore::ServiceWorkerContextData::isolatedCopy const):

  • workers/service/ServiceWorkerContextData.h:

(WebCore::ServiceWorkerContextData::encode const):
(WebCore::ServiceWorkerContextData::decode):

  • workers/service/ServiceWorkerFetchResult.h:

(WebCore::ServiceWorkerFetchResult::isolatedCopy const):
(WebCore::serviceWorkerFetchError):
(WebCore::ServiceWorkerFetchResult::encode const):
(WebCore::ServiceWorkerFetchResult::decode):

  • workers/service/ServiceWorkerJob.cpp:

(WebCore::ServiceWorkerJob::notifyFinished):

  • workers/service/ServiceWorkerJobClient.h:
  • workers/service/context/ServiceWorkerThread.cpp:

(WebCore::ServiceWorkerThread::ServiceWorkerThread):

  • workers/service/server/RegistrationDatabase.cpp:

(WebCore::RegistrationDatabase::doPushChanges):
(WebCore::RegistrationDatabase::importRecords):

  • workers/service/server/SWServer.cpp:

(WebCore::SWServer::addRegistrationFromStore):
(WebCore::SWServer::updateWorker):
(WebCore::SWServer::installContextData):

  • workers/service/server/SWServer.h:
  • workers/service/server/SWServerJobQueue.cpp:

(WebCore::SWServerJobQueue::scriptFetchFinished):

  • workers/service/server/SWServerWorker.cpp:

(WebCore::SWServerWorker::SWServerWorker):
(WebCore::SWServerWorker::contextData const):

  • workers/service/server/SWServerWorker.h:

Source/WebKit:

As mentioned in the WebCore changelog, we do all the COEP checks in the network process
instead of WebCore for added security. As a result, we need to pass more information
to the network process when doing loads in order to do those checks. The checks are done
in NetworkResourceLoader for navigations & worker script loads (similarly to CSP,
X-FrameOptions) and in NetworkLoadChecker for CORP checks of subresource loads (similarly
to CORS checks).

  • NetworkProcess/NetworkLoadChecker.cpp:

(WebKit::NetworkLoadChecker::NetworkLoadChecker):
(WebKit::NetworkLoadChecker::validateResponse):

  • NetworkProcess/NetworkLoadChecker.h:

(WebKit::NetworkLoadChecker::setParentCrossOriginEmbedderPolicy):
(WebKit::NetworkLoadChecker::setCrossOriginEmbedderPolicy):

  • NetworkProcess/NetworkResourceLoadParameters.cpp:

(WebKit::NetworkResourceLoadParameters::parentOrigin const):
(WebKit::NetworkResourceLoadParameters::encode const):
(WebKit::NetworkResourceLoadParameters::decode):

  • NetworkProcess/NetworkResourceLoadParameters.h:
  • NetworkProcess/NetworkResourceLoader.cpp:

(WebKit::NetworkResourceLoader::shouldInterruptLoadForCSPFrameAncestorsOrXFrameOptions):
(WebKit::NetworkResourceLoader::shouldInterruptNavigationForCrossOriginEmbedderPolicy):
(WebKit::NetworkResourceLoader::shouldInterruptWorkerLoadForCrossOriginEmbedderPolicy):
(WebKit::NetworkResourceLoader::didReceiveResponse):
(WebKit::NetworkResourceLoader::willSendRedirectedRequest):

  • NetworkProcess/NetworkResourceLoader.h:
  • NetworkProcess/PingLoad.cpp:

(WebKit::PingLoad::PingLoad):
(WebKit::PingLoad::initialize):

  • NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp:

(WebKit::ServiceWorkerFetchTask::didReceiveResponse):

  • NetworkProcess/ServiceWorker/ServiceWorkerSoftUpdateLoader.cpp:

(WebKit::ServiceWorkerSoftUpdateLoader::processResponse):
(WebKit::ServiceWorkerSoftUpdateLoader::didFinishLoading):

  • NetworkProcess/ServiceWorker/ServiceWorkerSoftUpdateLoader.h:
  • NetworkProcess/cache/CacheStorageEngineCache.cpp:

(WebKit::CacheStorage::Cache::retrieveRecords):

  • WebProcess/Network/WebLoaderStrategy.cpp:

(WebKit::addParametersShared):
(WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess):

Source/WTF:

Add experimental feature flag for Cross-Origin-Embedder-Policy (COEP), off by default.

  • Scripts/Preferences/WebPreferencesExperimental.yaml:

LayoutTests:

Update test expectations now that we support COEP on WK2.

  • TestExpectations:
  • http/wpt/html/cross-origin-embedder-policy/require-corp.https-expected.txt: Added.
  • http/wpt/html/cross-origin-embedder-policy/require-corp.https.html: Added.
  • http/wpt/html/cross-origin-embedder-policy/require-corp.https.html.headers: Added.
  • platform/mac-wk1/TestExpectations:
  • platform/win/TestExpectations:
Location:
trunk
Files:
4 added
2 deleted
91 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r280948 r280953  
     12021-08-11  Chris Dumez  <cdumez@apple.com>
     2
     3        Add initial support for Cross-Origin-Embedder-Policy (COEP)
     4        https://bugs.webkit.org/show_bug.cgi?id=228754
     5
     6        Reviewed by Alex Christensen.
     7
     8        Update test expectations now that we support COEP on WK2.
     9
     10        * TestExpectations:
     11        * http/wpt/html/cross-origin-embedder-policy/require-corp.https-expected.txt: Added.
     12        * http/wpt/html/cross-origin-embedder-policy/require-corp.https.html: Added.
     13        * http/wpt/html/cross-origin-embedder-policy/require-corp.https.html.headers: Added.
     14        * platform/mac-wk1/TestExpectations:
     15        * platform/win/TestExpectations:
     16
    1172021-08-11  Jean-Yves Avenard  <jya@apple.com>
    218
  • trunk/LayoutTests/TestExpectations

    r280928 r280953  
    395395
    396396# Console log lines may appear in a different order so we silence them.
     397http/wpt/html/cross-origin-embedder-policy/require-corp.https.html [ DumpJSConsoleLogInStdErr ]
    397398imported/w3c/web-platform-tests/eventsource/format-utf-8.htm [ DumpJSConsoleLogInStdErr ]
    398399imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/location-protocol-setter-non-broken.html [ DumpJSConsoleLogInStdErr Failure Pass ]
     
    530531imported/w3c/web-platform-tests/html/browsers/sandboxing/window-open-blank-from-different-initiator.html [ Skip ]
    531532imported/w3c/web-platform-tests/html/browsers/the-window-object/navigate-to-about-blank-while-initial-load-pending.html [ Skip ]
    532 imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/cache-storage-reporting-service-worker.https.html [ Skip ]
    533 imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/credentialless/shared-worker.tentative.https.html [ Skip ]
    534 imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/dedicated-worker.https.html [ Skip ]
    535 imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/none.https.html [ Skip ]
    536 imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/reporting-to-frame-owner.https.html [ Skip ]
    537533imported/w3c/web-platform-tests/html/infrastructure/urls/resolving-urls/query-encoding/windows-1251.html [ Skip ]
    538534imported/w3c/web-platform-tests/html/infrastructure/urls/resolving-urls/query-encoding/windows-1252.html [ Skip ]
     
    717713imported/w3c/web-platform-tests/html/cross-origin-opener-policy/reporting [ Skip ]
    718714
    719 # This test is timing out locally but passing on wpt.live. The issue is that we run the WPT tests over localhost and they
    720 # are thus marked as secure contexts even when served over HTTP. The test assumes the context is non-secure because the
    721 # test is served over HTTP.
     715# Cross-Origin-Embedder-Policy: credentialless is not supported.
     716imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/credentialless
     717
     718# These tests are timing out locally but passing on wpt.live. The issue is that we run the WPT tests over localhost and they
     719# are thus marked as secure contexts even when served over HTTP. These tests assume the context is non-secure because they
     720# are served over HTTP.
    722721imported/w3c/web-platform-tests/html/cross-origin-opener-policy/no-https.html [ Skip ]
     722imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/no-secure-context.html [ Skip ]
     723
     724# COEP test timing out due to lack of Blob URL support.
     725imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/blob.https.html [ Skip ]
     726imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/cross-origin-isolated-permission.https.html [ Skip ]
     727imported/w3c/web-platform-tests/html/cross-origin-opener-policy/coep-blob-popup.https.html [ Skip ]
     728
     729# This test makes the assumption that get_host_info().REMOTE_ORIGIN is same-site, which is not true for
     730# our layout tests. We maintain our own version of this test in http/wpt.
     731imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/require-corp.https.html [ Skip ]
     732
     733# We do not support COEP reporting.
     734imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/reporting-to-endpoint.https.html [ Failure Pass ]
     735imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/multi-globals/workers-coep-report.https.html [ Skip ]
    723736
    724737# Newly imported WPT tests that are crashing.
     
    775788imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/checkpoint-after-window-onerror-module.html [ Failure Pass ]
    776789imported/w3c/web-platform-tests/html/browsers/windows/targeting-cross-origin-nested-browsing-contexts.html [ Failure Pass ]
    777 imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/credentialless/iframe-coep-credentialless.tentative.https.html [ Failure Pass ]
    778 imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/credentialless/iframe-coep-require-corp.tentative.https.html [ Failure Pass ]
    779 imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/credentialless/image.tentative.https.html [ Failure Pass ]
    780 imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/header-parsing.https.html [ Failure Pass ]
    781 imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/reporting-to-endpoint.https.html [ Failure Pass ]
    782790imported/w3c/web-platform-tests/html/webappapis/update-rendering/child-document-raf-order.html [ Failure Pass ]
    783791imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/img-aspect-ratio-lazy.tentative.html [ Failure Pass ]
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r280933 r280953  
     12021-08-11  Chris Dumez  <cdumez@apple.com>
     2
     3        Add initial support for Cross-Origin-Embedder-Policy (COEP)
     4        https://bugs.webkit.org/show_bug.cgi?id=228754
     5
     6        Reviewed by Alex Christensen.
     7
     8        Rebaseline COEP WPT tests now that we are passing more checks.
     9
     10        * web-platform-tests/html/cross-origin-embedder-policy/blob.https-expected.txt:
     11        * web-platform-tests/html/cross-origin-embedder-policy/coep-frame-javascript.https-expected.txt:
     12        * web-platform-tests/html/cross-origin-embedder-policy/coep-on-response-from-service-worker.https-expected.txt:
     13        * web-platform-tests/html/cross-origin-embedder-policy/credentialless/iframe-coep-require-corp.tentative.https-expected.txt:
     14        * web-platform-tests/html/cross-origin-embedder-policy/cross-origin-isolated-permission.https-expected.txt:
     15        * web-platform-tests/html/cross-origin-embedder-policy/data.https-expected.txt:
     16        * web-platform-tests/html/cross-origin-embedder-policy/dedicated-worker-cache-storage.https-expected.txt:
     17        * web-platform-tests/html/cross-origin-embedder-policy/dedicated-worker.https-expected.txt:
     18        * web-platform-tests/html/cross-origin-embedder-policy/header-parsing.https-expected.txt:
     19        * web-platform-tests/html/cross-origin-embedder-policy/javascript.https-expected.txt:
     20        * web-platform-tests/html/cross-origin-embedder-policy/multi-globals/workers-coep-report.https-expected.txt:
     21        * web-platform-tests/html/cross-origin-embedder-policy/no-secure-context-expected.txt:
     22        * web-platform-tests/html/cross-origin-embedder-policy/none-sw-from-require-corp.https-expected.txt:
     23        * web-platform-tests/html/cross-origin-embedder-policy/none.https-expected.txt:
     24        * web-platform-tests/html/cross-origin-embedder-policy/reporting-to-endpoint.https-expected.txt:
     25        * web-platform-tests/html/cross-origin-embedder-policy/require-corp-about-blank-expected.txt: Removed.
     26        * web-platform-tests/html/cross-origin-embedder-policy/require-corp-about-blank.https-expected.txt:
     27        * web-platform-tests/html/cross-origin-embedder-policy/require-corp-about-srcdoc-expected.txt: Removed.
     28        * web-platform-tests/html/cross-origin-embedder-policy/require-corp-about-srcdoc.https-expected.txt:
     29        * web-platform-tests/html/cross-origin-embedder-policy/require-corp-load-from-cache-storage.https-expected.txt:
     30        * web-platform-tests/html/cross-origin-embedder-policy/require-corp-sw-from-none.https-expected.txt:
     31        * web-platform-tests/html/cross-origin-embedder-policy/require-corp-sw-from-require-corp.https-expected.txt:
     32        * web-platform-tests/html/cross-origin-embedder-policy/require-corp-sw.https-expected.txt:
     33        * web-platform-tests/html/cross-origin-embedder-policy/require-corp.https-expected.txt:
     34        * web-platform-tests/html/cross-origin-embedder-policy/sandbox.https-expected.txt:
     35        * web-platform-tests/html/cross-origin-embedder-policy/service-worker-cache-storage.https-expected.txt:
     36        * web-platform-tests/html/cross-origin-embedder-policy/srcdoc.https-expected.txt:
     37
    1382021-08-11  Chris Dumez  <cdumez@apple.com>
    239
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/blob.https-expected.txt

    r267646 r280953  
     1CONSOLE MESSAGE: Refused to display 'blob:https://localhost:9443/ce752f78-9f54-4192-885f-d338222dbf89' in a frame because of Cross-Origin-Embedder-Policy.
     2CONSOLE MESSAGE: Refused to display 'blob:https://127.0.0.1:9443/2d609484-fc8c-4162-b451-5e5a60ca6fb0' in a frame because of Cross-Origin-Embedder-Policy.
     3CONSOLE MESSAGE: Refused to display 'blob:https://127.0.0.1:9443/d6c69b1b-b9e2-468f-afd5-3ee0ca1f26cd' in a frame because of Cross-Origin-Embedder-Policy.
     4CONSOLE MESSAGE: Refused to display 'blob:https://localhost:9443/a2f48f74-c115-4535-8945-845540d08260' in a frame because of Cross-Origin-Embedder-Policy.
     5CONSOLE MESSAGE: Refused to display 'blob:https://127.0.0.1:9443/e46352d8-4f39-4348-addc-cf3be4c271d5' in a frame because of Cross-Origin-Embedder-Policy.
     6CONSOLE MESSAGE: Refused to display 'blob:https://127.0.0.1:9443/d4b68c8b-e74e-47a5-a08d-612bf0d709d7' in a frame because of Cross-Origin-Embedder-Policy.
    17
    2 Harness Error (FAIL), message = 2 duplicate test names: "Cross-Origin-Embedder-Policy and blob: URL from https://127.0.0.1:9443 in subframe via subframe", "Cross-Origin-Embedder-Policy and blob: URL from https://127.0.0.1:9443 in subframe via navigate"
     8Harness Error (TIMEOUT), message = null
    39
    4 FAIL Cross-Origin-Embedder-Policy and blob: URL from https://localhost:9443 in subframe via subframe assert_true: Cross-origin without CORP did not fail expected true got false
    5 PASS Cross-Origin-Embedder-Policy and blob: URL from https://localhost:9443 in subframe via navigate
    6 PASS Cross-Origin-Embedder-Policy and blob: URL from https://127.0.0.1:9443 in subframe via subframe
    7 PASS Cross-Origin-Embedder-Policy and blob: URL from https://127.0.0.1:9443 in subframe via navigate
    8 PASS Cross-Origin-Embedder-Policy and blob: URL from https://127.0.0.1:9443 in subframe via subframe
    9 PASS Cross-Origin-Embedder-Policy and blob: URL from https://127.0.0.1:9443 in subframe via navigate
     10TIMEOUT Cross-Origin-Embedder-Policy and blob: URL from https://localhost:9443 in subframe via subframe Test timed out
     11TIMEOUT Cross-Origin-Embedder-Policy and blob: URL from https://localhost:9443 in subframe via navigate Test timed out
     12TIMEOUT Cross-Origin-Embedder-Policy and blob: URL from https://127.0.0.1:9443 in subframe via subframe Test timed out
     13TIMEOUT Cross-Origin-Embedder-Policy and blob: URL from https://127.0.0.1:9443 in subframe via navigate Test timed out
     14TIMEOUT Cross-Origin-Embedder-Policy and blob: URL from https://127.0.0.1:9443 in subframe via subframe Test timed out
     15TIMEOUT Cross-Origin-Embedder-Policy and blob: URL from https://127.0.0.1:9443 in subframe via navigate Test timed out
    1016
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/coep-frame-javascript.https-expected.txt

    r264117 r280953  
     1CONSOLE MESSAGE: Cancelled load to https://127.0.0.1:9443/common/blank.html because it violates the resource's Cross-Origin-Resource-Policy response header.
     2CONSOLE MESSAGE: Fetch API cannot load https://127.0.0.1:9443/common/blank.html due to access control checks.
    13
    2 FAIL Cross-Origin-Embedder-Policy frame and javascript: URLs assert_true: Cross-origin without CORP did not fail expected true got false
     4PASS Cross-Origin-Embedder-Policy frame and javascript: URLs
    35
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/coep-on-response-from-service-worker.https-expected.txt

    r269227 r280953  
    11CONSOLE MESSAGE: FetchEvent.respondWith received an error: TypeError: Cancelled load to https://127.0.0.1:9443/html/cross-origin-embedder-policy/resources/nothing-same-origin-corp.txt because it violates the resource's Cross-Origin-Resource-Policy response header.
    22CONSOLE MESSAGE: Fetch API cannot load https://127.0.0.1:9443/html/cross-origin-embedder-policy/resources/nothing-same-origin-corp.txt.
     3CONSOLE MESSAGE: Cancelled load to https://127.0.0.1:9443/common/blank.html because it violates the resource's Cross-Origin-Resource-Policy response header.
     4CONSOLE MESSAGE: Fetch API cannot load https://127.0.0.1:9443/common/blank.html due to access control checks.
    35CONSOLE MESSAGE: Cancelled load to https://127.0.0.1:9443/html/cross-origin-embedder-policy/resources/nothing-same-origin-corp.txt?passthrough because it violates the resource's Cross-Origin-Resource-Policy response header.
    46CONSOLE MESSAGE: Fetch API cannot load https://127.0.0.1:9443/html/cross-origin-embedder-policy/resources/nothing-same-origin-corp.txt?passthrough due to access control checks.
     7CONSOLE MESSAGE: Cancelled load to https://127.0.0.1:9443/common/blank.html?passthrough because it violates the resource's Cross-Origin-Resource-Policy response header.
     8CONSOLE MESSAGE: Fetch API cannot load https://127.0.0.1:9443/common/blank.html?passthrough due to access control checks.
    59CONSOLE MESSAGE: FetchEvent.respondWith received an error: TypeError: Origin https://localhost:9443 is not allowed by Access-Control-Allow-Origin.
    610CONSOLE MESSAGE: Fetch API cannot load https://127.0.0.1:9443/common/blank.html.
     
    1115PASS making a same-origin request for CORP: cross-origin
    1216PASS making a cross-origin request for CORP: same-origin
    13 FAIL making a cross-origin request for no CORP assert_unreached: Should have rejected: undefined Reached unreachable code
     17PASS making a cross-origin request for no CORP
    1418PASS making a cross-origin request for CORP: cross-origin
    1519PASS making a cross-origin request for CORP: same-origin [PASS THROUGH]
    16 FAIL making a cross-origin request for no CORP [PASS THROUGH] assert_unreached: Should have rejected: undefined Reached unreachable code
     20PASS making a cross-origin request for no CORP [PASS THROUGH]
    1721PASS making a cross-origin request for CORP: cross-origin [PASS THROUGH]
    1822PASS making a cross-origin request with CORS without ACAO
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/credentialless/iframe-coep-require-corp.tentative.https-expected.txt

    r279427 r280953  
     1CONSOLE MESSAGE: Refused to display 'https://localhost:9443/html/cross-origin-embedder-policy/credentialless/resources/executor.html?pipe=|header(Cross-Origin-Embedder-Policy,none)&uuid=48c5cd5d-1a04-4b22-b367-348626e3e72f' in a frame because of Cross-Origin-Embedder-Policy.
     2CONSOLE MESSAGE: Refused to display 'https://127.0.0.1:9443/html/cross-origin-embedder-policy/credentialless/resources/executor.html?pipe=|header(Cross-Origin-Embedder-Policy,none)&uuid=dc38ab59-60a5-4ca7-846e-07f347cbb88b' in a frame because of Cross-Origin-Embedder-Policy.
     3CONSOLE MESSAGE: Refused to display 'https://127.0.0.1:9443/html/cross-origin-embedder-policy/credentialless/resources/executor.html?pipe=|header(Cross-Origin-Embedder-Policy,credentialless)&uuid=3bc9c936-138c-44a8-b89a-22d5348db081' in a frame because of Cross-Origin-Embedder-Policy.
     4CONSOLE MESSAGE: Cancelled load to https://127.0.0.1:9443/html/cross-origin-embedder-policy/credentialless/resources/executor.html?pipe=|header(Cross-Origin-Embedder-Policy,require-corp)&uuid=9b4fc8a0-7c1b-4ced-9055-368e754dc376 because it violates the resource's Cross-Origin-Resource-Policy response header.
     5CONSOLE MESSAGE: Refused to display 'https://localhost:9443/html/cross-origin-embedder-policy/credentialless/resources/executor.html?pipe=|header(Cross-Origin-Embedder-Policy,credentialless)&uuid=7f8abf5e-9254-4d23-b288-ed44441c26aa' in a frame because of Cross-Origin-Embedder-Policy.
     6CONSOLE MESSAGE: Refused to display 'https://localhost:9443/html/cross-origin-embedder-policy/credentialless/resources/executor.html?pipe=|header(Cross-Origin-Embedder-Policy,none)|header(Cross-Origin-Resource-Policy,cross-origin)&uuid=9bda0fd6-29fb-4c8f-acf4-04b6db9ebf7f' in a frame because of Cross-Origin-Embedder-Policy.
     7CONSOLE MESSAGE: Refused to display 'https://127.0.0.1:9443/html/cross-origin-embedder-policy/credentialless/resources/executor.html?pipe=|header(Cross-Origin-Embedder-Policy,none)|header(Cross-Origin-Resource-Policy,cross-origin)&uuid=14602c93-2124-4abb-9de9-5f98cb106608' in a frame because of Cross-Origin-Embedder-Policy.
     8CONSOLE MESSAGE: Refused to display 'https://127.0.0.1:9443/html/cross-origin-embedder-policy/credentialless/resources/executor.html?pipe=|header(Cross-Origin-Embedder-Policy,credentialless)|header(Cross-Origin-Resource-Policy,cross-origin)&uuid=c90ebc7d-77ed-486d-8b4f-5af18771d6f2' in a frame because of Cross-Origin-Embedder-Policy.
     9CONSOLE MESSAGE: Refused to display 'https://localhost:9443/html/cross-origin-embedder-policy/credentialless/resources/executor.html?pipe=|header(Cross-Origin-Embedder-Policy,credentialless)|header(Cross-Origin-Resource-Policy,cross-origin)&uuid=95a65629-9a80-4aa5-81fc-ae7e7d8c2d52' in a frame because of Cross-Origin-Embedder-Policy.
    110
    2 FAIL COEP:require-corp embeds same-origin COEP:none assert_equals: expected "block" but got "load"
    3 FAIL COEP:require-corp embeds cross-origin COEP:none assert_equals: expected "block" but got "load"
    4 PASS COEP:require-corp embeds same-origin COEP:credentialless
    5 FAIL COEP:require-corp embeds cross-origin COEP:credentialless assert_equals: expected "block" but got "load"
     11Harness Error (TIMEOUT), message = null
     12
     13PASS COEP:require-corp embeds same-origin COEP:none
     14PASS COEP:require-corp embeds cross-origin COEP:none
     15TIMEOUT COEP:require-corp embeds same-origin COEP:credentialless Test timed out
     16PASS COEP:require-corp embeds cross-origin COEP:credentialless
    617PASS COEP:require-corp embeds same-origin COEP:require-corp
    7 FAIL COEP:require-corp embeds cross-origin COEP:require-corp assert_equals: expected "block" but got "load"
    8 FAIL COEP:require-corp embeds same-origin COEP:none, CORP:cross-origin assert_equals: expected "block" but got "load"
    9 FAIL COEP:require-corp embeds cross-origin COEP:none, CORP:cross-origin assert_equals: expected "block" but got "load"
    10 PASS COEP:require-corp embeds same-origin COEP:credentialless, CORP:cross-origin
    11 PASS COEP:require-corp embeds cross-origin COEP:credentialless, CORP:cross-origin
     18PASS COEP:require-corp embeds cross-origin COEP:require-corp
     19PASS COEP:require-corp embeds same-origin COEP:none, CORP:cross-origin
     20PASS COEP:require-corp embeds cross-origin COEP:none, CORP:cross-origin
     21TIMEOUT COEP:require-corp embeds same-origin COEP:credentialless, CORP:cross-origin Test timed out
     22TIMEOUT COEP:require-corp embeds cross-origin COEP:credentialless, CORP:cross-origin Test timed out
    1223PASS COEP:require-corp embeds same-origin COEP:require-corp, CORP:cross-origin
    1324PASS COEP:require-corp embeds cross-origin COEP:require-corp, CORP:cross-origin
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/cross-origin-isolated-permission.https-expected.txt

    r280504 r280953  
     1CONSOLE MESSAGE: Refused to load 'blob:https://localhost:9443/0626116e-3414-4f35-bd1e-007f1312b79e' worker because of Cross-Origin-Embedder-Policy.
     2CONSOLE MESSAGE: Worker load was blocked by Cross-Origin-Embedder-Policy
     3CONSOLE MESSAGE: Cannot load blob:https://localhost:9443/0626116e-3414-4f35-bd1e-007f1312b79e due to access control checks.
     4CONSOLE MESSAGE: Refused to load 'blob:https://localhost:9443/a99eb341-4640-403a-a8f4-c2fcf28ede20' worker because of Cross-Origin-Embedder-Policy.
     5CONSOLE MESSAGE: Worker load was blocked by Cross-Origin-Embedder-Policy
     6CONSOLE MESSAGE: Cannot load blob:https://localhost:9443/a99eb341-4640-403a-a8f4-c2fcf28ede20 due to access control checks.
     7CONSOLE MESSAGE: Refused to load 'blob:https://localhost:9443/929d633e-ce48-43ff-b89d-e4e20fca6753' worker because of Cross-Origin-Embedder-Policy.
     8CONSOLE MESSAGE: Worker load was blocked by Cross-Origin-Embedder-Policy
     9CONSOLE MESSAGE: Cannot load blob:https://localhost:9443/929d633e-ce48-43ff-b89d-e4e20fca6753 due to access control checks.
     10CONSOLE MESSAGE: Refused to load 'blob:https://localhost:9443/0c8b6914-58db-417c-9e0c-e7ecacc4a16a' worker because of Cross-Origin-Embedder-Policy.
     11CONSOLE MESSAGE: Worker load was blocked by Cross-Origin-Embedder-Policy
     12CONSOLE MESSAGE: Cannot load blob:https://localhost:9443/0c8b6914-58db-417c-9e0c-e7ecacc4a16a due to access control checks.
     13
     14
     15Harness Error (TIMEOUT), message = null
    116
    217FAIL frame: origin = https://localhost:9443, value = undefined assert_equals: expected true but got false
     
    1631PASS dedicated worker: scheme = data, value = self
    1732PASS dedicated worker: scheme = data, value = (\)
    18 FAIL dedicated worker: scheme = blob, value = undefined assert_equals: expected true but got false
    19 FAIL dedicated worker: scheme = blob, value = * assert_equals: expected true but got false
    20 FAIL dedicated worker: scheme = blob, value = self assert_equals: expected true but got false
    21 PASS dedicated worker: scheme = blob, value = (\)
     33TIMEOUT dedicated worker: scheme = blob, value = undefined Test timed out
     34TIMEOUT dedicated worker: scheme = blob, value = * Test timed out
     35TIMEOUT dedicated worker: scheme = blob, value = self Test timed out
     36TIMEOUT dedicated worker: scheme = blob, value = (\) Test timed out
    2237FAIL shared worker: withCoopCoep = false Can't find variable: SharedWorker
    2338FAIL shared worker: withCoopCoep = true Can't find variable: SharedWorker
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/data.https-expected.txt

    r249886 r280953  
     1CONSOLE MESSAGE: Cancelled load to https://localhost:9443/common/blank.html because it violates the resource's Cross-Origin-Resource-Policy response header.
     2CONSOLE MESSAGE: Fetch API cannot load https://localhost:9443/common/blank.html due to access control checks.
    13
    2 FAIL Cross-Origin-Embedder-Policy and data: URLs assert_true: Cross-origin without CORP did not fail expected true got false
     4PASS Cross-Origin-Embedder-Policy and data: URLs
    35
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/dedicated-worker-cache-storage.https-expected.txt

    r267646 r280953  
     1CONSOLE MESSAGE: Refused to load 'https://localhost:9443/html/cross-origin-embedder-policy/resources/universal-worker.js?pipe=' worker because of Cross-Origin-Embedder-Policy.
     2CONSOLE MESSAGE: Worker load was blocked by Cross-Origin-Embedder-Policy
     3CONSOLE MESSAGE: Cannot load https://localhost:9443/html/cross-origin-embedder-policy/resources/universal-worker.js?pipe= due to access control checks.
     4CONSOLE MESSAGE: Refused to load 'https://localhost:9443/html/cross-origin-embedder-policy/resources/universal-worker.js?pipe=' worker because of Cross-Origin-Embedder-Policy.
     5CONSOLE MESSAGE: Worker load was blocked by Cross-Origin-Embedder-Policy
     6CONSOLE MESSAGE: Cannot load https://localhost:9443/html/cross-origin-embedder-policy/resources/universal-worker.js?pipe= due to access control checks.
    17
    28PASS coep-none coep-none corp-cross-origin
    39PASS coep-none coep-none corp-undefined
    410PASS coep-none coep-require-corp corp-cross-origin
    5 FAIL coep-none coep-require-corp corp-undefined assert_equals: expected "failure" but got "success"
    6 FAIL coep-require-corp coep-none corp-cross-origin assert_equals: expected "error" but got "success"
    7 FAIL coep-require-corp coep-none corp-undefined assert_equals: expected "error" but got "success"
     11PASS coep-none coep-require-corp corp-undefined
     12PASS coep-require-corp coep-none corp-cross-origin
     13PASS coep-require-corp coep-none corp-undefined
    814PASS coep-require-corp coep-require-corp corp-cross-origin
    9 FAIL coep-require-corp coep-require-corp corp-undefined assert_equals: expected "failure" but got "success"
     15PASS coep-require-corp coep-require-corp corp-undefined
    1016
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/dedicated-worker.https-expected.txt

    r267646 r280953  
    1 
    2 
    3 Harness Error (TIMEOUT), message = null
     1CONSOLE MESSAGE: Refused to load 'https://localhost:9443/html/cross-origin-embedder-policy/resources/dedicated-worker.js' worker because of Cross-Origin-Embedder-Policy.
     2CONSOLE MESSAGE: Worker load was blocked by Cross-Origin-Embedder-Policy
     3CONSOLE MESSAGE: Cannot load https://localhost:9443/html/cross-origin-embedder-policy/resources/dedicated-worker.js due to access control checks.
     4CONSOLE MESSAGE: Cancelled load to https://127.0.0.1:9443/common/blank.html because it violates the resource's Cross-Origin-Resource-Policy response header.
     5CONSOLE MESSAGE: Cancelled load to https://127.0.0.1:9443/common/blank.html because it violates the resource's Cross-Origin-Resource-Policy response header.
     6CONSOLE MESSAGE: Refused to load 'https://localhost:9443/html/cross-origin-embedder-policy/resources/dedicated-worker.js' worker because of Cross-Origin-Embedder-Policy.
     7CONSOLE MESSAGE: Worker load was blocked by Cross-Origin-Embedder-Policy
     8CONSOLE MESSAGE: Cannot load https://localhost:9443/html/cross-origin-embedder-policy/resources/dedicated-worker.js due to access control checks.
     9CONSOLE MESSAGE: Cancelled load to https://127.0.0.1:9443/common/blank.html because it violates the resource's Cross-Origin-Resource-Policy response header.
     10CONSOLE MESSAGE: Cancelled load to https://127.0.0.1:9443/common/blank.html because it violates the resource's Cross-Origin-Resource-Policy response header.
    411
    512PASS COEP: none worker in COEP: none frame
    6 TIMEOUT COEP: none worker in COEP: require-corp frame Test timed out
    7 NOTRUN COEP: require-corp worker in COEP: none frame
    8 NOTRUN COEP: require-corp worker in COEP: require-corp frame
    9 NOTRUN COEP: none module worker in COEP: none frame
    10 NOTRUN COEP: none module worker in COEP: require-corp frame
    11 NOTRUN COEP: require-corp module worker in COEP: none frame
    12 NOTRUN COEP: require-corp module worker in COEP: require-corp frame
     13PASS COEP: none worker in COEP: require-corp frame
     14PASS COEP: require-corp worker in COEP: none frame
     15PASS COEP: require-corp worker in COEP: require-corp frame
     16PASS COEP: none module worker in COEP: none frame
     17PASS COEP: none module worker in COEP: require-corp frame
     18PASS COEP: require-corp module worker in COEP: none frame
     19PASS COEP: require-corp module worker in COEP: require-corp frame
    1320
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/header-parsing.https-expected.txt

    r279427 r280953  
     1CONSOLE MESSAGE: Refused to display 'https://localhost:9443/common/blank.html' in a frame because of Cross-Origin-Embedder-Policy.
     2CONSOLE MESSAGE: Sandbox access violation: Blocked a frame at "https://localhost:9443" from accessing a frame at "null".  The frame being accessed is sandboxed and lacks the "allow-same-origin" flag.
     3CONSOLE MESSAGE: Refused to display 'https://localhost:9443/common/blank.html' in a frame because of Cross-Origin-Embedder-Policy.
     4CONSOLE MESSAGE: Sandbox access violation: Blocked a frame at "https://localhost:9443" from accessing a frame at "null".  The frame being accessed is sandboxed and lacks the "allow-same-origin" flag.
     5CONSOLE MESSAGE: Refused to display 'https://localhost:9443/common/blank.html' in a frame because of Cross-Origin-Embedder-Policy.
     6CONSOLE MESSAGE: Sandbox access violation: Blocked a frame at "https://localhost:9443" from accessing a frame at "null".  The frame being accessed is sandboxed and lacks the "allow-same-origin" flag.
     7CONSOLE MESSAGE: Refused to display 'https://localhost:9443/common/blank.html' in a frame because of Cross-Origin-Embedder-Policy.
     8CONSOLE MESSAGE: Sandbox access violation: Blocked a frame at "https://localhost:9443" from accessing a frame at "null".  The frame being accessed is sandboxed and lacks the "allow-same-origin" flag.
     9CONSOLE MESSAGE: Refused to display 'https://localhost:9443/common/blank.html' in a frame because of Cross-Origin-Embedder-Policy.
     10CONSOLE MESSAGE: Sandbox access violation: Blocked a frame at "https://localhost:9443" from accessing a frame at "null".  The frame being accessed is sandboxed and lacks the "allow-same-origin" flag.
     11CONSOLE MESSAGE: Refused to display 'https://localhost:9443/common/blank.html' in a frame because of Cross-Origin-Embedder-Policy.
     12CONSOLE MESSAGE: Sandbox access violation: Blocked a frame at "https://localhost:9443" from accessing a frame at "null".  The frame being accessed is sandboxed and lacks the "allow-same-origin" flag.
     13CONSOLE MESSAGE: Refused to display 'https://localhost:9443/common/blank.html' in a frame because of Cross-Origin-Embedder-Policy.
     14CONSOLE MESSAGE: Sandbox access violation: Blocked a frame at "https://localhost:9443" from accessing a frame at "null".  The frame being accessed is sandboxed and lacks the "allow-same-origin" flag.
     15CONSOLE MESSAGE: Refused to display 'https://localhost:9443/common/blank.html' in a frame because of Cross-Origin-Embedder-Policy.
     16CONSOLE MESSAGE: Sandbox access violation: Blocked a frame at "https://localhost:9443" from accessing a frame at "null".  The frame being accessed is sandboxed and lacks the "allow-same-origin" flag.
    117
    2 PASS navigation allowed for PASS navigation allowed for [""]
     18PASS navigation allowed for []
     19PASS navigation allowed for [""]
    320PASS navigation allowed for ["jibberish"]
    421PASS navigation allowed for [{"percentEncoded":"require%FFcorp"}]
     
    1633PASS navigation allowed for ["","require-corp"]
    1734PASS navigation allowed for ["require-corp",""]
    18 FAIL navigation blocked for ["require-corp"] assert_equals: expected null but got Document node with 1 child
    19 FAIL navigation blocked for [" require-corp "] assert_equals: expected null but got Document node with 1 child
    20 FAIL navigation blocked for ["\trequire-corp\t"] assert_equals: expected null but got Document node with 1 child
    21 FAIL navigation blocked for [" \trequire-corp"] assert_equals: expected null but got Document node with 1 child
    22 FAIL navigation blocked for ["require-corp\t "] assert_equals: expected null but got Document node with 1 child
    23 FAIL navigation blocked for ["require-corp; foo=bar"] assert_equals: expected null but got Document node with 1 child
    24 FAIL navigation blocked for ["require-corp;require-corp"] assert_equals: expected null but got Document node with 1 child
    25 FAIL navigation blocked for ["require-corp; report-to=\"data:","\""] assert_equals: expected null but got Document node with 1 child
     35PASS navigation blocked for ["require-corp"]
     36PASS navigation blocked for [" require-corp "]
     37PASS navigation blocked for ["\trequire-corp\t"]
     38PASS navigation blocked for [" \trequire-corp"]
     39PASS navigation blocked for ["require-corp\t "]
     40PASS navigation blocked for ["require-corp; foo=bar"]
     41PASS navigation blocked for ["require-corp;require-corp"]
     42PASS navigation blocked for ["require-corp; report-to=\"data:","\""]
    2643
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/javascript.https-expected.txt

    r264117 r280953  
     1CONSOLE MESSAGE: Cancelled load to https://127.0.0.1:9443/common/blank.html because it violates the resource's Cross-Origin-Resource-Policy response header.
     2CONSOLE MESSAGE: Fetch API cannot load https://127.0.0.1:9443/common/blank.html due to access control checks.
    13
    2 FAIL Cross-Origin-Embedder-Policy and javascript: URLs assert_true: Cross-origin without CORP did not fail expected true got false
     4PASS Cross-Origin-Embedder-Policy and javascript: URLs
    35
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/multi-globals/workers-coep-report.https-expected.txt

    r279427 r280953  
    44    }
    55  })')
     6CONSOLE MESSAGE: Refused to load 'https://localhost:9443/html/cross-origin-embedder-policy/multi-globals/current/worker.js' worker because of Cross-Origin-Embedder-Policy.
     7CONSOLE MESSAGE: Worker load was blocked by Cross-Origin-Embedder-Policy
     8CONSOLE MESSAGE: Cannot load https://localhost:9443/html/cross-origin-embedder-policy/multi-globals/current/worker.js due to access control checks.
    69 Hello
    710
     
    1215  })')
    1316
    14 FAIL Multiple globals for Worker constructor: COEP reports assert_unreached: worker should have been blocked by COEP Reached unreachable code
     17TIMEOUT Multiple globals for Worker constructor: COEP reports Test timed out
    1518
     19Harness Error (FAIL), message = Unhandled rejection: undefined is not a constructor (evaluating 'new global.ReportingObserver((rs) => {
     20    for (const r of rs) {
     21      reports.push(r.toJSON());
     22    }
     23  })')
     24
     25TIMEOUT Multiple globals for Worker constructor: COEP reports Test timed out
     26
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/no-secure-context-expected.txt

    r267646 r280953  
     1CONSOLE MESSAGE: Refused to display 'http://127.0.0.1:8800/html/cross-origin-embedder-policy/resources/iframe.html' in a frame because of Cross-Origin-Embedder-Policy.
    12
    2 PASS COEP requires a secure context
     3Harness Error (TIMEOUT), message = null
    34
     5TIMEOUT COEP requires a secure context Test timed out
     6
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/none-sw-from-require-corp.https-expected.txt

    r279427 r280953  
    11CONSOLE MESSAGE: FetchEvent.respondWith received an error: TypeError: Cancelled load to https://127.0.0.1:9443/html/cross-origin-embedder-policy/resources/nothing-same-origin-corp.txt because it violates the resource's Cross-Origin-Resource-Policy response header.
    22CONSOLE MESSAGE: Fetch API cannot load https://127.0.0.1:9443/html/cross-origin-embedder-policy/resources/nothing-same-origin-corp.txt.
     3CONSOLE MESSAGE: Cancelled load to https://127.0.0.1:9443/common/blank.html because it violates the resource's Cross-Origin-Resource-Policy response header.
     4CONSOLE MESSAGE: Fetch API cannot load https://127.0.0.1:9443/common/blank.html due to access control checks.
    35CONSOLE MESSAGE: Cancelled load to https://127.0.0.1:9443/html/cross-origin-embedder-policy/resources/nothing-same-origin-corp.txt?passthrough because it violates the resource's Cross-Origin-Resource-Policy response header.
    46CONSOLE MESSAGE: Fetch API cannot load https://127.0.0.1:9443/html/cross-origin-embedder-policy/resources/nothing-same-origin-corp.txt?passthrough due to access control checks.
     7CONSOLE MESSAGE: Cancelled load to https://127.0.0.1:9443/common/blank.html?passthrough because it violates the resource's Cross-Origin-Resource-Policy response header.
     8CONSOLE MESSAGE: Fetch API cannot load https://127.0.0.1:9443/common/blank.html?passthrough due to access control checks.
    59CONSOLE MESSAGE: FetchEvent.respondWith received an error: TypeError: Origin https://localhost:9443 is not allowed by Access-Control-Allow-Origin.
    610CONSOLE MESSAGE: Fetch API cannot load https://127.0.0.1:9443/common/blank.html.
     
    1115PASS making a same-origin request for CORP: cross-origin
    1216PASS making a cross-origin request for CORP: same-origin
    13 FAIL making a cross-origin request for no CORP assert_unreached: Should have rejected: undefined Reached unreachable code
     17PASS making a cross-origin request for no CORP
    1418PASS making a cross-origin request for CORP: cross-origin
    1519PASS making a cross-origin request for CORP: same-origin [PASS THROUGH]
    16 FAIL making a cross-origin request for no CORP [PASS THROUGH] assert_unreached: Should have rejected: undefined Reached unreachable code
     20PASS making a cross-origin request for no CORP [PASS THROUGH]
    1721PASS making a cross-origin request for CORP: cross-origin [PASS THROUGH]
    1822PASS making a cross-origin request with CORS without ACAO
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/none.https-expected.txt

    r279427 r280953  
    1 
    2 Harness Error (TIMEOUT), message = null
    31
    42PASS "none" top-level: navigating a frame to "none" should succeed
    53PASS "none" top-level: navigating a frame from "require-corp" to "none" should succeed
    6 TIMEOUT "none" top-level: navigating a frame back from "require-corp" should succeed Test timed out
    7 FAIL "require-corp" top-level noopener popup: navigating to "none" should succeed Can't find variable: BroadcastChannel
     4PASS "none" top-level: navigating a frame back from "require-corp" should succeed
     5PASS "require-corp" top-level noopener popup: navigating to "none" should succeed
    86PASS CORP: same-site is not checked.
    97
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/reporting-to-endpoint.https-expected.txt

    r264117 r280953  
    1 $
     1CONSOLE MESSAGE: Cancelled load to https://127.0.0.1:9443/common/text-plain.txt?5770c451-7494-433b-8c09-b31f6ee4ffc8 because it violates the resource's Cross-Origin-Resource-Policy response header.
     2CONSOLE MESSAGE: Fetch API cannot load https://127.0.0.1:9443/common/text-plain.txt?5770c451-7494-433b-8c09-b31f6ee4ffc8 due to access control checks.
     3CONSOLE MESSAGE: Refused to display 'https://127.0.0.1:9443/common/blank.html?61cf891c-f480-4336-8e40-08917296c4b1' in a frame because of Cross-Origin-Embedder-Policy.
     4CONSOLE MESSAGE: Refused to display 'https://localhost:9443/common/blank.html?99e6eced-bb02-418a-b988-2339189a16a2' in a frame because of Cross-Origin-Embedder-Policy.
     5CONSOLE MESSAGE: Refused to display 'https://localhost:9443/common/blank.html?03fa3aa7-2433-4e5d-af85-f3b4581de86a' in a frame because of Cross-Origin-Embedder-Policy.
    26
    3 FAIL subresource CORP assert_unreached: A report whose blocked-url is https://127.0.0.1:9443/common/text-plain.txt?5b94c235-d74d-4e80-b363-aa9bd466b1a6 and url is https://localhost:9443/html/cross-origin-embedder-policy/resources/reporting-empty-frame.html is not found. Reached unreachable code
    4 FAIL navigation CORP assert_unreached: A report whose blocked-url is https://127.0.0.1:9443/common/blank.html?6f615216-f22f-41cb-a707-0b977efc3d6d and url is https://localhost:9443/html/cross-origin-embedder-policy/resources/reporting-empty-frame.html is not found. Reached unreachable code
    5 FAIL COEP violation on nested frame navigation assert_unreached: A report whose blocked-url is https://localhost:9443/common/blank.html?f967cac2-4283-4ea6-8667-040244e52336 and url is https://localhost:9443/html/cross-origin-embedder-policy/resources/reporting-empty-frame.html is not found. Reached unreachable code
     7FAIL subresource CORP assert_unreached: A report whose blockedURL is https://127.0.0.1:9443/common/text-plain.txt?5770c451-7494-433b-8c09-b31f6ee4ffc8 and url is https://localhost:9443/html/cross-origin-embedder-policy/resources/reporting-empty-frame.html?pipe=header(cross-origin-embedder-policy,require-corp;report-to=%22endpoint%22)|header(cross-origin-embedder-policy-report-only,require-corp;report-to=%22report-only-endpoint%22) is not found. Reached unreachable code
     8FAIL navigation CORP assert_unreached: A report whose blockedURL is https://127.0.0.1:9443/common/blank.html?61cf891c-f480-4336-8e40-08917296c4b1 and url is https://localhost:9443/html/cross-origin-embedder-policy/resources/reporting-empty-frame.html?pipe=header(cross-origin-embedder-policy,require-corp;report-to=%22endpoint%22)|header(cross-origin-embedder-policy-report-only,require-corp;report-to=%22report-only-endpoint%22) is not found. Reached unreachable code
     9FAIL COEP violation on nested frame navigation assert_unreached: A report whose blockedURL is https://localhost:9443/common/blank.html?99e6eced-bb02-418a-b988-2339189a16a2 and url is https://localhost:9443/html/cross-origin-embedder-policy/resources/reporting-empty-frame.html?pipe=header(cross-origin-embedder-policy,require-corp;report-to=%22endpoint%22)|header(cross-origin-embedder-policy-report-only,require-corp;report-to=%22report-only-endpoint%22) is not found. Reached unreachable code
     10FAIL Two COEP headers, split inside report-to value assert_unreached: A report whose blockedURL is https://localhost:9443/common/blank.html?03fa3aa7-2433-4e5d-af85-f3b4581de86a and url is https://localhost:9443/html/cross-origin-embedder-policy/resources/reporting-empty-frame-multiple-headers.html.asis is not found. Reached unreachable code
    611
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/require-corp-about-blank.https-expected.txt

    r269186 r280953  
     1CONSOLE MESSAGE: Refused to display 'https://localhost:9443/common/blank.html' in a frame because of Cross-Origin-Embedder-Policy.
     2CONSOLE MESSAGE: Sandbox access violation: Blocked a frame at "https://localhost:9443" from accessing a frame at "null".  The frame being accessed is sandboxed and lacks the "allow-same-origin" flag.
    13
    24
    35PASS Wait for the DOM to be built.
    46PASS about:blank can always be embedded by a 'require-corp' document
    5 FAIL A(B(C)) A=require-corp, B=about:blank, C=no-require-corp => C can't load step_wait_func: Timed out waiting on condition
     7PASS A(B(C)) A=require-corp, B=about:blank, C=no-require-corp => C can't load
    68
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/require-corp-about-srcdoc.https-expected.txt

    r269186 r280953  
     1CONSOLE MESSAGE: Refused to display 'https://localhost:9443/common/blank.html' in a frame because of Cross-Origin-Embedder-Policy.
     2CONSOLE MESSAGE: Sandbox access violation: Blocked a frame at "https://localhost:9443" from accessing a frame at "null".  The frame being accessed is sandboxed and lacks the "allow-same-origin" flag.
    13
    24
    35PASS Wait for the DOM to be built.
    46PASS about:srcdoc can always be embedded by a 'require-corp' document
    5 FAIL A(B(C)) A=require-corp, B=about:srcdoc, C=no-require-corp => C can't load step_wait_func: Timed out waiting on condition
     7PASS A(B(C)) A=require-corp, B=about:srcdoc, C=no-require-corp => C can't load
    68
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/require-corp-load-from-cache-storage.https-expected.txt

    r267646 r280953  
     1CONSOLE MESSAGE: Cache API operation failed: Cross-Origin-Resource-Policy failure
     2CONSOLE MESSAGE: Cache API operation failed: Cross-Origin-Resource-Policy failure
    13
    24
     
    2628PASS Fetch cross-origin no-cors cors-disabled corp-cross-origin from network and CacheStorage.
    2729PASS Fetch cross-origin no-cors cors-disabled corp-same-origin from network and CacheStorage.
    28 FAIL Fetch cross-origin no-cors cors-disabled corp-undefined from network and CacheStorage. assert_unreached: Should have rejected: undefined Reached unreachable code
     30PASS Fetch cross-origin no-cors cors-disabled corp-undefined from network and CacheStorage.
    2931PASS Fetch cross-origin no-cors cors-enabled corp-cross-origin from network and CacheStorage.
    3032PASS Fetch cross-origin no-cors cors-enabled corp-same-origin from network and CacheStorage.
    31 FAIL Fetch cross-origin no-cors cors-enabled corp-undefined from network and CacheStorage. assert_unreached: Should have rejected: undefined Reached unreachable code
     33PASS Fetch cross-origin no-cors cors-enabled corp-undefined from network and CacheStorage.
    3234
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/require-corp-sw-from-none.https-expected.txt

    r279427 r280953  
    11CONSOLE MESSAGE: FetchEvent.respondWith received an error: TypeError: Cancelled load to https://127.0.0.1:9443/html/cross-origin-embedder-policy/resources/nothing-same-origin-corp.txt because it violates the resource's Cross-Origin-Resource-Policy response header.
    22CONSOLE MESSAGE: Fetch API cannot load https://127.0.0.1:9443/html/cross-origin-embedder-policy/resources/nothing-same-origin-corp.txt.
     3CONSOLE MESSAGE: FetchEvent.respondWith received an error: TypeError: Cancelled load to https://127.0.0.1:9443/common/blank.html because it violates the resource's Cross-Origin-Resource-Policy response header.
     4CONSOLE MESSAGE: Fetch API cannot load https://127.0.0.1:9443/common/blank.html.
    35CONSOLE MESSAGE: Cancelled load to https://127.0.0.1:9443/html/cross-origin-embedder-policy/resources/nothing-same-origin-corp.txt?passthrough because it violates the resource's Cross-Origin-Resource-Policy response header.
    46CONSOLE MESSAGE: Fetch API cannot load https://127.0.0.1:9443/html/cross-origin-embedder-policy/resources/nothing-same-origin-corp.txt?passthrough due to access control checks.
     
    1113PASS making a same-origin request for CORP: cross-origin
    1214PASS making a cross-origin request for CORP: same-origin
    13 FAIL making a cross-origin request for no CORP assert_unreached: Should have rejected: undefined Reached unreachable code
     15PASS making a cross-origin request for no CORP
    1416PASS making a cross-origin request for CORP: cross-origin
    1517PASS making a cross-origin request for CORP: same-origin [PASS THROUGH]
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/require-corp-sw-from-require-corp.https-expected.txt

    r279427 r280953  
    11CONSOLE MESSAGE: FetchEvent.respondWith received an error: TypeError: Cancelled load to https://127.0.0.1:9443/html/cross-origin-embedder-policy/resources/nothing-same-origin-corp.txt because it violates the resource's Cross-Origin-Resource-Policy response header.
    22CONSOLE MESSAGE: Fetch API cannot load https://127.0.0.1:9443/html/cross-origin-embedder-policy/resources/nothing-same-origin-corp.txt.
     3CONSOLE MESSAGE: FetchEvent.respondWith received an error: TypeError: Cancelled load to https://127.0.0.1:9443/common/blank.html because it violates the resource's Cross-Origin-Resource-Policy response header.
     4CONSOLE MESSAGE: Fetch API cannot load https://127.0.0.1:9443/common/blank.html.
    35CONSOLE MESSAGE: Cancelled load to https://127.0.0.1:9443/html/cross-origin-embedder-policy/resources/nothing-same-origin-corp.txt?passthrough because it violates the resource's Cross-Origin-Resource-Policy response header.
    46CONSOLE MESSAGE: Fetch API cannot load https://127.0.0.1:9443/html/cross-origin-embedder-policy/resources/nothing-same-origin-corp.txt?passthrough due to access control checks.
     7CONSOLE MESSAGE: Cancelled load to https://127.0.0.1:9443/common/blank.html?passthrough because it violates the resource's Cross-Origin-Resource-Policy response header.
     8CONSOLE MESSAGE: Fetch API cannot load https://127.0.0.1:9443/common/blank.html?passthrough due to access control checks.
    59CONSOLE MESSAGE: FetchEvent.respondWith received an error: TypeError: Origin https://localhost:9443 is not allowed by Access-Control-Allow-Origin.
    610CONSOLE MESSAGE: Fetch API cannot load https://127.0.0.1:9443/common/blank.html.
     
    1115PASS making a same-origin request for CORP: cross-origin
    1216PASS making a cross-origin request for CORP: same-origin
    13 FAIL making a cross-origin request for no CORP assert_unreached: Should have rejected: undefined Reached unreachable code
     17PASS making a cross-origin request for no CORP
    1418PASS making a cross-origin request for CORP: cross-origin
    1519PASS making a cross-origin request for CORP: same-origin [PASS THROUGH]
    16 FAIL making a cross-origin request for no CORP [PASS THROUGH] assert_unreached: Should have rejected: undefined Reached unreachable code
     20PASS making a cross-origin request for no CORP [PASS THROUGH]
    1721PASS making a cross-origin request for CORP: cross-origin [PASS THROUGH]
    1822PASS making a cross-origin request with CORS without ACAO
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/require-corp-sw.https-expected.txt

    r267646 r280953  
    22PASS Set up global state
    33PASS fetch() to 'CORP: cross-origin' response should succeed.
    4 FAIL fetch() to no CORP response should not succeed. assert_equals: expected "Exception: TypeError" but got "opaque"
    5 FAIL importScripts() fails for a script with no corp. assert_unreached: Should have rejected: register() should fail. Reached unreachable code
     4PASS fetch() to no CORP response should not succeed.
     5PASS importScripts() fails for a script with no corp.
    66PASS importScripts() succeeds for a script with corp: cross-origin.
    77PASS Clean up global state
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/require-corp.https-expected.txt

    r279971 r280953  
     1CONSOLE MESSAGE: Refused to display 'https://localhost:9443/common/blank.html' in a frame because of Cross-Origin-Embedder-Policy.
     2CONSOLE MESSAGE: Refused to display 'https://localhost:9443/common/blank.html' in a frame because of Cross-Origin-Embedder-Policy.
     3CONSOLE MESSAGE: Sandbox access violation: Blocked a frame at "null" from accessing a frame at "null".  The frame being accessed is sandboxed and lacks the "allow-same-origin" flag.
     4CONSOLE MESSAGE: Cancelled load to https://127.0.0.1:9443/html/cross-origin-embedder-policy/resources/navigate-require-corp-same-site.sub.html?token=5dcc16cb-9469-4bec-9602-a97aea5d9615 because it violates the resource's Cross-Origin-Resource-Policy response header.
     5CONSOLE MESSAGE: Cancelled load to https://127.0.0.1:9443/html/cross-origin-embedder-policy/resources/navigate-require-corp-same-site.sub.html?token=b26287fc-8f3f-4acc-8a8e-8a644072bf73 because it violates the resource's Cross-Origin-Resource-Policy response header.
     6CONSOLE MESSAGE: Cancelled load to https://127.0.0.1:9443/html/cross-origin-embedder-policy/resources/navigate-require-corp-same-site.sub.html?to=https%3A%2F%2Flocalhost%3A9443%2Fhtml%2Fcross-origin-embedder-policy%2Fresources%2Fnavigate-require-corp.sub.html%3FchannelName%3D8b07c736-9199-41a7-904c-4efbb7dfa027 because it violates the resource's Cross-Origin-Resource-Policy response header.
     7CONSOLE MESSAGE: Cancelled load to https://127.0.0.1:9443/html/cross-origin-embedder-policy/resources/navigate-require-corp-same-site.sub.html?to=https%3A%2F%2F127.0.0.1%3A9443%2Fhtml%2Fcross-origin-embedder-policy%2Fresources%2Fnavigate-require-corp.sub.html%3FchannelName%3Ddda15abf-6fbe-457f-a03d-ee8d6c919d65 because it violates the resource's Cross-Origin-Resource-Policy response header.
     8CONSOLE MESSAGE: Refused to display 'https://127.0.0.1:9443/common/redirect.py?location=https%3A%2F%2Flocalhost%3A9443%2Fhtml%2Fcross-origin-embedder-policy%2Fresources%2Fnavigate-require-corp.sub.html%3FchannelName%3D8f6cafbd-6cff-4b57-b369-4045fca85b49' in a frame because of Cross-Origin-Embedder-Policy.
     9CONSOLE MESSAGE: Redirection was blocked by Cross-Origin-Embedder-Policy
     10CONSOLE MESSAGE: Cancelled load to https://127.0.0.1:9443/common/blank.html because it violates the resource's Cross-Origin-Resource-Policy response header.
     11CONSOLE MESSAGE: Fetch API cannot load https://127.0.0.1:9443/common/blank.html due to access control checks.
     12CONSOLE MESSAGE: Cancelled load to https://127.0.0.1:9443/common/blank.html because it violates the resource's Cross-Origin-Resource-Policy response header.
     13CONSOLE MESSAGE: Fetch API cannot load https://127.0.0.1:9443/common/blank.html due to access control checks.
     14CONSOLE MESSAGE: Sandbox access violation: Blocked a frame at "https://localhost:9443" from accessing a frame at "null".  The frame being accessed is sandboxed and lacks the "allow-same-origin" flag.
     15CONSOLE MESSAGE: Refused to display 'https://localhost:9443/common/blank.html' in a frame because of Cross-Origin-Embedder-Policy.
     16CONSOLE MESSAGE: Sandbox access violation: Blocked a frame at "https://localhost:9443" from accessing a frame at "https://localhost:9443".  The frame being accessed is sandboxed and lacks the "allow-same-origin" flag.
    117
    2 FAIL "require-corp" top-level: navigating a frame to "none" should fail step_wait_func: Timed out waiting on condition
    3 FAIL "require-corp" top-level: navigating a frame from "require-corp" to "none" should fail step_wait_func: Timed out waiting on condition
     18Harness Error (TIMEOUT), message = null
     19
     20PASS "require-corp" top-level: navigating a frame to "none" should fail
     21PASS "require-corp" top-level: navigating a frame from "require-corp" to "none" should fail
    422PASS "require-corp" top-level: creating a noopener "none" popup should succeed
    523PASS "require-corp" top-level: creating a "none" popup should succeed.
     
    826PASS "require-corp" top-level (as popup with opener set to null): navigating to "none" should succeed
    927PASS "require-corp" top-level: fetch() to CORP: cross-origin response should succeed
    10 FAIL "require-corp" top-level: fetch() to response without CORP should fail assert_unreached: Should have rejected: undefined Reached unreachable code
    11 FAIL "require-corp" top-level: fetch() to response without CORP through a WindowProxy should fail assert_unreached: Should have rejected: undefined Reached unreachable code
    12 FAIL "require-corp" top-level: navigating an iframe to a page without CORP, through a WindowProxy, should fail step_wait_func: Timed out waiting on condition
    13 PASS CORP: same-site is checked and allowed.
    14 FAIL CORP: same-site is checked and blocked. assert_false: expected false got true
    15 PASS navigation CORP is checked with the parent frame, not the navigation source - to be allowed
     28PASS "require-corp" top-level: fetch() to response without CORP should fail
     29PASS "require-corp" top-level: fetch() to response without CORP through a WindowProxy should fail
     30PASS "require-corp" top-level: navigating an iframe to a page without CORP, through a WindowProxy, should fail
     31TIMEOUT CORP: same-site is checked and allowed. Test timed out
     32PASS CORP: same-site is checked and blocked.
     33TIMEOUT navigation CORP is checked with the parent frame, not the navigation source - to be allowed Test timed out
    1634PASS navigation CORP is checked with the parent frame, not the navigation source - to be blocked
    17 FAIL navigation CORP is checked for each redirect assert_false: expected false got true
     35PASS navigation CORP is checked for each redirect
    1836
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/sandbox.https-expected.txt

    r249886 r280953  
    11
    2 FAIL Cross-Origin-Embedder-Policy and sandbox assert_true: Request to same-origin resource without CORP did not fail expected true got false
     2PASS Cross-Origin-Embedder-Policy and sandbox
    33
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/service-worker-cache-storage.https-expected.txt

    r267646 r280953  
    22PASS A ServiceWorker with coep-none use CacheStorage to get a corp-undefined response.
    33PASS A ServiceWorker with coep-none use CacheStorage to get a corp-cross-origin response.
    4 FAIL A ServiceWorker with coep-require-corp use CacheStorage to get a corp-undefined response. assert_equals: expected false but got true
     4PASS A ServiceWorker with coep-require-corp use CacheStorage to get a corp-undefined response.
    55PASS A ServiceWorker with coep-require-corp use CacheStorage to get a corp-cross-origin response.
    66
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/srcdoc.https-expected.txt

    r249886 r280953  
     1CONSOLE MESSAGE: Cancelled load to https://127.0.0.1:9443/common/blank.html because it violates the resource's Cross-Origin-Resource-Policy response header.
     2CONSOLE MESSAGE: Fetch API cannot load https://127.0.0.1:9443/common/blank.html due to access control checks.
    13
    2 FAIL Cross-Origin-Embedder-Policy and srcdoc assert_true: Cross-origin without CORP did not fail expected true got false
     4PASS Cross-Origin-Embedder-Policy and srcdoc
    35
  • trunk/LayoutTests/platform/mac-wk1/TestExpectations

    r280932 r280953  
    355355imported/w3c/web-platform-tests/fetch/cross-origin-resource-policy [ Skip ]
    356356imported/w3c/web-platform-tests/fetch/range/sw.https.window.html [ Skip ]
    357 imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/cache-storage-reporting-dedicated-worker.https.html [ Skip ]
    358 imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/cache-storage-reporting-document.https.html [ Skip ]
    359 imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/cache-storage-reporting-shared-worker.https.html [ Skip ]
    360 imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/coep-on-response-from-service-worker.https.html [ Skip ]
    361 imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/credentialless/reporting-subresource-corp.tentative.https.html [ Skip ]
    362 imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/credentialless/service-worker.tentative.https.html [ Skip ]
    363 imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/cross-origin-isolated-permission.https.html [ Skip ]
    364 imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/dedicated-worker-cache-storage.https.html [ Skip ]
    365 imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/reporting-subresource-corp.https.html [ Skip ]
    366 imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/require-corp-sw.https.html [ Skip ]
    367 imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/service-worker-cache-storage.https.html [ Skip ]
    368357imported/w3c/web-platform-tests/html/cross-origin-opener-policy/popup-coop-by-sw-from-coop.https.html [ Skip ]
    369358imported/w3c/web-platform-tests/html/cross-origin-opener-policy/popup-coop-by-sw.https.html [ Skip ]
     
    384373http/wpt/webrtc/transfer-datachannel-service-worker.https.html [ Skip ]
    385374
     375# No Cross-Origin-Embedder-Policy in WK1.
     376imported/w3c/web-platform-tests/html/cross-origin-embedder-policy [ Skip ]
     377http/wpt/html/cross-origin-embedder-policy/require-corp.https.html [ Skip ]
     378
    386379# Quota check missing in WK1
    387380http/tests/IndexedDB/storage-limit.https.html [ Skip ]
  • trunk/LayoutTests/platform/win/TestExpectations

    r280923 r280953  
    37223722imported/w3c/web-platform-tests/fetch/api/request/destination [ Skip ]
    37233723imported/w3c/web-platform-tests/fetch/cross-origin-resource-policy [ Skip ]
    3724 imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/cache-storage-reporting-dedicated-worker.https.html [ Skip ]
    3725 imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/cache-storage-reporting-document.https.html [ Skip ]
    3726 imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/cache-storage-reporting-shared-worker.https.html [ Skip ]
    3727 imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/coep-on-response-from-service-worker.https.html [ Skip ]
    3728 imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/dedicated-worker-cache-storage.https.html [ Skip ]
    3729 imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/reporting-subresource-corp.https.html [ Skip ]
    3730 imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/require-corp-sw.https.html [ Skip ]
    3731 imported/w3c/web-platform-tests/html/cross-origin-embedder-policy/service-worker-cache-storage.https.html [ Skip ]
    37323724imported/w3c/web-platform-tests/html/cross-origin-opener-policy/popup-coop-by-sw-from-coop.https.html [ Skip ]
    37333725imported/w3c/web-platform-tests/html/cross-origin-opener-policy/popup-coop-by-sw.https.html [ Skip ]
     
    37393731imported/w3c/web-platform-tests/worklets/layout-worklet-service-worker-interception.https.html [ Skip ]
    37403732imported/w3c/web-platform-tests/worklets/paint-worklet-service-worker-interception.https.html [ Skip ]
     3733
     3734# No Cross-Origin-Embedder-Policy in WK1.
     3735imported/w3c/web-platform-tests/html/cross-origin-embedder-policy [ Skip ]
     3736http/wpt/html/cross-origin-embedder-policy/require-corp.https.html [ Skip ]
    37413737
    37423738# No header filtering for WK1
  • trunk/Source/WTF/ChangeLog

    r280952 r280953  
     12021-08-11  Chris Dumez  <cdumez@apple.com>
     2
     3        Add initial support for Cross-Origin-Embedder-Policy (COEP)
     4        https://bugs.webkit.org/show_bug.cgi?id=228754
     5
     6        Reviewed by Alex Christensen.
     7
     8        Add experimental feature flag for Cross-Origin-Embedder-Policy (COEP), off by default.
     9
     10        * Scripts/Preferences/WebPreferencesExperimental.yaml:
     11
    1122021-08-11  Darin Adler  <darin@apple.com>
    213
  • trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml

    r280908 r280953  
    322322      default: false
    323323
     324CrossOriginEmbedderPolicyEnabled:
     325  type: bool
     326  humanReadableName: "Cross-Origin-Embedder-Policy (COEP) header"
     327  humanReadableDescription: "Support for Cross-Origin-Embedder-Policy (COEP) header"
     328  defaultValue:
     329    WebKitLegacy:
     330      default: false
     331    WebKit:
     332      default: false
     333    WebCore:
     334      default: false
     335
    324336CrossOriginOpenerPolicyEnabled:
    325337  type: bool
  • trunk/Source/WebCore/ChangeLog

    r280948 r280953  
     12021-08-11  Chris Dumez  <cdumez@apple.com>
     2
     3        Add initial support for Cross-Origin-Embedder-Policy (COEP)
     4        https://bugs.webkit.org/show_bug.cgi?id=228754
     5
     6        Reviewed by Alex Christensen.
     7
     8        Add initial support for Cross-Origin-Embedder-Policy (COEP) behind a runtime feature flag, off by default:
     9        - https://html.spec.whatwg.org/multipage/origin.html#coep
     10
     11        The COEP header has the following impacts:
     12        - When a document with `Cross-Origin-Embedder-Policy: require-corp` loads an iframe or a worker script, if the network
     13          response for that iframe doesn't also contain `Cross-Origin-Embedder-Policy: require-corp`, then we fail the load.
     14        - When a document with `Cross-Origin-Embedder-Policy: require-corp` loads cross-origin subresources, then either CORS
     15          must be used or the resource response must be allowed by Cross-Origin-Resource-Policy (CORP) header.
     16
     17        Support is only for WK2 and checks are done in the network process for better security. Support for workers and service
     18        workers (including cache storage) is included.
     19
     20        Most of the Web-Platform-Tests for COEP are passing with this patch. The exceptions are:
     21        - Some tests relying on Blob are failing. Similarly to COOP, Blobs need to inherit COEP from their
     22          creator. This is currently unimplemented as the change will likely be non-trivial. I will follow-up
     23          to fix Blob support for both COOP and COEP.
     24        - Tests in the credentialless/ folder are failing because we do not support `Cross-Origin-Embedder-Policy: credentialless`.
     25          This seems to be a fairly recent extension proposed by Google and it is not part of the HTML specification yet.
     26        - Some tests expect violation reporting and they are failing and we do not implement reporting yet.
     27
     28        Note that `self.crossOriginIsolated` still returns false, even if the pages opts into both COOP & COEP, and APIs such
     29        as SharedArrayBuffer still are not permitted to use. In order to support this, we will have to actually implement process
     30        swapping so that we know a process is not actually shared by several origins.
     31
     32        Test: http/wpt/html/cross-origin-embedder-policy/require-corp.https.html
     33
     34        * Modules/cache/DOMCache.cpp:
     35        (WebCore::DOMCache::queryCache):
     36        * Modules/cache/DOMCacheEngine.cpp:
     37        (WebCore::DOMCacheEngine::convertToException):
     38        * Modules/cache/DOMCacheEngine.h:
     39        * Modules/cache/RetrieveRecordsOptions.h:
     40        (WebCore::RetrieveRecordsOptions::isolatedCopy const):
     41        (WebCore::RetrieveRecordsOptions::encode const):
     42        (WebCore::RetrieveRecordsOptions::decode):
     43        * dom/Document.cpp:
     44        (WebCore::Document::initSecurityContext):
     45        * dom/SecurityContext.h:
     46        (WebCore::SecurityContext::crossOriginEmbedderPolicy const):
     47        (WebCore::SecurityContext::setCrossOriginEmbedderPolicy):
     48        * loader/CrossOriginAccessControl.cpp:
     49        (WebCore::shouldCrossOriginResourcePolicyCancelLoad):
     50        (WebCore::validateCrossOriginResourcePolicy):
     51        * loader/CrossOriginAccessControl.h:
     52        * loader/CrossOriginEmbedderPolicy.cpp:
     53        (WebCore::obtainCrossOriginEmbedderPolicy):
     54        (WebCore::CrossOriginEmbedderPolicy::isolatedCopy const):
     55        * loader/CrossOriginEmbedderPolicy.h:
     56        (WebCore::CrossOriginEmbedderPolicy::encode const):
     57        (WebCore::CrossOriginEmbedderPolicy::decode):
     58        * loader/CrossOriginOpenerPolicy.cpp:
     59        (WebCore::obtainCrossOriginOpenerPolicy):
     60        * loader/DocumentThreadableLoader.cpp:
     61        (WebCore::DocumentThreadableLoader::loadResourceSynchronously):
     62        (WebCore::DocumentThreadableLoader::create):
     63        (WebCore::DocumentThreadableLoader::DocumentThreadableLoader):
     64        (WebCore::DocumentThreadableLoader::crossOriginEmbedderPolicy const):
     65        * loader/DocumentThreadableLoader.h:
     66        * loader/DocumentWriter.cpp:
     67        (WebCore::DocumentWriter::begin):
     68        * loader/FrameLoader.cpp:
     69        (WebCore::FrameLoader::didBeginDocument):
     70        * loader/ResourceLoaderOptions.h:
     71        * loader/WorkerThreadableLoader.cpp:
     72        (WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge):
     73        * loader/cache/CachedResourceLoader.cpp:
     74        (WebCore::CachedResourceLoader::requestResource):
     75        * page/SecurityOrigin.h:
     76        * platform/network/HTTPParsers.cpp:
     77        (WebCore::parseCrossOriginResourcePolicyHeader):
     78        * platform/network/HTTPParsers.h:
     79        * workers/Worker.cpp:
     80        (WebCore::Worker::notifyFinished):
     81        * workers/WorkerGlobalScope.cpp:
     82        (WebCore::WorkerGlobalScope::WorkerGlobalScope):
     83        * workers/WorkerGlobalScopeProxy.h:
     84        * workers/WorkerMessagingProxy.cpp:
     85        (WebCore::WorkerMessagingProxy::startWorkerGlobalScope):
     86        * workers/WorkerMessagingProxy.h:
     87        * workers/WorkerScriptLoader.cpp:
     88        (WebCore::WorkerScriptLoader::loadSynchronously):
     89        (WebCore::WorkerScriptLoader::loadAsynchronously):
     90        (WebCore::WorkerScriptLoader::didReceiveResponse):
     91        * workers/WorkerScriptLoader.h:
     92        (WebCore::WorkerScriptLoader::crossOriginEmbedderPolicy const):
     93        * workers/WorkerThread.cpp:
     94        (WebCore::WorkerParameters::isolatedCopy const):
     95        * workers/WorkerThread.h:
     96        * workers/service/ServiceWorkerContainer.cpp:
     97        (WebCore::ServiceWorkerContainer::jobFinishedLoadingScript):
     98        * workers/service/ServiceWorkerContainer.h:
     99        * workers/service/ServiceWorkerContextData.cpp:
     100        (WebCore::ServiceWorkerContextData::isolatedCopy const):
     101        * workers/service/ServiceWorkerContextData.h:
     102        (WebCore::ServiceWorkerContextData::encode const):
     103        (WebCore::ServiceWorkerContextData::decode):
     104        * workers/service/ServiceWorkerFetchResult.h:
     105        (WebCore::ServiceWorkerFetchResult::isolatedCopy const):
     106        (WebCore::serviceWorkerFetchError):
     107        (WebCore::ServiceWorkerFetchResult::encode const):
     108        (WebCore::ServiceWorkerFetchResult::decode):
     109        * workers/service/ServiceWorkerJob.cpp:
     110        (WebCore::ServiceWorkerJob::notifyFinished):
     111        * workers/service/ServiceWorkerJobClient.h:
     112        * workers/service/context/ServiceWorkerThread.cpp:
     113        (WebCore::ServiceWorkerThread::ServiceWorkerThread):
     114        * workers/service/server/RegistrationDatabase.cpp:
     115        (WebCore::RegistrationDatabase::doPushChanges):
     116        (WebCore::RegistrationDatabase::importRecords):
     117        * workers/service/server/SWServer.cpp:
     118        (WebCore::SWServer::addRegistrationFromStore):
     119        (WebCore::SWServer::updateWorker):
     120        (WebCore::SWServer::installContextData):
     121        * workers/service/server/SWServer.h:
     122        * workers/service/server/SWServerJobQueue.cpp:
     123        (WebCore::SWServerJobQueue::scriptFetchFinished):
     124        * workers/service/server/SWServerWorker.cpp:
     125        (WebCore::SWServerWorker::SWServerWorker):
     126        (WebCore::SWServerWorker::contextData const):
     127        * workers/service/server/SWServerWorker.h:
     128
    11292021-08-11  Jean-Yves Avenard  <jya@apple.com>
    2130
  • trunk/Source/WebCore/Modules/cache/DOMCache.cpp

    r278714 r280953  
    453453void DOMCache::queryCache(ResourceRequest&& request, const CacheQueryOptions& options, ShouldRetrieveResponses shouldRetrieveResponses, RecordsCallback&& callback)
    454454{
    455     RetrieveRecordsOptions retrieveOptions { WTFMove(request), options.ignoreSearch, options.ignoreMethod, options.ignoreVary, shouldRetrieveResponses == ShouldRetrieveResponses::Yes };
     455    RetrieveRecordsOptions retrieveOptions { WTFMove(request), scriptExecutionContext()->crossOriginEmbedderPolicy(), *scriptExecutionContext()->securityOrigin(), options.ignoreSearch, options.ignoreMethod, options.ignoreVary, shouldRetrieveResponses == ShouldRetrieveResponses::Yes };
    456456    m_connection->retrieveRecords(m_identifier, retrieveOptions, [this, pendingActivity = makePendingActivity(*this), callback = WTFMove(callback)](auto&& result) mutable {
    457457        if (m_isStopped) {
  • trunk/Source/WebCore/Modules/cache/DOMCacheEngine.cpp

    r278669 r280953  
    2929
    3030#include "CacheQueryOptions.h"
     31#include "CrossOriginAccessControl.h"
    3132#include "Exception.h"
    3233#include "HTTPParsers.h"
     
    5253    case Error::Stopped:
    5354        return Exception { TypeError, "Context is stopped"_s };
     55    case Error::CORP:
     56        return Exception { TypeError, "Cross-Origin-Resource-Policy failure"_s };
    5457    }
    5558    ASSERT_NOT_REACHED();
  • trunk/Source/WebCore/Modules/cache/DOMCacheEngine.h

    r278253 r280953  
    4242namespace DOMCacheEngine {
    4343
    44 enum class Error {
     44enum class Error : uint8_t {
    4545    NotImplemented,
    4646    ReadDisk,
     
    4848    QuotaExceeded,
    4949    Internal,
    50     Stopped
     50    Stopped,
     51    CORP
    5152};
    5253
     
    171172        WebCore::DOMCacheEngine::Error::WriteDisk,
    172173        WebCore::DOMCacheEngine::Error::QuotaExceeded,
    173         WebCore::DOMCacheEngine::Error::Internal
     174        WebCore::DOMCacheEngine::Error::Internal,
     175        WebCore::DOMCacheEngine::Error::Stopped,
     176        WebCore::DOMCacheEngine::Error::CORP
    174177    >;
    175178};
  • trunk/Source/WebCore/Modules/cache/RetrieveRecordsOptions.h

    r278253 r280953  
    2727#pragma once
    2828
     29#include "CrossOriginEmbedderPolicy.h"
    2930#include "ResourceRequest.h"
     31#include "SecurityOrigin.h"
    3032
    3133namespace WebCore {
    3234
    3335struct RetrieveRecordsOptions {
    34     RetrieveRecordsOptions isolatedCopy() const { return { request.isolatedCopy(), ignoreSearch, ignoreMethod, ignoreVary, shouldProvideResponse }; }
     36    RetrieveRecordsOptions isolatedCopy() const { return { request.isolatedCopy(), crossOriginEmbedderPolicy.isolatedCopy(), sourceOrigin->isolatedCopy(), ignoreSearch, ignoreMethod, ignoreVary, shouldProvideResponse }; }
    3537
    3638    template<class Encoder> void encode(Encoder&) const;
     
    3840
    3941    ResourceRequest request;
     42    CrossOriginEmbedderPolicy crossOriginEmbedderPolicy;
     43    Ref<SecurityOrigin> sourceOrigin;
    4044    bool ignoreSearch { false };
    4145    bool ignoreMethod { false };
     
    4650template<class Encoder> inline void RetrieveRecordsOptions::encode(Encoder& encoder) const
    4751{
    48     encoder << request << ignoreSearch << ignoreMethod << ignoreVary << shouldProvideResponse;
     52    encoder << request << crossOriginEmbedderPolicy << sourceOrigin.get() << ignoreSearch << ignoreMethod << ignoreVary << shouldProvideResponse;
    4953}
    5054
     
    5458    decoder >> request;
    5559    if (!request)
     60        return std::nullopt;
     61
     62    std::optional<CrossOriginEmbedderPolicy> crossOriginEmbedderPolicy;
     63    decoder >> crossOriginEmbedderPolicy;
     64    if (!crossOriginEmbedderPolicy)
     65        return std::nullopt;
     66
     67    auto sourceOrigin = SecurityOrigin::decode(decoder);
     68    if (!sourceOrigin)
    5669        return std::nullopt;
    5770
     
    7689        return std::nullopt;
    7790
    78     return { { WTFMove(*request), WTFMove(*ignoreSearch), WTFMove(*ignoreMethod), WTFMove(*ignoreVary), WTFMove(*shouldProvideResponse) } };
     91    return { { WTFMove(*request), WTFMove(*crossOriginEmbedderPolicy), sourceOrigin.releaseNonNull(), WTFMove(*ignoreSearch), WTFMove(*ignoreMethod), WTFMove(*ignoreVary), WTFMove(*shouldProvideResponse) } };
    7992}
    8093
  • trunk/Source/WebCore/dom/Document.cpp

    r280870 r280953  
    62716271    contentSecurityPolicy()->updateSourceSelf(ownerFrame->document()->securityOrigin());
    62726272
     6273    setCrossOriginEmbedderPolicy(ownerFrame->document()->crossOriginEmbedderPolicy());
     6274
    62736275    // https://html.spec.whatwg.org/multipage/browsers.html#creating-a-new-browsing-context (Step 12)
    62746276    // If creator is non-null and creator's origin is same origin with creator's relevant settings object's top-level origin, then set coop
  • trunk/Source/WebCore/dom/SecurityContext.h

    r280504 r280953  
    2828#pragma once
    2929
     30#include "CrossOriginEmbedderPolicy.h"
    3031#include <memory>
    3132#include <wtf/Forward.h>
     
    8889    void setContentSecurityPolicy(std::unique_ptr<ContentSecurityPolicy>&&);
    8990
     91    const CrossOriginEmbedderPolicy& crossOriginEmbedderPolicy() const { return m_crossOriginEmbedderPolicy; }
     92    void setCrossOriginEmbedderPolicy(const CrossOriginEmbedderPolicy& crossOriginEmbedderPolicy) { m_crossOriginEmbedderPolicy = crossOriginEmbedderPolicy; }
     93
    9094    WEBCORE_EXPORT SecurityOrigin* securityOrigin() const;
    9195
     
    131135    RefPtr<SecurityOriginPolicy> m_securityOriginPolicy;
    132136    std::unique_ptr<ContentSecurityPolicy> m_contentSecurityPolicy;
     137    CrossOriginEmbedderPolicy m_crossOriginEmbedderPolicy;
    133138    SandboxFlags m_creationSandboxFlags { SandboxNone };
    134139    SandboxFlags m_sandboxFlags { SandboxNone };
  • trunk/Source/WebCore/loader/CrossOriginAccessControl.cpp

    r279750 r280953  
    2929
    3030#include "CachedResourceRequest.h"
     31#include "CrossOriginEmbedderPolicy.h"
    3132#include "CrossOriginPreflightResultCache.h"
    3233#include "HTTPHeaderNames.h"
     
    281282}
    282283
    283 static inline bool shouldCrossOriginResourcePolicyCancelLoad(const SecurityOrigin& origin, const ResourceResponse& response)
    284 {
    285     if (origin.canRequest(response.url()))
     284// https://fetch.spec.whatwg.org/#cross-origin-resource-policy-internal-check
     285static inline bool shouldCrossOriginResourcePolicyCancelLoad(CrossOriginEmbedderPolicyValue coep, const SecurityOrigin& origin, const ResourceResponse& response, ForNavigation forNavigation)
     286{
     287    if (forNavigation == ForNavigation::Yes && coep != CrossOriginEmbedderPolicyValue::RequireCORP)
    286288        return false;
    287289
     290    if (response.isNull() || origin.canRequest(response.url()))
     291        return false;
     292
    288293    auto policy = parseCrossOriginResourcePolicyHeader(response.httpHeaderField(HTTPHeaderName::CrossOriginResourcePolicy));
     294
     295    // https://fetch.spec.whatwg.org/#cross-origin-resource-policy-internal-check (step 4).
     296    if ((policy == CrossOriginResourcePolicy::None || policy == CrossOriginResourcePolicy::Invalid) && coep == CrossOriginEmbedderPolicyValue::RequireCORP)
     297        return true;
    289298
    290299    if (policy == CrossOriginResourcePolicy::SameOrigin)
     
    305314}
    306315
    307 std::optional<ResourceError> validateCrossOriginResourcePolicy(const SecurityOrigin& origin, const URL& requestURL, const ResourceResponse& response)
    308 {
    309     if (shouldCrossOriginResourcePolicyCancelLoad(origin, response))
     316std::optional<ResourceError> validateCrossOriginResourcePolicy(CrossOriginEmbedderPolicyValue coep, const SecurityOrigin& origin, const URL& requestURL, const ResourceResponse& response, ForNavigation forNavigation)
     317{
     318    if (shouldCrossOriginResourcePolicyCancelLoad(coep, origin, response, forNavigation))
    310319        return ResourceError { errorDomainWebKitInternal, 0, requestURL, makeString("Cancelled load to ", response.url().stringCenterEllipsizedToLength(), " because it violates the resource's Cross-Origin-Resource-Policy response header."), ResourceError::Type::AccessControl };
    311320    return std::nullopt;
  • trunk/Source/WebCore/loader/CrossOriginAccessControl.h

    r278849 r280953  
    5050struct ResourceLoaderOptions;
    5151
     52enum class CrossOriginEmbedderPolicyValue : bool;
     53
    5254WEBCORE_EXPORT bool isSimpleCrossOriginAccessRequest(const String& method, const HTTPHeaderMap&);
    5355bool isOnAccessControlSimpleRequestMethodAllowlist(const String&);
     
    8587WEBCORE_EXPORT Expected<void, String> validatePreflightResponse(PAL::SessionID, const ResourceRequest&, const ResourceResponse&, StoredCredentialsPolicy, const SecurityOrigin&, const CrossOriginAccessControlCheckDisabler*);
    8688
    87 WEBCORE_EXPORT std::optional<ResourceError> validateCrossOriginResourcePolicy(const SecurityOrigin&, const URL&, const ResourceResponse&);
     89enum class ForNavigation : bool { No, Yes };
     90WEBCORE_EXPORT std::optional<ResourceError> validateCrossOriginResourcePolicy(CrossOriginEmbedderPolicyValue, const SecurityOrigin&, const URL&, const ResourceResponse&, ForNavigation);
    8891std::optional<ResourceError> validateRangeRequestedFlag(const ResourceRequest&, const ResourceResponse&);
    8992String validateCrossOriginRedirectionURL(const URL&);
  • trunk/Source/WebCore/loader/CrossOriginEmbedderPolicy.cpp

    r280890 r280953  
    3131#include "ResourceResponse.h"
    3232#include "ScriptExecutionContext.h"
     33#include "SecurityOrigin.h"
    3334
    3435namespace WebCore {
    3536
    3637// https://html.spec.whatwg.org/multipage/origin.html#obtain-an-embedder-policy
    37 CrossOriginEmbedderPolicy obtainCrossOriginEmbedderPolicy(const ResourceResponse& response, const ScriptExecutionContext& context)
     38CrossOriginEmbedderPolicy obtainCrossOriginEmbedderPolicy(const ResourceResponse& response, IsSecureContext isSecureContext)
    3839{
    3940    auto parseCOEPHeader = [&response](HTTPHeaderName headerName, auto& value, auto& reportingEndpoint) {
     
    4647
    4748    CrossOriginEmbedderPolicy policy;
    48     // FIXME: about:blank should be marked as secure as per https://w3c.github.io/webappsec-secure-contexts/#potentially-trustworthy-url.
    49     if (!context.isSecureContext() && context.url() != aboutBlankURL() && !context.url().isEmpty())
     49    if (isSecureContext == IsSecureContext::No)
    5050        return policy;
    5151
     
    5555}
    5656
     57CrossOriginEmbedderPolicy obtainCrossOriginEmbedderPolicy(const ResourceResponse& response, const ScriptExecutionContext& context)
     58{
     59    if (!context.settingsValues().crossOriginEmbedderPolicyEnabled)
     60        return { };
     61
     62    // FIXME: about:blank should be marked as secure as per https://w3c.github.io/webappsec-secure-contexts/#potentially-trustworthy-url.
     63    auto isSecureContext = context.isSecureContext() || context.url() == aboutBlankURL() || context.url().isEmpty() ? IsSecureContext::Yes : IsSecureContext::No;
     64    return obtainCrossOriginEmbedderPolicy(response, isSecureContext);
     65}
     66
     67CrossOriginEmbedderPolicy CrossOriginEmbedderPolicy::isolatedCopy() const
     68{
     69    return {
     70        value,
     71        reportingEndpoint.isolatedCopy(),
     72        reportOnlyValue,
     73        reportOnlyReportingEndpoint.isolatedCopy()
     74    };
     75}
     76
    5777} // namespace WebCore
  • trunk/Source/WebCore/loader/CrossOriginEmbedderPolicy.h

    r280504 r280953  
    4545    CrossOriginEmbedderPolicyValue reportOnlyValue { CrossOriginEmbedderPolicyValue::UnsafeNone };
    4646    String reportOnlyReportingEndpoint;
     47
     48    CrossOriginEmbedderPolicy isolatedCopy() const;
     49    template<class Encoder> void encode(Encoder&) const;
     50    template<class Decoder> static std::optional<CrossOriginEmbedderPolicy> decode(Decoder&);
    4751};
     52
     53template<class Encoder>
     54void CrossOriginEmbedderPolicy::encode(Encoder& encoder) const
     55{
     56    encoder << value << reportingEndpoint << reportOnlyValue << reportOnlyReportingEndpoint;
     57}
     58
     59template<class Decoder>
     60std::optional<CrossOriginEmbedderPolicy> CrossOriginEmbedderPolicy::decode(Decoder& decoder)
     61{
     62    std::optional<CrossOriginEmbedderPolicyValue> value;
     63    decoder >> value;
     64    if (!value)
     65        return std::nullopt;
     66
     67    std::optional<String> reportingEndpoint;
     68    decoder >> reportingEndpoint;
     69    if (!reportingEndpoint)
     70        return std::nullopt;
     71
     72    std::optional<CrossOriginEmbedderPolicyValue> reportOnlyValue;
     73    decoder >> reportOnlyValue;
     74    if (!reportOnlyValue)
     75        return std::nullopt;
     76
     77    std::optional<String> reportOnlyReportingEndpoint;
     78    decoder >> reportOnlyReportingEndpoint;
     79    if (!reportOnlyReportingEndpoint)
     80        return std::nullopt;
     81
     82    return {{
     83        *value,
     84        WTFMove(*reportingEndpoint),
     85        *reportOnlyValue,
     86        WTFMove(*reportOnlyReportingEndpoint)
     87    }};
     88}
    4889
    4990CrossOriginEmbedderPolicy obtainCrossOriginEmbedderPolicy(const ResourceResponse&, const ScriptExecutionContext&);
    5091
     92enum class IsSecureContext : bool { No, Yes };
     93WEBCORE_EXPORT CrossOriginEmbedderPolicy obtainCrossOriginEmbedderPolicy(const ResourceResponse&, IsSecureContext);
     94
    5195} // namespace WebCore
  • trunk/Source/WebCore/loader/CrossOriginOpenerPolicy.cpp

    r280890 r280953  
    7676
    7777    CrossOriginOpenerPolicy policy;
     78    if (!context.settingsValues().crossOriginOpenerPolicyEnabled)
     79        return policy;
    7880    // FIXME: about:blank should be marked as secure as per https://w3c.github.io/webappsec-secure-contexts/#potentially-trustworthy-url.
    7981    if (!context.isSecureContext() && context.url() != aboutBlankURL() && !context.url().isEmpty())
  • trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp

    r278800 r280953  
    7171namespace WebCore {
    7272
    73 void DocumentThreadableLoader::loadResourceSynchronously(Document& document, ResourceRequest&& request, ThreadableLoaderClient& client, const ThreadableLoaderOptions& options, RefPtr<SecurityOrigin>&& origin, std::unique_ptr<ContentSecurityPolicy>&& contentSecurityPolicy)
     73void DocumentThreadableLoader::loadResourceSynchronously(Document& document, ResourceRequest&& request, ThreadableLoaderClient& client, const ThreadableLoaderOptions& options, RefPtr<SecurityOrigin>&& origin, std::unique_ptr<ContentSecurityPolicy>&& contentSecurityPolicy, std::optional<CrossOriginEmbedderPolicy>&& crossOriginEmbedderPolicy)
    7474{
    7575    // The loader will be deleted as soon as this function exits.
    76     Ref<DocumentThreadableLoader> loader = adoptRef(*new DocumentThreadableLoader(document, client, LoadSynchronously, WTFMove(request), options, WTFMove(origin), WTFMove(contentSecurityPolicy), String(), ShouldLogError::Yes));
     76    Ref<DocumentThreadableLoader> loader = adoptRef(*new DocumentThreadableLoader(document, client, LoadSynchronously, WTFMove(request), options, WTFMove(origin), WTFMove(contentSecurityPolicy), WTFMove(crossOriginEmbedderPolicy), String(), ShouldLogError::Yes));
    7777    ASSERT(loader->hasOneRef());
    7878}
     
    8080void DocumentThreadableLoader::loadResourceSynchronously(Document& document, ResourceRequest&& request, ThreadableLoaderClient& client, const ThreadableLoaderOptions& options)
    8181{
    82     loadResourceSynchronously(document, WTFMove(request), client, options, nullptr, nullptr);
     82    loadResourceSynchronously(document, WTFMove(request), client, options, nullptr, nullptr, std::nullopt);
    8383}
    8484
    8585RefPtr<DocumentThreadableLoader> DocumentThreadableLoader::create(Document& document, ThreadableLoaderClient& client,
    8686ResourceRequest&& request, const ThreadableLoaderOptions& options, RefPtr<SecurityOrigin>&& origin,
    87 std::unique_ptr<ContentSecurityPolicy>&& contentSecurityPolicy, String&& referrer, ShouldLogError shouldLogError)
    88 {
    89     RefPtr<DocumentThreadableLoader> loader = adoptRef(new DocumentThreadableLoader(document, client, LoadAsynchronously, WTFMove(request), options, WTFMove(origin), WTFMove(contentSecurityPolicy), WTFMove(referrer), shouldLogError));
     87std::unique_ptr<ContentSecurityPolicy>&& contentSecurityPolicy, std::optional<CrossOriginEmbedderPolicy>&& crossOriginEmbedderPolicy, String&& referrer, ShouldLogError shouldLogError)
     88{
     89    RefPtr<DocumentThreadableLoader> loader = adoptRef(new DocumentThreadableLoader(document, client, LoadAsynchronously, WTFMove(request), options, WTFMove(origin), WTFMove(contentSecurityPolicy), WTFMove(crossOriginEmbedderPolicy), WTFMove(referrer), shouldLogError));
    9090    if (!loader->isLoading())
    9191        loader = nullptr;
     
    9595RefPtr<DocumentThreadableLoader> DocumentThreadableLoader::create(Document& document, ThreadableLoaderClient& client, ResourceRequest&& request, const ThreadableLoaderOptions& options, String&& referrer)
    9696{
    97     return create(document, client, WTFMove(request), options, nullptr, nullptr, WTFMove(referrer), ShouldLogError::Yes);
     97    return create(document, client, WTFMove(request), options, nullptr, nullptr, std::nullopt, WTFMove(referrer), ShouldLogError::Yes);
    9898}
    9999
     
    116116}
    117117
    118 DocumentThreadableLoader::DocumentThreadableLoader(Document& document, ThreadableLoaderClient& client, BlockingBehavior blockingBehavior, ResourceRequest&& request, const ThreadableLoaderOptions& options, RefPtr<SecurityOrigin>&& origin, std::unique_ptr<ContentSecurityPolicy>&& contentSecurityPolicy, String&& referrer, ShouldLogError shouldLogError)
     118DocumentThreadableLoader::DocumentThreadableLoader(Document& document, ThreadableLoaderClient& client, BlockingBehavior blockingBehavior, ResourceRequest&& request, const ThreadableLoaderOptions& options, RefPtr<SecurityOrigin>&& origin, std::unique_ptr<ContentSecurityPolicy>&& contentSecurityPolicy, std::optional<CrossOriginEmbedderPolicy>&& crossOriginEmbedderPolicy, String&& referrer, ShouldLogError shouldLogError)
    119119    : m_client(&client)
    120120    , m_document(document)
     
    127127    , m_delayCallbacksForIntegrityCheck(!m_options.integrity.isEmpty())
    128128    , m_contentSecurityPolicy(WTFMove(contentSecurityPolicy))
     129    , m_crossOriginEmbedderPolicy(WTFMove(crossOriginEmbedderPolicy))
    129130    , m_shouldLogError(shouldLogError)
    130131{
     
    167168
    168169    m_options.cspResponseHeaders = m_options.contentSecurityPolicyEnforcement != ContentSecurityPolicyEnforcement::DoNotEnforce ? this->contentSecurityPolicy().responseHeaders() : ContentSecurityPolicyResponseHeaders { };
     170    m_options.crossOriginEmbedderPolicy = this->crossOriginEmbedderPolicy();
    169171
    170172    // As per step 11 of https://fetch.spec.whatwg.org/#main-fetch, data scheme (if same-origin data-URL flag is set) and about scheme are considered same-origin.
     
    711713}
    712714
     715const CrossOriginEmbedderPolicy& DocumentThreadableLoader::crossOriginEmbedderPolicy() const
     716{
     717    if (m_crossOriginEmbedderPolicy)
     718        return *m_crossOriginEmbedderPolicy;
     719    return m_document.crossOriginEmbedderPolicy();
     720}
     721
    713722void DocumentThreadableLoader::reportRedirectionWithBadScheme(const URL& url)
    714723{
  • trunk/Source/WebCore/loader/DocumentThreadableLoader.h

    r278516 r280953  
    4848        WTF_MAKE_FAST_ALLOCATED;
    4949    public:
    50         static void loadResourceSynchronously(Document&, ResourceRequest&&, ThreadableLoaderClient&, const ThreadableLoaderOptions&, RefPtr<SecurityOrigin>&&, std::unique_ptr<ContentSecurityPolicy>&&);
     50        static void loadResourceSynchronously(Document&, ResourceRequest&&, ThreadableLoaderClient&, const ThreadableLoaderOptions&, RefPtr<SecurityOrigin>&&, std::unique_ptr<ContentSecurityPolicy>&&, std::optional<CrossOriginEmbedderPolicy>&&);
    5151        static void loadResourceSynchronously(Document&, ResourceRequest&&, ThreadableLoaderClient&, const ThreadableLoaderOptions&);
    5252
    5353        enum class ShouldLogError { No, Yes };
    54         static RefPtr<DocumentThreadableLoader> create(Document&, ThreadableLoaderClient&, ResourceRequest&&, const ThreadableLoaderOptions&, RefPtr<SecurityOrigin>&&, std::unique_ptr<ContentSecurityPolicy>&&, String&& referrer, ShouldLogError);
     54        static RefPtr<DocumentThreadableLoader> create(Document&, ThreadableLoaderClient&, ResourceRequest&&, const ThreadableLoaderOptions&, RefPtr<SecurityOrigin>&&, std::unique_ptr<ContentSecurityPolicy>&&, std::optional<CrossOriginEmbedderPolicy>&&, String&& referrer, ShouldLogError);
    5555        static RefPtr<DocumentThreadableLoader> create(Document&, ThreadableLoaderClient&, ResourceRequest&&, const ThreadableLoaderOptions&, String&& referrer = String());
    5656
     
    7979        };
    8080
    81         DocumentThreadableLoader(Document&, ThreadableLoaderClient&, BlockingBehavior, ResourceRequest&&, const ThreadableLoaderOptions&, RefPtr<SecurityOrigin>&&, std::unique_ptr<ContentSecurityPolicy>&&, String&&, ShouldLogError);
     81        DocumentThreadableLoader(Document&, ThreadableLoaderClient&, BlockingBehavior, ResourceRequest&&, const ThreadableLoaderOptions&, RefPtr<SecurityOrigin>&&, std::unique_ptr<ContentSecurityPolicy>&&, std::optional<CrossOriginEmbedderPolicy>&&, String&&, ShouldLogError);
    8282
    8383        void clearResource();
     
    108108        SecurityOrigin& securityOrigin() const;
    109109        const ContentSecurityPolicy& contentSecurityPolicy() const;
     110        const CrossOriginEmbedderPolicy& crossOriginEmbedderPolicy() const;
    110111
    111112        Document& document() { return m_document; }
     
    135136        bool m_delayCallbacksForIntegrityCheck;
    136137        std::unique_ptr<ContentSecurityPolicy> m_contentSecurityPolicy;
     138        std::optional<CrossOriginEmbedderPolicy> m_crossOriginEmbedderPolicy;
    137139        std::optional<CrossOriginPreflightChecker> m_preflightChecker;
    138140        std::optional<HTTPHeaderMap> m_originalHeaders;
  • trunk/Source/WebCore/loader/DocumentWriter.cpp

    r280504 r280953  
    176176        document->setSecurityOriginPolicy(ownerDocument->securityOriginPolicy());
    177177        document->setStrictMixedContentMode(ownerDocument->isStrictMixedContentMode());
     178        document->setCrossOriginEmbedderPolicy(ownerDocument->crossOriginEmbedderPolicy());
    178179
    179180        document->setContentSecurityPolicy(makeUnique<ContentSecurityPolicy>(URL { url }, document));
     
    184185            document->setContentSecurityPolicy(makeUnique<ContentSecurityPolicy>(URL { url }, document));
    185186            document->contentSecurityPolicy()->copyStateFrom(existingDocument->contentSecurityPolicy());
     187            document->setCrossOriginEmbedderPolicy(existingDocument->crossOriginEmbedderPolicy());
    186188
    187189            // Fix up 'self' for blob: and data:, which is inherited from its embedding document or opener.
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r280870 r280953  
    5151#include "ContentSecurityPolicy.h"
    5252#include "CrossOriginAccessControl.h"
     53#include "CrossOriginEmbedderPolicy.h"
    5354#include "DOMWindow.h"
    5455#include "DatabaseManager.h"
     
    751752        m_frame.document()->contentSecurityPolicy()->didReceiveHeaders(ContentSecurityPolicyResponseHeaders(m_documentLoader->response()), referrer(), ContentSecurityPolicy::ReportParsingErrors::No);
    752753
     754        if (m_frame.document()->url().protocolIsInHTTPFamily())
     755            m_frame.document()->setCrossOriginEmbedderPolicy(obtainCrossOriginEmbedderPolicy(m_documentLoader->response(), *m_frame.document()));
     756
    753757        String referrerPolicy = m_documentLoader->response().httpHeaderField(HTTPHeaderName::ReferrerPolicy);
    754758        if (!referrerPolicy.isNull())
  • trunk/Source/WebCore/loader/ResourceLoaderOptions.h

    r263218 r280953  
    3333#include "ContentSecurityPolicyResponseHeaders.h"
    3434#include "CrossOriginAccessControl.h"
     35#include "CrossOriginEmbedderPolicy.h"
    3536#include "FetchOptions.h"
    3637#include "HTTPHeaderNames.h"
     
    201202#endif
    202203    Markable<ContentSecurityPolicyResponseHeaders, ContentSecurityPolicyResponseHeaders::MarkableTraits> cspResponseHeaders;
     204    std::optional<CrossOriginEmbedderPolicy> crossOriginEmbedderPolicy;
    203205    OptionSet<HTTPHeadersToKeepFromCleaning> httpHeadersToKeep;
    204206    uint8_t maxRedirectCount { 20 };
  • trunk/Source/WebCore/loader/WorkerThreadableLoader.cpp

    r278516 r280953  
    125125    contentSecurityPolicyCopy->copyStateFrom(contentSecurityPolicy);
    126126    contentSecurityPolicyCopy->copyUpgradeInsecureRequestStateFrom(*contentSecurityPolicy);
     127    auto crossOriginEmbedderPolicyCopy = globalScope.crossOriginEmbedderPolicy().isolatedCopy();
    127128
    128129    auto optionsCopy = makeUnique<LoaderTaskOptions>(options, request.httpReferrer().isNull() ? outgoingReferrer : request.httpReferrer(), WTFMove(securityOriginCopy));
     
    142143
    143144    // Can we benefit from request being an r-value to create more efficiently its isolated copy?
    144     m_loaderProxy.postTaskToLoader([this, request = request.isolatedCopy(), options = WTFMove(optionsCopy), contentSecurityPolicyCopy = WTFMove(contentSecurityPolicyCopy)](ScriptExecutionContext& context) mutable {
     145    m_loaderProxy.postTaskToLoader([this, request = request.isolatedCopy(), options = WTFMove(optionsCopy), contentSecurityPolicyCopy = WTFMove(contentSecurityPolicyCopy), crossOriginEmbedderPolicyCopy = WTFMove(crossOriginEmbedderPolicyCopy)](ScriptExecutionContext& context) mutable {
    145146        ASSERT(isMainThread());
    146147        Document& document = downcast<Document>(context);
     
    148149        // FIXME: If the site requests a local resource, then this will return a non-zero value but the sync path will return a 0 value.
    149150        // Either this should return 0 or the other code path should call a failure callback.
    150         m_mainThreadLoader = DocumentThreadableLoader::create(document, *this, WTFMove(request), options->options, WTFMove(options->origin), WTFMove(contentSecurityPolicyCopy), WTFMove(options->referrer), DocumentThreadableLoader::ShouldLogError::No);
     151        m_mainThreadLoader = DocumentThreadableLoader::create(document, *this, WTFMove(request), options->options, WTFMove(options->origin), WTFMove(contentSecurityPolicyCopy), WTFMove(crossOriginEmbedderPolicyCopy), WTFMove(options->referrer), DocumentThreadableLoader::ShouldLogError::No);
    151152        ASSERT(m_mainThreadLoader || m_loadingFinished);
    152153    });
  • trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp

    r280081 r280953  
    10061006    case Use:
    10071007        ASSERT(resource);
     1008        if (request.options().mode == FetchOptions::Mode::Navigate && !frame.isMainFrame()) {
     1009            if (auto* parentDocument = frame.tree().parent() ? frame.tree().parent()->document() : nullptr) {
     1010                auto coep = parentDocument->crossOriginEmbedderPolicy().value;
     1011                if (auto error = validateCrossOriginResourcePolicy(coep, parentDocument->securityOrigin(), request.resourceRequest().url(), resource->response(), ForNavigation::Yes))
     1012                    return makeUnexpected(WTFMove(*error));
     1013            }
     1014        }
    10081015        if (request.options().mode == FetchOptions::Mode::NoCors) {
    1009             if (auto error = validateCrossOriginResourcePolicy(*request.origin(), request.resourceRequest().url(), resource->response()))
     1016            auto coep = document() ? document()->crossOriginEmbedderPolicy().value : CrossOriginEmbedderPolicyValue::UnsafeNone;
     1017            if (auto error = validateCrossOriginResourcePolicy(coep, *request.origin(), request.resourceRequest().url(), resource->response(), ForNavigation::No))
    10101018                return makeUnexpected(WTFMove(*error));
    10111019
  • trunk/Source/WebCore/page/SecurityOrigin.h

    r278806 r280953  
    9090    // own protocol, or, when relevant, on the protocol of its "inner URL"
    9191    // Protocols like blob: and filesystem: fall into this latter category.
    92     static bool isSecure(const URL&);
     92    WEBCORE_EXPORT static bool isSecure(const URL&);
    9393
    9494    // This method implements the "same origin-domain" algorithm from the HTML Standard:
  • trunk/Source/WebCore/platform/network/HTTPParsers.cpp

    r280686 r280953  
    10261026        return CrossOriginResourcePolicy::SameSite;
    10271027
     1028    if (strippedHeader == "cross-origin")
     1029        return CrossOriginResourcePolicy::CrossOrigin;
     1030
    10281031    return CrossOriginResourcePolicy::Invalid;
    10291032}
  • trunk/Source/WebCore/platform/network/HTTPParsers.h

    r280504 r280953  
    6262};
    6363
    64 enum class CrossOriginResourcePolicy {
     64enum class CrossOriginResourcePolicy : uint8_t {
    6565    None,
     66    CrossOrigin,
    6667    SameOrigin,
    6768    SameSite,
  • trunk/Source/WebCore/workers/Worker.cpp

    r278372 r280953  
    229229            responseURL.setFragmentIdentifier(m_scriptLoader->url().fragmentIdentifier());
    230230    }
    231     m_contextProxy.startWorkerGlobalScope(responseURL, m_name, context->userAgent(responseURL), isOnline, m_scriptLoader->script(), contentSecurityPolicyResponseHeaders, m_shouldBypassMainWorldContentSecurityPolicy, m_workerCreationTime, referrerPolicy, m_type, m_credentials, m_runtimeFlags);
     231    m_contextProxy.startWorkerGlobalScope(responseURL, m_name, context->userAgent(responseURL), isOnline, m_scriptLoader->script(), contentSecurityPolicyResponseHeaders, m_shouldBypassMainWorldContentSecurityPolicy, m_scriptLoader->crossOriginEmbedderPolicy(), m_workerCreationTime, referrerPolicy, m_type, m_credentials, m_runtimeFlags);
    232232    InspectorInstrumentation::scriptImported(*context, m_scriptLoader->identifier(), m_scriptLoader->script().toString());
    233233}
  • trunk/Source/WebCore/workers/WorkerGlobalScope.cpp

    r280504 r280953  
    103103    setSecurityOriginPolicy(SecurityOriginPolicy::create(WTFMove(origin)));
    104104    setContentSecurityPolicy(makeUnique<ContentSecurityPolicy>(URL { m_url }, *this));
     105    setCrossOriginEmbedderPolicy(params.crossOriginEmbedderPolicy);
    105106}
    106107
  • trunk/Source/WebCore/workers/WorkerGlobalScopeProxy.h

    r276384 r280953  
    5252    static WorkerGlobalScopeProxy& create(Worker&);
    5353
    54     virtual void startWorkerGlobalScope(const URL& scriptURL, const String& name, const String& userAgent, bool isOnline, const ScriptBuffer& sourceCode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, MonotonicTime timeOrigin, ReferrerPolicy, WorkerType, FetchRequestCredentials, JSC::RuntimeFlags) = 0;
     54    virtual void startWorkerGlobalScope(const URL& scriptURL, const String& name, const String& userAgent, bool isOnline, const ScriptBuffer& sourceCode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const CrossOriginEmbedderPolicy&, MonotonicTime timeOrigin, ReferrerPolicy, WorkerType, FetchRequestCredentials, JSC::RuntimeFlags) = 0;
    5555    virtual void terminateWorkerGlobalScope() = 0;
    5656    virtual void postMessageToWorkerGlobalScope(MessageWithMessagePorts&&) = 0;
  • trunk/Source/WebCore/workers/WorkerMessagingProxy.cpp

    r275465 r280953  
    7676}
    7777
    78 void WorkerMessagingProxy::startWorkerGlobalScope(const URL& scriptURL, const String& name, const String& userAgent, bool isOnline, const ScriptBuffer& sourceCode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, MonotonicTime timeOrigin, ReferrerPolicy referrerPolicy, WorkerType workerType, FetchRequestCredentials credentials, JSC::RuntimeFlags runtimeFlags)
     78void WorkerMessagingProxy::startWorkerGlobalScope(const URL& scriptURL, const String& name, const String& userAgent, bool isOnline, const ScriptBuffer& sourceCode, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders, bool shouldBypassMainWorldContentSecurityPolicy, const CrossOriginEmbedderPolicy& crossOriginEmbedderPolicy, MonotonicTime timeOrigin, ReferrerPolicy referrerPolicy, WorkerType workerType, FetchRequestCredentials credentials, JSC::RuntimeFlags runtimeFlags)
    7979{
    8080    // FIXME: This need to be revisited when we support nested worker one day
     
    8888    SocketProvider* socketProvider = document.socketProvider();
    8989
    90     WorkerParameters params = { scriptURL, name, identifier, userAgent, isOnline, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, timeOrigin, referrerPolicy, workerType, credentials, document.settingsValues() };
     90    WorkerParameters params = { scriptURL, name, identifier, userAgent, isOnline, contentSecurityPolicyResponseHeaders, shouldBypassMainWorldContentSecurityPolicy, crossOriginEmbedderPolicy, timeOrigin, referrerPolicy, workerType, credentials, document.settingsValues() };
    9191    auto thread = DedicatedWorkerThread::create(params, sourceCode, *this, *this, *this, startMode, document.topOrigin(), proxy, socketProvider, runtimeFlags);
    9292
  • trunk/Source/WebCore/workers/WorkerMessagingProxy.h

    r275465 r280953  
    5151    // Implementations of WorkerGlobalScopeProxy.
    5252    // (Only use these functions in the worker object thread.)
    53     void startWorkerGlobalScope(const URL& scriptURL, const String& name, const String& userAgent, bool isOnline, const ScriptBuffer& sourceCode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, MonotonicTime timeOrigin, ReferrerPolicy, WorkerType, FetchRequestCredentials, JSC::RuntimeFlags) final;
     53    void startWorkerGlobalScope(const URL& scriptURL, const String& name, const String& userAgent, bool isOnline, const ScriptBuffer& sourceCode, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, const CrossOriginEmbedderPolicy&, MonotonicTime timeOrigin, ReferrerPolicy, WorkerType, FetchRequestCredentials, JSC::RuntimeFlags) final;
    5454    void terminateWorkerGlobalScope() final;
    5555    void postMessageToWorkerGlobalScope(MessageWithMessagePorts&&) final;
  • trunk/Source/WebCore/workers/WorkerScriptLoader.cpp

    r279602 r280953  
    5959    m_url = url;
    6060    m_destination = FetchOptions::Destination::Script;
     61    m_isSecureContext = workerGlobalScope.isSecureContext();
    6162
    6263#if ENABLE(SERVICE_WORKER)
     
    117118    m_url = scriptRequest.url();
    118119    m_destination = fetchOptions.destination;
     120    m_isSecureContext = scriptExecutionContext.isSecureContext();
    119121
    120122    ASSERT(scriptRequest.httpMethod() == "GET");
     
    192194    m_isRedirected = response.isRedirected();
    193195    m_contentSecurityPolicy = ContentSecurityPolicyResponseHeaders { response };
     196    m_crossOriginEmbedderPolicy = obtainCrossOriginEmbedderPolicy(response, m_isSecureContext ? IsSecureContext::Yes : IsSecureContext::No);
    194197    m_referrerPolicy = response.httpHeaderField(HTTPHeaderName::ReferrerPolicy);
    195198    if (m_client)
  • trunk/Source/WebCore/workers/WorkerScriptLoader.h

    r278516 r280953  
    2929#include "CertificateInfo.h"
    3030#include "ContentSecurityPolicyResponseHeaders.h"
     31#include "CrossOriginEmbedderPolicy.h"
    3132#include "FetchOptions.h"
    3233#include "ResourceError.h"
     
    6768    const ContentSecurityPolicyResponseHeaders& contentSecurityPolicy() const { return m_contentSecurityPolicy; }
    6869    const String& referrerPolicy() const { return m_referrerPolicy; }
     70    const CrossOriginEmbedderPolicy& crossOriginEmbedderPolicy() const { return m_crossOriginEmbedderPolicy; }
    6971    const URL& url() const { return m_url; }
    7072    const URL& responseURL() const;
     
    108110    ContentSecurityPolicyResponseHeaders m_contentSecurityPolicy;
    109111    String m_referrerPolicy;
     112    CrossOriginEmbedderPolicy m_crossOriginEmbedderPolicy;
    110113    unsigned long m_identifier { 0 };
    111114    bool m_failed { false };
    112115    bool m_finishing { false };
    113116    bool m_isRedirected { false };
     117    bool m_isSecureContext { false };
    114118    ResourceResponse::Source m_responseSource { ResourceResponse::Source::Unknown };
    115119    ResourceError m_error;
  • trunk/Source/WebCore/workers/WorkerThread.cpp

    r278253 r280953  
    5656        contentSecurityPolicyResponseHeaders,
    5757        shouldBypassMainWorldContentSecurityPolicy,
     58        crossOriginEmbedderPolicy.isolatedCopy(),
    5859        timeOrigin,
    5960        referrerPolicy,
  • trunk/Source/WebCore/workers/WorkerThread.h

    r275465 r280953  
    2727
    2828#include "ContentSecurityPolicyResponseHeaders.h"
     29#include "CrossOriginEmbedderPolicy.h"
    2930#include "FetchRequestCredentials.h"
    3031#include "WorkerOrWorkletThread.h"
     
    6667    ContentSecurityPolicyResponseHeaders contentSecurityPolicyResponseHeaders;
    6768    bool shouldBypassMainWorldContentSecurityPolicy;
     69    CrossOriginEmbedderPolicy crossOriginEmbedderPolicy;
    6870    MonotonicTime timeOrigin;
    6971    ReferrerPolicy referrerPolicy;
  • trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp

    r278788 r280953  
    458458}
    459459
    460 void ServiceWorkerContainer::jobFinishedLoadingScript(ServiceWorkerJob& job, const ScriptBuffer& script, const CertificateInfo& certificateInfo, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicy, const String& referrerPolicy)
     460void ServiceWorkerContainer::jobFinishedLoadingScript(ServiceWorkerJob& job, const ScriptBuffer& script, const CertificateInfo& certificateInfo, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicy, const CrossOriginEmbedderPolicy& coep, const String& referrerPolicy)
    461461{
    462462    ASSERT(m_creationThread.ptr() == &Thread::current());
     
    464464    CONTAINER_RELEASE_LOG("jobFinishedLoadingScript: Successfuly finished fetching script for job %" PRIu64, job.identifier().toUInt64());
    465465
    466     ensureSWClientConnection().finishFetchingScriptInServer(ServiceWorkerFetchResult { job.data().identifier(), job.data().registrationKey(), script, certificateInfo, contentSecurityPolicy, referrerPolicy, { } });
     466    ensureSWClientConnection().finishFetchingScriptInServer(ServiceWorkerFetchResult { job.data().identifier(), job.data().registrationKey(), script, certificateInfo, contentSecurityPolicy, coep, referrerPolicy, { } });
    467467}
    468468
  • trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h

    r278788 r280953  
    101101    void jobResolvedWithUnregistrationResult(ServiceWorkerJob&, bool unregistrationResult) final;
    102102    void startScriptFetchForJob(ServiceWorkerJob&, FetchOptions::Cache) final;
    103     void jobFinishedLoadingScript(ServiceWorkerJob&, const ScriptBuffer&, const CertificateInfo&, const ContentSecurityPolicyResponseHeaders&, const String& referrerPolicy) final;
     103    void jobFinishedLoadingScript(ServiceWorkerJob&, const ScriptBuffer&, const CertificateInfo&, const ContentSecurityPolicyResponseHeaders&, const CrossOriginEmbedderPolicy&, const String& referrerPolicy) final;
    104104    void jobFailedLoadingScript(ServiceWorkerJob&, const ResourceError&, Exception&&) final;
    105105
  • trunk/Source/WebCore/workers/service/ServiceWorkerContextData.cpp

    r279750 r280953  
    4141        certificateInfo.isolatedCopy(),
    4242        contentSecurityPolicy.isolatedCopy(),
     43        crossOriginEmbedderPolicy.isolatedCopy(),
    4344        referrerPolicy.isolatedCopy(),
    4445        scriptURL.isolatedCopy(),
  • trunk/Source/WebCore/workers/service/ServiceWorkerContextData.h

    r279750 r280953  
    2828#include "CertificateInfo.h"
    2929#include "ContentSecurityPolicyResponseHeaders.h"
     30#include "CrossOriginEmbedderPolicy.h"
    3031#include "ScriptBuffer.h"
    3132#include "ServiceWorkerIdentifier.h"
     
    8687    CertificateInfo certificateInfo;
    8788    ContentSecurityPolicyResponseHeaders contentSecurityPolicy;
     89    CrossOriginEmbedderPolicy crossOriginEmbedderPolicy;
    8890    String referrerPolicy;
    8991    URL scriptURL;
     
    102104void ServiceWorkerContextData::encode(Encoder& encoder) const
    103105{
    104     encoder << jobDataIdentifier << registration << serviceWorkerIdentifier << script << contentSecurityPolicy << referrerPolicy
     106    encoder << jobDataIdentifier << registration << serviceWorkerIdentifier << script << contentSecurityPolicy << crossOriginEmbedderPolicy << referrerPolicy
    105107        << scriptURL << workerType << loadedFromDisk << lastNavigationWasAppInitiated << scriptResourceMap << certificateInfo;
    106108}
     
    130132    ContentSecurityPolicyResponseHeaders contentSecurityPolicy;
    131133    if (!decoder.decode(contentSecurityPolicy))
     134        return std::nullopt;
     135
     136    std::optional<CrossOriginEmbedderPolicy> crossOriginEmbedderPolicy;
     137    decoder >> crossOriginEmbedderPolicy;
     138    if (!crossOriginEmbedderPolicy)
    132139        return std::nullopt;
    133140
     
    168175        WTFMove(*certificateInfo),
    169176        WTFMove(contentSecurityPolicy),
     177        WTFMove(*crossOriginEmbedderPolicy),
    170178        WTFMove(referrerPolicy),
    171179        WTFMove(scriptURL),
  • trunk/Source/WebCore/workers/service/ServiceWorkerFetchResult.h

    r278253 r280953  
    2929
    3030#include "ContentSecurityPolicyResponseHeaders.h"
     31#include "CrossOriginEmbedderPolicy.h"
    3132#include "ResourceError.h"
    3233#include "ScriptBuffer.h"
     
    4243    CertificateInfo certificateInfo;
    4344    ContentSecurityPolicyResponseHeaders contentSecurityPolicy;
     45    CrossOriginEmbedderPolicy crossOriginEmbedderPolicy;
    4446    String referrerPolicy;
    4547    ResourceError scriptError;
    4648
    47     ServiceWorkerFetchResult isolatedCopy() const { return { jobDataIdentifier, registrationKey.isolatedCopy(), script.isolatedCopy(), certificateInfo.isolatedCopy(), contentSecurityPolicy.isolatedCopy(), referrerPolicy.isolatedCopy(), scriptError.isolatedCopy() }; }
     49    ServiceWorkerFetchResult isolatedCopy() const { return { jobDataIdentifier, registrationKey.isolatedCopy(), script.isolatedCopy(), certificateInfo.isolatedCopy(), contentSecurityPolicy.isolatedCopy(), crossOriginEmbedderPolicy.isolatedCopy(), referrerPolicy.isolatedCopy(), scriptError.isolatedCopy() }; }
    4850
    4951    template<class Encoder> void encode(Encoder&) const;
     
    5355inline ServiceWorkerFetchResult serviceWorkerFetchError(ServiceWorkerJobDataIdentifier jobDataIdentifier, ServiceWorkerRegistrationKey&& registrationKey, ResourceError&& error)
    5456{
    55     return { jobDataIdentifier, WTFMove(registrationKey), { }, { }, { }, { }, WTFMove(error) };
     57    return { jobDataIdentifier, WTFMove(registrationKey), { }, { }, { }, { }, { }, WTFMove(error) };
    5658}
    5759
     
    5961void ServiceWorkerFetchResult::encode(Encoder& encoder) const
    6062{
    61     encoder << jobDataIdentifier << registrationKey << script << contentSecurityPolicy << referrerPolicy << scriptError;
     63    encoder << jobDataIdentifier << registrationKey << script << contentSecurityPolicy << crossOriginEmbedderPolicy << referrerPolicy << scriptError;
    6264    encoder << certificateInfo;
    6365}
     
    8183    if (!decoder.decode(result.contentSecurityPolicy))
    8284        return false;
     85    if (!decoder.decode(result.crossOriginEmbedderPolicy))
     86        return false;
    8387    if (!decoder.decode(result.referrerPolicy))
    8488        return false;
  • trunk/Source/WebCore/workers/service/ServiceWorkerJob.cpp

    r273299 r280953  
    166166
    167167    if (!scriptLoader->failed()) {
    168         m_client.jobFinishedLoadingScript(*this, scriptLoader->script(), scriptLoader->certificateInfo(), scriptLoader->contentSecurityPolicy(), scriptLoader->referrerPolicy());
     168        m_client.jobFinishedLoadingScript(*this, scriptLoader->script(), scriptLoader->certificateInfo(), scriptLoader->contentSecurityPolicy(), scriptLoader->crossOriginEmbedderPolicy(), scriptLoader->referrerPolicy());
    169169        return;
    170170    }
  • trunk/Source/WebCore/workers/service/ServiceWorkerJobClient.h

    r275465 r280953  
    3838class ScriptBuffer;
    3939class ServiceWorkerJob;
     40struct CrossOriginEmbedderPolicy;
    4041struct ServiceWorkerRegistrationData;
    4142
     
    5051    virtual void jobResolvedWithUnregistrationResult(ServiceWorkerJob&, bool unregistrationResult) = 0;
    5152    virtual void startScriptFetchForJob(ServiceWorkerJob&, FetchOptions::Cache) = 0;
    52     virtual void jobFinishedLoadingScript(ServiceWorkerJob&, const ScriptBuffer&, const CertificateInfo&, const ContentSecurityPolicyResponseHeaders&, const String& referrerPolicy) = 0;
     53    virtual void jobFinishedLoadingScript(ServiceWorkerJob&, const ScriptBuffer&, const CertificateInfo&, const ContentSecurityPolicyResponseHeaders&, const CrossOriginEmbedderPolicy&, const String& referrerPolicy) = 0;
    5354    virtual void jobFailedLoadingScript(ServiceWorkerJob&, const ResourceError&, Exception&&) = 0;
    5455};
  • trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp

    r278253 r280953  
    7575
    7676ServiceWorkerThread::ServiceWorkerThread(ServiceWorkerContextData&& data, String&& userAgent, const Settings::Values& settingsValues, WorkerLoaderProxy& loaderProxy, WorkerDebuggerProxy& debuggerProxy, IDBClient::IDBConnectionProxy* idbConnectionProxy, SocketProvider* socketProvider)
    77     : WorkerThread({ data.scriptURL, emptyString(), "serviceworker:" + Inspector::IdentifiersFactory::createIdentifier(), WTFMove(userAgent), platformStrategies()->loaderStrategy()->isOnLine(), data.contentSecurityPolicy, false, MonotonicTime::now(), { }, data.workerType, FetchRequestCredentials::Omit, settingsValues }, data.script, loaderProxy, debuggerProxy, DummyServiceWorkerThreadProxy::shared(), WorkerThreadStartMode::Normal, data.registration.key.topOrigin().securityOrigin().get(), idbConnectionProxy, socketProvider, JSC::RuntimeFlags::createAllEnabled())
     77    : WorkerThread({ data.scriptURL, emptyString(), "serviceworker:" + Inspector::IdentifiersFactory::createIdentifier(), WTFMove(userAgent), platformStrategies()->loaderStrategy()->isOnLine(), data.contentSecurityPolicy, false, data.crossOriginEmbedderPolicy, MonotonicTime::now(), { }, data.workerType, FetchRequestCredentials::Omit, settingsValues }, data.script, loaderProxy, debuggerProxy, DummyServiceWorkerThreadProxy::shared(), WorkerThreadStartMode::Normal, data.registration.key.topOrigin().securityOrigin().get(), idbConnectionProxy, socketProvider, JSC::RuntimeFlags::createAllEnabled())
    7878    , m_serviceWorkerIdentifier(data.serviceWorkerIdentifier)
    7979    , m_jobDataIdentifier(data.jobDataIdentifier)
  • trunk/Source/WebCore/workers/service/server/RegistrationDatabase.cpp

    r279750 r280953  
    5151namespace WebCore {
    5252
    53 static const uint64_t schemaVersion = 6;
     53static const uint64_t schemaVersion = 7;
    5454
    5555#define RECORDS_TABLE_SCHEMA_PREFIX "CREATE TABLE "
     
    6464    ", workerType TEXT NOT NULL ON CONFLICT FAIL" \
    6565    ", contentSecurityPolicy BLOB NOT NULL ON CONFLICT FAIL" \
     66    ", crossOriginEmbedderPolicy BLOB NOT NULL ON CONFLICT FAIL" \
    6667    ", referrerPolicy TEXT NOT NULL ON CONFLICT FAIL" \
    6768    ", scriptResourceMap BLOB NOT NULL ON CONFLICT FAIL" \
     
    422423    transaction.begin();
    423424
    424     auto insertStatement = m_database->prepareStatement("INSERT INTO Records VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"_s);
     425    auto insertStatement = m_database->prepareStatement("INSERT INTO Records VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"_s);
    425426    if (!insertStatement) {
    426427        RELEASE_LOG_ERROR(ServiceWorker, "Failed to prepare statement to store registration data into records table (%i) - %s", m_database->lastError(), m_database->lastErrorMsg());
     
    443444        WTF::Persistence::Encoder cspEncoder;
    444445        data.contentSecurityPolicy.encode(cspEncoder);
     446
     447        WTF::Persistence::Encoder coepEncoder;
     448        data.crossOriginEmbedderPolicy.encode(coepEncoder);
    445449
    446450        // We don't actually encode the script sources to the database. They will be stored separately in the ScriptStorage.
     
    461465            || insertStatement->bindText(8, workerTypeToString(data.workerType)) != SQLITE_OK
    462466            || insertStatement->bindBlob(9, Span { cspEncoder.buffer(), cspEncoder.bufferSize() }) != SQLITE_OK
    463             || insertStatement->bindText(10, data.referrerPolicy) != SQLITE_OK
    464             || insertStatement->bindBlob(11, Span { scriptResourceMapEncoder.buffer(), scriptResourceMapEncoder.bufferSize() }) != SQLITE_OK
    465             || insertStatement->bindBlob(12, Span { certificateInfoEncoder.buffer(), certificateInfoEncoder.bufferSize() }) != SQLITE_OK
     467            || insertStatement->bindBlob(10, Span { coepEncoder.buffer(), coepEncoder.bufferSize() }) != SQLITE_OK
     468            || insertStatement->bindText(11, data.referrerPolicy) != SQLITE_OK
     469            || insertStatement->bindBlob(12, Span { scriptResourceMapEncoder.buffer(), scriptResourceMapEncoder.bufferSize() }) != SQLITE_OK
     470            || insertStatement->bindBlob(13, Span { certificateInfoEncoder.buffer(), certificateInfoEncoder.bufferSize() }) != SQLITE_OK
    466471            || insertStatement->step() != SQLITE_DONE) {
    467472            RELEASE_LOG_ERROR(ServiceWorker, "Failed to store registration data into records table (%i) - %s", m_database->lastError(), m_database->lastErrorMsg());
     
    526531        }
    527532
    528         auto referrerPolicy = sql->columnText(9);
     533        std::optional<CrossOriginEmbedderPolicy> coep;
     534        auto coepDataSpan = sql->columnBlobAsSpan(9);
     535        if (coepDataSpan.size()) {
     536            WTF::Persistence::Decoder coepDecoder(coepDataSpan);
     537            coepDecoder >> coep;
     538            if (!coep) {
     539                RELEASE_LOG_ERROR(ServiceWorker, "RegistrationDatabase::importRecords: Failed to decode crossOriginEmbedderPolicy");
     540                continue;
     541            }
     542        }
     543
     544        auto referrerPolicy = sql->columnText(10);
    529545
    530546        HashMap<URL, ServiceWorkerContextData::ImportedScript> scriptResourceMap;
    531         auto scriptResourceMapDataSpan = sql->columnBlobAsSpan(10);
     547        auto scriptResourceMapDataSpan = sql->columnBlobAsSpan(11);
    532548        if (scriptResourceMapDataSpan.size()) {
    533549            WTF::Persistence::Decoder scriptResourceMapDecoder(scriptResourceMapDataSpan);
     
    541557        }
    542558
    543         auto certificateInfoDataSpan = sql->columnBlobAsSpan(11);
     559        auto certificateInfoDataSpan = sql->columnBlobAsSpan(12);
    544560        std::optional<CertificateInfo> certificateInfo;
    545561
     
    570586        auto serviceWorkerData = ServiceWorkerData { workerIdentifier, scriptURL, ServiceWorkerState::Activated, *workerType, registrationIdentifier };
    571587        auto registration = ServiceWorkerRegistrationData { WTFMove(*key), registrationIdentifier, WTFMove(scopeURL), *updateViaCache, lastUpdateCheckTime, std::nullopt, std::nullopt, WTFMove(serviceWorkerData) };
    572         auto contextData = ServiceWorkerContextData { std::nullopt, WTFMove(registration), workerIdentifier, WTFMove(script), WTFMove(*certificateInfo), WTFMove(*contentSecurityPolicy), WTFMove(referrerPolicy), WTFMove(scriptURL), *workerType, true, LastNavigationWasAppInitiated::Yes, WTFMove(scriptResourceMap) };
     588        auto contextData = ServiceWorkerContextData { std::nullopt, WTFMove(registration), workerIdentifier, WTFMove(script), WTFMove(*certificateInfo), WTFMove(*contentSecurityPolicy), WTFMove(*coep), WTFMove(referrerPolicy), WTFMove(scriptURL), *workerType, true, LastNavigationWasAppInitiated::Yes, WTFMove(scriptResourceMap) };
    573589
    574590        callOnMainThread([protectedThis = makeRef(*this), contextData = contextData.isolatedCopy()]() mutable {
  • trunk/Source/WebCore/workers/service/server/SWServer.cpp

    r280319 r280953  
    170170            addRegistration(WTFMove(registration));
    171171
    172             auto worker = SWServerWorker::create(*this, *registrationPtr, data.scriptURL, data.script, data.certificateInfo, data.contentSecurityPolicy, WTFMove(data.referrerPolicy), data.workerType, data.serviceWorkerIdentifier, WTFMove(data.scriptResourceMap));
     172            auto worker = SWServerWorker::create(*this, *registrationPtr, data.scriptURL, data.script, data.certificateInfo, data.contentSecurityPolicy, data.crossOriginEmbedderPolicy, WTFMove(data.referrerPolicy), data.workerType, data.serviceWorkerIdentifier, WTFMove(data.scriptResourceMap));
    173173            registrationPtr->updateRegistrationState(ServiceWorkerRegistrationState::Active, worker.ptr());
    174174            worker->setState(ServiceWorkerState::Activated);
     
    653653}
    654654
    655 void SWServer::updateWorker(const ServiceWorkerJobDataIdentifier& jobDataIdentifier, SWServerRegistration& registration, const URL& url, const ScriptBuffer& script, const CertificateInfo& certificateInfo, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicy, const String& referrerPolicy, WorkerType type, HashMap<URL, ServiceWorkerContextData::ImportedScript>&& scriptResourceMap)
    656 {
    657     tryInstallContextData(ServiceWorkerContextData { jobDataIdentifier, registration.data(), ServiceWorkerIdentifier::generate(), script, certificateInfo, contentSecurityPolicy, referrerPolicy, url, type, false, clientIsAppInitiatedForRegistrableDomain(RegistrableDomain(url)), WTFMove(scriptResourceMap) });
     655void SWServer::updateWorker(const ServiceWorkerJobDataIdentifier& jobDataIdentifier, SWServerRegistration& registration, const URL& url, const ScriptBuffer& script, const CertificateInfo& certificateInfo, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicy, const CrossOriginEmbedderPolicy& coep, const String& referrerPolicy, WorkerType type, HashMap<URL, ServiceWorkerContextData::ImportedScript>&& scriptResourceMap)
     656{
     657    tryInstallContextData(ServiceWorkerContextData { jobDataIdentifier, registration.data(), ServiceWorkerIdentifier::generate(), script, certificateInfo, contentSecurityPolicy, coep, referrerPolicy, url, type, false, clientIsAppInitiatedForRegistrableDomain(RegistrableDomain(url)), WTFMove(scriptResourceMap) });
    658658}
    659659
     
    720720
    721721    auto* registration = m_scopeToRegistrationMap.get(data.registration.key).get();
    722     auto worker = SWServerWorker::create(*this, *registration, data.scriptURL, data.script, data.certificateInfo, data.contentSecurityPolicy, String { data.referrerPolicy }, data.workerType, data.serviceWorkerIdentifier, HashMap<URL, ServiceWorkerContextData::ImportedScript> { data.scriptResourceMap });
     722    auto worker = SWServerWorker::create(*this, *registration, data.scriptURL, data.script, data.certificateInfo, data.contentSecurityPolicy, data.crossOriginEmbedderPolicy, String { data.referrerPolicy }, data.workerType, data.serviceWorkerIdentifier, HashMap<URL, ServiceWorkerContextData::ImportedScript> { data.scriptResourceMap });
    723723
    724724    auto* connection = worker->contextConnection();
  • trunk/Source/WebCore/workers/service/server/SWServer.h

    r280319 r280953  
    153153    void startScriptFetch(const ServiceWorkerJobData&, SWServerRegistration&);
    154154
    155     void updateWorker(const ServiceWorkerJobDataIdentifier&, SWServerRegistration&, const URL&, const ScriptBuffer&, const CertificateInfo&, const ContentSecurityPolicyResponseHeaders&, const String& referrerPolicy, WorkerType, HashMap<URL, ServiceWorkerContextData::ImportedScript>&&);
     155    void updateWorker(const ServiceWorkerJobDataIdentifier&, SWServerRegistration&, const URL&, const ScriptBuffer&, const CertificateInfo&, const ContentSecurityPolicyResponseHeaders&, const CrossOriginEmbedderPolicy&, const String& referrerPolicy, WorkerType, HashMap<URL, ServiceWorkerContextData::ImportedScript>&&);
    156156    void fireInstallEvent(SWServerWorker&);
    157157    void fireActivateEvent(SWServerWorker&);
  • trunk/Source/WebCore/workers/service/server/SWServerJobQueue.cpp

    r275952 r280953  
    115115    // FIXME: Update all the imported scripts as per spec. For now, we just do as if there is none.
    116116
    117     m_server.updateWorker(job.identifier(), *registration, job.scriptURL, result.script, result.certificateInfo, result.contentSecurityPolicy, result.referrerPolicy, job.workerType, { });
     117    m_server.updateWorker(job.identifier(), *registration, job.scriptURL, result.script, result.certificateInfo, result.contentSecurityPolicy, result.crossOriginEmbedderPolicy, result.referrerPolicy, job.workerType, { });
    118118}
    119119
  • trunk/Source/WebCore/workers/service/server/SWServerWorker.cpp

    r279750 r280953  
    5151
    5252// FIXME: Use r-value references for script and contentSecurityPolicy
    53 SWServerWorker::SWServerWorker(SWServer& server, SWServerRegistration& registration, const URL& scriptURL, const ScriptBuffer& script, const CertificateInfo& certificateInfo, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicy, String&& referrerPolicy, WorkerType type, ServiceWorkerIdentifier identifier, HashMap<URL, ServiceWorkerContextData::ImportedScript>&& scriptResourceMap)
     53SWServerWorker::SWServerWorker(SWServer& server, SWServerRegistration& registration, const URL& scriptURL, const ScriptBuffer& script, const CertificateInfo& certificateInfo, const ContentSecurityPolicyResponseHeaders& contentSecurityPolicy, const CrossOriginEmbedderPolicy& crossOriginEmbedderPolicy, String&& referrerPolicy, WorkerType type, ServiceWorkerIdentifier identifier, HashMap<URL, ServiceWorkerContextData::ImportedScript>&& scriptResourceMap)
    5454    : m_server(makeWeakPtr(server))
    5555    , m_registrationKey(registration.key())
     
    5959    , m_certificateInfo(certificateInfo)
    6060    , m_contentSecurityPolicy(contentSecurityPolicy)
     61    , m_crossOriginEmbedderPolicy(crossOriginEmbedderPolicy)
    6162    , m_referrerPolicy(WTFMove(referrerPolicy))
    6263    , m_registrableDomain(m_data.scriptURL)
     
    8889    ASSERT(m_registration);
    8990
    90     return { std::nullopt, m_registration->data(), m_data.identifier, m_script, m_certificateInfo, m_contentSecurityPolicy, m_referrerPolicy, m_data.scriptURL, m_data.type, false, m_lastNavigationWasAppInitiated, m_scriptResourceMap };
     91    return { std::nullopt, m_registration->data(), m_data.identifier, m_script, m_certificateInfo, m_contentSecurityPolicy, m_crossOriginEmbedderPolicy, m_referrerPolicy, m_data.scriptURL, m_data.type, false, m_lastNavigationWasAppInitiated, m_scriptResourceMap };
    9192}
    9293
  • trunk/Source/WebCore/workers/service/server/SWServerWorker.h

    r279750 r280953  
    3030#include "ClientOrigin.h"
    3131#include "ContentSecurityPolicyResponseHeaders.h"
     32#include "CrossOriginEmbedderPolicy.h"
    3233#include "RegistrableDomain.h"
    3334#include "ServiceWorkerClientData.h"
     
    131132
    132133private:
    133     SWServerWorker(SWServer&, SWServerRegistration&, const URL&, const ScriptBuffer&, const CertificateInfo&, const ContentSecurityPolicyResponseHeaders&, String&& referrerPolicy, WorkerType, ServiceWorkerIdentifier, HashMap<URL, ServiceWorkerContextData::ImportedScript>&&);
     134    SWServerWorker(SWServer&, SWServerRegistration&, const URL&, const ScriptBuffer&, const CertificateInfo&, const ContentSecurityPolicyResponseHeaders&, const CrossOriginEmbedderPolicy&, String&& referrerPolicy, WorkerType, ServiceWorkerIdentifier, HashMap<URL, ServiceWorkerContextData::ImportedScript>&&);
    134135
    135136    void callWhenActivatedHandler(bool success);
     
    147148    CertificateInfo m_certificateInfo;
    148149    ContentSecurityPolicyResponseHeaders m_contentSecurityPolicy;
     150    CrossOriginEmbedderPolicy m_crossOriginEmbedderPolicy;
    149151    String m_referrerPolicy;
    150152    bool m_hasPendingEvents { false };
  • trunk/Source/WebKit/ChangeLog

    r280952 r280953  
     12021-08-11  Chris Dumez  <cdumez@apple.com>
     2
     3        Add initial support for Cross-Origin-Embedder-Policy (COEP)
     4        https://bugs.webkit.org/show_bug.cgi?id=228754
     5
     6        Reviewed by Alex Christensen.
     7
     8        As mentioned in the WebCore changelog, we do all the COEP checks in the network process
     9        instead of WebCore for added security. As a result, we need to pass more information
     10        to the network process when doing loads in order to do those checks. The checks are done
     11        in NetworkResourceLoader for navigations & worker script loads (similarly to CSP,
     12        X-FrameOptions) and in NetworkLoadChecker for CORP checks of subresource loads (similarly
     13        to CORS checks).
     14
     15        * NetworkProcess/NetworkLoadChecker.cpp:
     16        (WebKit::NetworkLoadChecker::NetworkLoadChecker):
     17        (WebKit::NetworkLoadChecker::validateResponse):
     18        * NetworkProcess/NetworkLoadChecker.h:
     19        (WebKit::NetworkLoadChecker::setParentCrossOriginEmbedderPolicy):
     20        (WebKit::NetworkLoadChecker::setCrossOriginEmbedderPolicy):
     21        * NetworkProcess/NetworkResourceLoadParameters.cpp:
     22        (WebKit::NetworkResourceLoadParameters::parentOrigin const):
     23        (WebKit::NetworkResourceLoadParameters::encode const):
     24        (WebKit::NetworkResourceLoadParameters::decode):
     25        * NetworkProcess/NetworkResourceLoadParameters.h:
     26        * NetworkProcess/NetworkResourceLoader.cpp:
     27        (WebKit::NetworkResourceLoader::shouldInterruptLoadForCSPFrameAncestorsOrXFrameOptions):
     28        (WebKit::NetworkResourceLoader::shouldInterruptNavigationForCrossOriginEmbedderPolicy):
     29        (WebKit::NetworkResourceLoader::shouldInterruptWorkerLoadForCrossOriginEmbedderPolicy):
     30        (WebKit::NetworkResourceLoader::didReceiveResponse):
     31        (WebKit::NetworkResourceLoader::willSendRedirectedRequest):
     32        * NetworkProcess/NetworkResourceLoader.h:
     33        * NetworkProcess/PingLoad.cpp:
     34        (WebKit::PingLoad::PingLoad):
     35        (WebKit::PingLoad::initialize):
     36        * NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp:
     37        (WebKit::ServiceWorkerFetchTask::didReceiveResponse):
     38        * NetworkProcess/ServiceWorker/ServiceWorkerSoftUpdateLoader.cpp:
     39        (WebKit::ServiceWorkerSoftUpdateLoader::processResponse):
     40        (WebKit::ServiceWorkerSoftUpdateLoader::didFinishLoading):
     41        * NetworkProcess/ServiceWorker/ServiceWorkerSoftUpdateLoader.h:
     42        * NetworkProcess/cache/CacheStorageEngineCache.cpp:
     43        (WebKit::CacheStorage::Cache::retrieveRecords):
     44        * WebProcess/Network/WebLoaderStrategy.cpp:
     45        (WebKit::addParametersShared):
     46        (WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess):
     47
    1482021-08-11  Darin Adler  <darin@apple.com>
    249
  • trunk/Source/WebKit/NetworkProcess/NetworkLoadChecker.cpp

    r278953 r280953  
    5151}
    5252
    53 NetworkLoadChecker::NetworkLoadChecker(NetworkProcess& networkProcess, NetworkResourceLoader* networkResourceLoader, NetworkSchemeRegistry* schemeRegistry, FetchOptions&& options, PAL::SessionID sessionID, WebPageProxyIdentifier webPageProxyID, HTTPHeaderMap&& originalRequestHeaders, URL&& url, DocumentURL&& documentURL, RefPtr<SecurityOrigin>&& sourceOrigin, RefPtr<SecurityOrigin>&& topOrigin, PreflightPolicy preflightPolicy, String&& referrer, bool shouldCaptureExtraNetworkLoadMetrics, LoadType requestLoadType)
     53NetworkLoadChecker::NetworkLoadChecker(NetworkProcess& networkProcess, NetworkResourceLoader* networkResourceLoader, NetworkSchemeRegistry* schemeRegistry, FetchOptions&& options, PAL::SessionID sessionID, WebPageProxyIdentifier webPageProxyID, HTTPHeaderMap&& originalRequestHeaders, URL&& url, DocumentURL&& documentURL, RefPtr<SecurityOrigin>&& sourceOrigin, RefPtr<SecurityOrigin>&& topOrigin, RefPtr<SecurityOrigin>&& parentOrigin, PreflightPolicy preflightPolicy, String&& referrer, bool shouldCaptureExtraNetworkLoadMetrics, LoadType requestLoadType)
    5454    : m_options(WTFMove(options))
    5555    , m_sessionID(sessionID)
     
    6161    , m_origin(WTFMove(sourceOrigin))
    6262    , m_topOrigin(WTFMove(topOrigin))
     63    , m_parentOrigin(WTFMove(parentOrigin))
    6364    , m_preflightPolicy(preflightPolicy)
    6465    , m_referrer(WTFMove(referrer))
     
    169170
    170171    if (m_options.mode == FetchOptions::Mode::Navigate || m_isSameOriginRequest) {
     172        if (m_options.mode == FetchOptions::Mode::Navigate && m_parentOrigin) {
     173            if (auto error = validateCrossOriginResourcePolicy(m_parentCrossOriginEmbedderPolicy.value, *m_parentOrigin, m_url, response, ForNavigation::Yes))
     174                return WTFMove(*error);
     175        }
    171176        response.setTainting(ResourceResponse::Tainting::Basic);
    172177        return { };
     
    177182
    178183    if (m_options.mode == FetchOptions::Mode::NoCors) {
    179         if (auto error = validateCrossOriginResourcePolicy(*m_origin, m_url, response))
     184        if (auto error = validateCrossOriginResourcePolicy(m_crossOriginEmbedderPolicy.value, *m_origin, m_url, response, ForNavigation::No))
    180185            return WTFMove(*error);
    181186
  • trunk/Source/WebKit/NetworkProcess/NetworkLoadChecker.h

    r278253 r280953  
    3030#include <WebCore/ContentExtensionActions.h>
    3131#include <WebCore/ContentSecurityPolicyResponseHeaders.h>
     32#include <WebCore/CrossOriginEmbedderPolicy.h>
    3233#include <WebCore/FetchOptions.h>
    3334#include <WebCore/NetworkLoadInformation.h>
     
    6162    enum class LoadType : bool { MainFrame, Other };
    6263
    63     NetworkLoadChecker(NetworkProcess&, NetworkResourceLoader*, NetworkSchemeRegistry*, WebCore::FetchOptions&&, PAL::SessionID, WebPageProxyIdentifier, WebCore::HTTPHeaderMap&&, URL&&, DocumentURL&&,  RefPtr<WebCore::SecurityOrigin>&&, RefPtr<WebCore::SecurityOrigin>&& topOrigin, WebCore::PreflightPolicy, String&& referrer, bool shouldCaptureExtraNetworkLoadMetrics = false, LoadType requestLoadType = LoadType::Other);
     64    NetworkLoadChecker(NetworkProcess&, NetworkResourceLoader*, NetworkSchemeRegistry*, WebCore::FetchOptions&&, PAL::SessionID, WebPageProxyIdentifier, WebCore::HTTPHeaderMap&&, URL&&, DocumentURL&&,  RefPtr<WebCore::SecurityOrigin>&&, RefPtr<WebCore::SecurityOrigin>&& topOrigin, RefPtr<WebCore::SecurityOrigin>&& parentOrigin, WebCore::PreflightPolicy, String&& referrer, bool shouldCaptureExtraNetworkLoadMetrics = false, LoadType requestLoadType = LoadType::Other);
    6465    ~NetworkLoadChecker();
    6566
     
    8182
    8283    void setCSPResponseHeaders(WebCore::ContentSecurityPolicyResponseHeaders&& headers) { m_cspResponseHeaders = WTFMove(headers); }
     84    void setParentCrossOriginEmbedderPolicy(const WebCore::CrossOriginEmbedderPolicy& parentCrossOriginEmbedderPolicy) { m_parentCrossOriginEmbedderPolicy = parentCrossOriginEmbedderPolicy; }
     85    void setCrossOriginEmbedderPolicy(const WebCore::CrossOriginEmbedderPolicy& crossOriginEmbedderPolicy) { m_crossOriginEmbedderPolicy = crossOriginEmbedderPolicy; }
    8386#if ENABLE(CONTENT_EXTENSIONS)
    8487    void setContentExtensionController(URL&& mainDocumentURL, std::optional<UserContentControllerIdentifier> identifier)
     
    139142    RefPtr<WebCore::SecurityOrigin> m_origin;
    140143    RefPtr<WebCore::SecurityOrigin> m_topOrigin;
     144    RefPtr<WebCore::SecurityOrigin> m_parentOrigin;
    141145    std::optional<WebCore::ContentSecurityPolicyResponseHeaders> m_cspResponseHeaders;
     146    WebCore::CrossOriginEmbedderPolicy m_parentCrossOriginEmbedderPolicy;
     147    WebCore::CrossOriginEmbedderPolicy m_crossOriginEmbedderPolicy;
    142148#if ENABLE(CONTENT_EXTENSIONS)
    143149    URL m_mainDocumentURL;
  • trunk/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp

    r278253 r280953  
    3232using namespace WebCore;
    3333
     34RefPtr<SecurityOrigin> NetworkResourceLoadParameters::parentOrigin() const
     35{
     36    if (frameAncestorOrigins.isEmpty())
     37        return nullptr;
     38    return frameAncestorOrigins.first();
     39}
     40
    3441void NetworkResourceLoadParameters::encode(IPC::Encoder& encoder) const
    3542{
     
    97104    encoder << options;
    98105    encoder << cspResponseHeaders;
     106    encoder << parentCrossOriginEmbedderPolicy;
     107    encoder << crossOriginEmbedderPolicy;
    99108    encoder << originalRequestHeaders;
    100109
     
    232241    if (!decoder.decode(result.cspResponseHeaders))
    233242        return std::nullopt;
     243
     244    std::optional<WebCore::CrossOriginEmbedderPolicy> parentCrossOriginEmbedderPolicy;
     245    decoder >> parentCrossOriginEmbedderPolicy;
     246    if (!parentCrossOriginEmbedderPolicy)
     247        return std::nullopt;
     248    result.parentCrossOriginEmbedderPolicy = WTFMove(*parentCrossOriginEmbedderPolicy);
     249
     250    std::optional<WebCore::CrossOriginEmbedderPolicy> crossOriginEmbedderPolicy;
     251    decoder >> crossOriginEmbedderPolicy;
     252    if (!crossOriginEmbedderPolicy)
     253        return std::nullopt;
     254    result.crossOriginEmbedderPolicy = WTFMove(*crossOriginEmbedderPolicy);
     255
    234256    if (!decoder.decode(result.originalRequestHeaders))
    235257        return std::nullopt;
  • trunk/Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.h

    r278738 r280953  
    3232#include <WebCore/ContentSecurityPolicyResponseHeaders.h>
    3333#include <WebCore/CrossOriginAccessControl.h>
     34#include <WebCore/CrossOriginEmbedderPolicy.h>
    3435#include <WebCore/FetchOptions.h>
    3536#include <wtf/Seconds.h>
     
    4950    static std::optional<NetworkResourceLoadParameters> decode(IPC::Decoder&);
    5051
     52    RefPtr<WebCore::SecurityOrigin> parentOrigin() const;
     53
    5154    ResourceLoadIdentifier identifier { 0 };
    5255    Vector<RefPtr<SandboxExtension>> requestBodySandboxExtensions; // Created automatically for the sender.
     
    5558    WebCore::FetchOptions options;
    5659    std::optional<WebCore::ContentSecurityPolicyResponseHeaders> cspResponseHeaders;
     60    WebCore::CrossOriginEmbedderPolicy parentCrossOriginEmbedderPolicy;
     61    WebCore::CrossOriginEmbedderPolicy crossOriginEmbedderPolicy;
    5762    WebCore::HTTPHeaderMap originalRequestHeaders;
    5863    bool shouldRestrictHTTPResponseAccess { false };
  • trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp

    r279750 r280953  
    121121    if (synchronousReply || parameters.shouldRestrictHTTPResponseAccess || parameters.options.keepAlive) {
    122122        NetworkLoadChecker::LoadType requestLoadType = isMainFrameLoad() ? NetworkLoadChecker::LoadType::MainFrame : NetworkLoadChecker::LoadType::Other;
    123         m_networkLoadChecker = makeUnique<NetworkLoadChecker>(connection.networkProcess(), this,  &connection.schemeRegistry(), FetchOptions { m_parameters.options }, sessionID(), m_parameters.webPageProxyID, HTTPHeaderMap { m_parameters.originalRequestHeaders }, URL { m_parameters.request.url() }, URL { m_parameters.documentURL }, m_parameters.sourceOrigin.copyRef(), m_parameters.topOrigin.copyRef(), m_parameters.preflightPolicy, originalRequest().httpReferrer(), shouldCaptureExtraNetworkLoadMetrics(), requestLoadType);
     123        m_networkLoadChecker = makeUnique<NetworkLoadChecker>(connection.networkProcess(), this,  &connection.schemeRegistry(), FetchOptions { m_parameters.options }, sessionID(), m_parameters.webPageProxyID, HTTPHeaderMap { m_parameters.originalRequestHeaders }, URL { m_parameters.request.url() }, URL { m_parameters.documentURL }, m_parameters.sourceOrigin.copyRef(), m_parameters.topOrigin.copyRef(), m_parameters.parentOrigin(), m_parameters.preflightPolicy, originalRequest().httpReferrer(), shouldCaptureExtraNetworkLoadMetrics(), requestLoadType);
    124124        if (m_parameters.cspResponseHeaders)
    125125            m_networkLoadChecker->setCSPResponseHeaders(ContentSecurityPolicyResponseHeaders { m_parameters.cspResponseHeaders.value() });
     126        m_networkLoadChecker->setParentCrossOriginEmbedderPolicy(m_parameters.parentCrossOriginEmbedderPolicy);
     127        m_networkLoadChecker->setCrossOriginEmbedderPolicy(m_parameters.crossOriginEmbedderPolicy);
    126128#if ENABLE(CONTENT_EXTENSIONS)
    127129        m_networkLoadChecker->setContentExtensionController(URL { m_parameters.mainDocumentURL }, m_parameters.userContentControllerIdentifier);
     
    576578        String xFrameOptions = m_response.httpHeaderField(HTTPHeaderName::XFrameOptions);
    577579        if (!xFrameOptions.isNull() && shouldInterruptLoadForXFrameOptions(xFrameOptions, response.url())) {
    578             String errorMessage = "Refused to display '" + response.url().stringCenterEllipsizedToLength() + "' in a frame because it set 'X-Frame-Options' to '" + xFrameOptions + "'.";
     580            String errorMessage = makeString("Refused to display '", response.url().stringCenterEllipsizedToLength(), "' in a frame because it set 'X-Frame-Options' to '", xFrameOptions, "'.");
     581            send(Messages::WebPage::AddConsoleMessage { m_parameters.webFrameID,  MessageSource::Security, MessageLevel::Error, errorMessage, identifier() }, m_parameters.webPageID);
     582            return true;
     583        }
     584    }
     585
     586    return shouldInterruptNavigationForCrossOriginEmbedderPolicy(m_response);
     587}
     588
     589bool NetworkResourceLoader::shouldInterruptNavigationForCrossOriginEmbedderPolicy(const ResourceResponse& response)
     590{
     591    ASSERT(isMainResource());
     592
     593    // https://html.spec.whatwg.org/multipage/origin.html#check-a-navigation-response's-adherence-to-its-embedder-policy
     594    if (m_parameters.parentCrossOriginEmbedderPolicy.value != WebCore::CrossOriginEmbedderPolicyValue::UnsafeNone && m_parameters.sourceOrigin) {
     595        auto responseCOEP = WebCore::obtainCrossOriginEmbedderPolicy(response, m_parameters.sourceOrigin->isPotentiallyTrustworthy() ? IsSecureContext::Yes : IsSecureContext::No);
     596        if (responseCOEP.value != WebCore::CrossOriginEmbedderPolicyValue::RequireCORP) {
     597            String errorMessage = makeString("Refused to display '", response.url().stringCenterEllipsizedToLength(), "' in a frame because of Cross-Origin-Embedder-Policy.");
     598            send(Messages::WebPage::AddConsoleMessage { m_parameters.webFrameID,  MessageSource::Security, MessageLevel::Error, errorMessage, identifier() }, m_parameters.webPageID);
     599            return true;
     600        }
     601    }
     602    return false;
     603}
     604
     605bool NetworkResourceLoader::shouldInterruptWorkerLoadForCrossOriginEmbedderPolicy(const ResourceResponse& response)
     606{
     607    if (m_parameters.options.destination != FetchOptions::Destination::Worker)
     608        return false;
     609
     610    if (m_parameters.crossOriginEmbedderPolicy.value != WebCore::CrossOriginEmbedderPolicyValue::UnsafeNone && m_parameters.sourceOrigin) {
     611        auto responseCOEP = WebCore::obtainCrossOriginEmbedderPolicy(response, m_parameters.sourceOrigin->isPotentiallyTrustworthy() ? IsSecureContext::Yes : IsSecureContext::No);
     612        if (responseCOEP.value != WebCore::CrossOriginEmbedderPolicyValue::RequireCORP) {
     613            String errorMessage = makeString("Refused to load '", response.url().stringCenterEllipsizedToLength(), "' worker because of Cross-Origin-Embedder-Policy.");
    579614            send(Messages::WebPage::AddConsoleMessage { m_parameters.webFrameID,  MessageSource::Security, MessageLevel::Error, errorMessage, identifier() }, m_parameters.webPageID);
    580615            return true;
     
    624659        auto response = sanitizeResponseIfPossible(ResourceResponse { m_response }, ResourceResponse::SanitizationType::CrossOriginSafe);
    625660        send(Messages::WebResourceLoader::StopLoadingAfterXFrameOptionsOrContentSecurityPolicyDenied { response });
     661        return completionHandler(PolicyAction::Ignore);
     662    }
     663
     664    // https://html.spec.whatwg.org/multipage/origin.html#check-a-global-object's-embedder-policy
     665    if (shouldInterruptWorkerLoadForCrossOriginEmbedderPolicy(m_response)) {
     666        LOADER_RELEASE_LOG_ERROR("didReceiveResponse: Interrupting worker load due to Cross-Origin-Opener-Policy");
     667        RunLoop::main().dispatch([protectedThis = makeRef(*this), url = m_response.url()] {
     668            if (protectedThis->m_networkLoad)
     669                protectedThis->didFailLoading(ResourceError { errorDomainWebKitInternal, 0, url, "Worker load was blocked by Cross-Origin-Embedder-Policy"_s, ResourceError::Type::AccessControl });
     670        });
    626671        return completionHandler(PolicyAction::Ignore);
    627672    }
     
    834879    if (redirectResponse.source() == ResourceResponse::Source::Network && canUseCachedRedirect(request))
    835880        m_cache->storeRedirect(request, redirectResponse, redirectRequest, maxAgeCap);
     881
     882    if (isMainResource() && shouldInterruptNavigationForCrossOriginEmbedderPolicy(redirectResponse)) {
     883        this->didFailLoading(ResourceError { errorDomainWebKitInternal, 0, redirectRequest.url(), "Redirection was blocked by Cross-Origin-Embedder-Policy"_s, ResourceError::Type::AccessControl });
     884        return;
     885    }
    836886
    837887    if (m_networkLoadChecker) {
  • trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.h

    r279750 r280953  
    164164    bool shouldInterruptLoadForXFrameOptions(const String&, const URL&);
    165165    bool shouldInterruptLoadForCSPFrameAncestorsOrXFrameOptions(const WebCore::ResourceResponse&);
     166    bool shouldInterruptNavigationForCrossOriginEmbedderPolicy(const WebCore::ResourceResponse&);
     167    bool shouldInterruptWorkerLoadForCrossOriginEmbedderPolicy(const WebCore::ResourceResponse&);
    166168
    167169    enum class FirstLoad { No, Yes };
  • trunk/Source/WebKit/NetworkProcess/PingLoad.cpp

    r278953 r280953  
    4646    , m_completionHandler(WTFMove(completionHandler))
    4747    , m_timeoutTimer(*this, &PingLoad::timeoutTimerFired)
    48     , m_networkLoadChecker(makeUniqueRef<NetworkLoadChecker>(networkProcess, nullptr, nullptr, FetchOptions { m_parameters.options}, m_sessionID, m_parameters.webPageProxyID, WTFMove(m_parameters.originalRequestHeaders), URL { m_parameters.request.url() }, URL { m_parameters.documentURL }, m_parameters.sourceOrigin.copyRef(), m_parameters.topOrigin.copyRef(), m_parameters.preflightPolicy, m_parameters.request.httpReferrer()))
     48    , m_networkLoadChecker(makeUniqueRef<NetworkLoadChecker>(networkProcess, nullptr, nullptr, FetchOptions { m_parameters.options}, m_sessionID, m_parameters.webPageProxyID, WTFMove(m_parameters.originalRequestHeaders), URL { m_parameters.request.url() }, URL { m_parameters.documentURL }, m_parameters.sourceOrigin.copyRef(), m_parameters.topOrigin.copyRef(), m_parameters.parentOrigin(), m_parameters.preflightPolicy, m_parameters.request.httpReferrer()))
    4949{
    5050    initialize(networkProcess);
     
    5656    , m_completionHandler(WTFMove(completionHandler))
    5757    , m_timeoutTimer(*this, &PingLoad::timeoutTimerFired)
    58     , m_networkLoadChecker(makeUniqueRef<NetworkLoadChecker>(connection.networkProcess(), nullptr,  &connection.schemeRegistry(), FetchOptions { m_parameters.options}, m_sessionID, m_parameters.webPageProxyID, WTFMove(m_parameters.originalRequestHeaders), URL { m_parameters.request.url() }, URL { m_parameters.documentURL }, m_parameters.sourceOrigin.copyRef(), m_parameters.topOrigin.copyRef(), m_parameters.preflightPolicy, m_parameters.request.httpReferrer()))
     58    , m_networkLoadChecker(makeUniqueRef<NetworkLoadChecker>(connection.networkProcess(), nullptr,  &connection.schemeRegistry(), FetchOptions { m_parameters.options}, m_sessionID, m_parameters.webPageProxyID, WTFMove(m_parameters.originalRequestHeaders), URL { m_parameters.request.url() }, URL { m_parameters.documentURL }, m_parameters.sourceOrigin.copyRef(), m_parameters.topOrigin.copyRef(), m_parameters.parentOrigin(), m_parameters.preflightPolicy, m_parameters.request.httpReferrer()))
    5959    , m_blobFiles(connection.resolveBlobReferences(m_parameters))
    6060{
     
    7272    if (m_parameters.cspResponseHeaders)
    7373        m_networkLoadChecker->setCSPResponseHeaders(WTFMove(m_parameters.cspResponseHeaders.value()));
     74    m_networkLoadChecker->setParentCrossOriginEmbedderPolicy(m_parameters.parentCrossOriginEmbedderPolicy);
     75    m_networkLoadChecker->setCrossOriginEmbedderPolicy(m_parameters.crossOriginEmbedderPolicy);
    7476#if ENABLE(CONTENT_EXTENSIONS)
    7577    m_networkLoadChecker->setContentExtensionController(WTFMove(m_parameters.mainDocumentURL), m_parameters.userContentControllerIdentifier);
  • trunk/Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp

    r279750 r280953  
    146146    softUpdateIfNeeded();
    147147
     148    if (m_loader.parameters().options.mode == FetchOptions::Mode::Navigate) {
     149        if (auto parentOrigin = m_loader.parameters().parentOrigin()) {
     150            if (auto error = validateCrossOriginResourcePolicy(m_loader.parameters().parentCrossOriginEmbedderPolicy.value, *parentOrigin, m_currentRequest.url(), response, ForNavigation::Yes)) {
     151                didFail(*error);
     152                return;
     153            }
     154        }
     155    }
     156    if (m_loader.parameters().options.mode == FetchOptions::Mode::NoCors) {
     157        if (auto error = validateCrossOriginResourcePolicy(m_loader.parameters().crossOriginEmbedderPolicy.value, *m_loader.parameters().sourceOrigin, m_currentRequest.url(), response, ForNavigation::No)) {
     158            didFail(*error);
     159            return;
     160        }
     161    }
     162
    148163    response.setSource(ResourceResponse::Source::ServiceWorker);
    149164    sendToClient(Messages::WebResourceLoader::DidReceiveResponse { response, needsContinueDidReceiveResponseMessage });
  • trunk/Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerSoftUpdateLoader.cpp

    r279750 r280953  
    170170
    171171    m_contentSecurityPolicy = ContentSecurityPolicyResponseHeaders { response };
     172    // Service workers are always secure contexts.
     173    m_crossOriginEmbedderPolicy = obtainCrossOriginEmbedderPolicy(response, IsSecureContext::Yes);
    172174    m_referrerPolicy = response.httpHeaderField(HTTPHeaderName::ReferrerPolicy);
    173175    m_responseEncoding = response.textEncodingName();
     
    193195    if (m_decoder)
    194196        m_script.append(m_decoder->flush());
    195     m_completionHandler({ m_jobData.identifier(), m_jobData.registrationKey(), ScriptBuffer { m_script.toString() }, m_certificateInfo, m_contentSecurityPolicy, m_referrerPolicy, { } });
     197    m_completionHandler({ m_jobData.identifier(), m_jobData.registrationKey(), ScriptBuffer { m_script.toString() }, m_certificateInfo, m_contentSecurityPolicy, m_crossOriginEmbedderPolicy, m_referrerPolicy, { } });
    196198    didComplete();
    197199}
  • trunk/Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerSoftUpdateLoader.h

    r264724 r280953  
    3131#include "NetworkLoadClient.h"
    3232#include <WebCore/ContentSecurityPolicyResponseHeaders.h>
     33#include <WebCore/CrossOriginEmbedderPolicy.h>
    3334#include <WebCore/FetchOptions.h>
    3435#include <WebCore/ServiceWorkerJobData.h>
     
    8283    String m_referrerPolicy;
    8384    WebCore::ContentSecurityPolicyResponseHeaders m_contentSecurityPolicy;
     85    WebCore::CrossOriginEmbedderPolicy m_crossOriginEmbedderPolicy;
    8486
    8587    std::unique_ptr<NetworkCache::Entry> m_cacheEntry;
  • trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCache.cpp

    r279645 r280953  
    3434#include "WebCoreArgumentCoders.h"
    3535#include <WebCore/CacheQueryOptions.h>
     36#include <WebCore/CrossOriginAccessControl.h>
    3637#include <WebCore/HTTPParsers.h>
    3738#include <WebCore/RetrieveRecordsOptions.h>
     
    287288    ASSERT(m_state == State::Open);
    288289
    289     auto taskCounter = ReadRecordTaskCounter::create([caches = makeRef(m_caches), identifier = m_identifier, shouldProvideResponse = options.shouldProvideResponse, callback = WTFMove(callback)](Vector<Record>&& records, Vector<uint64_t>&& failedRecordIdentifiers) mutable {
     290    auto taskCounter = ReadRecordTaskCounter::create([caches = makeRef(m_caches), identifier = m_identifier, options, callback = WTFMove(callback)](Vector<Record>&& records, Vector<uint64_t>&& failedRecordIdentifiers) mutable {
    290291        auto* cache = caches->find(identifier);
    291292        if (cache)
    292293            cache->removeFromRecordList(failedRecordIdentifiers);
    293294
    294         if (!shouldProvideResponse) {
     295        // https://w3c.github.io/ServiceWorker/#dom-cache-matchall (Step 5.4)
     296        for (auto& record : records) {
     297            if (record.response.type() != ResourceResponse::Type::Opaque)
     298                continue;
     299
     300            if (validateCrossOriginResourcePolicy(options.crossOriginEmbedderPolicy.value, options.sourceOrigin, record.request.url(), record.response, ForNavigation::No)) {
     301                callback(makeUnexpected(DOMCacheEngine::Error::CORP));
     302                return;
     303            }
     304        }
     305
     306        if (!options.shouldProvideResponse) {
    295307            for (auto& record : records) {
    296308                record.response = { };
  • trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp

    r280014 r280953  
    277277        return;
    278278
     279    if (auto* document = frame->document())
     280        parameters.crossOriginEmbedderPolicy = document->crossOriginEmbedderPolicy();
     281
    279282    if (auto* page = frame->page()) {
    280283        parameters.pageHasResourceLoadClient = page->hasResourceLoadClient();
     
    284287
    285288    if (auto* ownerElement = frame->ownerElement()) {
    286         if (auto* parentFrame = ownerElement->document().frame())
     289        if (auto* parentFrame = ownerElement->document().frame()) {
    287290            parameters.parentFrameID = parentFrame->loader().frameID();
     291            parameters.parentCrossOriginEmbedderPolicy = ownerElement->document().crossOriginEmbedderPolicy();
     292        }
    288293    }
    289294}
     
    337342            loadParameters.cspResponseHeaders = contentSecurityPolicy->responseHeaders();
    338343    }
     344
     345    if (resourceLoader.options().crossOriginEmbedderPolicy)
     346        loadParameters.crossOriginEmbedderPolicy = *resourceLoader.options().crossOriginEmbedderPolicy;
    339347   
    340348#if ENABLE(APP_BOUND_DOMAINS) || ENABLE(CONTENT_EXTENSIONS)
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm

    r278590 r280953  
    19441944
    19451945    NSURL* directory = [NSURL fileURLWithPath:path isDirectory:YES];
    1946     NSURL *swDBPath = [directory URLByAppendingPathComponent:@"ServiceWorkerRegistrations-6.sqlite3"];
     1946    NSURL *swDBPath = [directory URLByAppendingPathComponent:@"ServiceWorkerRegistrations-7.sqlite3"];
    19471947
    19481948    EXPECT_TRUE([[NSFileManager defaultManager] fileExistsAtPath:swDBPath.path]);
     
    19711971
    19721972    [[NSFileManager defaultManager] createDirectoryAtURL:swPath withIntermediateDirectories:YES attributes:nil error:nil];
    1973     [[NSFileManager defaultManager] copyItemAtURL:url1 toURL:[swPath URLByAppendingPathComponent:@"ServiceWorkerRegistrations-6.sqlite3"] error:nil];
     1973    [[NSFileManager defaultManager] copyItemAtURL:url1 toURL:[swPath URLByAppendingPathComponent:@"ServiceWorkerRegistrations-7.sqlite3"] error:nil];
    19741974
    19751975    auto websiteDataStoreConfiguration = adoptNS([[_WKWebsiteDataStoreConfiguration alloc] init]);
     
    23802380
    23812381    unsigned timeout = 0;
    2382     while (![[NSFileManager defaultManager] fileExistsAtPath:[swPath URLByAppendingPathComponent:@"ServiceWorkerRegistrations-6.sqlite3"].path] && ++timeout < 20)
     2382    while (![[NSFileManager defaultManager] fileExistsAtPath:[swPath URLByAppendingPathComponent:@"ServiceWorkerRegistrations-7.sqlite3"].path] && ++timeout < 20)
    23832383        TestWebKitAPI::Util::sleep(0.1);
    2384     EXPECT_TRUE([[NSFileManager defaultManager] fileExistsAtPath:[swPath URLByAppendingPathComponent:@"ServiceWorkerRegistrations-6.sqlite3"].path]);
     2384    EXPECT_TRUE([[NSFileManager defaultManager] fileExistsAtPath:[swPath URLByAppendingPathComponent:@"ServiceWorkerRegistrations-7.sqlite3"].path]);
    23852385
    23862386    // Fetch SW records
Note: See TracChangeset for help on using the changeset viewer.