Revision 4f06a45252465792447f80b6559b17c4c4e9712c authored by Daniel Vogelheim on 10 April 2018, 13:07:39 UTC, committed by Chromium WPT Sync on 10 April 2018, 13:07:39 UTC
Allow control of the deprecation via runtime enabled features, with a first
step for logging a warning to the console, and the second step to block it
outright.

Intent:  https://groups.google.com/a/chromium.org/d/msg/blink-dev/35t5cJQ3J_Q/FH45dl0vAwAJ

Change-Id: I1be1001cbbef152458119b1516750bb4f1d1e4de
Reviewed-on: https://chromium-review.googlesource.com/975611
Commit-Queue: Daniel Vogelheim <vogelheim@chromium.org>
Reviewed-by: Mike West <mkwst@chromium.org>
Cr-Commit-Position: refs/heads/master@{#549495}
1 parent 069680c
Raw File
cookieStore_special_names.tentative.html
<!doctype html>
<meta charset="utf-8">
<title>Cookie Store: cookieStore handles special cookie names correctly</title>
<link rel="help" href="https://github.com/WICG/cookie-store">
<link rel="author" href="pwnall@chromium.org" title="Victor Costan">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
'use strict';

['__Secure-', '__Host-'].forEach(prefix => {
  promise_test(async testCase => {
    await promise_rejects(
      testCase, new TypeError(),
      cookieStore.set(`${prefix}cookie-name`, `secure-cookie-value`),
      `Setting ${prefix} cookies should fail in non-secure contexts`);

    try { await cookieStore.delete(`${prefix}cookie-name`); } catch (e) {}
  }, `cookieStore.set with ${prefix} name on non-secure origin`);

  promise_test(async testCase => {
    await promise_rejects(
      testCase, new TypeError(),
      cookieStore.set(
        `${prefix}cookie-name`, `secure-cookie-value`, {
          expires: Date.now() - (24 * 60 * 60 * 1000)
        }),
      `Setting expired ${prefix} cookies should fail in non-secure contexts`);

    try { await cookieStore.delete(`${prefix}cookie-name`); } catch (e) {}
  }, `cookieStore.set of expired ${prefix} cookie on non-secure origin`);

  promise_test(async testCase => {
    assert_equals(
      await cookieStore.get(`${prefix}cookie-name`),
      null,
      'get with ${prefix} prefix should not reject');
    assert_equals(
      await cookieStore.get({name: `${prefix}cookie-name`}),
      null,
      'get with ${prefix} prefix name option should not reject');
    assert_equals(
      await cookieStore.get({name: prefix, matchType: 'startsWith'}),
      null,
      'get with ${prefix} name and startsWith options should not reject');
  }, `cookieStore.get with ${prefix} name on non-secure origin`);

  promise_test(async testCase => {
    assert_array_equals(
      await cookieStore.getAll(`${prefix}cookie-name`),
      [],
      'getAll with ${prefix} prefix should not reject');
    assert_array_equals(
      await cookieStore.getAll({name: `${prefix}cookie-name`}),
      [],
      'getAll with ${prefix} prefix name option should not reject');
    assert_array_equals(
      await cookieStore.getAll({name: prefix, matchType: 'startsWith'}),
      [],
      'getAll with ${prefix} name and startsWith options should not reject');
  }, `cookieStore.getAll with ${prefix} name on non-secure origin`);

  promise_test(async testCase => {
    await promise_rejects(
      testCase, new TypeError(),
      cookieStore.delete(`${prefix}cookie-name`, `host-cookie-value`),
      `Deleting ${prefix} cookies should fail in non-secure contexts`);
  }, `cookieStore.delete with ${prefix} name on non-secure origin`);
});

</script>
back to top