Skip to content

Commit

Permalink
Implement the set function in the Cookie Store API
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=259196

Reviewed by Chris Dumez.

CookieStore (on the WebProcess side), will make an IPC to the
Network Process (via WebCookieJar) and will pass the constructed
cookie through the IPC. The Network process will store the cookie
and if this process is successful, the promise will be resolved
with undefined. Otherwise, the promise will be rejected with a
TypeError.

* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_delete_arguments.https.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_event_basic.https.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_event_delete.https.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_event_overwrite.https.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_getAll_arguments.https.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_getAll_multiple.https.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_getAll_set_basic.https.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_get_arguments.https.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_get_delete_basic.https.any-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-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_get_set_ordering.https.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_set_arguments.https.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookie-store/cookieStore_special_names.https.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/cookies/partitioned-cookies/partitioned-cookies.tentative.https-expected.txt:
* LayoutTests/platform/glib/TestExpectations:
* LayoutTests/platform/mac-wk1/TestExpectations:
* LayoutTests/platform/wincairo/TestExpectations:
* Source/WebCore/Modules/cookie-store/CookieInit.h:
* Source/WebCore/Modules/cookie-store/CookieStore.cpp:
(WebCore::CookieStore::set):
* Source/WebCore/Modules/cookie-store/CookieStore.h:
* Source/WebCore/loader/CookieJar.cpp:
(WebCore::CookieJar::setCookieAsync const):
* Source/WebCore/loader/CookieJar.h:
* Source/WebCore/platform/network/NetworkStorageSession.h:
* Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm:
(WebCore::NetworkStorageSession::cookiesForSessionAsVector const):
(WebCore::NetworkStorageSession::cookiesForDOMAsVector const):
(WebCore::NetworkStorageSession::setCookieFromDOM const):
* Source/WebCore/platform/network/curl/NetworkStorageSessionCurl.cpp:
(WebCore::NetworkStorageSession::setCookieFromDOM const):
(WebCore::NetworkStorageSession::cookiesForDOMAsVector const):
* Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp:
(WebCore::NetworkStorageSession::setCookieFromDOM const):
(WebCore::NetworkStorageSession::cookiesForDOMAsVector const):
* 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/WebPage/WebCookieJar.cpp:
(WebKit::WebCookieJar::setCookieAsync const):
* Source/WebKit/WebProcess/WebPage/WebCookieJar.h:

Canonical link: https://commits.webkit.org/266064@main
  • Loading branch information
RupinMittal authored and cdumez committed Jul 14, 2023
1 parent 29e1ced commit 7d9eada
Show file tree
Hide file tree
Showing 32 changed files with 267 additions and 113 deletions.
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@

Harness Error (FAIL), message = Test named 'cookieStore.delete with name in options' specified 1 'cleanup' function, and 1 failed.

FAIL cookieStore.delete with positional name promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.delete with name in options promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.delete domain starts with "." promise_rejects_js: function "function() { throw e }" threw object "NotSupportedError: The operation is not supported." ("NotSupportedError") expected instance of function "function TypeError() {
[native code]
}" ("TypeError")
FAIL cookieStore.delete with domain that is not equal current host promise_rejects_js: function "function() { throw e }" threw object "NotSupportedError: The operation is not supported." ("NotSupportedError") expected instance of function "function TypeError() {
[native code]
}" ("TypeError")
FAIL cookieStore.delete with domain set to the current hostname promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.delete with domain set to a subdomain of the current hostname promise_rejects_js: function "function() { throw e }" threw object "NotSupportedError: The operation is not supported." ("NotSupportedError") expected instance of function "function TypeError() {
[native code]
}" ("TypeError")
FAIL cookieStore.delete with domain set to a non-domain-matching suffix of the current hostname promise_rejects_js: function "function() { throw e }" threw object "NotSupportedError: The operation is not supported." ("NotSupportedError") expected instance of function "function TypeError() {
[native code]
}" ("TypeError")
FAIL cookieStore.delete with path set to the current directory promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.delete with path set to subdirectory of the current directory promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.delete with missing / at the end of path promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.delete with path that does not start with / promise_rejects_js: function "function() { throw e }" threw object "NotSupportedError: The operation is not supported." ("NotSupportedError") expected instance of function "function TypeError() {
[native code]
}" ("TypeError")
FAIL cookieStore.delete with get result promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.delete with positional empty name promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.delete with empty name in options promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
NOTRUN cookieStore.delete domain starts with "."
NOTRUN cookieStore.delete with domain that is not equal current host
NOTRUN cookieStore.delete with domain set to the current hostname
NOTRUN cookieStore.delete with domain set to a subdomain of the current hostname
NOTRUN cookieStore.delete with domain set to a non-domain-matching suffix of the current hostname
NOTRUN cookieStore.delete with path set to the current directory
NOTRUN cookieStore.delete with path set to subdirectory of the current directory
NOTRUN cookieStore.delete with missing / at the end of path
NOTRUN cookieStore.delete with path that does not start with /
NOTRUN cookieStore.delete with get result
NOTRUN cookieStore.delete with positional empty name
NOTRUN cookieStore.delete with empty name in options

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@

FAIL cookieStore fires change event for cookie set by cookieStore.set() promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
Harness Error (TIMEOUT), message = null

TIMEOUT cookieStore fires change event for cookie set by cookieStore.set() Test timed out

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@

Harness Error (FAIL), message = Test named 'cookieStore fires change event for cookie deleted by cookieStore.delete()' specified 1 'cleanup' function, and 1 failed.

FAIL cookieStore fires change event for cookie deleted by cookieStore.delete() promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@

FAIL cookieStore fires change event for cookie overwritten by cookieStore.set() promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
Harness Error (TIMEOUT), message = null

TIMEOUT cookieStore fires change event for cookie overwritten by cookieStore.set() Test timed out

Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@

Harness Error (FAIL), message = Test named 'cookieStore.getAll with no arguments' specified 2 'cleanup' functions, and 2 failed.

FAIL cookieStore.getAll with no arguments promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.getAll with empty options promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.getAll with positional name promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.getAll with name in options promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.getAll with name in both positional arguments and options promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.getAll with absolute url in options promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.getAll with relative url in options promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.getAll with invalid url path in options promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.getAll with invalid url host in options promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
NOTRUN cookieStore.getAll with empty options
NOTRUN cookieStore.getAll with positional name
NOTRUN cookieStore.getAll with name in options
NOTRUN cookieStore.getAll with name in both positional arguments and options
NOTRUN cookieStore.getAll with absolute url in options
NOTRUN cookieStore.getAll with relative url in options
NOTRUN cookieStore.getAll with invalid url path in options
NOTRUN cookieStore.getAll with invalid url host in options

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@

Harness Error (FAIL), message = Test named 'cookieStore.getAll returns multiple cookies written by cookieStore.set' specified 3 'cleanup' functions, and 3 failed.

FAIL cookieStore.getAll returns multiple cookies written by cookieStore.set promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@

Harness Error (FAIL), message = Test named 'cookieStore.getAll returns the cookie written by cookieStore.set' specified 1 'cleanup' function, and 1 failed.

FAIL cookieStore.getAll returns the cookie written by cookieStore.set promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."

Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@

FAIL cookieStore.get with no arguments returns TypeError promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.get with empty options returns TypeError promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.get with positional name promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.get with name in options promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.get with name in both positional arguments and options promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.get with absolute url in options promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.get with relative url in options promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.get with invalid url path in options assert_unreached: Should have rejected: undefined Reached unreachable code
FAIL cookieStore.get with invalid url host in options assert_unreached: Should have rejected: undefined Reached unreachable code
Harness Error (FAIL), message = Test named 'cookieStore.get with no arguments returns TypeError' specified 1 'cleanup' function, and 1 failed.

FAIL cookieStore.get with no arguments returns TypeError assert_unreached: Should have rejected: undefined Reached unreachable code
NOTRUN cookieStore.get with empty options returns TypeError
NOTRUN cookieStore.get with positional name
NOTRUN cookieStore.get with name in options
NOTRUN cookieStore.get with name in both positional arguments and options
NOTRUN cookieStore.get with absolute url in options
NOTRUN cookieStore.get with relative url in options
NOTRUN cookieStore.get with invalid url path in options
NOTRUN cookieStore.get with invalid url host in options

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@

Harness Error (FAIL), message = Test named 'cookieStore.get returns null for a cookie deleted by cookieStore.delete' specified 1 'cleanup' function, and 1 failed.

FAIL cookieStore.get returns null for a cookie deleted by cookieStore.delete promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."

Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

FAIL cookieStore.get() sees cookieStore.set() in frame promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.get() in frame sees cookieStore.set() promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
Harness Error (FAIL), message = Test named 'cookieStore.get() sees cookieStore.set() in frame' specified 1 'cleanup' function, and 1 failed.

FAIL cookieStore.get() sees cookieStore.set() in frame promise_test: Unhandled rejection with value: object "TypeError: null is not an object (evaluating 'frameCookie.value')"
NOTRUN cookieStore.get() in frame sees cookieStore.set()

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@

FAIL cookieStore.get returns the cookie written by cookieStore.set promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
Harness Error (FAIL), message = Test named 'cookieStore.get returns the cookie written by cookieStore.set' specified 1 'cleanup' function, and 1 failed.

PASS cookieStore.get returns the cookie written by cookieStore.set

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

FAIL Set three simple origin session cookies sequentially and ensure they all end up in the cookie jar in order. promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL Set three simple origin session cookies in undefined order using Promise.all and ensure they all end up in the cookie jar in any order. promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
PASS Set three simple origin session cookies sequentially and ensure they all end up in the cookie jar in order.
PASS Set three simple origin session cookies in undefined order using Promise.all and ensure they all end up in the cookie jar in any order.

Original file line number Diff line number Diff line change
@@ -1,34 +1,24 @@

Harness Error (FAIL), message = Test named 'cookieStore.set with get result' specified 1 'cleanup' function, and 1 failed.

FAIL cookieStore.set with positional name and value promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.set with name and value in options promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.set with empty name and an '=' in value promise_rejects_js: function "function() { throw e }" threw object "NotSupportedError: The operation is not supported." ("NotSupportedError") expected instance of function "function TypeError() {
[native code]
}" ("TypeError")
PASS cookieStore.set with empty name and an '=' in value
FAIL cookieStore.set with normal name and an '=' in value promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.set with expires set to a future Date promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.set with expires set to a past Date promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.set with expires set to a future timestamp promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.set with expires set to a past timestamp promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.set domain starts with "." promise_rejects_js: function "function() { throw e }" threw object "NotSupportedError: The operation is not supported." ("NotSupportedError") expected instance of function "function TypeError() {
[native code]
}" ("TypeError")
FAIL cookieStore.set with domain that is not equal current host promise_rejects_js: function "function() { throw e }" threw object "NotSupportedError: The operation is not supported." ("NotSupportedError") expected instance of function "function TypeError() {
[native code]
}" ("TypeError")
FAIL cookieStore.set domain starts with "." assert_unreached: Should have rejected: undefined Reached unreachable code
FAIL cookieStore.set with domain that is not equal current host assert_unreached: Should have rejected: undefined Reached unreachable code
FAIL cookieStore.set with domain set to the current hostname promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.set with domain set to a subdomain of the current hostname promise_rejects_js: function "function() { throw e }" threw object "NotSupportedError: The operation is not supported." ("NotSupportedError") expected instance of function "function TypeError() {
[native code]
}" ("TypeError")
FAIL cookieStore.set with domain set to a non-domain-matching suffix of the current hostname promise_rejects_js: function "function() { throw e }" threw object "NotSupportedError: The operation is not supported." ("NotSupportedError") expected instance of function "function TypeError() {
[native code]
}" ("TypeError")
FAIL cookieStore.set with domain set to a subdomain of the current hostname assert_unreached: Should have rejected: undefined Reached unreachable code
FAIL cookieStore.set with domain set to a non-domain-matching suffix of the current hostname assert_unreached: Should have rejected: undefined Reached unreachable code
FAIL cookieStore.set default domain is null and differs from current hostname promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.set with path set to the current directory promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.set with path set to a subdirectory of the current directory promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.set default path is / promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.set adds / to path that does not end with / promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.set with path that does not start with / promise_rejects_js: function "function() { throw e }" threw object "NotSupportedError: The operation is not supported." ("NotSupportedError") expected instance of function "function TypeError() {
[native code]
}" ("TypeError")
FAIL cookieStore.set with get result promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.set with path that does not start with / assert_unreached: Should have rejected: undefined Reached unreachable code
FAIL cookieStore.set with get result assert_equals: expected "old-cookie-value" but got "cookie-value"

Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@

FAIL cookieStore.set with __Secure- name on secure origin promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.set of expired __Secure- cookie name on secure origin promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.set with __Secure- name on secure origin promise_test: Unhandled rejection with value: object "TypeError: null is not an object (evaluating '(await cookieStore.get(`${prefix}cookie-name`)).value')"
PASS cookieStore.set of expired __Secure- cookie name on secure origin
FAIL cookieStore.delete with __Secure- name on secure origin promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.set with __Host- name on secure origin promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.set of expired __Host- cookie name on secure origin promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.set with __Host- name on secure origin promise_test: Unhandled rejection with value: object "TypeError: null is not an object (evaluating '(await cookieStore.get(`${prefix}cookie-name`)).value')"
PASS cookieStore.set of expired __Host- cookie name on secure origin
FAIL cookieStore.delete with __Host- name on secure origin promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.set with __Host- prefix and a domain option promise_rejects_js: function "function() { throw e }" threw object "NotSupportedError: The operation is not supported." ("NotSupportedError") expected instance of function "function TypeError() {
[native code]
}" ("TypeError")
FAIL cookieStore.set with __Host- prefix a path option promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
FAIL cookieStore.set with malformed name. assert_equals: cookieStore thrown an incorrect exception - expected "TypeError" but got "NotSupportedError"
FAIL cookieStore.set with __Host- prefix and a domain option assert_unreached: Should have rejected: undefined Reached unreachable code
FAIL cookieStore.set with __Host- prefix a path option promise_test: Unhandled rejection with value: object "TypeError: null is not an object (evaluating '(await cookieStore.get(`__Host-cookie-name`)).value')"
PASS cookieStore.set with malformed name.

Loading

0 comments on commit 7d9eada

Please sign in to comment.