From 663c322dad1acda181b1c75a52f24e61da41359a Mon Sep 17 00:00:00 2001 From: Youenn Fablet Date: Mon, 20 Feb 2023 04:21:44 -0800 Subject: [PATCH] Add background fetch WebIDL https://bugs.webkit.org/show_bug.cgi?id=251980 rdar://problem/105213321 Reviewed by Chris Dumez. Introduce WebIDL, experimental flag and minimal implementation. Covered by rebased tests. * LayoutTests/TestExpectations: * LayoutTests/imported/w3c/web-platform-tests/background-fetch/abort.https.window-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/background-fetch/content-security-policy.https.window-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/background-fetch/fetch-uploads.https.window-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/background-fetch/fetch.https.window-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/background-fetch/get-ids.https.window-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/background-fetch/get.https.window-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/background-fetch/idlharness.https.any-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/background-fetch/idlharness.https.any.serviceworker-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/background-fetch/idlharness.https.any.sharedworker-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/background-fetch/idlharness.https.any.worker-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/background-fetch/interfaces.worker-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/background-fetch/match.https.window-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/background-fetch/mixed-content-and-allowed-schemes.https.window-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/background-fetch/port-blocking.https.window-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/background-fetch/update-ui.https.window-expected.txt: Added. * Source/JavaScriptCore/runtime/IntlListFormat.h: * Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: * Source/WebCore/CMakeLists.txt: * Source/WebCore/DerivedSources-input.xcfilelist: * Source/WebCore/DerivedSources-output.xcfilelist: * Source/WebCore/DerivedSources.make: * Source/WebCore/Headers.cmake: * Source/WebCore/Modules/fetch/FetchHeaders.h: * Source/WebCore/Modules/fetch/FetchHeadersGuard.h: Added. * Source/WebCore/Modules/fetch/FetchResponseBodyLoader.h: Added. (WebCore::FetchResponseBodyLoader::takeConsumeDataCallback): (WebCore::FetchResponseBodyLoader::hasConsumeDataCallback const): (WebCore::FetchResponseBodyLoader::consumeDataCallback): (WebCore::FetchResponseBodyLoader::consumeDataByChunk): * Source/WebCore/Sources.txt: * Source/WebCore/WebCore.xcodeproj/project.pbxproj: * Source/WebCore/bindings/js/WebCoreBuiltinNames.h: * Source/WebCore/dom/EventNames.h: * Source/WebCore/dom/EventNames.in: * Source/WebCore/dom/EventTargetFactory.in: * Source/WebCore/workers/service/background-fetch/BackgroundFetchEvent.cpp: Added. (WebCore::BackgroundFetchEvent::create): (WebCore::BackgroundFetchEvent::BackgroundFetchEvent): (WebCore::BackgroundFetchEvent::~BackgroundFetchEvent): (WebCore::BackgroundFetchEvent::registration const): * Source/WebCore/workers/service/background-fetch/BackgroundFetchEvent.h: Added. * Source/WebCore/workers/service/background-fetch/BackgroundFetchEvent.idl: Added. * Source/WebCore/workers/service/background-fetch/BackgroundFetchEventInit.h: Added. * Source/WebCore/workers/service/background-fetch/BackgroundFetchEventInit.idl: Added. * Source/WebCore/workers/service/background-fetch/BackgroundFetchFailureReason.h: Added. * Source/WebCore/workers/service/background-fetch/BackgroundFetchFailureReason.idl: Added. * Source/WebCore/workers/service/background-fetch/BackgroundFetchInformation.h: Added. (WebCore::BackgroundFetchInformation::isolatedCopy const): (WebCore::BackgroundFetchInformation::isolatedCopy): * Source/WebCore/workers/service/background-fetch/BackgroundFetchManager.cpp: Added. (WebCore::BackgroundFetchManager::BackgroundFetchManager): (WebCore::BackgroundFetchManager::~BackgroundFetchManager): (WebCore::BackgroundFetchManager::fetch): (WebCore::BackgroundFetchManager::get): (WebCore::BackgroundFetchManager::getIds): * Source/WebCore/workers/service/background-fetch/BackgroundFetchManager.h: Added. (WebCore::BackgroundFetchManager::create): * Source/WebCore/workers/service/background-fetch/BackgroundFetchManager.idl: Added. * Source/WebCore/workers/service/background-fetch/BackgroundFetchOptions.h: Added. (WebCore::BackgroundFetchOptions::BackgroundFetchOptions): (WebCore::BackgroundFetchOptions::downloadTotal): (WebCore::BackgroundFetchOptions::isolatedCopy const): (WebCore::BackgroundFetchOptions::isolatedCopy): * Source/WebCore/workers/service/background-fetch/BackgroundFetchOptions.idl: Added. * Source/WebCore/workers/service/background-fetch/BackgroundFetchRecord.cpp: Added. (WebCore::BackgroundFetchRecord::BackgroundFetchRecord): (WebCore::BackgroundFetchRecord::~BackgroundFetchRecord): (WebCore::BackgroundFetchRecord::request): (WebCore::BackgroundFetchRecord::settleResponseReadyPromise): * Source/WebCore/workers/service/background-fetch/BackgroundFetchRecord.h: Added. (WebCore::BackgroundFetchRecord::create): (WebCore::BackgroundFetchRecord::responseReady): * Source/WebCore/workers/service/background-fetch/BackgroundFetchRecord.idl: Added. * Source/WebCore/workers/service/background-fetch/BackgroundFetchRecordIdentifier.h: Added. * Source/WebCore/workers/service/background-fetch/BackgroundFetchRecordInformation.h: Added. (WebCore::BackgroundFetchRecordInformation::isolatedCopy const): (WebCore::BackgroundFetchRecordInformation::isolatedCopy): * Source/WebCore/workers/service/background-fetch/BackgroundFetchRegistration.cpp: Added. (WebCore::BackgroundFetchRegistration::create): (WebCore::BackgroundFetchRegistration::BackgroundFetchRegistration): (WebCore::BackgroundFetchRegistration::~BackgroundFetchRegistration): (WebCore::BackgroundFetchRegistration::abort): (WebCore::BackgroundFetchRegistration::match): (WebCore::BackgroundFetchRegistration::matchAll): (WebCore::BackgroundFetchRegistration::updateInformation): (WebCore::BackgroundFetchRegistration::activeDOMObjectName const): (WebCore::BackgroundFetchRegistration::stop): (WebCore::BackgroundFetchRegistration::virtualHasPendingActivity const): * Source/WebCore/workers/service/background-fetch/BackgroundFetchRegistration.h: Added. (WebCore::BackgroundFetchRegistration::id const): (WebCore::BackgroundFetchRegistration::uploadTotal const): (WebCore::BackgroundFetchRegistration::uploaded const): (WebCore::BackgroundFetchRegistration::downloadTotal const): (WebCore::BackgroundFetchRegistration::downloaded const): (WebCore::BackgroundFetchRegistration::result): (WebCore::BackgroundFetchRegistration::failureReason): (WebCore::BackgroundFetchRegistration::recordsAvailable): (WebCore::BackgroundFetchRegistration::registrationIdentifier const): * Source/WebCore/workers/service/background-fetch/BackgroundFetchRegistration.idl: Added. * Source/WebCore/workers/service/background-fetch/BackgroundFetchRequest.h: Added. (WebCore::BackgroundFetchRequest::isolatedCopy const): (WebCore::BackgroundFetchRequest::isolatedCopy): * Source/WebCore/workers/service/background-fetch/BackgroundFetchResult.h: Added. * Source/WebCore/workers/service/background-fetch/BackgroundFetchResult.idl: Added. * Source/WebCore/workers/service/background-fetch/BackgroundFetchUIOptions.h: Added. * Source/WebCore/workers/service/background-fetch/BackgroundFetchUIOptions.idl: Added. * Source/WebCore/workers/service/background-fetch/BackgroundFetchUpdateUIEvent.cpp: Added. (WebCore::BackgroundFetchUpdateUIEvent::create): (WebCore::BackgroundFetchUpdateUIEvent::BackgroundFetchUpdateUIEvent): (WebCore::BackgroundFetchUpdateUIEvent::~BackgroundFetchUpdateUIEvent): (WebCore::BackgroundFetchUpdateUIEvent::updateUI): * Source/WebCore/workers/service/background-fetch/BackgroundFetchUpdateUIEvent.h: Added. * Source/WebCore/workers/service/background-fetch/BackgroundFetchUpdateUIEvent.idl: Added. * Source/WebCore/workers/service/background-fetch/ImageResource.h: Added. (WebCore::ImageResource::isolatedCopy const): (WebCore::ImageResource::isolatedCopy): * Source/WebCore/workers/service/background-fetch/ImageResource.idl: Added. * Source/WebCore/workers/service/background-fetch/ServiceWorkerGlobalScope+BackgroundFetchAPI.idl: Added. * Source/WebCore/workers/service/background-fetch/ServiceWorkerRegistration+BackgroundFetchAPI.idl: Added. * Source/WebCore/workers/service/background-fetch/ServiceWorkerRegistrationBackgroundFetchAPI.cpp: Added. (WebCore::ServiceWorkerRegistrationBackgroundFetchAPI::ServiceWorkerRegistrationBackgroundFetchAPI): (WebCore::ServiceWorkerRegistrationBackgroundFetchAPI::~ServiceWorkerRegistrationBackgroundFetchAPI): (WebCore::ServiceWorkerRegistrationBackgroundFetchAPI::backgroundFetch): (WebCore::ServiceWorkerRegistrationBackgroundFetchAPI::backgroundFetchIfCreated): (WebCore::ServiceWorkerRegistrationBackgroundFetchAPI::backgroundFetchManager): (WebCore::ServiceWorkerRegistrationBackgroundFetchAPI::from): (WebCore::ServiceWorkerRegistrationBackgroundFetchAPI::supplementName): * Source/WebCore/workers/service/background-fetch/ServiceWorkerRegistrationBackgroundFetchAPI.h: Added. Canonical link: https://commits.webkit.org/260532@main --- LayoutTests/TestExpectations | 3 - .../abort.https.window-expected.txt | 5 + ...-security-policy.https.window-expected.txt | 3 + .../fetch-uploads.https.window-expected.txt | 5 + .../fetch.https.window-expected.txt | 18 +++ .../get-ids.https.window-expected.txt | 4 + .../get.https.window-expected.txt | 5 + .../idlharness.https.any-expected.txt | 47 ++++++++ ...rness.https.any.serviceworker-expected.txt | 63 ++++++++++ ...arness.https.any.sharedworker-expected.txt | 47 ++++++++ .../idlharness.https.any.worker-expected.txt | 47 ++++++++ .../background-fetch/interfaces-expected.txt | 76 ------------ .../interfaces.worker-expected.txt | 51 -------- .../background-fetch/interfaces.worker.html | 1 - .../match.https.window-expected.txt | 7 ++ ...-allowed-schemes.https.window-expected.txt | 10 ++ .../port-blocking.https.window-expected.txt | 8 ++ .../update-ui.https.window-expected.txt | 5 + LayoutTests/platform/mac-wk1/TestExpectations | 1 + .../Preferences/UnifiedWebPreferences.yaml | 14 +++ Source/WebCore/CMakeLists.txt | 15 +++ .../WebCore/DerivedSources-input.xcfilelist | 13 ++ .../WebCore/DerivedSources-output.xcfilelist | 26 ++++ Source/WebCore/DerivedSources.make | 13 ++ Source/WebCore/Headers.cmake | 11 ++ Source/WebCore/Modules/fetch/FetchHeaders.h | 24 +--- .../WebCore/Modules/fetch/FetchHeadersGuard.h | 58 +++++++++ .../Modules/fetch/FetchResponseBodyLoader.h | 72 +++++++++++ Source/WebCore/Sources.txt | 17 +++ .../WebCore/WebCore.xcodeproj/project.pbxproj | 82 +++++++++++++ .../WebCore/bindings/js/WebCoreBuiltinNames.h | 9 ++ Source/WebCore/dom/EventNames.h | 4 + Source/WebCore/dom/EventNames.in | 2 + Source/WebCore/dom/EventTargetFactory.in | 1 + .../WebCore/inspector/InspectorFrontendHost.h | 1 + .../background-fetch/BackgroundFetchEvent.cpp | 62 ++++++++++ .../background-fetch/BackgroundFetchEvent.h | 56 +++++++++ .../background-fetch/BackgroundFetchEvent.idl | 33 +++++ .../BackgroundFetchEventInit.h | 41 +++++++ .../BackgroundFetchEventInit.idl | 30 +++++ .../BackgroundFetchFailureReason.h | 61 ++++++++++ .../BackgroundFetchFailureReason.idl | 42 +++++++ .../BackgroundFetchInformation.h | 53 ++++++++ .../BackgroundFetchManager.cpp | 60 +++++++++ .../background-fetch/BackgroundFetchManager.h | 61 ++++++++++ .../BackgroundFetchManager.idl | 36 ++++++ .../background-fetch/BackgroundFetchOptions.h | 51 ++++++++ .../BackgroundFetchOptions.idl | 30 +++++ .../BackgroundFetchRecord.cpp | 66 ++++++++++ .../background-fetch/BackgroundFetchRecord.h | 61 ++++++++++ .../BackgroundFetchRecord.idl | 33 +++++ .../BackgroundFetchRecordIdentifier.h | 36 ++++++ .../BackgroundFetchRecordInformation.h | 53 ++++++++ .../BackgroundFetchRegistration.cpp | 114 ++++++++++++++++++ .../BackgroundFetchRegistration.h | 94 +++++++++++++++ .../BackgroundFetchRegistration.idl | 48 ++++++++ .../background-fetch/BackgroundFetchRequest.h | 50 ++++++++ .../background-fetch/BackgroundFetchResult.h | 53 ++++++++ .../BackgroundFetchResult.idl | 28 +++++ .../BackgroundFetchUIOptions.h | 42 +++++++ .../BackgroundFetchUIOptions.idl | 31 +++++ .../BackgroundFetchUpdateUIEvent.cpp | 62 ++++++++++ .../BackgroundFetchUpdateUIEvent.h | 55 +++++++++ .../BackgroundFetchUpdateUIEvent.idl | 33 +++++ .../service/background-fetch/ImageResource.h | 47 ++++++++ .../background-fetch/ImageResource.idl | 33 +++++ ...ceWorkerGlobalScope+BackgroundFetchAPI.idl | 34 ++++++ ...eWorkerRegistration+BackgroundFetchAPI.idl | 32 +++++ ...ceWorkerRegistrationBackgroundFetchAPI.cpp | 82 +++++++++++++ ...viceWorkerRegistrationBackgroundFetchAPI.h | 59 +++++++++ 70 files changed, 2376 insertions(+), 154 deletions(-) create mode 100644 LayoutTests/imported/w3c/web-platform-tests/background-fetch/abort.https.window-expected.txt create mode 100644 LayoutTests/imported/w3c/web-platform-tests/background-fetch/content-security-policy.https.window-expected.txt create mode 100644 LayoutTests/imported/w3c/web-platform-tests/background-fetch/fetch-uploads.https.window-expected.txt create mode 100644 LayoutTests/imported/w3c/web-platform-tests/background-fetch/fetch.https.window-expected.txt create mode 100644 LayoutTests/imported/w3c/web-platform-tests/background-fetch/get-ids.https.window-expected.txt create mode 100644 LayoutTests/imported/w3c/web-platform-tests/background-fetch/get.https.window-expected.txt create mode 100644 LayoutTests/imported/w3c/web-platform-tests/background-fetch/idlharness.https.any-expected.txt create mode 100644 LayoutTests/imported/w3c/web-platform-tests/background-fetch/idlharness.https.any.serviceworker-expected.txt create mode 100644 LayoutTests/imported/w3c/web-platform-tests/background-fetch/idlharness.https.any.sharedworker-expected.txt create mode 100644 LayoutTests/imported/w3c/web-platform-tests/background-fetch/idlharness.https.any.worker-expected.txt delete mode 100644 LayoutTests/imported/w3c/web-platform-tests/background-fetch/interfaces-expected.txt delete mode 100644 LayoutTests/imported/w3c/web-platform-tests/background-fetch/interfaces.worker-expected.txt delete mode 100644 LayoutTests/imported/w3c/web-platform-tests/background-fetch/interfaces.worker.html create mode 100644 LayoutTests/imported/w3c/web-platform-tests/background-fetch/match.https.window-expected.txt create mode 100644 LayoutTests/imported/w3c/web-platform-tests/background-fetch/mixed-content-and-allowed-schemes.https.window-expected.txt create mode 100644 LayoutTests/imported/w3c/web-platform-tests/background-fetch/port-blocking.https.window-expected.txt create mode 100644 LayoutTests/imported/w3c/web-platform-tests/background-fetch/update-ui.https.window-expected.txt create mode 100644 Source/WebCore/Modules/fetch/FetchHeadersGuard.h create mode 100644 Source/WebCore/Modules/fetch/FetchResponseBodyLoader.h create mode 100644 Source/WebCore/workers/service/background-fetch/BackgroundFetchEvent.cpp create mode 100644 Source/WebCore/workers/service/background-fetch/BackgroundFetchEvent.h create mode 100644 Source/WebCore/workers/service/background-fetch/BackgroundFetchEvent.idl create mode 100644 Source/WebCore/workers/service/background-fetch/BackgroundFetchEventInit.h create mode 100644 Source/WebCore/workers/service/background-fetch/BackgroundFetchEventInit.idl create mode 100644 Source/WebCore/workers/service/background-fetch/BackgroundFetchFailureReason.h create mode 100644 Source/WebCore/workers/service/background-fetch/BackgroundFetchFailureReason.idl create mode 100644 Source/WebCore/workers/service/background-fetch/BackgroundFetchInformation.h create mode 100644 Source/WebCore/workers/service/background-fetch/BackgroundFetchManager.cpp create mode 100644 Source/WebCore/workers/service/background-fetch/BackgroundFetchManager.h create mode 100644 Source/WebCore/workers/service/background-fetch/BackgroundFetchManager.idl create mode 100644 Source/WebCore/workers/service/background-fetch/BackgroundFetchOptions.h create mode 100644 Source/WebCore/workers/service/background-fetch/BackgroundFetchOptions.idl create mode 100644 Source/WebCore/workers/service/background-fetch/BackgroundFetchRecord.cpp create mode 100644 Source/WebCore/workers/service/background-fetch/BackgroundFetchRecord.h create mode 100644 Source/WebCore/workers/service/background-fetch/BackgroundFetchRecord.idl create mode 100644 Source/WebCore/workers/service/background-fetch/BackgroundFetchRecordIdentifier.h create mode 100644 Source/WebCore/workers/service/background-fetch/BackgroundFetchRecordInformation.h create mode 100644 Source/WebCore/workers/service/background-fetch/BackgroundFetchRegistration.cpp create mode 100644 Source/WebCore/workers/service/background-fetch/BackgroundFetchRegistration.h create mode 100644 Source/WebCore/workers/service/background-fetch/BackgroundFetchRegistration.idl create mode 100644 Source/WebCore/workers/service/background-fetch/BackgroundFetchRequest.h create mode 100644 Source/WebCore/workers/service/background-fetch/BackgroundFetchResult.h create mode 100644 Source/WebCore/workers/service/background-fetch/BackgroundFetchResult.idl create mode 100644 Source/WebCore/workers/service/background-fetch/BackgroundFetchUIOptions.h create mode 100644 Source/WebCore/workers/service/background-fetch/BackgroundFetchUIOptions.idl create mode 100644 Source/WebCore/workers/service/background-fetch/BackgroundFetchUpdateUIEvent.cpp create mode 100644 Source/WebCore/workers/service/background-fetch/BackgroundFetchUpdateUIEvent.h create mode 100644 Source/WebCore/workers/service/background-fetch/BackgroundFetchUpdateUIEvent.idl create mode 100644 Source/WebCore/workers/service/background-fetch/ImageResource.h create mode 100644 Source/WebCore/workers/service/background-fetch/ImageResource.idl create mode 100644 Source/WebCore/workers/service/background-fetch/ServiceWorkerGlobalScope+BackgroundFetchAPI.idl create mode 100644 Source/WebCore/workers/service/background-fetch/ServiceWorkerRegistration+BackgroundFetchAPI.idl create mode 100644 Source/WebCore/workers/service/background-fetch/ServiceWorkerRegistrationBackgroundFetchAPI.cpp create mode 100644 Source/WebCore/workers/service/background-fetch/ServiceWorkerRegistrationBackgroundFetchAPI.h diff --git a/LayoutTests/TestExpectations b/LayoutTests/TestExpectations index bfd9e90445b7a..d0c2fde9cfc52 100644 --- a/LayoutTests/TestExpectations +++ b/LayoutTests/TestExpectations @@ -1225,9 +1225,6 @@ imported/w3c/web-platform-tests/fetch/metadata/redirect/ [ Skip ] # These tests have unreliable ordering and are flakey -# Not supported -imported/w3c/web-platform-tests/background-fetch [ Skip ] - # This is a resources folder. http/tests/workers/service/other_resources [ Skip ] diff --git a/LayoutTests/imported/w3c/web-platform-tests/background-fetch/abort.https.window-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/background-fetch/abort.https.window-expected.txt new file mode 100644 index 0000000000000..a40b1286bdff8 --- /dev/null +++ b/LayoutTests/imported/w3c/web-platform-tests/background-fetch/abort.https.window-expected.txt @@ -0,0 +1,5 @@ + +FAIL Aborting the same registration twice fails promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL Calling BackgroundFetchRegistration.abort sets the correct fields and responses are still available promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL An aborted fetch throws a DOM exception when accessing an incomplete record promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." + diff --git a/LayoutTests/imported/w3c/web-platform-tests/background-fetch/content-security-policy.https.window-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/background-fetch/content-security-policy.https.window-expected.txt new file mode 100644 index 0000000000000..2ecc0db99f20d --- /dev/null +++ b/LayoutTests/imported/w3c/web-platform-tests/background-fetch/content-security-policy.https.window-expected.txt @@ -0,0 +1,3 @@ + +FAIL fetch blocked by CSP should reject promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." + diff --git a/LayoutTests/imported/w3c/web-platform-tests/background-fetch/fetch-uploads.https.window-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/background-fetch/fetch-uploads.https.window-expected.txt new file mode 100644 index 0000000000000..dc074c119acf2 --- /dev/null +++ b/LayoutTests/imported/w3c/web-platform-tests/background-fetch/fetch-uploads.https.window-expected.txt @@ -0,0 +1,5 @@ + +FAIL Fetch with an upload should work promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL Progress event includes uploaded bytes promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL Duplicate upload requests work and can be distinguished. promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." + diff --git a/LayoutTests/imported/w3c/web-platform-tests/background-fetch/fetch.https.window-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/background-fetch/fetch.https.window-expected.txt new file mode 100644 index 0000000000000..950f6c3d43cc4 --- /dev/null +++ b/LayoutTests/imported/w3c/web-platform-tests/background-fetch/fetch.https.window-expected.txt @@ -0,0 +1,18 @@ + +FAIL Background Fetch requires an activated Service Worker promise_rejects_js: fetch() must reject on pending and installing workers function "function () { throw e }" threw object "NotSupportedError: The operation is not supported." ("NotSupportedError") expected instance of function "function TypeError() { + [native code] +}" ("TypeError") +FAIL Argument verification is done for BackgroundFetchManager.fetch() promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL IDs must be unique among active Background Fetch registrations promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL Empty URL is OK. promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL Requests with PUT method require CORS Preflight and succeed. promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL Requests with text/json content type require CORS Preflight and succeed. promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL Using Background Fetch to successfully fetch a single resource promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL Registration object gets updated values when a background fetch completes. promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL Background Fetch that exceeds the quota throws a QuotaExceededError promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL Fetches can have requests with duplicate URLs promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL recordsAvailable is false after onbackgroundfetchsuccess finishes execution. promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL Using Background Fetch to fetch a non-existent resource should fail. promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL Fetches with mixed content should fail. promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL Responses failing CORS checks are not leaked promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." + diff --git a/LayoutTests/imported/w3c/web-platform-tests/background-fetch/get-ids.https.window-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/background-fetch/get-ids.https.window-expected.txt new file mode 100644 index 0000000000000..f3caf9ba27fc7 --- /dev/null +++ b/LayoutTests/imported/w3c/web-platform-tests/background-fetch/get-ids.https.window-expected.txt @@ -0,0 +1,4 @@ + +FAIL BackgroundFetchManager.getIds() does not require an activated worker promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported." +FAIL The BackgroundFetchManager exposes active fetches promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." + diff --git a/LayoutTests/imported/w3c/web-platform-tests/background-fetch/get.https.window-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/background-fetch/get.https.window-expected.txt new file mode 100644 index 0000000000000..9b0b5428e45d4 --- /dev/null +++ b/LayoutTests/imported/w3c/web-platform-tests/background-fetch/get.https.window-expected.txt @@ -0,0 +1,5 @@ + +FAIL BackgroundFetchManager.get() does not require an activated worker promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported." +FAIL Getting non-existing registrations yields `undefined` promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL Getting an existing registration has the expected values promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." + diff --git a/LayoutTests/imported/w3c/web-platform-tests/background-fetch/idlharness.https.any-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/background-fetch/idlharness.https.any-expected.txt new file mode 100644 index 0000000000000..5dc0b68ed85da --- /dev/null +++ b/LayoutTests/imported/w3c/web-platform-tests/background-fetch/idlharness.https.any-expected.txt @@ -0,0 +1,47 @@ + +PASS idl_test setup +PASS idl_test validation +PASS Partial interface ServiceWorkerGlobalScope: original interface defined +PASS Partial interface ServiceWorkerGlobalScope: member names are unique +PASS Partial interface ServiceWorkerRegistration: original interface defined +PASS Partial interface ServiceWorkerRegistration: member names are unique +PASS WorkerGlobalScope includes WindowOrWorkerGlobalScope: member names are unique +PASS BackgroundFetchManager interface: existence and properties of interface object +PASS BackgroundFetchManager interface object length +PASS BackgroundFetchManager interface object name +PASS BackgroundFetchManager interface: existence and properties of interface prototype object +PASS BackgroundFetchManager interface: existence and properties of interface prototype object's "constructor" property +PASS BackgroundFetchManager interface: existence and properties of interface prototype object's @@unscopables property +PASS BackgroundFetchManager interface: operation fetch(DOMString, (RequestInfo or sequence), optional BackgroundFetchOptions) +PASS BackgroundFetchManager interface: operation get(DOMString) +PASS BackgroundFetchManager interface: operation getIds() +PASS BackgroundFetchRegistration interface: existence and properties of interface object +PASS BackgroundFetchRegistration interface object length +PASS BackgroundFetchRegistration interface object name +PASS BackgroundFetchRegistration interface: existence and properties of interface prototype object +PASS BackgroundFetchRegistration interface: existence and properties of interface prototype object's "constructor" property +PASS BackgroundFetchRegistration interface: existence and properties of interface prototype object's @@unscopables property +PASS BackgroundFetchRegistration interface: attribute id +PASS BackgroundFetchRegistration interface: attribute uploadTotal +PASS BackgroundFetchRegistration interface: attribute uploaded +PASS BackgroundFetchRegistration interface: attribute downloadTotal +PASS BackgroundFetchRegistration interface: attribute downloaded +PASS BackgroundFetchRegistration interface: attribute result +PASS BackgroundFetchRegistration interface: attribute failureReason +PASS BackgroundFetchRegistration interface: attribute recordsAvailable +PASS BackgroundFetchRegistration interface: attribute onprogress +PASS BackgroundFetchRegistration interface: operation abort() +PASS BackgroundFetchRegistration interface: operation match(RequestInfo, optional CacheQueryOptions) +PASS BackgroundFetchRegistration interface: operation matchAll(optional RequestInfo, optional CacheQueryOptions) +PASS BackgroundFetchRecord interface: existence and properties of interface object +PASS BackgroundFetchRecord interface object length +PASS BackgroundFetchRecord interface object name +PASS BackgroundFetchRecord interface: existence and properties of interface prototype object +PASS BackgroundFetchRecord interface: existence and properties of interface prototype object's "constructor" property +PASS BackgroundFetchRecord interface: existence and properties of interface prototype object's @@unscopables property +PASS BackgroundFetchRecord interface: attribute request +PASS BackgroundFetchRecord interface: attribute responseReady +PASS BackgroundFetchEvent interface: existence and properties of interface object +FAIL BackgroundFetchUpdateUIEvent interface: existence and properties of interface object assert_false: expected false got true +PASS ServiceWorkerRegistration interface: attribute backgroundFetch + diff --git a/LayoutTests/imported/w3c/web-platform-tests/background-fetch/idlharness.https.any.serviceworker-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/background-fetch/idlharness.https.any.serviceworker-expected.txt new file mode 100644 index 0000000000000..4e4592ea4ba7d --- /dev/null +++ b/LayoutTests/imported/w3c/web-platform-tests/background-fetch/idlharness.https.any.serviceworker-expected.txt @@ -0,0 +1,63 @@ + +PASS idl_test setup +PASS idl_test validation +PASS Partial interface ServiceWorkerGlobalScope: original interface defined +PASS Partial interface ServiceWorkerGlobalScope: member names are unique +PASS Partial interface ServiceWorkerRegistration: original interface defined +PASS Partial interface ServiceWorkerRegistration: member names are unique +PASS WorkerGlobalScope includes WindowOrWorkerGlobalScope: member names are unique +PASS BackgroundFetchManager interface: existence and properties of interface object +PASS BackgroundFetchManager interface object length +PASS BackgroundFetchManager interface object name +PASS BackgroundFetchManager interface: existence and properties of interface prototype object +PASS BackgroundFetchManager interface: existence and properties of interface prototype object's "constructor" property +PASS BackgroundFetchManager interface: existence and properties of interface prototype object's @@unscopables property +PASS BackgroundFetchManager interface: operation fetch(DOMString, (RequestInfo or sequence), optional BackgroundFetchOptions) +PASS BackgroundFetchManager interface: operation get(DOMString) +PASS BackgroundFetchManager interface: operation getIds() +PASS BackgroundFetchRegistration interface: existence and properties of interface object +PASS BackgroundFetchRegistration interface object length +PASS BackgroundFetchRegistration interface object name +PASS BackgroundFetchRegistration interface: existence and properties of interface prototype object +PASS BackgroundFetchRegistration interface: existence and properties of interface prototype object's "constructor" property +PASS BackgroundFetchRegistration interface: existence and properties of interface prototype object's @@unscopables property +PASS BackgroundFetchRegistration interface: attribute id +PASS BackgroundFetchRegistration interface: attribute uploadTotal +PASS BackgroundFetchRegistration interface: attribute uploaded +PASS BackgroundFetchRegistration interface: attribute downloadTotal +PASS BackgroundFetchRegistration interface: attribute downloaded +PASS BackgroundFetchRegistration interface: attribute result +PASS BackgroundFetchRegistration interface: attribute failureReason +PASS BackgroundFetchRegistration interface: attribute recordsAvailable +PASS BackgroundFetchRegistration interface: attribute onprogress +PASS BackgroundFetchRegistration interface: operation abort() +PASS BackgroundFetchRegistration interface: operation match(RequestInfo, optional CacheQueryOptions) +PASS BackgroundFetchRegistration interface: operation matchAll(optional RequestInfo, optional CacheQueryOptions) +PASS BackgroundFetchRecord interface: existence and properties of interface object +PASS BackgroundFetchRecord interface object length +PASS BackgroundFetchRecord interface object name +PASS BackgroundFetchRecord interface: existence and properties of interface prototype object +PASS BackgroundFetchRecord interface: existence and properties of interface prototype object's "constructor" property +PASS BackgroundFetchRecord interface: existence and properties of interface prototype object's @@unscopables property +PASS BackgroundFetchRecord interface: attribute request +PASS BackgroundFetchRecord interface: attribute responseReady +PASS BackgroundFetchEvent interface: existence and properties of interface object +PASS BackgroundFetchEvent interface object length +PASS BackgroundFetchEvent interface object name +PASS BackgroundFetchEvent interface: existence and properties of interface prototype object +PASS BackgroundFetchEvent interface: existence and properties of interface prototype object's "constructor" property +PASS BackgroundFetchEvent interface: existence and properties of interface prototype object's @@unscopables property +PASS BackgroundFetchEvent interface: attribute registration +PASS BackgroundFetchUpdateUIEvent interface: existence and properties of interface object +PASS BackgroundFetchUpdateUIEvent interface object length +PASS BackgroundFetchUpdateUIEvent interface object name +PASS BackgroundFetchUpdateUIEvent interface: existence and properties of interface prototype object +PASS BackgroundFetchUpdateUIEvent interface: existence and properties of interface prototype object's "constructor" property +PASS BackgroundFetchUpdateUIEvent interface: existence and properties of interface prototype object's @@unscopables property +PASS BackgroundFetchUpdateUIEvent interface: operation updateUI(optional BackgroundFetchUIOptions) +PASS ServiceWorkerRegistration interface: attribute backgroundFetch +PASS ServiceWorkerGlobalScope interface: attribute onbackgroundfetchsuccess +PASS ServiceWorkerGlobalScope interface: attribute onbackgroundfetchfail +PASS ServiceWorkerGlobalScope interface: attribute onbackgroundfetchabort +PASS ServiceWorkerGlobalScope interface: attribute onbackgroundfetchclick + diff --git a/LayoutTests/imported/w3c/web-platform-tests/background-fetch/idlharness.https.any.sharedworker-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/background-fetch/idlharness.https.any.sharedworker-expected.txt new file mode 100644 index 0000000000000..5dc0b68ed85da --- /dev/null +++ b/LayoutTests/imported/w3c/web-platform-tests/background-fetch/idlharness.https.any.sharedworker-expected.txt @@ -0,0 +1,47 @@ + +PASS idl_test setup +PASS idl_test validation +PASS Partial interface ServiceWorkerGlobalScope: original interface defined +PASS Partial interface ServiceWorkerGlobalScope: member names are unique +PASS Partial interface ServiceWorkerRegistration: original interface defined +PASS Partial interface ServiceWorkerRegistration: member names are unique +PASS WorkerGlobalScope includes WindowOrWorkerGlobalScope: member names are unique +PASS BackgroundFetchManager interface: existence and properties of interface object +PASS BackgroundFetchManager interface object length +PASS BackgroundFetchManager interface object name +PASS BackgroundFetchManager interface: existence and properties of interface prototype object +PASS BackgroundFetchManager interface: existence and properties of interface prototype object's "constructor" property +PASS BackgroundFetchManager interface: existence and properties of interface prototype object's @@unscopables property +PASS BackgroundFetchManager interface: operation fetch(DOMString, (RequestInfo or sequence), optional BackgroundFetchOptions) +PASS BackgroundFetchManager interface: operation get(DOMString) +PASS BackgroundFetchManager interface: operation getIds() +PASS BackgroundFetchRegistration interface: existence and properties of interface object +PASS BackgroundFetchRegistration interface object length +PASS BackgroundFetchRegistration interface object name +PASS BackgroundFetchRegistration interface: existence and properties of interface prototype object +PASS BackgroundFetchRegistration interface: existence and properties of interface prototype object's "constructor" property +PASS BackgroundFetchRegistration interface: existence and properties of interface prototype object's @@unscopables property +PASS BackgroundFetchRegistration interface: attribute id +PASS BackgroundFetchRegistration interface: attribute uploadTotal +PASS BackgroundFetchRegistration interface: attribute uploaded +PASS BackgroundFetchRegistration interface: attribute downloadTotal +PASS BackgroundFetchRegistration interface: attribute downloaded +PASS BackgroundFetchRegistration interface: attribute result +PASS BackgroundFetchRegistration interface: attribute failureReason +PASS BackgroundFetchRegistration interface: attribute recordsAvailable +PASS BackgroundFetchRegistration interface: attribute onprogress +PASS BackgroundFetchRegistration interface: operation abort() +PASS BackgroundFetchRegistration interface: operation match(RequestInfo, optional CacheQueryOptions) +PASS BackgroundFetchRegistration interface: operation matchAll(optional RequestInfo, optional CacheQueryOptions) +PASS BackgroundFetchRecord interface: existence and properties of interface object +PASS BackgroundFetchRecord interface object length +PASS BackgroundFetchRecord interface object name +PASS BackgroundFetchRecord interface: existence and properties of interface prototype object +PASS BackgroundFetchRecord interface: existence and properties of interface prototype object's "constructor" property +PASS BackgroundFetchRecord interface: existence and properties of interface prototype object's @@unscopables property +PASS BackgroundFetchRecord interface: attribute request +PASS BackgroundFetchRecord interface: attribute responseReady +PASS BackgroundFetchEvent interface: existence and properties of interface object +FAIL BackgroundFetchUpdateUIEvent interface: existence and properties of interface object assert_false: expected false got true +PASS ServiceWorkerRegistration interface: attribute backgroundFetch + diff --git a/LayoutTests/imported/w3c/web-platform-tests/background-fetch/idlharness.https.any.worker-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/background-fetch/idlharness.https.any.worker-expected.txt new file mode 100644 index 0000000000000..5dc0b68ed85da --- /dev/null +++ b/LayoutTests/imported/w3c/web-platform-tests/background-fetch/idlharness.https.any.worker-expected.txt @@ -0,0 +1,47 @@ + +PASS idl_test setup +PASS idl_test validation +PASS Partial interface ServiceWorkerGlobalScope: original interface defined +PASS Partial interface ServiceWorkerGlobalScope: member names are unique +PASS Partial interface ServiceWorkerRegistration: original interface defined +PASS Partial interface ServiceWorkerRegistration: member names are unique +PASS WorkerGlobalScope includes WindowOrWorkerGlobalScope: member names are unique +PASS BackgroundFetchManager interface: existence and properties of interface object +PASS BackgroundFetchManager interface object length +PASS BackgroundFetchManager interface object name +PASS BackgroundFetchManager interface: existence and properties of interface prototype object +PASS BackgroundFetchManager interface: existence and properties of interface prototype object's "constructor" property +PASS BackgroundFetchManager interface: existence and properties of interface prototype object's @@unscopables property +PASS BackgroundFetchManager interface: operation fetch(DOMString, (RequestInfo or sequence), optional BackgroundFetchOptions) +PASS BackgroundFetchManager interface: operation get(DOMString) +PASS BackgroundFetchManager interface: operation getIds() +PASS BackgroundFetchRegistration interface: existence and properties of interface object +PASS BackgroundFetchRegistration interface object length +PASS BackgroundFetchRegistration interface object name +PASS BackgroundFetchRegistration interface: existence and properties of interface prototype object +PASS BackgroundFetchRegistration interface: existence and properties of interface prototype object's "constructor" property +PASS BackgroundFetchRegistration interface: existence and properties of interface prototype object's @@unscopables property +PASS BackgroundFetchRegistration interface: attribute id +PASS BackgroundFetchRegistration interface: attribute uploadTotal +PASS BackgroundFetchRegistration interface: attribute uploaded +PASS BackgroundFetchRegistration interface: attribute downloadTotal +PASS BackgroundFetchRegistration interface: attribute downloaded +PASS BackgroundFetchRegistration interface: attribute result +PASS BackgroundFetchRegistration interface: attribute failureReason +PASS BackgroundFetchRegistration interface: attribute recordsAvailable +PASS BackgroundFetchRegistration interface: attribute onprogress +PASS BackgroundFetchRegistration interface: operation abort() +PASS BackgroundFetchRegistration interface: operation match(RequestInfo, optional CacheQueryOptions) +PASS BackgroundFetchRegistration interface: operation matchAll(optional RequestInfo, optional CacheQueryOptions) +PASS BackgroundFetchRecord interface: existence and properties of interface object +PASS BackgroundFetchRecord interface object length +PASS BackgroundFetchRecord interface object name +PASS BackgroundFetchRecord interface: existence and properties of interface prototype object +PASS BackgroundFetchRecord interface: existence and properties of interface prototype object's "constructor" property +PASS BackgroundFetchRecord interface: existence and properties of interface prototype object's @@unscopables property +PASS BackgroundFetchRecord interface: attribute request +PASS BackgroundFetchRecord interface: attribute responseReady +PASS BackgroundFetchEvent interface: existence and properties of interface object +FAIL BackgroundFetchUpdateUIEvent interface: existence and properties of interface object assert_false: expected false got true +PASS ServiceWorkerRegistration interface: attribute backgroundFetch + diff --git a/LayoutTests/imported/w3c/web-platform-tests/background-fetch/interfaces-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/background-fetch/interfaces-expected.txt deleted file mode 100644 index 3c0927e00aabf..0000000000000 --- a/LayoutTests/imported/w3c/web-platform-tests/background-fetch/interfaces-expected.txt +++ /dev/null @@ -1,76 +0,0 @@ -idlharness test - -This test validates the WebIDL included in the Background Fetch API (Documents). - - -PASS Exposed interfaces in a Document. -FAIL ServiceWorkerRegistration interface: attribute backgroundFetch assert_true: The prototype object must have a property "backgroundFetch" expected true got false -PASS Unscopable handled correctly for backgroundFetch property on ServiceWorkerRegistration -PASS ServiceWorkerGlobalScope interface: existence and properties of interface object -FAIL BackgroundFetchManager interface: existence and properties of interface object assert_own_property: self does not have own property "BackgroundFetchManager" expected property "BackgroundFetchManager" missing -FAIL BackgroundFetchManager interface object length assert_own_property: self does not have own property "BackgroundFetchManager" expected property "BackgroundFetchManager" missing -FAIL BackgroundFetchManager interface object name assert_own_property: self does not have own property "BackgroundFetchManager" expected property "BackgroundFetchManager" missing -FAIL BackgroundFetchManager interface: existence and properties of interface prototype object assert_own_property: self does not have own property "BackgroundFetchManager" expected property "BackgroundFetchManager" missing -FAIL BackgroundFetchManager interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "BackgroundFetchManager" expected property "BackgroundFetchManager" missing -FAIL BackgroundFetchManager interface: existence and properties of interface prototype object's @@unscopables property assert_own_property: self does not have own property "BackgroundFetchManager" expected property "BackgroundFetchManager" missing -FAIL BackgroundFetchManager interface: operation fetch(DOMString, [object Object],[object Object], BackgroundFetchOptions) assert_own_property: self does not have own property "BackgroundFetchManager" expected property "BackgroundFetchManager" missing -PASS Unscopable handled correctly for fetch(DOMString, [object Object],[object Object], BackgroundFetchOptions) on BackgroundFetchManager -FAIL BackgroundFetchManager interface: operation get(DOMString) assert_own_property: self does not have own property "BackgroundFetchManager" expected property "BackgroundFetchManager" missing -PASS Unscopable handled correctly for get(DOMString) on BackgroundFetchManager -FAIL BackgroundFetchManager interface: operation getIds() assert_own_property: self does not have own property "BackgroundFetchManager" expected property "BackgroundFetchManager" missing -PASS Unscopable handled correctly for getIds() on BackgroundFetchManager -FAIL BackgroundFetchRegistration interface: existence and properties of interface object assert_own_property: self does not have own property "BackgroundFetchRegistration" expected property "BackgroundFetchRegistration" missing -FAIL BackgroundFetchRegistration interface object length assert_own_property: self does not have own property "BackgroundFetchRegistration" expected property "BackgroundFetchRegistration" missing -FAIL BackgroundFetchRegistration interface object name assert_own_property: self does not have own property "BackgroundFetchRegistration" expected property "BackgroundFetchRegistration" missing -FAIL BackgroundFetchRegistration interface: existence and properties of interface prototype object assert_own_property: self does not have own property "BackgroundFetchRegistration" expected property "BackgroundFetchRegistration" missing -FAIL BackgroundFetchRegistration interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "BackgroundFetchRegistration" expected property "BackgroundFetchRegistration" missing -FAIL BackgroundFetchRegistration interface: existence and properties of interface prototype object's @@unscopables property assert_own_property: self does not have own property "BackgroundFetchRegistration" expected property "BackgroundFetchRegistration" missing -FAIL BackgroundFetchRegistration interface: attribute id assert_own_property: self does not have own property "BackgroundFetchRegistration" expected property "BackgroundFetchRegistration" missing -PASS Unscopable handled correctly for id property on BackgroundFetchRegistration -FAIL BackgroundFetchRegistration interface: attribute uploadTotal assert_own_property: self does not have own property "BackgroundFetchRegistration" expected property "BackgroundFetchRegistration" missing -PASS Unscopable handled correctly for uploadTotal property on BackgroundFetchRegistration -FAIL BackgroundFetchRegistration interface: attribute uploaded assert_own_property: self does not have own property "BackgroundFetchRegistration" expected property "BackgroundFetchRegistration" missing -PASS Unscopable handled correctly for uploaded property on BackgroundFetchRegistration -FAIL BackgroundFetchRegistration interface: attribute downloadTotal assert_own_property: self does not have own property "BackgroundFetchRegistration" expected property "BackgroundFetchRegistration" missing -PASS Unscopable handled correctly for downloadTotal property on BackgroundFetchRegistration -FAIL BackgroundFetchRegistration interface: attribute downloaded assert_own_property: self does not have own property "BackgroundFetchRegistration" expected property "BackgroundFetchRegistration" missing -PASS Unscopable handled correctly for downloaded property on BackgroundFetchRegistration -FAIL BackgroundFetchRegistration interface: attribute activeFetches assert_own_property: self does not have own property "BackgroundFetchRegistration" expected property "BackgroundFetchRegistration" missing -PASS Unscopable handled correctly for activeFetches property on BackgroundFetchRegistration -FAIL BackgroundFetchRegistration interface: attribute onprogress assert_own_property: self does not have own property "BackgroundFetchRegistration" expected property "BackgroundFetchRegistration" missing -PASS Unscopable handled correctly for onprogress property on BackgroundFetchRegistration -FAIL BackgroundFetchRegistration interface: operation abort() assert_own_property: self does not have own property "BackgroundFetchRegistration" expected property "BackgroundFetchRegistration" missing -PASS Unscopable handled correctly for abort() on BackgroundFetchRegistration -FAIL BackgroundFetchFetch interface: existence and properties of interface object assert_own_property: self does not have own property "BackgroundFetchFetch" expected property "BackgroundFetchFetch" missing -FAIL BackgroundFetchFetch interface object length assert_own_property: self does not have own property "BackgroundFetchFetch" expected property "BackgroundFetchFetch" missing -FAIL BackgroundFetchFetch interface object name assert_own_property: self does not have own property "BackgroundFetchFetch" expected property "BackgroundFetchFetch" missing -FAIL BackgroundFetchFetch interface: existence and properties of interface prototype object assert_own_property: self does not have own property "BackgroundFetchFetch" expected property "BackgroundFetchFetch" missing -FAIL BackgroundFetchFetch interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "BackgroundFetchFetch" expected property "BackgroundFetchFetch" missing -FAIL BackgroundFetchFetch interface: existence and properties of interface prototype object's @@unscopables property assert_own_property: self does not have own property "BackgroundFetchFetch" expected property "BackgroundFetchFetch" missing -FAIL BackgroundFetchFetch interface: attribute request assert_own_property: self does not have own property "BackgroundFetchFetch" expected property "BackgroundFetchFetch" missing -PASS Unscopable handled correctly for request property on BackgroundFetchFetch -FAIL BackgroundFetchActiveFetches interface: existence and properties of interface object assert_own_property: self does not have own property "BackgroundFetchActiveFetches" expected property "BackgroundFetchActiveFetches" missing -FAIL BackgroundFetchActiveFetches interface object length assert_own_property: self does not have own property "BackgroundFetchActiveFetches" expected property "BackgroundFetchActiveFetches" missing -FAIL BackgroundFetchActiveFetches interface object name assert_own_property: self does not have own property "BackgroundFetchActiveFetches" expected property "BackgroundFetchActiveFetches" missing -FAIL BackgroundFetchActiveFetches interface: existence and properties of interface prototype object assert_own_property: self does not have own property "BackgroundFetchActiveFetches" expected property "BackgroundFetchActiveFetches" missing -FAIL BackgroundFetchActiveFetches interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "BackgroundFetchActiveFetches" expected property "BackgroundFetchActiveFetches" missing -FAIL BackgroundFetchActiveFetches interface: existence and properties of interface prototype object's @@unscopables property assert_own_property: self does not have own property "BackgroundFetchActiveFetches" expected property "BackgroundFetchActiveFetches" missing -FAIL BackgroundFetchActiveFetches interface: operation match(RequestInfo) assert_own_property: self does not have own property "BackgroundFetchActiveFetches" expected property "BackgroundFetchActiveFetches" missing -PASS Unscopable handled correctly for match(RequestInfo) on BackgroundFetchActiveFetches -FAIL BackgroundFetchActiveFetches interface: operation values() assert_own_property: self does not have own property "BackgroundFetchActiveFetches" expected property "BackgroundFetchActiveFetches" missing -PASS Unscopable handled correctly for values() on BackgroundFetchActiveFetches -FAIL BackgroundFetchActiveFetch interface: existence and properties of interface object assert_own_property: self does not have own property "BackgroundFetchActiveFetch" expected property "BackgroundFetchActiveFetch" missing -FAIL BackgroundFetchActiveFetch interface object length assert_own_property: self does not have own property "BackgroundFetchActiveFetch" expected property "BackgroundFetchActiveFetch" missing -FAIL BackgroundFetchActiveFetch interface object name assert_own_property: self does not have own property "BackgroundFetchActiveFetch" expected property "BackgroundFetchActiveFetch" missing -FAIL BackgroundFetchActiveFetch interface: existence and properties of interface prototype object assert_own_property: self does not have own property "BackgroundFetchActiveFetch" expected property "BackgroundFetchActiveFetch" missing -FAIL BackgroundFetchActiveFetch interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "BackgroundFetchActiveFetch" expected property "BackgroundFetchActiveFetch" missing -FAIL BackgroundFetchActiveFetch interface: existence and properties of interface prototype object's @@unscopables property assert_own_property: self does not have own property "BackgroundFetchActiveFetch" expected property "BackgroundFetchActiveFetch" missing -FAIL BackgroundFetchActiveFetch interface: attribute responseReady assert_own_property: self does not have own property "BackgroundFetchActiveFetch" expected property "BackgroundFetchActiveFetch" missing -PASS Unscopable handled correctly for responseReady property on BackgroundFetchActiveFetch -PASS BackgroundFetchEvent interface: existence and properties of interface object -PASS BackgroundFetchSettledEvent interface: existence and properties of interface object -PASS BackgroundFetchSettledFetches interface: existence and properties of interface object -PASS BackgroundFetchSettledFetch interface: existence and properties of interface object -PASS BackgroundFetchUpdateEvent interface: existence and properties of interface object -PASS BackgroundFetchClickEvent interface: existence and properties of interface object - diff --git a/LayoutTests/imported/w3c/web-platform-tests/background-fetch/interfaces.worker-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/background-fetch/interfaces.worker-expected.txt deleted file mode 100644 index 37cc340b3a71a..0000000000000 --- a/LayoutTests/imported/w3c/web-platform-tests/background-fetch/interfaces.worker-expected.txt +++ /dev/null @@ -1,51 +0,0 @@ - -PASS Exposed interfaces in a Service Worker. -PASS ServiceWorkerRegistration interface: existence and properties of interface object -PASS ServiceWorkerGlobalScope interface: existence and properties of interface object -FAIL BackgroundFetchManager interface: existence and properties of interface object assert_own_property: self does not have own property "BackgroundFetchManager" expected property "BackgroundFetchManager" missing -FAIL BackgroundFetchManager interface object length assert_own_property: self does not have own property "BackgroundFetchManager" expected property "BackgroundFetchManager" missing -FAIL BackgroundFetchManager interface object name assert_own_property: self does not have own property "BackgroundFetchManager" expected property "BackgroundFetchManager" missing -FAIL BackgroundFetchManager interface: existence and properties of interface prototype object assert_own_property: self does not have own property "BackgroundFetchManager" expected property "BackgroundFetchManager" missing -FAIL BackgroundFetchManager interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "BackgroundFetchManager" expected property "BackgroundFetchManager" missing -FAIL BackgroundFetchManager interface: operation fetch(DOMString, [object Object],[object Object], BackgroundFetchOptions) assert_own_property: self does not have own property "BackgroundFetchManager" expected property "BackgroundFetchManager" missing -FAIL BackgroundFetchManager interface: operation get(DOMString) assert_own_property: self does not have own property "BackgroundFetchManager" expected property "BackgroundFetchManager" missing -FAIL BackgroundFetchManager interface: operation getIds() assert_own_property: self does not have own property "BackgroundFetchManager" expected property "BackgroundFetchManager" missing -FAIL BackgroundFetchRegistration interface: existence and properties of interface object assert_own_property: self does not have own property "BackgroundFetchRegistration" expected property "BackgroundFetchRegistration" missing -FAIL BackgroundFetchRegistration interface object length assert_own_property: self does not have own property "BackgroundFetchRegistration" expected property "BackgroundFetchRegistration" missing -FAIL BackgroundFetchRegistration interface object name assert_own_property: self does not have own property "BackgroundFetchRegistration" expected property "BackgroundFetchRegistration" missing -FAIL BackgroundFetchRegistration interface: existence and properties of interface prototype object assert_own_property: self does not have own property "BackgroundFetchRegistration" expected property "BackgroundFetchRegistration" missing -FAIL BackgroundFetchRegistration interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "BackgroundFetchRegistration" expected property "BackgroundFetchRegistration" missing -FAIL BackgroundFetchRegistration interface: attribute id assert_own_property: self does not have own property "BackgroundFetchRegistration" expected property "BackgroundFetchRegistration" missing -FAIL BackgroundFetchRegistration interface: attribute uploadTotal assert_own_property: self does not have own property "BackgroundFetchRegistration" expected property "BackgroundFetchRegistration" missing -FAIL BackgroundFetchRegistration interface: attribute uploaded assert_own_property: self does not have own property "BackgroundFetchRegistration" expected property "BackgroundFetchRegistration" missing -FAIL BackgroundFetchRegistration interface: attribute downloadTotal assert_own_property: self does not have own property "BackgroundFetchRegistration" expected property "BackgroundFetchRegistration" missing -FAIL BackgroundFetchRegistration interface: attribute downloaded assert_own_property: self does not have own property "BackgroundFetchRegistration" expected property "BackgroundFetchRegistration" missing -FAIL BackgroundFetchRegistration interface: attribute activeFetches assert_own_property: self does not have own property "BackgroundFetchRegistration" expected property "BackgroundFetchRegistration" missing -FAIL BackgroundFetchRegistration interface: attribute onprogress assert_own_property: self does not have own property "BackgroundFetchRegistration" expected property "BackgroundFetchRegistration" missing -FAIL BackgroundFetchRegistration interface: operation abort() assert_own_property: self does not have own property "BackgroundFetchRegistration" expected property "BackgroundFetchRegistration" missing -FAIL BackgroundFetchFetch interface: existence and properties of interface object assert_own_property: self does not have own property "BackgroundFetchFetch" expected property "BackgroundFetchFetch" missing -FAIL BackgroundFetchFetch interface object length assert_own_property: self does not have own property "BackgroundFetchFetch" expected property "BackgroundFetchFetch" missing -FAIL BackgroundFetchFetch interface object name assert_own_property: self does not have own property "BackgroundFetchFetch" expected property "BackgroundFetchFetch" missing -FAIL BackgroundFetchFetch interface: existence and properties of interface prototype object assert_own_property: self does not have own property "BackgroundFetchFetch" expected property "BackgroundFetchFetch" missing -FAIL BackgroundFetchFetch interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "BackgroundFetchFetch" expected property "BackgroundFetchFetch" missing -FAIL BackgroundFetchFetch interface: attribute request assert_own_property: self does not have own property "BackgroundFetchFetch" expected property "BackgroundFetchFetch" missing -FAIL BackgroundFetchActiveFetches interface: existence and properties of interface object assert_own_property: self does not have own property "BackgroundFetchActiveFetches" expected property "BackgroundFetchActiveFetches" missing -FAIL BackgroundFetchActiveFetches interface object length assert_own_property: self does not have own property "BackgroundFetchActiveFetches" expected property "BackgroundFetchActiveFetches" missing -FAIL BackgroundFetchActiveFetches interface object name assert_own_property: self does not have own property "BackgroundFetchActiveFetches" expected property "BackgroundFetchActiveFetches" missing -FAIL BackgroundFetchActiveFetches interface: existence and properties of interface prototype object assert_own_property: self does not have own property "BackgroundFetchActiveFetches" expected property "BackgroundFetchActiveFetches" missing -FAIL BackgroundFetchActiveFetches interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "BackgroundFetchActiveFetches" expected property "BackgroundFetchActiveFetches" missing -FAIL BackgroundFetchActiveFetches interface: operation match(RequestInfo) assert_own_property: self does not have own property "BackgroundFetchActiveFetches" expected property "BackgroundFetchActiveFetches" missing -FAIL BackgroundFetchActiveFetches interface: operation values() assert_own_property: self does not have own property "BackgroundFetchActiveFetches" expected property "BackgroundFetchActiveFetches" missing -FAIL BackgroundFetchActiveFetch interface: existence and properties of interface object assert_own_property: self does not have own property "BackgroundFetchActiveFetch" expected property "BackgroundFetchActiveFetch" missing -FAIL BackgroundFetchActiveFetch interface object length assert_own_property: self does not have own property "BackgroundFetchActiveFetch" expected property "BackgroundFetchActiveFetch" missing -FAIL BackgroundFetchActiveFetch interface object name assert_own_property: self does not have own property "BackgroundFetchActiveFetch" expected property "BackgroundFetchActiveFetch" missing -FAIL BackgroundFetchActiveFetch interface: existence and properties of interface prototype object assert_own_property: self does not have own property "BackgroundFetchActiveFetch" expected property "BackgroundFetchActiveFetch" missing -FAIL BackgroundFetchActiveFetch interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "BackgroundFetchActiveFetch" expected property "BackgroundFetchActiveFetch" missing -FAIL BackgroundFetchActiveFetch interface: attribute responseReady assert_own_property: self does not have own property "BackgroundFetchActiveFetch" expected property "BackgroundFetchActiveFetch" missing -PASS BackgroundFetchEvent interface: existence and properties of interface object -PASS BackgroundFetchSettledEvent interface: existence and properties of interface object -PASS BackgroundFetchSettledFetches interface: existence and properties of interface object -PASS BackgroundFetchSettledFetch interface: existence and properties of interface object -PASS BackgroundFetchUpdateEvent interface: existence and properties of interface object -PASS BackgroundFetchClickEvent interface: existence and properties of interface object - diff --git a/LayoutTests/imported/w3c/web-platform-tests/background-fetch/interfaces.worker.html b/LayoutTests/imported/w3c/web-platform-tests/background-fetch/interfaces.worker.html deleted file mode 100644 index 2382913528e69..0000000000000 --- a/LayoutTests/imported/w3c/web-platform-tests/background-fetch/interfaces.worker.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/LayoutTests/imported/w3c/web-platform-tests/background-fetch/match.https.window-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/background-fetch/match.https.window-expected.txt new file mode 100644 index 0000000000000..77c9ec3cb619c --- /dev/null +++ b/LayoutTests/imported/w3c/web-platform-tests/background-fetch/match.https.window-expected.txt @@ -0,0 +1,7 @@ + +FAIL Matching to a single request should work promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL Matching to a non-existing request should work promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL Matching multiple times on the same request works as expected. promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL Access to active fetches is supported. promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL Match with query options. promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." + diff --git a/LayoutTests/imported/w3c/web-platform-tests/background-fetch/mixed-content-and-allowed-schemes.https.window-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/background-fetch/mixed-content-and-allowed-schemes.https.window-expected.txt new file mode 100644 index 0000000000000..83e6ae05bd244 --- /dev/null +++ b/LayoutTests/imported/w3c/web-platform-tests/background-fetch/mixed-content-and-allowed-schemes.https.window-expected.txt @@ -0,0 +1,10 @@ + +FAIL https: fetch should register ok promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL loopback IPv4 http: fetch should register ok promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL loopback IPv6 http: fetch should register ok promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL localhost http: fetch should register ok promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL wss: fetch should reject promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL file: fetch should reject promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL data: fetch should reject promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL unknown scheme fetch should reject promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." + diff --git a/LayoutTests/imported/w3c/web-platform-tests/background-fetch/port-blocking.https.window-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/background-fetch/port-blocking.https.window-expected.txt new file mode 100644 index 0000000000000..e14da083e9e6c --- /dev/null +++ b/LayoutTests/imported/w3c/web-platform-tests/background-fetch/port-blocking.https.window-expected.txt @@ -0,0 +1,8 @@ + +FAIL fetch to default https port should register ok promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL fetch to default http port should register ok promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL fetch to port 443 should register ok promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL fetch to port 80 should register ok, even over https promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL fetch to non-default non-bad port (8080) should register ok promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL fetch to bad port (SMTP) should reject promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." + diff --git a/LayoutTests/imported/w3c/web-platform-tests/background-fetch/update-ui.https.window-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/background-fetch/update-ui.https.window-expected.txt new file mode 100644 index 0000000000000..d7d6ebbc64db5 --- /dev/null +++ b/LayoutTests/imported/w3c/web-platform-tests/background-fetch/update-ui.https.window-expected.txt @@ -0,0 +1,5 @@ + +FAIL Background Fetch updateUI resolves promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL Background Fetch updateUI called twice fails promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." +FAIL Background Fetch updateUI fails when event is not active promise_test: Unhandled rejection with value: object "Error: Unsupported permission name "background-fetch"." + diff --git a/LayoutTests/platform/mac-wk1/TestExpectations b/LayoutTests/platform/mac-wk1/TestExpectations index 3dca02e61b982..6824ee15e45a2 100644 --- a/LayoutTests/platform/mac-wk1/TestExpectations +++ b/LayoutTests/platform/mac-wk1/TestExpectations @@ -1089,6 +1089,7 @@ http/tests/cookies/same-site/fetch-in-same-origin-service-worker.html [ Skip ] http/wpt/cache-storage [ Skip ] http/wpt/push-api [ Skip ] http/wpt/service-workers [ Skip ] +imported/w3c/web-platform-tests/background-fetch [ Skip ] imported/w3c/web-platform-tests/content-security-policy/inside-worker/serviceworker-report-only.https.sub.html [ Skip ] imported/w3c/web-platform-tests/content-security-policy/sandbox/service-worker-sandbox.https.html [ Skip ] imported/w3c/web-platform-tests/content-security-policy/securitypolicyviolation/inside-service-worker.https.html [ Skip ] diff --git a/Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml b/Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml index a7c7c15e60c4a..a25825d2bce02 100644 --- a/Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml +++ b/Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml @@ -689,6 +689,20 @@ AutomaticLiveResizeEnabled: "HAVE(UIKIT_WEBKIT_INTERNALS)": true default: false +BackgroundFetchAPIEnabled: + type: bool + status: testable + category: networking + humanReadableName: "Enable background-fetch API" + humanReadableDescription: "Enable background-fetch API" + exposed: [ WebKit ] + condition: ENABLE(SERVICE_WORKER) + defaultValue: + WebCore: + default: false + WebKit: + default: false + BackgroundWebContentRunningBoardThrottlingEnabled: type: bool status: unstable diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt index dbe6d15c52ac2..26262aa47bbd6 100644 --- a/Source/WebCore/CMakeLists.txt +++ b/Source/WebCore/CMakeLists.txt @@ -181,6 +181,7 @@ set(WebCore_PRIVATE_INCLUDE_DIRECTORIES "${WEBCORE_DIR}/websockets" "${WEBCORE_DIR}/workers" "${WEBCORE_DIR}/workers/service" + "${WEBCORE_DIR}/workers/service/background-fetch" "${WEBCORE_DIR}/workers/service/context" "${WEBCORE_DIR}/workers/service/server" "${WEBCORE_DIR}/workers/shared" @@ -1351,6 +1352,20 @@ set(WebCore_NON_SVG_IDL_FILES workers/service/ServiceWorkerUpdateViaCache.idl workers/service/ServiceWorkerWindowClient.idl + workers/service/background-fetch/BackgroundFetchEvent.idl + workers/service/background-fetch/BackgroundFetchEventInit.idl + workers/service/background-fetch/BackgroundFetchFailureReason.idl + workers/service/background-fetch/BackgroundFetchManager.idl + workers/service/background-fetch/BackgroundFetchOptions.idl + workers/service/background-fetch/BackgroundFetchRecord.idl + workers/service/background-fetch/BackgroundFetchRegistration.idl + workers/service/background-fetch/BackgroundFetchResult.idl + workers/service/background-fetch/BackgroundFetchUIOptions.idl + workers/service/background-fetch/BackgroundFetchUpdateUIEvent.idl + workers/service/background-fetch/ImageResource.idl + workers/service/background-fetch/ServiceWorkerGlobalScope+BackgroundFetchAPI.idl + workers/service/background-fetch/ServiceWorkerRegistration+BackgroundFetchAPI.idl + workers/shared/SharedWorker.idl workers/shared/SharedWorkerGlobalScope.idl diff --git a/Source/WebCore/DerivedSources-input.xcfilelist b/Source/WebCore/DerivedSources-input.xcfilelist index 57615f6f25a36..9064e3305fb80 100644 --- a/Source/WebCore/DerivedSources-input.xcfilelist +++ b/Source/WebCore/DerivedSources-input.xcfilelist @@ -1742,6 +1742,19 @@ $(PROJECT_DIR)/workers/service/ServiceWorkerGlobalScope.idl $(PROJECT_DIR)/workers/service/ServiceWorkerRegistration.idl $(PROJECT_DIR)/workers/service/ServiceWorkerUpdateViaCache.idl $(PROJECT_DIR)/workers/service/ServiceWorkerWindowClient.idl +$(PROJECT_DIR)/workers/service/background-fetch/BackgroundFetchEvent.idl +$(PROJECT_DIR)/workers/service/background-fetch/BackgroundFetchEventInit.idl +$(PROJECT_DIR)/workers/service/background-fetch/BackgroundFetchFailureReason.idl +$(PROJECT_DIR)/workers/service/background-fetch/BackgroundFetchManager.idl +$(PROJECT_DIR)/workers/service/background-fetch/BackgroundFetchOptions.idl +$(PROJECT_DIR)/workers/service/background-fetch/BackgroundFetchRecord.idl +$(PROJECT_DIR)/workers/service/background-fetch/BackgroundFetchRegistration.idl +$(PROJECT_DIR)/workers/service/background-fetch/BackgroundFetchResult.idl +$(PROJECT_DIR)/workers/service/background-fetch/BackgroundFetchUIOptions.idl +$(PROJECT_DIR)/workers/service/background-fetch/BackgroundFetchUpdateUIEvent.idl +$(PROJECT_DIR)/workers/service/background-fetch/ImageResource.idl +$(PROJECT_DIR)/workers/service/background-fetch/ServiceWorkerGlobalScope+BackgroundFetchAPI.idl +$(PROJECT_DIR)/workers/service/background-fetch/ServiceWorkerRegistration+BackgroundFetchAPI.idl $(PROJECT_DIR)/workers/shared/SharedWorker.idl $(PROJECT_DIR)/workers/shared/SharedWorkerGlobalScope.idl $(PROJECT_DIR)/worklets/PaintWorkletGlobalScope.idl diff --git a/Source/WebCore/DerivedSources-output.xcfilelist b/Source/WebCore/DerivedSources-output.xcfilelist index 4559b54d562b1..3df053c8b51d4 100644 --- a/Source/WebCore/DerivedSources-output.xcfilelist +++ b/Source/WebCore/DerivedSources-output.xcfilelist @@ -283,6 +283,26 @@ $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAutomationRate.cpp $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAutomationRate.h $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAvcEncoderConfig.cpp $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAvcEncoderConfig.h +$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSBackgroundFetchEvent.cpp +$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSBackgroundFetchEvent.h +$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSBackgroundFetchEventInit.cpp +$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSBackgroundFetchEventInit.h +$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSBackgroundFetchFailureReason.cpp +$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSBackgroundFetchFailureReason.h +$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSBackgroundFetchManager.cpp +$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSBackgroundFetchManager.h +$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSBackgroundFetchOptions.cpp +$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSBackgroundFetchOptions.h +$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSBackgroundFetchRecord.cpp +$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSBackgroundFetchRecord.h +$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSBackgroundFetchRegistration.cpp +$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSBackgroundFetchRegistration.h +$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSBackgroundFetchResult.cpp +$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSBackgroundFetchResult.h +$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSBackgroundFetchUIOptions.cpp +$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSBackgroundFetchUIOptions.h +$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSBackgroundFetchUpdateUIEvent.cpp +$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSBackgroundFetchUpdateUIEvent.h $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSBarProp.cpp $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSBarProp.h $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSBaseAudioContext.cpp @@ -1541,6 +1561,8 @@ $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSImageData.cpp $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSImageData.h $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSImageDataSettings.cpp $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSImageDataSettings.h +$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSImageResource.cpp +$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSImageResource.h $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSImageSmoothingQuality.cpp $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSImageSmoothingQuality.h $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSInnerHTML.cpp @@ -2581,12 +2603,16 @@ $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSServiceWorkerClients.cpp $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSServiceWorkerClients.h $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSServiceWorkerContainer.cpp $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSServiceWorkerContainer.h +$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSServiceWorkerGlobalScope+BackgroundFetchAPI.cpp +$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSServiceWorkerGlobalScope+BackgroundFetchAPI.h $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSServiceWorkerGlobalScope+PushAPI.cpp $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSServiceWorkerGlobalScope+PushAPI.h $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSServiceWorkerGlobalScope.cpp $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSServiceWorkerGlobalScope.h $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSServiceWorkerInternals.cpp $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSServiceWorkerInternals.h +$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSServiceWorkerRegistration+BackgroundFetchAPI.cpp +$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSServiceWorkerRegistration+BackgroundFetchAPI.h $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSServiceWorkerRegistration+PushAPI.cpp $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSServiceWorkerRegistration+PushAPI.h $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSServiceWorkerRegistration.cpp diff --git a/Source/WebCore/DerivedSources.make b/Source/WebCore/DerivedSources.make index 34df9b2a6cb08..5c30fa61f980f 100644 --- a/Source/WebCore/DerivedSources.make +++ b/Source/WebCore/DerivedSources.make @@ -1555,6 +1555,19 @@ JS_BINDING_IDLS := \ $(WebCore)/workers/service/ServiceWorkerRegistration.idl \ $(WebCore)/workers/service/ServiceWorkerUpdateViaCache.idl \ $(WebCore)/workers/service/ServiceWorkerWindowClient.idl \ + $(WebCore)/workers/service/background-fetch/BackgroundFetchEvent.idl \ + $(WebCore)/workers/service/background-fetch/BackgroundFetchEventInit.idl \ + $(WebCore)/workers/service/background-fetch/BackgroundFetchFailureReason.idl \ + $(WebCore)/workers/service/background-fetch/BackgroundFetchManager.idl \ + $(WebCore)/workers/service/background-fetch/BackgroundFetchOptions.idl \ + $(WebCore)/workers/service/background-fetch/BackgroundFetchRecord.idl \ + $(WebCore)/workers/service/background-fetch/BackgroundFetchRegistration.idl \ + $(WebCore)/workers/service/background-fetch/BackgroundFetchResult.idl \ + $(WebCore)/workers/service/background-fetch/BackgroundFetchUIOptions.idl \ + $(WebCore)/workers/service/background-fetch/BackgroundFetchUpdateUIEvent.idl \ + $(WebCore)/workers/service/background-fetch/ImageResource.idl \ + $(WebCore)/workers/service/background-fetch/ServiceWorkerGlobalScope+BackgroundFetchAPI.idl \ + $(WebCore)/workers/service/background-fetch/ServiceWorkerRegistration+BackgroundFetchAPI.idl \ $(WebCore)/workers/shared/SharedWorker.idl \ $(WebCore)/workers/shared/SharedWorkerGlobalScope.idl \ $(WebCore)/worklets/PaintWorkletGlobalScope.idl \ diff --git a/Source/WebCore/Headers.cmake b/Source/WebCore/Headers.cmake index 910aa0ce3b07e..a9f46df8e726c 100644 --- a/Source/WebCore/Headers.cmake +++ b/Source/WebCore/Headers.cmake @@ -175,6 +175,7 @@ set(WebCore_PRIVATE_FRAMEWORK_HEADERS Modules/fetch/FetchBodyConsumer.h Modules/fetch/FetchBodySource.h Modules/fetch/FetchHeaders.h + Modules/fetch/FetchHeadersGuard.h Modules/fetch/FetchIdentifier.h Modules/fetch/FetchLoader.h Modules/fetch/FetchLoaderClient.h @@ -2243,6 +2244,16 @@ set(WebCore_PRIVATE_FRAMEWORK_HEADERS workers/service/ServiceWorkerTypes.h workers/service/ServiceWorkerUpdateViaCache.h + workers/service/background-fetch/BackgroundFetchFailureReason.h + workers/service/background-fetch/BackgroundFetchInformation.h + workers/service/background-fetch/BackgroundFetchOptions.h + workers/service/background-fetch/BackgroundFetchRecordIdentifier.h + workers/service/background-fetch/BackgroundFetchRecordInformation.h + workers/service/background-fetch/BackgroundFetchRequest.h + workers/service/background-fetch/BackgroundFetchResult.h + workers/service/background-fetch/BackgroundFetchUIOptions.h + workers/service/background-fetch/ImageResource.h + workers/service/context/SWContextManager.h workers/service/context/ServiceWorkerDebuggable.h workers/service/context/ServiceWorkerFetch.h diff --git a/Source/WebCore/Modules/fetch/FetchHeaders.h b/Source/WebCore/Modules/fetch/FetchHeaders.h index 02c1ce9586df3..e8fef80402400 100644 --- a/Source/WebCore/Modules/fetch/FetchHeaders.h +++ b/Source/WebCore/Modules/fetch/FetchHeaders.h @@ -29,6 +29,7 @@ #pragma once #include "ExceptionOr.h" +#include "FetchHeadersGuard.h" #include "HTTPHeaderMap.h" #include #include @@ -38,14 +39,6 @@ namespace WebCore { class ScriptExecutionContext; -enum class FetchHeadersGuard : uint8_t { - None, - Immutable, - Request, - RequestNoCors, - Response -}; - class FetchHeaders : public RefCounted { public: using Guard = FetchHeadersGuard; @@ -117,18 +110,3 @@ inline void FetchHeaders::setGuard(Guard guard) } } // namespace WebCore - -namespace WTF { - -template<> struct EnumTraitsForPersistence { - using values = EnumValues< - WebCore::FetchHeaders::Guard, - WebCore::FetchHeaders::Guard::None, - WebCore::FetchHeaders::Guard::Immutable, - WebCore::FetchHeaders::Guard::Request, - WebCore::FetchHeaders::Guard::RequestNoCors, - WebCore::FetchHeaders::Guard::Response - >; -}; - -} diff --git a/Source/WebCore/Modules/fetch/FetchHeadersGuard.h b/Source/WebCore/Modules/fetch/FetchHeadersGuard.h new file mode 100644 index 0000000000000..1864e9e448457 --- /dev/null +++ b/Source/WebCore/Modules/fetch/FetchHeadersGuard.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2016 Canon Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions + * are required to be met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Canon Inc. nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include + +namespace WebCore { + +enum class FetchHeadersGuard : uint8_t { + None, + Immutable, + Request, + RequestNoCors, + Response +}; + +} // namespace WebCore + +namespace WTF { + +template<> struct EnumTraitsForPersistence { + using values = EnumValues< + WebCore::FetchHeadersGuard, + WebCore::FetchHeadersGuard::None, + WebCore::FetchHeadersGuard::Immutable, + WebCore::FetchHeadersGuard::Request, + WebCore::FetchHeadersGuard::RequestNoCors, + WebCore::FetchHeadersGuard::Response + >; +}; + +} diff --git a/Source/WebCore/Modules/fetch/FetchResponseBodyLoader.h b/Source/WebCore/Modules/fetch/FetchResponseBodyLoader.h new file mode 100644 index 0000000000000..7a34480cea8ea --- /dev/null +++ b/Source/WebCore/Modules/fetch/FetchResponseBodyLoader.h @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2016 Canon Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted, provided that the following conditions + * are required to be met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Canon Inc. nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY CANON INC. AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include "ExceptionOr.h" +#include "SharedBuffer.h" +#include +#include + +namespace WebCore { + +class FragmentedSharedBuffer; + +class FetchResponseBodyLoader { + WTF_MAKE_FAST_ALLOCATED; +public: + virtual ~FetchResponseBodyLoader() = default; + + virtual void stop() = 0; + virtual bool isActive() const = 0; + virtual RefPtr startStreaming() = 0; + + using ConsumeDataByChunkCallback = Function*>&&)>; + void consumeDataByChunk(ConsumeDataByChunkCallback&&); + ConsumeDataByChunkCallback takeConsumeDataCallback() { return WTFMove(m_consumeDataCallback); } + bool hasConsumeDataCallback() const { return !!m_consumeDataCallback; } + ConsumeDataByChunkCallback& consumeDataCallback() { return m_consumeDataCallback; } + +private: + ConsumeDataByChunkCallback m_consumeDataCallback; +}; + +inline void FetchResponseBodyLoader::consumeDataByChunk(ConsumeDataByChunkCallback&& callback) +{ + ASSERT(!m_consumeDataCallback); + m_consumeDataCallback = WTFMove(callback); + auto data = startStreaming(); + if (!data) + return; + + auto contiguousBuffer = data->makeContiguous(); + Span chunk { contiguousBuffer->data(), data->size() }; + m_consumeDataCallback(&chunk); +} + +} // namespace WebCore diff --git a/Source/WebCore/Sources.txt b/Source/WebCore/Sources.txt index b783f88dd8c3c..2a62b648cc874 100644 --- a/Source/WebCore/Sources.txt +++ b/Source/WebCore/Sources.txt @@ -2943,6 +2943,12 @@ workers/service/ServiceWorkerRegistrationKey.cpp workers/service/ServiceWorkerRegistrationOptions.cpp workers/service/ServiceWorkerWindowClient.cpp workers/service/WorkerSWClientConnection.cpp +workers/service/background-fetch/BackgroundFetchEvent.cpp +workers/service/background-fetch/BackgroundFetchManager.cpp +workers/service/background-fetch/BackgroundFetchRecord.cpp +workers/service/background-fetch/BackgroundFetchRegistration.cpp +workers/service/background-fetch/BackgroundFetchUpdateUIEvent.cpp +workers/service/background-fetch/ServiceWorkerRegistrationBackgroundFetchAPI.cpp workers/service/context/SWContextManager.cpp workers/service/context/ServiceWorkerDebuggable.cpp workers/service/context/ServiceWorkerFetch.cpp @@ -3096,6 +3102,17 @@ JSBiquadFilterNode.cpp JSBiquadFilterOptions.cpp JSBiquadFilterType.cpp JSAvcEncoderConfig.cpp +JSBackgroundFetchEvent.cpp +JSBackgroundFetchEventInit.cpp +JSBackgroundFetchFailureReason.cpp +JSBackgroundFetchManager.cpp +JSBackgroundFetchOptions.cpp +JSBackgroundFetchRecord.cpp +JSBackgroundFetchRegistration.cpp +JSBackgroundFetchResult.cpp +JSBackgroundFetchUIOptions.cpp +JSBackgroundFetchUpdateUIEvent.cpp +JSImageResource.cpp JSBitrateMode.cpp JSBlob.cpp JSBlobCallback.cpp diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj index f9030f294b091..c037a3b9a8d30 100644 --- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj +++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj @@ -1225,6 +1225,7 @@ 418FCBC22706E50100F96ECA /* PushEventInit.h in Headers */ = {isa = PBXBuildFile; fileRef = 418FCBBF2706E4F800F96ECA /* PushEventInit.h */; settings = {ATTRIBUTES = (Private, ); }; }; 418FCBE72715A28F00F96ECA /* RTCRtpCodecCapability.h in Headers */ = {isa = PBXBuildFile; fileRef = 41E0A7DC23BB63DB00561060 /* RTCRtpCodecCapability.h */; settings = {ATTRIBUTES = (Private, ); }; }; 4190F3A524A0B4EE00531C57 /* FrameRateMonitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 4190F3A3249D152800531C57 /* FrameRateMonitor.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 4191981829950767007576C8 /* FetchHeadersGuard.h in Headers */ = {isa = PBXBuildFile; fileRef = 4191981729950763007576C8 /* FetchHeadersGuard.h */; settings = {ATTRIBUTES = (Private, ); }; }; 419242492127B93E00634FCF /* RealtimeOutgoingVideoSourceCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 419242472127B7CC00634FCF /* RealtimeOutgoingVideoSourceCocoa.mm */; }; 4192BB1327CF638600F29A46 /* PageIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 4192BB1227CF638300F29A46 /* PageIdentifier.h */; settings = {ATTRIBUTES = (Private, ); }; }; 4195B986296442AA0071566E /* GraphicsContextGLCVCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4195B985296442A90071566E /* GraphicsContextGLCVCocoa.mm */; }; @@ -8998,6 +8999,7 @@ 41209E94216EA69A00A73A12 /* RTCCertificate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RTCCertificate.cpp; sourceTree = ""; }; 41209E95216EC34E00A73A12 /* LibWebRTCCertificateGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LibWebRTCCertificateGenerator.h; path = libwebrtc/LibWebRTCCertificateGenerator.h; sourceTree = ""; }; 41209E96216EC34F00A73A12 /* LibWebRTCCertificateGenerator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibWebRTCCertificateGenerator.cpp; path = libwebrtc/LibWebRTCCertificateGenerator.cpp; sourceTree = ""; }; + 4127338A29A371600050CADA /* BackgroundFetchEvent.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = BackgroundFetchEvent.idl; sourceTree = ""; }; 412827B027E4A9C3005ADDE2 /* VideoFrame.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = VideoFrame.mm; sourceTree = ""; }; 4129C9801F5861C7009D7403 /* ReadableStreamSink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReadableStreamSink.h; sourceTree = ""; }; 4129C9811F5861C7009D7403 /* ReadableStreamSink.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ReadableStreamSink.idl; sourceTree = ""; }; @@ -9263,6 +9265,41 @@ 418FCBED2715B85200F96ECA /* WorkerNavigatorMediaCapabilities.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WorkerNavigatorMediaCapabilities.cpp; sourceTree = ""; }; 4190F3A1249D152700531C57 /* FrameRateMonitor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FrameRateMonitor.cpp; sourceTree = ""; }; 4190F3A3249D152800531C57 /* FrameRateMonitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FrameRateMonitor.h; sourceTree = ""; }; + 419197EB2994FD46007576C8 /* BackgroundFetchOptions.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = BackgroundFetchOptions.idl; sourceTree = ""; }; + 419197EC2994FD47007576C8 /* BackgroundFetchUIOptions.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = BackgroundFetchUIOptions.idl; sourceTree = ""; }; + 419197ED2994FD48007576C8 /* BackgroundFetchManager.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = BackgroundFetchManager.cpp; sourceTree = ""; }; + 419197EE2994FD49007576C8 /* ImageResource.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ImageResource.h; sourceTree = ""; }; + 419197EF2994FD4A007576C8 /* ServiceWorkerRegistration+BackgroundFetchAPI.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = "ServiceWorkerRegistration+BackgroundFetchAPI.idl"; sourceTree = ""; }; + 419197F02994FD4B007576C8 /* BackgroundFetchEventInit.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = BackgroundFetchEventInit.idl; sourceTree = ""; }; + 419197F12994FD4B007576C8 /* BackgroundFetchManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BackgroundFetchManager.h; sourceTree = ""; }; + 419197F22994FD4C007576C8 /* BackgroundFetchRegistration.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = BackgroundFetchRegistration.idl; sourceTree = ""; }; + 419197F42994FD4D007576C8 /* ServiceWorkerRegistrationBackgroundFetchAPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ServiceWorkerRegistrationBackgroundFetchAPI.h; sourceTree = ""; }; + 419197F52994FD4E007576C8 /* BackgroundFetchInformation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BackgroundFetchInformation.h; sourceTree = ""; }; + 419197F62994FD4E007576C8 /* BackgroundFetchOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BackgroundFetchOptions.h; sourceTree = ""; }; + 419197F72994FD4F007576C8 /* BackgroundFetchEvent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BackgroundFetchEvent.h; sourceTree = ""; }; + 419197F82994FD50007576C8 /* BackgroundFetchResult.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BackgroundFetchResult.h; sourceTree = ""; }; + 419197F92994FD50007576C8 /* BackgroundFetchRecord.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = BackgroundFetchRecord.idl; sourceTree = ""; }; + 419197FA2994FD51007576C8 /* BackgroundFetchManager.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = BackgroundFetchManager.idl; sourceTree = ""; }; + 419197FB2994FD52007576C8 /* BackgroundFetchFailureReason.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = BackgroundFetchFailureReason.idl; sourceTree = ""; }; + 419197FC2994FD52007576C8 /* BackgroundFetchUpdateUIEvent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BackgroundFetchUpdateUIEvent.h; sourceTree = ""; }; + 419197FD2994FD53007576C8 /* BackgroundFetchRegistration.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = BackgroundFetchRegistration.cpp; sourceTree = ""; }; + 419197FE2994FD53007576C8 /* ServiceWorkerGlobalScope+BackgroundFetchAPI.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = "ServiceWorkerGlobalScope+BackgroundFetchAPI.idl"; sourceTree = ""; }; + 419197FF2994FD54007576C8 /* BackgroundFetchRecordInformation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BackgroundFetchRecordInformation.h; sourceTree = ""; }; + 419198002994FD55007576C8 /* BackgroundFetchRecord.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BackgroundFetchRecord.h; sourceTree = ""; }; + 419198012994FD55007576C8 /* BackgroundFetchRecord.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = BackgroundFetchRecord.cpp; sourceTree = ""; }; + 419198022994FD55007576C8 /* BackgroundFetchResult.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = BackgroundFetchResult.idl; sourceTree = ""; }; + 419198032994FD56007576C8 /* BackgroundFetchRegistration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BackgroundFetchRegistration.h; sourceTree = ""; }; + 419198042994FD57007576C8 /* BackgroundFetchUpdateUIEvent.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = BackgroundFetchUpdateUIEvent.cpp; sourceTree = ""; }; + 419198052994FD57007576C8 /* BackgroundFetchRequest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BackgroundFetchRequest.h; sourceTree = ""; }; + 419198062994FD58007576C8 /* BackgroundFetchEvent.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = BackgroundFetchEvent.cpp; sourceTree = ""; }; + 419198072994FD58007576C8 /* BackgroundFetchRecordIdentifier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BackgroundFetchRecordIdentifier.h; sourceTree = ""; }; + 419198082994FD59007576C8 /* BackgroundFetchFailureReason.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BackgroundFetchFailureReason.h; sourceTree = ""; }; + 419198092994FD5A007576C8 /* BackgroundFetchEventInit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BackgroundFetchEventInit.h; sourceTree = ""; }; + 4191980A2994FD5A007576C8 /* BackgroundFetchUIOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BackgroundFetchUIOptions.h; sourceTree = ""; }; + 4191980B2994FD5A007576C8 /* BackgroundFetchUpdateUIEvent.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = BackgroundFetchUpdateUIEvent.idl; sourceTree = ""; }; + 4191980C2994FD5B007576C8 /* ImageResource.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = ImageResource.idl; sourceTree = ""; }; + 4191980D2994FD5C007576C8 /* ServiceWorkerRegistrationBackgroundFetchAPI.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ServiceWorkerRegistrationBackgroundFetchAPI.cpp; sourceTree = ""; }; + 4191981729950763007576C8 /* FetchHeadersGuard.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FetchHeadersGuard.h; sourceTree = ""; }; 419242472127B7CC00634FCF /* RealtimeOutgoingVideoSourceCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RealtimeOutgoingVideoSourceCocoa.mm; sourceTree = ""; }; 4192BB1227CF638300F29A46 /* PageIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageIdentifier.h; sourceTree = ""; }; 41945694203502A5004BA277 /* ApplicationCacheResourceLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ApplicationCacheResourceLoader.cpp; sourceTree = ""; }; @@ -22418,6 +22455,48 @@ path = "push-api"; sourceTree = ""; }; + 419197EA2994FD23007576C8 /* background-fetch */ = { + isa = PBXGroup; + children = ( + 419198062994FD58007576C8 /* BackgroundFetchEvent.cpp */, + 419197F72994FD4F007576C8 /* BackgroundFetchEvent.h */, + 4127338A29A371600050CADA /* BackgroundFetchEvent.idl */, + 419198092994FD5A007576C8 /* BackgroundFetchEventInit.h */, + 419197F02994FD4B007576C8 /* BackgroundFetchEventInit.idl */, + 419198082994FD59007576C8 /* BackgroundFetchFailureReason.h */, + 419197FB2994FD52007576C8 /* BackgroundFetchFailureReason.idl */, + 419197F52994FD4E007576C8 /* BackgroundFetchInformation.h */, + 419197ED2994FD48007576C8 /* BackgroundFetchManager.cpp */, + 419197F12994FD4B007576C8 /* BackgroundFetchManager.h */, + 419197FA2994FD51007576C8 /* BackgroundFetchManager.idl */, + 419197F62994FD4E007576C8 /* BackgroundFetchOptions.h */, + 419197EB2994FD46007576C8 /* BackgroundFetchOptions.idl */, + 419198012994FD55007576C8 /* BackgroundFetchRecord.cpp */, + 419198002994FD55007576C8 /* BackgroundFetchRecord.h */, + 419197F92994FD50007576C8 /* BackgroundFetchRecord.idl */, + 419198072994FD58007576C8 /* BackgroundFetchRecordIdentifier.h */, + 419197FF2994FD54007576C8 /* BackgroundFetchRecordInformation.h */, + 419197FD2994FD53007576C8 /* BackgroundFetchRegistration.cpp */, + 419198032994FD56007576C8 /* BackgroundFetchRegistration.h */, + 419197F22994FD4C007576C8 /* BackgroundFetchRegistration.idl */, + 419198052994FD57007576C8 /* BackgroundFetchRequest.h */, + 419197F82994FD50007576C8 /* BackgroundFetchResult.h */, + 419198022994FD55007576C8 /* BackgroundFetchResult.idl */, + 4191980A2994FD5A007576C8 /* BackgroundFetchUIOptions.h */, + 419197EC2994FD47007576C8 /* BackgroundFetchUIOptions.idl */, + 419198042994FD57007576C8 /* BackgroundFetchUpdateUIEvent.cpp */, + 419197FC2994FD52007576C8 /* BackgroundFetchUpdateUIEvent.h */, + 4191980B2994FD5A007576C8 /* BackgroundFetchUpdateUIEvent.idl */, + 419197EE2994FD49007576C8 /* ImageResource.h */, + 4191980C2994FD5B007576C8 /* ImageResource.idl */, + 419197FE2994FD53007576C8 /* ServiceWorkerGlobalScope+BackgroundFetchAPI.idl */, + 419197EF2994FD4A007576C8 /* ServiceWorkerRegistration+BackgroundFetchAPI.idl */, + 4191980D2994FD5C007576C8 /* ServiceWorkerRegistrationBackgroundFetchAPI.cpp */, + 419197F42994FD4D007576C8 /* ServiceWorkerRegistrationBackgroundFetchAPI.h */, + ); + path = "background-fetch"; + sourceTree = ""; + }; 41A023EA1A39DB7900F722CF /* streams */ = { isa = PBXGroup; children = ( @@ -22523,6 +22602,7 @@ 41F54F821C50C4F600338488 /* FetchHeaders.cpp */, 41F54F831C50C4F600338488 /* FetchHeaders.h */, 41F54F841C50C4F600338488 /* FetchHeaders.idl */, + 4191981729950763007576C8 /* FetchHeadersGuard.h */, 416E0B37209BC3C2004A95D9 /* FetchIdentifier.h */, 4147E2B41C89912600A7E715 /* FetchLoader.cpp */, 4147E2B51C89912600A7E715 /* FetchLoader.h */, @@ -23677,6 +23757,7 @@ 51F175441F3EBBF200C74950 /* service */ = { isa = PBXGroup; children = ( + 419197EA2994FD23007576C8 /* background-fetch */, 517C87071F8E8FF200EB8076 /* context */, 517A52EC1F47532D00DCDC0A /* server */, 41AF37921F8DA48A00111C31 /* ExtendableEvent.cpp */, @@ -36428,6 +36509,7 @@ 4129C9971F59B963009D7403 /* FetchBodySource.h in Headers */, 41860F0D2847A49600E4A395 /* FetchEvent.h in Headers */, 41D129DB1F3D143800D15E47 /* FetchHeaders.h in Headers */, + 4191981829950767007576C8 /* FetchHeadersGuard.h in Headers */, 416E0B3A209BC3CB004A95D9 /* FetchIdentifier.h in Headers */, CEBB8C3320786DCB00039547 /* FetchIdioms.h in Headers */, 4161E2D51FE48DC500EC2E96 /* FetchLoader.h in Headers */, diff --git a/Source/WebCore/bindings/js/WebCoreBuiltinNames.h b/Source/WebCore/bindings/js/WebCoreBuiltinNames.h index aa8a0f853842c..aeb81ba353ba5 100644 --- a/Source/WebCore/bindings/js/WebCoreBuiltinNames.h +++ b/Source/WebCore/bindings/js/WebCoreBuiltinNames.h @@ -91,6 +91,11 @@ namespace WebCore { macro(AuthenticatorAssertionResponse) \ macro(AuthenticatorAttestationResponse) \ macro(AuthenticatorResponse) \ + macro(BackgroundFetchEvent) \ + macro(BackgroundFetchManager) \ + macro(BackgroundFetchRecord) \ + macro(BackgroundFetchRegistration) \ + macro(BackgroundFetchUpdateUIEvent) \ macro(BaseAudioContext) \ macro(BiquadFilterNode) \ macro(BlobEvent) \ @@ -552,6 +557,10 @@ namespace WebCore { macro(makeThisTypeError) \ macro(matchingElementInFlatTree) \ macro(mediaStreamTrackConstraints) \ + macro(onbackgroundfetchsuccess) \ + macro(onbackgroundfetchfail) \ + macro(onbackgroundfetchabort) \ + macro(onbackgroundfetchclick) \ macro(onnotificationclick) \ macro(onnotificationclose) \ macro(onpush) \ diff --git a/Source/WebCore/dom/EventNames.h b/Source/WebCore/dom/EventNames.h index eab4d33e34c29..b0350940291d5 100644 --- a/Source/WebCore/dom/EventNames.h +++ b/Source/WebCore/dom/EventNames.h @@ -61,6 +61,10 @@ namespace WebCore { macro(audiostart) \ macro(autocomplete) \ macro(autocompleteerror) \ + macro(backgroundfetchsuccess) \ + macro(backgroundfetchfail) \ + macro(backgroundfetchabort) \ + macro(backgroundfetchclick) \ macro(beforecopy) \ macro(beforecut) \ macro(beforeinput) \ diff --git a/Source/WebCore/dom/EventNames.in b/Source/WebCore/dom/EventNames.in index 862b0bd1ee684..8dd5adbedff6f 100644 --- a/Source/WebCore/dom/EventNames.in +++ b/Source/WebCore/dom/EventNames.in @@ -6,6 +6,8 @@ Event Events interfaceName=Event HTMLEvents interfaceName=Event AnimationPlaybackEvent +BackgroundFetchEvent conditional=SERVICE_WORKER +BackgroundFetchUpdateUIEvent conditional=SERVICE_WORKER BeforeLoadEvent interfaceName=Event BeforeUnloadEvent ClipboardEvent diff --git a/Source/WebCore/dom/EventTargetFactory.in b/Source/WebCore/dom/EventTargetFactory.in index 79098f0b5bc68..31425bbdc9ab8 100644 --- a/Source/WebCore/dom/EventTargetFactory.in +++ b/Source/WebCore/dom/EventTargetFactory.in @@ -6,6 +6,7 @@ AbortSignal ApplePaySession conditional=APPLE_PAY AudioNode conditional=WEB_AUDIO AudioTrackList conditional=VIDEO +BackgroundFetchRegistration conditional=SERVICE_WORKER BaseAudioContext conditional=WEB_AUDIO BroadcastChannel Clipboard diff --git a/Source/WebCore/inspector/InspectorFrontendHost.h b/Source/WebCore/inspector/InspectorFrontendHost.h index 30f447e5bd8d1..93268f47d037e 100644 --- a/Source/WebCore/inspector/InspectorFrontendHost.h +++ b/Source/WebCore/inspector/InspectorFrontendHost.h @@ -32,6 +32,7 @@ #include "ContextMenuProvider.h" #include "ExceptionOr.h" #include "InspectorFrontendClient.h" +#include #include #include #include diff --git a/Source/WebCore/workers/service/background-fetch/BackgroundFetchEvent.cpp b/Source/WebCore/workers/service/background-fetch/BackgroundFetchEvent.cpp new file mode 100644 index 0000000000000..cfa667972bb9b --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/BackgroundFetchEvent.cpp @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "BackgroundFetchEvent.h" + +#include + +#if ENABLE(SERVICE_WORKER) + +namespace WebCore { + +WTF_MAKE_ISO_ALLOCATED_IMPL(BackgroundFetchEvent); + +Ref BackgroundFetchEvent::create(const AtomString& type, Init&& init, IsTrusted isTrusted) +{ + auto registration = init.registration; + return adoptRef(*new BackgroundFetchEvent(type, WTFMove(init), WTFMove(registration), isTrusted)); +} + +BackgroundFetchEvent::BackgroundFetchEvent(const AtomString& type, ExtendableEventInit&& eventInit, RefPtr&& registration, IsTrusted isTrusted) + : ExtendableEvent(type, WTFMove(eventInit), isTrusted) + , m_registration(WTFMove(registration)) +{ +} + +BackgroundFetchEvent::~BackgroundFetchEvent() +{ +} + +RefPtr BackgroundFetchEvent::registration() const +{ + return m_registration; +} + +} // namespace WebCore + +#endif // ENABLE(SERVICE_WORKER) + + diff --git a/Source/WebCore/workers/service/background-fetch/BackgroundFetchEvent.h b/Source/WebCore/workers/service/background-fetch/BackgroundFetchEvent.h new file mode 100644 index 0000000000000..ba3c1833ca523 --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/BackgroundFetchEvent.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#if ENABLE(SERVICE_WORKER) + +#include "BackgroundFetchEventInit.h" +#include "ExtendableEvent.h" + +namespace WebCore { + +class BackgroundFetchEvent : public ExtendableEvent { + WTF_MAKE_ISO_ALLOCATED(BackgroundFetchEvent); +public: + ~BackgroundFetchEvent(); + + using Init = BackgroundFetchEventInit; + static Ref create(const AtomString&, Init&&, IsTrusted = IsTrusted::No); + + EventInterface eventInterface() const override { return BackgroundFetchEventInterfaceType; } + + RefPtr registration() const; + +protected: + BackgroundFetchEvent(const AtomString&, ExtendableEventInit&&, RefPtr&&, IsTrusted); + +private: + RefPtr m_registration; +}; + +} // namespace WebCore + +#endif // ENABLE(SERVICE_WORKER) diff --git a/Source/WebCore/workers/service/background-fetch/BackgroundFetchEvent.idl b/Source/WebCore/workers/service/background-fetch/BackgroundFetchEvent.idl new file mode 100644 index 0000000000000..7df6bb4a883b2 --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/BackgroundFetchEvent.idl @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +[ + Conditional=SERVICE_WORKER, + EnabledBySetting=ServiceWorkersEnabled&BackgroundFetchAPIEnabled, + Exposed=ServiceWorker +] interface BackgroundFetchEvent : ExtendableEvent { + constructor([AtomString] DOMString type, BackgroundFetchEventInit init); + readonly attribute BackgroundFetchRegistration registration; +}; diff --git a/Source/WebCore/workers/service/background-fetch/BackgroundFetchEventInit.h b/Source/WebCore/workers/service/background-fetch/BackgroundFetchEventInit.h new file mode 100644 index 0000000000000..19977159fde84 --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/BackgroundFetchEventInit.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#if ENABLE(SERVICE_WORKER) + +#include "BackgroundFetchRegistration.h" +#include "ExtendableEventInit.h" + +namespace WebCore { + +struct BackgroundFetchEventInit : ExtendableEventInit { + RefPtr registration; +}; + +} // namespace WebCore + +#endif // ENABLE(SERVICE_WORKER) diff --git a/Source/WebCore/workers/service/background-fetch/BackgroundFetchEventInit.idl b/Source/WebCore/workers/service/background-fetch/BackgroundFetchEventInit.idl new file mode 100644 index 0000000000000..f3f92b445ca17 --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/BackgroundFetchEventInit.idl @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +[ + Conditional=SERVICE_WORKER, +] dictionary BackgroundFetchEventInit : ExtendableEventInit { + required BackgroundFetchRegistration registration; +}; diff --git a/Source/WebCore/workers/service/background-fetch/BackgroundFetchFailureReason.h b/Source/WebCore/workers/service/background-fetch/BackgroundFetchFailureReason.h new file mode 100644 index 0000000000000..550d2446b6330 --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/BackgroundFetchFailureReason.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#if ENABLE(SERVICE_WORKER) + +#include + +namespace WebCore { + +enum class BackgroundFetchFailureReason : uint8_t { + EmptyString, + Aborted, + BadStatus, + FetchError, + QuotaExceeded, + DownloadTotalExceeded +}; + +} // namespace WebCore + +namespace WTF { + +template<> struct EnumTraits { + using values = EnumValues< + WebCore::BackgroundFetchFailureReason, + WebCore::BackgroundFetchFailureReason::EmptyString, + WebCore::BackgroundFetchFailureReason::Aborted, + WebCore::BackgroundFetchFailureReason::BadStatus, + WebCore::BackgroundFetchFailureReason::FetchError, + WebCore::BackgroundFetchFailureReason::QuotaExceeded, + WebCore::BackgroundFetchFailureReason::DownloadTotalExceeded + >; +}; + +} // namespace WTF + +#endif // ENABLE(SERVICE_WORKER) diff --git a/Source/WebCore/workers/service/background-fetch/BackgroundFetchFailureReason.idl b/Source/WebCore/workers/service/background-fetch/BackgroundFetchFailureReason.idl new file mode 100644 index 0000000000000..9c3a5a7152fab --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/BackgroundFetchFailureReason.idl @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +[ + Conditional=SERVICE_WORKER, +] enum BackgroundFetchFailureReason { + // The background fetch has not completed yet, or was successful. + "", + // The operation was aborted by the user, or abort() was called. + "aborted", + // A response had a not-ok-status. + "bad-status", + // A fetch failed for other reasons, e.g. CORS, MIX, an invalid partial response, + // or a general network failure for a fetch that cannot be retried. + "fetch-error", + // Storage quota was reached during the operation. + "quota-exceeded", + // The provided downloadTotal was exceeded. + "download-total-exceeded" +}; diff --git a/Source/WebCore/workers/service/background-fetch/BackgroundFetchInformation.h b/Source/WebCore/workers/service/background-fetch/BackgroundFetchInformation.h new file mode 100644 index 0000000000000..2dbe7514d4d38 --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/BackgroundFetchInformation.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#if ENABLE(SERVICE_WORKER) + +#include "BackgroundFetchFailureReason.h" +#include "BackgroundFetchResult.h" +#include "ServiceWorkerTypes.h" + +namespace WebCore { + +struct BackgroundFetchInformation { + BackgroundFetchInformation isolatedCopy() const & { return { registrationIdentifier, identifier.isolatedCopy(), uploadTotal, uploaded, downloadTotal, downloaded, result, failureReason, recordsAvailable }; } + BackgroundFetchInformation isolatedCopy() && { return { registrationIdentifier, WTFMove(identifier).isolatedCopy(), uploadTotal, uploaded, downloadTotal, downloaded, result, failureReason, recordsAvailable }; } + + ServiceWorkerRegistrationIdentifier registrationIdentifier; + String identifier; + uint64_t uploadTotal { 0 }; + uint64_t uploaded { 0 }; + uint64_t downloadTotal { 0 }; + uint64_t downloaded { 0 }; + BackgroundFetchResult result { BackgroundFetchResult::EmptyString }; + BackgroundFetchFailureReason failureReason { BackgroundFetchFailureReason::EmptyString }; + bool recordsAvailable { true }; +}; + +} // namespace WebCore + +#endif // ENABLE(SERVICE_WORKER) diff --git a/Source/WebCore/workers/service/background-fetch/BackgroundFetchManager.cpp b/Source/WebCore/workers/service/background-fetch/BackgroundFetchManager.cpp new file mode 100644 index 0000000000000..8fa4311843f75 --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/BackgroundFetchManager.cpp @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "BackgroundFetchManager.h" + +#if ENABLE(SERVICE_WORKER) + +#include "ServiceWorkerRegistration.h" + +namespace WebCore { + +BackgroundFetchManager::BackgroundFetchManager(ServiceWorkerRegistration&) +{ +} + +BackgroundFetchManager::~BackgroundFetchManager() +{ +} + +void BackgroundFetchManager::fetch(ScriptExecutionContext&, const String&, Requests&&, BackgroundFetchOptions&&, DOMPromiseDeferred>&& promise) +{ + promise.reject(Exception { NotSupportedError }); +} + +void BackgroundFetchManager::get(ScriptExecutionContext&, const String&, DOMPromiseDeferred>>&& promise) +{ + promise.reject(Exception { NotSupportedError }); +} + +void BackgroundFetchManager::getIds(ScriptExecutionContext&, DOMPromiseDeferred>&& promise) +{ + promise.reject(Exception { NotSupportedError }); +} + +} // namespace WebCore + +#endif // ENABLE(SERVICE_WORKER) diff --git a/Source/WebCore/workers/service/background-fetch/BackgroundFetchManager.h b/Source/WebCore/workers/service/background-fetch/BackgroundFetchManager.h new file mode 100644 index 0000000000000..1e4078a3b9106 --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/BackgroundFetchManager.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#if ENABLE(SERVICE_WORKER) + +#include "JSDOMPromiseDeferred.h" +#include "ServiceWorkerTypes.h" +#include +#include + +namespace WebCore { + +struct BackgroundFetchInformation; +class BackgroundFetchRegistration; +struct BackgroundFetchRegistrationData; +struct BackgroundFetchOptions; +class FetchRequest; +class ServiceWorkerRegistration; + +class BackgroundFetchManager : public RefCounted, public CanMakeWeakPtr { +public: + static Ref create(ServiceWorkerRegistration& registration) { return adoptRef(*new BackgroundFetchManager(registration)); } + ~BackgroundFetchManager(); + + using RequestInfo = std::variant, String>; + using Requests = std::variant, String, Vector>; + void fetch(ScriptExecutionContext&, const String&, Requests&&, BackgroundFetchOptions&&, DOMPromiseDeferred>&&); + void get(ScriptExecutionContext&, const String&, DOMPromiseDeferred>>&&); + void getIds(ScriptExecutionContext&, DOMPromiseDeferred>&&); + +private: + explicit BackgroundFetchManager(ServiceWorkerRegistration&); +}; + +} // namespace WebCore + +#endif // ENABLE(SERVICE_WORKER) diff --git a/Source/WebCore/workers/service/background-fetch/BackgroundFetchManager.idl b/Source/WebCore/workers/service/background-fetch/BackgroundFetchManager.idl new file mode 100644 index 0000000000000..c56b963ad23ee --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/BackgroundFetchManager.idl @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +typedef (FetchRequest or USVString) RequestInfo; + +[ + Conditional=SERVICE_WORKER, + EnabledBySetting=ServiceWorkersEnabled&BackgroundFetchAPIEnabled, + Exposed=(Window,Worker) +] interface BackgroundFetchManager { + [CallWith=CurrentScriptExecutionContext] Promise fetch(DOMString id, (RequestInfo or sequence) requests, optional BackgroundFetchOptions options = {}); + [CallWith=CurrentScriptExecutionContext] Promise get(DOMString id); + [CallWith=CurrentScriptExecutionContext] Promise> getIds(); +}; diff --git a/Source/WebCore/workers/service/background-fetch/BackgroundFetchOptions.h b/Source/WebCore/workers/service/background-fetch/BackgroundFetchOptions.h new file mode 100644 index 0000000000000..5439e2bebd669 --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/BackgroundFetchOptions.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#if ENABLE(SERVICE_WORKER) + +#include "BackgroundFetchUIOptions.h" +#include + +namespace WebCore { + +struct BackgroundFetchOptions : BackgroundFetchUIOptions { + BackgroundFetchOptions() = default; + BackgroundFetchOptions(Vector&& icons, String title, uint64_t downloadTotal) + : BackgroundFetchUIOptions { WTFMove(icons), WTFMove(title) } + , downloadTotal(downloadTotal) + { + } + + BackgroundFetchOptions isolatedCopy() const & { return { crossThreadCopy(icons), title.isolatedCopy(), downloadTotal }; } + BackgroundFetchOptions isolatedCopy() && { return { crossThreadCopy(WTFMove(icons)), WTFMove(title).isolatedCopy(), downloadTotal }; } + + uint64_t downloadTotal { 0 }; +}; + +} // namespace WebCore + +#endif // ENABLE(SERVICE_WORKER) diff --git a/Source/WebCore/workers/service/background-fetch/BackgroundFetchOptions.idl b/Source/WebCore/workers/service/background-fetch/BackgroundFetchOptions.idl new file mode 100644 index 0000000000000..7c86f24ddffa1 --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/BackgroundFetchOptions.idl @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +[ + Conditional=SERVICE_WORKER, +] dictionary BackgroundFetchOptions : BackgroundFetchUIOptions { + unsigned long long downloadTotal = 0; +}; diff --git a/Source/WebCore/workers/service/background-fetch/BackgroundFetchRecord.cpp b/Source/WebCore/workers/service/background-fetch/BackgroundFetchRecord.cpp new file mode 100644 index 0000000000000..0372c96416fde --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/BackgroundFetchRecord.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "BackgroundFetchRecord.h" + +#if ENABLE(SERVICE_WORKER) + +#include "BackgroundFetchRecordInformation.h" +#include "FetchRequest.h" +#include "JSFetchResponse.h" + +namespace WebCore { + +BackgroundFetchRecord::BackgroundFetchRecord(ScriptExecutionContext& context, BackgroundFetchRecordInformation&& information) + : m_responseReadyPromise(makeUniqueRef()) + , m_request(FetchRequest::create(context, { }, FetchHeaders::create(information.guard, WTFMove(information.httpHeaders)), WTFMove(information.internalRequest), WTFMove(information.options), WTFMove(information.referrer))) +{ + // FIXME: We should provide a body to the request. +} + +BackgroundFetchRecord::~BackgroundFetchRecord() +{ +} + +Ref BackgroundFetchRecord::request() +{ + return m_request; +} + +void BackgroundFetchRecord::settleResponseReadyPromise(ExceptionOr>&& result) +{ + if (result.hasException()) { + m_responseReadyPromise->reject(result.releaseException()); + return; + } + m_responseReadyPromise->resolveWithNewlyCreated(result.releaseReturnValue()); +} + +} // namespace WebCore + +#endif // ENABLE(SERVICE_WORKER) + + diff --git a/Source/WebCore/workers/service/background-fetch/BackgroundFetchRecord.h b/Source/WebCore/workers/service/background-fetch/BackgroundFetchRecord.h new file mode 100644 index 0000000000000..e3f9646dabd5c --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/BackgroundFetchRecord.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#if ENABLE(SERVICE_WORKER) + +#include "DOMPromiseProxy.h" +#include + +namespace WebCore { + +struct BackgroundFetchRecordInformation; +class FetchRequest; +class FetchResponse; +class ScriptExecutionContext; + +class BackgroundFetchRecord : public RefCounted { +public: + static Ref create(ScriptExecutionContext& context, BackgroundFetchRecordInformation&& information) { return adoptRef(*new BackgroundFetchRecord(context, WTFMove(information))); } + + ~BackgroundFetchRecord(); + + using ResponseReadyPromise = DOMPromiseProxy>; + ResponseReadyPromise& responseReady() { return m_responseReadyPromise; } + Ref request(); + + void settleResponseReadyPromise(ExceptionOr>&&); + +private: + BackgroundFetchRecord(ScriptExecutionContext&, BackgroundFetchRecordInformation&&); + + UniqueRef m_responseReadyPromise; + Ref m_request; +}; + +} // namespace WebCore + +#endif // ENABLE(SERVICE_WORKER) diff --git a/Source/WebCore/workers/service/background-fetch/BackgroundFetchRecord.idl b/Source/WebCore/workers/service/background-fetch/BackgroundFetchRecord.idl new file mode 100644 index 0000000000000..dc50e1d2d9086 --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/BackgroundFetchRecord.idl @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +[ + Conditional=SERVICE_WORKER, + EnabledBySetting=ServiceWorkersEnabled&BackgroundFetchAPIEnabled, + Exposed=(Window,Worker) +] interface BackgroundFetchRecord { + readonly attribute FetchRequest request; + readonly attribute Promise responseReady; +}; diff --git a/Source/WebCore/workers/service/background-fetch/BackgroundFetchRecordIdentifier.h b/Source/WebCore/workers/service/background-fetch/BackgroundFetchRecordIdentifier.h new file mode 100644 index 0000000000000..e9963a596bef3 --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/BackgroundFetchRecordIdentifier.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include + +namespace WebCore { + +enum BackgroundFetchRecordIdentifierType { }; +using BackgroundFetchRecordIdentifier = ObjectIdentifier; + +} // namespace WebCore + diff --git a/Source/WebCore/workers/service/background-fetch/BackgroundFetchRecordInformation.h b/Source/WebCore/workers/service/background-fetch/BackgroundFetchRecordInformation.h new file mode 100644 index 0000000000000..72e63ab9c789c --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/BackgroundFetchRecordInformation.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#if ENABLE(SERVICE_WORKER) + +#include "BackgroundFetchRecordIdentifier.h" +#include "FetchHeadersGuard.h" +#include "FetchOptions.h" +#include "HTTPHeaderMap.h" +#include "ResourceRequest.h" +#include + +namespace WebCore { + +struct BackgroundFetchRecordInformation { + BackgroundFetchRecordIdentifier identifier; + ResourceRequest internalRequest; + FetchOptions options; + FetchHeadersGuard guard { FetchHeadersGuard::None }; + HTTPHeaderMap httpHeaders; + String referrer; + + BackgroundFetchRecordInformation isolatedCopy() const & { return { identifier, internalRequest.isolatedCopy(), options.isolatedCopy(), guard, httpHeaders.isolatedCopy(), referrer.isolatedCopy() }; } + BackgroundFetchRecordInformation isolatedCopy() && { return { identifier, WTFMove(internalRequest).isolatedCopy(), WTFMove(options).isolatedCopy(), guard, WTFMove(httpHeaders).isolatedCopy(), WTFMove(referrer).isolatedCopy() }; } +}; + +} // namespace WebCore + +#endif // ENABLE(SERVICE_WORKER) diff --git a/Source/WebCore/workers/service/background-fetch/BackgroundFetchRegistration.cpp b/Source/WebCore/workers/service/background-fetch/BackgroundFetchRegistration.cpp new file mode 100644 index 0000000000000..12060afa13dfc --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/BackgroundFetchRegistration.cpp @@ -0,0 +1,114 @@ +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "BackgroundFetchRegistration.h" + +#if ENABLE(SERVICE_WORKER) + +#include "BackgroundFetchManager.h" +#include "BackgroundFetchRecordInformation.h" +#include "CacheQueryOptions.h" +#include "EventNames.h" +#include "RetrieveRecordsOptions.h" +#include "ServiceWorkerContainer.h" +#include "ServiceWorkerRegistrationBackgroundFetchAPI.h" +#include + +namespace WebCore { + +WTF_MAKE_ISO_ALLOCATED_IMPL(BackgroundFetchRegistration); + +Ref BackgroundFetchRegistration::create(ScriptExecutionContext& context, BackgroundFetchInformation&& information) +{ + auto registration = adoptRef(*new BackgroundFetchRegistration(context, WTFMove(information))); + registration->suspendIfNeeded(); + return registration; +} + +BackgroundFetchRegistration::BackgroundFetchRegistration(ScriptExecutionContext& context, BackgroundFetchInformation&& information) + : ActiveDOMObject(&context) + , m_information(WTFMove(information)) +{ +} + +BackgroundFetchRegistration::~BackgroundFetchRegistration() +{ +} + +void BackgroundFetchRegistration::abort(ScriptExecutionContext&, DOMPromiseDeferred&& promise) +{ + promise.reject(Exception { NotSupportedError }); +} + +void BackgroundFetchRegistration::match(ScriptExecutionContext&, RequestInfo&&, const CacheQueryOptions&, DOMPromiseDeferred>&& promise) +{ + promise.reject(Exception { NotSupportedError }); +} + +void BackgroundFetchRegistration::matchAll(ScriptExecutionContext&, std::optional&&, const CacheQueryOptions&, DOMPromiseDeferred>>&& promise) +{ + promise.reject(Exception { NotSupportedError }); +} + +void BackgroundFetchRegistration::updateInformation(const BackgroundFetchInformation& information) +{ + ASSERT(m_information.registrationIdentifier == information.registrationIdentifier); + ASSERT(m_information.identifier == information.identifier); + ASSERT(m_information.recordsAvailable); + + if (m_information.downloaded == information.downloaded && m_information.uploaded == information.uploaded && m_information.result == information.result && m_information.failureReason == information.failureReason) + return; + + m_information.uploadTotal = information.uploadTotal; + m_information.uploaded = information.uploaded; + m_information.downloadTotal = information.downloadTotal; + m_information.downloaded = information.downloaded; + m_information.result = information.result; + m_information.failureReason = information.failureReason; + m_information.recordsAvailable = information.recordsAvailable; + + dispatchEvent(Event::create(eventNames().progressEvent, Event::CanBubble::No, Event::IsCancelable::No)); +} + +const char* BackgroundFetchRegistration::activeDOMObjectName() const +{ + return "BackgroundFetchRegistration"; +} + +void BackgroundFetchRegistration::stop() +{ +} + +bool BackgroundFetchRegistration::virtualHasPendingActivity() const +{ + return m_information.recordsAvailable; +} + +} // namespace WebCore + +#endif // ENABLE(SERVICE_WORKER) + + diff --git a/Source/WebCore/workers/service/background-fetch/BackgroundFetchRegistration.h b/Source/WebCore/workers/service/background-fetch/BackgroundFetchRegistration.h new file mode 100644 index 0000000000000..c5a2d4e11cf65 --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/BackgroundFetchRegistration.h @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#if ENABLE(SERVICE_WORKER) + +#include "ActiveDOMObject.h" +#include "BackgroundFetchFailureReason.h" +#include "BackgroundFetchInformation.h" +#include "BackgroundFetchResult.h" +#include "EventTarget.h" +#include "JSDOMPromiseDeferred.h" +#include +#include + +namespace WebCore { + +class BackgroundFetchRecord; +class FetchRequest; +struct BackgroundFetchInformation; +struct BackgroundFetchRecordInformation; +struct CacheQueryOptions; + +class BackgroundFetchRegistration final : public RefCounted, public EventTarget, public ActiveDOMObject { + WTF_MAKE_ISO_ALLOCATED(BackgroundFetchRegistration); +public: + static Ref create(ScriptExecutionContext&, BackgroundFetchInformation&&); + ~BackgroundFetchRegistration(); + + const String& id() const { return m_information.identifier; } + uint64_t uploadTotal() const { return m_information.uploadTotal; } + uint64_t uploaded() const { return m_information.uploaded; } + uint64_t downloadTotal() const { return m_information.downloadTotal; } + uint64_t downloaded() const { return m_information.downloaded; } + BackgroundFetchResult result() const { return m_information.result; } + BackgroundFetchFailureReason failureReason() const { return m_information.failureReason; } + bool recordsAvailable() const { return m_information.recordsAvailable; } + + using RequestInfo = std::variant, String>; + + void abort(ScriptExecutionContext&, DOMPromiseDeferred&&); + void match(ScriptExecutionContext&, RequestInfo&&, const CacheQueryOptions&, DOMPromiseDeferred>&&); + void matchAll(ScriptExecutionContext&, std::optional&&, const CacheQueryOptions&, DOMPromiseDeferred>>&&); + + void updateInformation(const BackgroundFetchInformation&); + + using RefCounted::ref; + using RefCounted::deref; + +private: + BackgroundFetchRegistration(ScriptExecutionContext&, BackgroundFetchInformation&&); + + ServiceWorkerRegistrationIdentifier registrationIdentifier() const { return m_information.registrationIdentifier; } + + // EventTarget + EventTargetInterface eventTargetInterface() const final { return BackgroundFetchRegistrationEventTargetInterfaceType; } + ScriptExecutionContext* scriptExecutionContext() const final { return ActiveDOMObject::scriptExecutionContext(); } + void refEventTarget() final { ref(); } + void derefEventTarget() final { deref(); } + + // ActiveDOMObject + const char* activeDOMObjectName() const final; + void stop() final; + bool virtualHasPendingActivity() const final; + + BackgroundFetchInformation m_information; +}; + +} // namespace WebCore + +#endif // ENABLE(SERVICE_WORKER) diff --git a/Source/WebCore/workers/service/background-fetch/BackgroundFetchRegistration.idl b/Source/WebCore/workers/service/background-fetch/BackgroundFetchRegistration.idl new file mode 100644 index 0000000000000..691294dee370b --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/BackgroundFetchRegistration.idl @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +typedef (FetchRequest or USVString) RequestInfo; + +[ + ActiveDOMObject, + Conditional=SERVICE_WORKER, + EnabledBySetting=ServiceWorkersEnabled&BackgroundFetchAPIEnabled, + Exposed=(Window,Worker) +] interface BackgroundFetchRegistration : EventTarget { + readonly attribute DOMString id; + readonly attribute unsigned long long uploadTotal; + readonly attribute unsigned long long uploaded; + readonly attribute unsigned long long downloadTotal; + readonly attribute unsigned long long downloaded; + readonly attribute BackgroundFetchResult result; + readonly attribute BackgroundFetchFailureReason failureReason; + readonly attribute boolean recordsAvailable; + + attribute EventHandler onprogress; + + [CallWith=CurrentScriptExecutionContext] Promise abort(); + [CallWith=CurrentScriptExecutionContext] Promise match(RequestInfo request, optional CacheQueryOptions options = {}); + [CallWith=CurrentScriptExecutionContext] Promise> matchAll(optional RequestInfo request, optional CacheQueryOptions options = {}); +}; diff --git a/Source/WebCore/workers/service/background-fetch/BackgroundFetchRequest.h b/Source/WebCore/workers/service/background-fetch/BackgroundFetchRequest.h new file mode 100644 index 0000000000000..42f561b1ea182 --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/BackgroundFetchRequest.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#if ENABLE(SERVICE_WORKER) + +#include "FetchHeadersGuard.h" +#include "FetchOptions.h" +#include "HTTPHeaderMap.h" +#include "ResourceRequest.h" + +namespace WebCore { + +struct BackgroundFetchRequest { + BackgroundFetchRequest isolatedCopy() const & { return { internalRequest.isolatedCopy(), options.isolatedCopy(), guard, httpHeaders.isolatedCopy(), referrer.isolatedCopy() }; } + BackgroundFetchRequest isolatedCopy() && { return { WTFMove(internalRequest).isolatedCopy(), WTFMove(options).isolatedCopy(), guard, WTFMove(httpHeaders).isolatedCopy(), WTFMove(referrer).isolatedCopy() }; } + + ResourceRequest internalRequest; + FetchOptions options; + FetchHeadersGuard guard; + HTTPHeaderMap httpHeaders; + String referrer; +}; + +} // namespace WebCore + +#endif // ENABLE(SERVICE_WORKER) diff --git a/Source/WebCore/workers/service/background-fetch/BackgroundFetchResult.h b/Source/WebCore/workers/service/background-fetch/BackgroundFetchResult.h new file mode 100644 index 0000000000000..ae3d661033402 --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/BackgroundFetchResult.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#if ENABLE(SERVICE_WORKER) + +namespace WebCore { + +enum class BackgroundFetchResult : uint8_t { + EmptyString, + Success, + Failure +}; + +} // namespace WebCore + +namespace WTF { + +template<> struct EnumTraits { + using values = EnumValues< + WebCore::BackgroundFetchResult, + WebCore::BackgroundFetchResult::EmptyString, + WebCore::BackgroundFetchResult::Success, + WebCore::BackgroundFetchResult::Failure + >; +}; + +} // namespace WTF + +#endif // ENABLE(SERVICE_WORKER) diff --git a/Source/WebCore/workers/service/background-fetch/BackgroundFetchResult.idl b/Source/WebCore/workers/service/background-fetch/BackgroundFetchResult.idl new file mode 100644 index 0000000000000..f66703e921418 --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/BackgroundFetchResult.idl @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +[ + Conditional=SERVICE_WORKER, +] enum BackgroundFetchResult { "", "success", "failure" }; diff --git a/Source/WebCore/workers/service/background-fetch/BackgroundFetchUIOptions.h b/Source/WebCore/workers/service/background-fetch/BackgroundFetchUIOptions.h new file mode 100644 index 0000000000000..5cca613a57d07 --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/BackgroundFetchUIOptions.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#if ENABLE(SERVICE_WORKER) + +#include "ImageResource.h" +#include + +namespace WebCore { + +struct BackgroundFetchUIOptions { + Vector icons; + String title; +}; + +} // namespace WebCore + +#endif // ENABLE(SERVICE_WORKER) diff --git a/Source/WebCore/workers/service/background-fetch/BackgroundFetchUIOptions.idl b/Source/WebCore/workers/service/background-fetch/BackgroundFetchUIOptions.idl new file mode 100644 index 0000000000000..1541cb9a625bb --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/BackgroundFetchUIOptions.idl @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +[ + Conditional=SERVICE_WORKER, +] dictionary BackgroundFetchUIOptions { + sequence icons; + DOMString title; +}; diff --git a/Source/WebCore/workers/service/background-fetch/BackgroundFetchUpdateUIEvent.cpp b/Source/WebCore/workers/service/background-fetch/BackgroundFetchUpdateUIEvent.cpp new file mode 100644 index 0000000000000..ec0408ec24661 --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/BackgroundFetchUpdateUIEvent.cpp @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "BackgroundFetchUpdateUIEvent.h" + +#include "NotImplemented.h" +#include + +#if ENABLE(SERVICE_WORKER) + +namespace WebCore { + +WTF_MAKE_ISO_ALLOCATED_IMPL(BackgroundFetchUpdateUIEvent); + +Ref BackgroundFetchUpdateUIEvent::create(const AtomString& type, Init&& init, IsTrusted isTrusted) +{ + auto registration = init.registration; + return adoptRef(*new BackgroundFetchUpdateUIEvent(type, WTFMove(init), WTFMove(registration), isTrusted)); +} + +BackgroundFetchUpdateUIEvent::BackgroundFetchUpdateUIEvent(const AtomString& type, ExtendableEventInit&& eventInit, RefPtr&& registration, IsTrusted isTrusted) + : BackgroundFetchEvent(type, WTFMove(eventInit), WTFMove(registration), isTrusted) +{ +} + +BackgroundFetchUpdateUIEvent::~BackgroundFetchUpdateUIEvent() +{ +} + +void BackgroundFetchUpdateUIEvent::updateUI(BackgroundFetchUIOptions&&, DOMPromiseDeferred&&) +{ + notImplemented(); +} + +} // namespace WebCore + +#endif // ENABLE(SERVICE_WORKER) + + diff --git a/Source/WebCore/workers/service/background-fetch/BackgroundFetchUpdateUIEvent.h b/Source/WebCore/workers/service/background-fetch/BackgroundFetchUpdateUIEvent.h new file mode 100644 index 0000000000000..7c90642c630bd --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/BackgroundFetchUpdateUIEvent.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#if ENABLE(SERVICE_WORKER) + +#include "BackgroundFetchEvent.h" +#include "JSDOMPromiseDeferred.h" + +namespace WebCore { + +struct BackgroundFetchUIOptions; + +class BackgroundFetchUpdateUIEvent final : public BackgroundFetchEvent { + WTF_MAKE_ISO_ALLOCATED(BackgroundFetchUpdateUIEvent); +public: + using Init = BackgroundFetchEventInit; + static Ref create(const AtomString&, Init&&, IsTrusted = IsTrusted::No); + + ~BackgroundFetchUpdateUIEvent(); + + EventInterface eventInterface() const final { return BackgroundFetchUpdateUIEventInterfaceType; } + + void updateUI(BackgroundFetchUIOptions&&, DOMPromiseDeferred&&); + +private: + BackgroundFetchUpdateUIEvent(const AtomString&, ExtendableEventInit&&, RefPtr&&, IsTrusted); +}; + +} // namespace WebCore + +#endif // ENABLE(SERVICE_WORKER) diff --git a/Source/WebCore/workers/service/background-fetch/BackgroundFetchUpdateUIEvent.idl b/Source/WebCore/workers/service/background-fetch/BackgroundFetchUpdateUIEvent.idl new file mode 100644 index 0000000000000..0bed74b957efb --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/BackgroundFetchUpdateUIEvent.idl @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +[ + Conditional=SERVICE_WORKER, + EnabledBySetting=ServiceWorkersEnabled&BackgroundFetchAPIEnabled, + Exposed=(Window,Worker) +] interface BackgroundFetchUpdateUIEvent : BackgroundFetchEvent { + constructor([AtomString] DOMString type, BackgroundFetchEventInit init); + Promise updateUI(optional BackgroundFetchUIOptions options = {}); +}; diff --git a/Source/WebCore/workers/service/background-fetch/ImageResource.h b/Source/WebCore/workers/service/background-fetch/ImageResource.h new file mode 100644 index 0000000000000..fe6442f1108e6 --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/ImageResource.h @@ -0,0 +1,47 @@ + +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#if ENABLE(SERVICE_WORKER) + +#include + +namespace WebCore { + +struct ImageResource { + ImageResource isolatedCopy() const & { return { src.isolatedCopy(), sizes.isolatedCopy(), type.isolatedCopy(), label.isolatedCopy() }; } + ImageResource isolatedCopy() && { return { WTFMove(src).isolatedCopy(), WTFMove(sizes).isolatedCopy(), WTFMove(type).isolatedCopy(), WTFMove(label).isolatedCopy() }; } + + String src; + String sizes; + String type; + String label; +}; + +} // namespace WebCore + +#endif // ENABLE(SERVICE_WORKER) diff --git a/Source/WebCore/workers/service/background-fetch/ImageResource.idl b/Source/WebCore/workers/service/background-fetch/ImageResource.idl new file mode 100644 index 0000000000000..ca6f2829a74ac --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/ImageResource.idl @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +[ + Conditional=SERVICE_WORKER, +] dictionary ImageResource { + required USVString src; + DOMString sizes; + DOMString type; + DOMString label; +}; diff --git a/Source/WebCore/workers/service/background-fetch/ServiceWorkerGlobalScope+BackgroundFetchAPI.idl b/Source/WebCore/workers/service/background-fetch/ServiceWorkerGlobalScope+BackgroundFetchAPI.idl new file mode 100644 index 0000000000000..65d609bbf4939 --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/ServiceWorkerGlobalScope+BackgroundFetchAPI.idl @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +[ + Conditional=SERVICE_WORKER, + EnabledBySetting=ServiceWorkersEnabled&BackgroundFetchAPIEnabled +] partial interface ServiceWorkerGlobalScope { + attribute EventHandler onbackgroundfetchsuccess; + attribute EventHandler onbackgroundfetchfail; + attribute EventHandler onbackgroundfetchabort; + attribute EventHandler onbackgroundfetchclick; +}; diff --git a/Source/WebCore/workers/service/background-fetch/ServiceWorkerRegistration+BackgroundFetchAPI.idl b/Source/WebCore/workers/service/background-fetch/ServiceWorkerRegistration+BackgroundFetchAPI.idl new file mode 100644 index 0000000000000..62017f3bbfcd5 --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/ServiceWorkerRegistration+BackgroundFetchAPI.idl @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +[ + Conditional=SERVICE_WORKER, + EnabledBySetting=ServiceWorkersEnabled&BackgroundFetchAPIEnabled, + ImplementedBy=ServiceWorkerRegistrationBackgroundFetchAPI +] partial interface ServiceWorkerRegistration { + readonly attribute BackgroundFetchManager backgroundFetch; +}; diff --git a/Source/WebCore/workers/service/background-fetch/ServiceWorkerRegistrationBackgroundFetchAPI.cpp b/Source/WebCore/workers/service/background-fetch/ServiceWorkerRegistrationBackgroundFetchAPI.cpp new file mode 100644 index 0000000000000..e1d368e8eeb66 --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/ServiceWorkerRegistrationBackgroundFetchAPI.cpp @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "ServiceWorkerRegistrationBackgroundFetchAPI.h" + +#if ENABLE(SERVICE_WORKER) + +#include "BackgroundFetchManager.h" +#include "ServiceWorkerRegistration.h" +#include + +namespace WebCore { + +ServiceWorkerRegistrationBackgroundFetchAPI::ServiceWorkerRegistrationBackgroundFetchAPI(ServiceWorkerRegistration& serviceWorkerRegistration) + : m_serviceWorkerRegistration(serviceWorkerRegistration) +{ +} + +ServiceWorkerRegistrationBackgroundFetchAPI::~ServiceWorkerRegistrationBackgroundFetchAPI() +{ +} + +BackgroundFetchManager& ServiceWorkerRegistrationBackgroundFetchAPI::backgroundFetch(ServiceWorkerRegistration& serviceWorkerRegistration) +{ + return ServiceWorkerRegistrationBackgroundFetchAPI::from(serviceWorkerRegistration).backgroundFetchManager(); +} + +RefPtr ServiceWorkerRegistrationBackgroundFetchAPI::backgroundFetchIfCreated(ServiceWorkerRegistration& serviceWorkerRegistration) +{ + return ServiceWorkerRegistrationBackgroundFetchAPI::from(serviceWorkerRegistration).m_backgroundFetchManager; +} + +BackgroundFetchManager& ServiceWorkerRegistrationBackgroundFetchAPI::backgroundFetchManager() +{ + if (!m_backgroundFetchManager) + m_backgroundFetchManager = BackgroundFetchManager::create(m_serviceWorkerRegistration); + + return *m_backgroundFetchManager; +} + +ServiceWorkerRegistrationBackgroundFetchAPI& ServiceWorkerRegistrationBackgroundFetchAPI::from(ServiceWorkerRegistration& serviceWorkerRegistration) +{ + auto* supplement = static_cast(Supplement::from(&serviceWorkerRegistration, supplementName())); + if (!supplement) { + auto newSupplement = makeUnique(serviceWorkerRegistration); + supplement = newSupplement.get(); + provideTo(&serviceWorkerRegistration, supplementName(), WTFMove(newSupplement)); + } + return *supplement; +} + +const char* ServiceWorkerRegistrationBackgroundFetchAPI::supplementName() +{ + return "ServiceWorkerRegistrationBackgroundFetchAPI"; +} + +} + +#endif // ENABLE(SERVICE_WORKER) diff --git a/Source/WebCore/workers/service/background-fetch/ServiceWorkerRegistrationBackgroundFetchAPI.h b/Source/WebCore/workers/service/background-fetch/ServiceWorkerRegistrationBackgroundFetchAPI.h new file mode 100644 index 0000000000000..df2719149661d --- /dev/null +++ b/Source/WebCore/workers/service/background-fetch/ServiceWorkerRegistrationBackgroundFetchAPI.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2023 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#if ENABLE(SERVICE_WORKER) + +#include "Supplementable.h" +#include + +namespace WebCore { + +class BackgroundFetchManager; +class ServiceWorkerRegistration; + +class ServiceWorkerRegistrationBackgroundFetchAPI : public Supplement { + WTF_MAKE_FAST_ALLOCATED; +public: + explicit ServiceWorkerRegistrationBackgroundFetchAPI(ServiceWorkerRegistration&); + ~ServiceWorkerRegistrationBackgroundFetchAPI(); + + static BackgroundFetchManager& backgroundFetch(ServiceWorkerRegistration&); + BackgroundFetchManager& backgroundFetchManager(); + + static RefPtr backgroundFetchIfCreated(ServiceWorkerRegistration&); + +private: + static ServiceWorkerRegistrationBackgroundFetchAPI& from(ServiceWorkerRegistration&); + static const char* supplementName(); + + ServiceWorkerRegistration& m_serviceWorkerRegistration; + RefPtr m_backgroundFetchManager; +}; + +} + +#endif // ENABLE(SERVICE_WORKER)