gecko-dev/testing/web-platform/tests/cookies
jugglinmike 5ebe2f5c98 Bug 1488592 [wpt PR 12835] - [cookies] Correct utility function and tests, a=testonly
Automatic update from web-platform-tests[cookies] Correct utility function and tests (#12835)

* [cookies] Fail on exceptional circumstance

Some tests which use the `credFetch` utility include assertions only for
the absence of cookies. Because `fetch` does not reject the returned
promise for valid HTTP responses outside of the 2XX range, these tests
could be satisfied by querying non-existent URLs. This is not an issue
in any existing tests, but it has the potential to hide problems in
future patches.

Update the `credFetch` function to report unsuccessful requests as
failures.

* [cookies] Correct utility function and tests

The `cookie-helper.sub.js` utility script includes
`set_prefixed_cookie_via_http_test`, a function that defines sub-tests
using the `promise_test` API. Previously, it included the following
code:

    promise_test(t => {
      var postDelete = _ => {
        // (elided)
      };

      if (!options.origin) {
        return postDelete;
      } else {
        // (elided)
      }
    });

The `promise_test` function does not recognize return values which are
functions, so returning the `postDelete` method had no effect, and as a
result, the generated tests performed zero assertions. Because none of
the consumers of `set_prefixed_cookie_via_http_test` specified a value
for 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:

- The logic intended to defensively remove cookies prior to testing was
  implemented using `document.cookie`. Because some tests create cookies
  which include the `HttpOnly` attribute, the DOM API cannot remove
  cookies 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.)
- The test name `__secure.header.html` incorrectly asserted that a
  cookie set with the `Secure` attribute could be observed in a
  non-secure context. This patch corrects the expectation.
- The test named `__secure.header.https.html` incorrectly asserted that
  a cookie set with a foreign `Origin` attribute could be observed from
  the current origin. This patch corrects the expectation.

--

wpt-commits: 88d4f4cc118320c4e02003ffc1ba2c5ee81b1753
wpt-pr: 12835
2018-09-10 10:12:14 +00:00
..
http-state Bug 1487423 [wpt PR 12762] - Import all remaining cookie tests into WPT, a=testonly 2018-09-05 13:09:17 +00:00
path Bug 1466557 [wpt PR 8584] - Clarify expectations and disable failing cookie tests, a=testonly 2018-06-25 21:35:41 +00:00
prefix Bug 1488592 [wpt PR 12835] - [cookies] Correct utility function and tests, a=testonly 2018-09-10 10:12:14 +00:00
resources Bug 1488592 [wpt PR 12835] - [cookies] Correct utility function and tests, a=testonly 2018-09-10 10:12:14 +00:00
samesite Bug 1488983 [wpt PR 12861] - [cookies] Correct typo, a=testonly 2018-09-10 10:12:10 +00:00
secure Bug 1487364 [wpt PR 12756] - Remove 'cookies/secure/create-cookie-http.html', a=testonly 2018-09-05 13:09:02 +00:00
META.yml Bug 1464894 [wpt PR 11201] - Rename of OWNER files to META.yml, a=testonly 2018-07-11 07:49:41 +01:00
README.md Bug 1419296 - Update web-platform-tests to fa27b785c62e67cc3a12201612db188c4fdd49ad, a=testonly 2017-11-21 07:39:00 +00:00
meta-blocked.html Bug 1429043 - Update web-platform-tests to revision 4de5305adf3d33badc23952672bcf28168fea37e, a=testonly 2018-01-09 14:45:43 +00:00

README.md

This directory contains tests for Leave Secure Cookies Alone.