From 643c701b85063133e0f5c9f5168c7ebfd9fccb0c Mon Sep 17 00:00:00 2001 From: Ayu Ishii Date: Mon, 20 Apr 2020 17:54:43 -0700 Subject: [PATCH] CookieStore: Add domain validation wpt This change adds tests for domain validation in wpt. Change-Id: Id8c74374d23bd72787ecc40919070b98684e163c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2149699 Commit-Queue: Victor Costan Reviewed-by: Victor Costan Cr-Commit-Position: refs/heads/master@{#760748} --- ...cookieStore_set_arguments.tentative.https.any.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cookie-store/cookieStore_set_arguments.tentative.https.any.js b/cookie-store/cookieStore_set_arguments.tentative.https.any.js index 6685f5fd3b7186..5668b858be0e2d 100644 --- a/cookie-store/cookieStore_set_arguments.tentative.https.any.js +++ b/cookie-store/cookieStore_set_arguments.tentative.https.any.js @@ -156,6 +156,19 @@ promise_test(async testCase => { assert_equals(cookie, null); }, 'cookieStore.set with name and value in options and expires in the past'); +promise_test(async testCase => { + const currentUrl = new URL(self.location.href); + const currentDomain = currentUrl.hostname; + + await promise_rejects_js(testCase, TypeError, cookieStore.set( + 'cookie-name', 'cookie-value', { domain: `.${currentDomain}` })); +}, 'cookieStore.set domain starts with "."'); + +promise_test(async testCase => { + await promise_rejects_js(testCase, TypeError, cookieStore.set( + 'cookie-name', 'cookie-value', { domain: 'example.com' })); +}, 'cookieStore.set with domain that is not equal current host'); + promise_test(async testCase => { const currentUrl = new URL(self.location.href); const currentDomain = currentUrl.hostname;