Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement the Cookie Store API get/set/delete functions for Service Workers #17083

Merged
merged 1 commit into from
Sep 16, 2023

Conversation

RupinMittal
Copy link
Contributor

@RupinMittal RupinMittal commented Aug 25, 2023

2ecb71d

Implement the Cookie Store API get/set/delete functions for Service Workers
https://bugs.webkit.org/show_bug.cgi?id=260737

Reviewed by Chris Dumez.

The Cookie Store API should be supported for Service Workers. This patch
adds Service Worker support for the get/set/delete cookie functions.
The Cookie Store is now created using a ScriptExecutionContext rather
the CookieJar where needed.

Since get/set/delete are called through the CookieJar, and CookieJar is
a main thread object, we now have a CookieStore::MainThreadBridge which
is used to hop between the main thread and the service worker thread
when needed. This will also be used for cookie change notifications in
a future patch.

* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieListItem_attributes.https.any.serviceworker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_delete_arguments.https.any.serviceworker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_delete_basic.https.any.serviceworker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_getAll_arguments.https.any.serviceworker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_getAll_multiple.https.any.serviceworker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_getAll_set_basic.https.any.serviceworker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_get_arguments.https.any.serviceworker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_get_delete_basic.https.any.serviceworker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_get_set_across_frames.https-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_get_set_basic.https.any.serviceworker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_get_set_ordering.https.any.serviceworker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_opaque_origin.https-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_set_arguments.https.any.serviceworker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_special_names.https.any.serviceworker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/encoding.https.any.serviceworker-expected.txt:
* Source/WebCore/Modules/cookie-store/CookieInit.h:
(WebCore::CookieInit::isolatedCopy const):
(WebCore::CookieInit::isolatedCopy):
* Source/WebCore/Modules/cookie-store/CookieStore.cpp:
(WebCore::CookieStore::MainThreadBridge::create):
(WebCore::CookieStore::MainThreadBridge::MainThreadBridge):
(WebCore::CookieStore::MainThreadBridge::ensureOnMainThread):
(WebCore::CookieStore::MainThreadBridge::ensureOnContextThread):
(WebCore::CookieStore::MainThreadBridge::get):
(WebCore::CookieStore::MainThreadBridge::getAll):
(WebCore::CookieStore::MainThreadBridge::set):
(WebCore::CookieStore::create):
(WebCore::CookieStore::CookieStore):
(WebCore::CookieStore::get):
(WebCore::CookieStore::getAll):
(WebCore::CookieStore::set):
(WebCore::CookieStore::cookiesAdded):
(WebCore::CookieStore::cookiesDeleted):
(WebCore::CookieStore::stop):
(WebCore::CookieStore::eventListenersDidChange):
(WebCore::CookieStore::takePromise):
* Source/WebCore/Modules/cookie-store/CookieStore.h:
* Source/WebCore/Modules/cookie-store/CookieStoreGetOptions.h:
(WebCore::CookieStoreGetOptions::isolatedCopy const):
(WebCore::CookieStoreGetOptions::isolatedCopy):
* Source/WebCore/loader/CookieJar.cpp:
(WebCore::CookieJar::sameSiteInfo):
* Source/WebCore/platform/Cookie.h:
(WebCore::Cookie::Cookie):
(WebCore::Cookie::isolatedCopy const):
(WebCore::Cookie::isolatedCopy):
* Source/WebCore/workers/service/ServiceWorkerGlobalScope.cpp:
(WebCore::ServiceWorkerGlobalScope::cookieStore):
* Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::cookiesForDOMAsync):
(WebKit::NetworkConnectionToWebProcess::setCookieFromDOMAsync):
* Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h:
* Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in:
* Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp:
(WebKit::WebSWContextManagerConnection::installServiceWorker):
* Source/WebKit/WebProcess/WebPage/WebCookieJar.cpp:
(WebKit::WebCookieJar::getCookiesAsync const):
(WebKit::WebCookieJar::setCookieAsync const):

Canonical link: https://commits.webkit.org/268055@main

bfa34c8

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  wincairo
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug βœ… πŸ§ͺ wpe-wk2
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac βœ… πŸ›  gtk
βœ… πŸ§ͺ ios-wk2-wpt βœ… πŸ§ͺ mac-wk1 βœ… πŸ§ͺ gtk-wk2
βœ… πŸ§ͺ api-ios ❌ πŸ§ͺ mac-wk2 βœ… πŸ§ͺ api-gtk
βœ… πŸ›  tv βœ… πŸ§ͺ mac-AS-debug-wk2
βœ… πŸ›  tv-sim
❌ πŸ›  πŸ§ͺ merge βœ… πŸ›  watch
βœ… πŸ›  πŸ§ͺ unsafe-merge βœ… πŸ›  watch-sim

@RupinMittal RupinMittal self-assigned this Aug 25, 2023
@RupinMittal RupinMittal added the WebKit API For issues and bugs in the Web Kit public embedding APIs label Aug 25, 2023
@RupinMittal RupinMittal marked this pull request as draft August 25, 2023 21:29
@RupinMittal
Copy link
Contributor Author

This pr is still in progress (so I've marked it as a draft). I still need to investigate a few layout test results that are running as intended.

Source/WebCore/Modules/cookie-store/CookieStore.cpp Outdated Show resolved Hide resolved
Source/WebCore/Modules/cookie-store/CookieStore.cpp Outdated Show resolved Hide resolved
Source/WebCore/Modules/cookie-store/CookieStore.cpp Outdated Show resolved Hide resolved
Source/WebCore/Modules/cookie-store/CookieStore.cpp Outdated Show resolved Hide resolved
Source/WebCore/Modules/cookie-store/CookieStore.cpp Outdated Show resolved Hide resolved
Source/WebCore/Modules/cookie-store/CookieStore.cpp Outdated Show resolved Hide resolved
Source/WebCore/Modules/cookie-store/CookieStore.cpp Outdated Show resolved Hide resolved
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Aug 25, 2023
@RupinMittal RupinMittal removed the merging-blocked Applied to prevent a change from being merged label Aug 29, 2023
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Aug 29, 2023
@RupinMittal RupinMittal removed the merging-blocked Applied to prevent a change from being merged label Aug 30, 2023
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Aug 30, 2023
Source/WebCore/Modules/cookie-store/CookieStore.cpp Outdated Show resolved Hide resolved
Source/WebCore/Modules/cookie-store/CookieStore.cpp Outdated Show resolved Hide resolved
Source/WebCore/Modules/cookie-store/CookieStore.cpp Outdated Show resolved Hide resolved
@RupinMittal RupinMittal removed the merging-blocked Applied to prevent a change from being merged label Sep 5, 2023
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Sep 5, 2023
@RupinMittal RupinMittal removed the merging-blocked Applied to prevent a change from being merged label Sep 14, 2023
@RupinMittal RupinMittal force-pushed the eng/260737 branch 2 times, most recently from b1c3710 to 8626c7a Compare September 14, 2023 21:23
Copy link
Contributor

@cdumez cdumez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I think it looks good, assuming EWS is happy.

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Sep 16, 2023
@cdumez cdumez added merge-queue Applied to send a pull request to merge-queue and removed merging-blocked Applied to prevent a change from being merged labels Sep 16, 2023
@webkit-commit-queue webkit-commit-queue added merging-blocked Applied to prevent a change from being merged and removed merge-queue Applied to send a pull request to merge-queue labels Sep 16, 2023
@cdumez cdumez added unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing and removed merging-blocked Applied to prevent a change from being merged labels Sep 16, 2023
…orkers

https://bugs.webkit.org/show_bug.cgi?id=260737

Reviewed by Chris Dumez.

The Cookie Store API should be supported for Service Workers. This patch
adds Service Worker support for the get/set/delete cookie functions.
The Cookie Store is now created using a ScriptExecutionContext rather
the CookieJar where needed.

Since get/set/delete are called through the CookieJar, and CookieJar is
a main thread object, we now have a CookieStore::MainThreadBridge which
is used to hop between the main thread and the service worker thread
when needed. This will also be used for cookie change notifications in
a future patch.

* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieListItem_attributes.https.any.serviceworker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_delete_arguments.https.any.serviceworker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_delete_basic.https.any.serviceworker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_getAll_arguments.https.any.serviceworker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_getAll_multiple.https.any.serviceworker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_getAll_set_basic.https.any.serviceworker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_get_arguments.https.any.serviceworker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_get_delete_basic.https.any.serviceworker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_get_set_across_frames.https-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_get_set_basic.https.any.serviceworker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_get_set_ordering.https.any.serviceworker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_opaque_origin.https-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_set_arguments.https.any.serviceworker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_special_names.https.any.serviceworker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/encoding.https.any.serviceworker-expected.txt:
* Source/WebCore/Modules/cookie-store/CookieInit.h:
(WebCore::CookieInit::isolatedCopy const):
(WebCore::CookieInit::isolatedCopy):
* Source/WebCore/Modules/cookie-store/CookieStore.cpp:
(WebCore::CookieStore::MainThreadBridge::create):
(WebCore::CookieStore::MainThreadBridge::MainThreadBridge):
(WebCore::CookieStore::MainThreadBridge::ensureOnMainThread):
(WebCore::CookieStore::MainThreadBridge::ensureOnContextThread):
(WebCore::CookieStore::MainThreadBridge::get):
(WebCore::CookieStore::MainThreadBridge::getAll):
(WebCore::CookieStore::MainThreadBridge::set):
(WebCore::CookieStore::create):
(WebCore::CookieStore::CookieStore):
(WebCore::CookieStore::get):
(WebCore::CookieStore::getAll):
(WebCore::CookieStore::set):
(WebCore::CookieStore::cookiesAdded):
(WebCore::CookieStore::cookiesDeleted):
(WebCore::CookieStore::stop):
(WebCore::CookieStore::eventListenersDidChange):
(WebCore::CookieStore::takePromise):
* Source/WebCore/Modules/cookie-store/CookieStore.h:
* Source/WebCore/Modules/cookie-store/CookieStoreGetOptions.h:
(WebCore::CookieStoreGetOptions::isolatedCopy const):
(WebCore::CookieStoreGetOptions::isolatedCopy):
* Source/WebCore/loader/CookieJar.cpp:
(WebCore::CookieJar::sameSiteInfo):
* Source/WebCore/platform/Cookie.h:
(WebCore::Cookie::Cookie):
(WebCore::Cookie::isolatedCopy const):
(WebCore::Cookie::isolatedCopy):
* Source/WebCore/workers/service/ServiceWorkerGlobalScope.cpp:
(WebCore::ServiceWorkerGlobalScope::cookieStore):
* Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::cookiesForDOMAsync):
(WebKit::NetworkConnectionToWebProcess::setCookieFromDOMAsync):
* Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h:
* Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in:
* Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp:
(WebKit::WebSWContextManagerConnection::installServiceWorker):
* Source/WebKit/WebProcess/WebPage/WebCookieJar.cpp:
(WebKit::WebCookieJar::getCookiesAsync const):
(WebKit::WebCookieJar::setCookieAsync const):

Canonical link: https://commits.webkit.org/268055@main
@webkit-commit-queue
Copy link
Collaborator

Committed 268055@main (2ecb71d): https://commits.webkit.org/268055@main

Reviewed commits have been landed. Closing PR #17083 and removing active labels.

@webkit-commit-queue webkit-commit-queue removed the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Sep 16, 2023
@webkit-commit-queue webkit-commit-queue merged commit 2ecb71d into WebKit:main Sep 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebKit API For issues and bugs in the Web Kit public embedding APIs
Projects
None yet
6 participants