Commit 91dfc8d8 authored by Joshua Bell's avatar Joshua Bell Committed by Commit Bot

Cookie Store API: Add test showing BOMs are not stripped

The cookie RFC[1] does not define an encoding for cookie names/values;
they are treated as a sequence of octets.

The Cookie Store spec[2] mandates treating the octets as UTF-8 encoded.
When decoding octet sequences into strings, the decode should be done
without treating a leading U+FEFF as a BOM. Add a test to verify this.

[1] https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-02
[2] https://wicg.github.io/cookie-store/

Bug: 729800
Change-Id: I23b7eb82b35862b8797a203ae6ea86cbd69001d2
Reviewed-on: https://chromium-review.googlesource.com/1159336Reviewed-by: default avatarVictor Costan <pwnall@chromium.org>
Commit-Queue: Victor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579985}
parent 3bacc2ae
// META: script=resources/cookie-test-helpers.js
'use strict';
cookie_test(async t => {
await setCookieStringHttp('\uFEFFcookie=value; path=/');
const cookie = await cookieStore.get('\uFEFFcookie');
assert_equals(cookie.name, '\uFEFFcookie');
assert_equals(cookie.value, 'value');
}, 'BOM not stripped from name');
cookie_test(async t => {
await setCookieStringHttp('cookie=\uFEFFvalue; path=/');
const cookie = await cookieStore.get('cookie');
assert_equals(cookie.name, 'cookie');
assert_equals(cookie.value, '\uFEFFvalue');
}, 'BOM not stripped from value');
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment