[cookies] Correct utility function and tests #12835
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
cookie-helper.sub.js
utility script includesset_prefixed_cookie_via_http_test
, a function that defines sub-testsusing the
promise_test
API. Previously, it included the followingcode:
The
promise_test
function does not recognize return values which arefunctions, so returning the
postDelete
method had no effect, and as aresult, the generated tests performed zero assertions. Because none of
the consumers of
set_prefixed_cookie_via_http_test
specified a valuefor the
origin
option, all invocations were effected by this bug.Correcting the problem surfaced a number of errors in the tests. In the
interest of atomicity, this patch attempts to address them all:
implemented using
document.cookie
. Because some tests create cookieswhich include the
HttpOnly
attribute, the DOM API cannot removecookies in all cases. This patch refactors the solution to remove
such cookies via an HTTP request. It also assumes the environment is
initially clean and instead expresses the concern via an asynchronous
"cleanup" function. (This change necessitated an extension to the
set.py
script so that it could be used to expire cookies.)__secure.header.html
incorrectly asserted that acookie set with the
Secure
attribute could be observed in anon-secure context. This patch corrects the expectation.
__secure.header.https.html
incorrectly asserted thata cookie set with a foreign
Origin
attribute could be observed fromthe current origin. This patch corrects the expectation.
This patch does not affect the test results in Firefox or Chrome. The commands:
...both continue to report the following: