diff --git a/types/chrome/index.d.ts b/types/chrome/index.d.ts index 016458df3a..3a6bf635a3 100644 --- a/types/chrome/index.d.ts +++ b/types/chrome/index.d.ts @@ -1266,6 +1266,9 @@ declare namespace chrome.contextMenus { * Permissions: "cookies", host permissions */ declare namespace chrome.cookies { + /** A cookie's 'SameSite' state (https://tools.ietf.org/html/draft-west-first-party-cookies). 'no_restriction' corresponds to a cookie set with 'SameSite=None', 'lax' to 'SameSite=Lax', and 'strict' to 'SameSite=Strict'. 'unspecified' corresponds to a cookie set without the SameSite attribute. **/ + export type SameSiteStatus = 'unspecified' | 'no_restriction' | 'lax' | 'strict'; + /** Represents information about an HTTP cookie. */ export interface Cookie { /** The domain of the cookie (e.g. "www.google.com", "example.com"). */ @@ -1288,6 +1291,11 @@ declare namespace chrome.cookies { httpOnly: boolean; /** True if the cookie is marked as Secure (i.e. its scope is limited to secure channels, typically HTTPS). */ secure: boolean; + /** + * The cookie's same-site status (i.e. whether the cookie is sent with cross-site requests). + * @since Chrome 51. + */ + sameSite: SameSiteStatus } /** Represents a cookie store in the browser. An incognito mode window, for instance, uses a separate cookie store from a non-incognito window. */ @@ -1334,6 +1342,11 @@ declare namespace chrome.cookies { httpOnly?: boolean; /** Optional. Whether the cookie should be marked as Secure. Defaults to false. */ secure?: boolean; + /** + * Optional. The cookie's same-site status. Defaults to "unspecified", i.e., if omitted, the cookie is set without specifying a SameSite attribute. + * @since Chrome 51. + */ + sameSite?: SameSiteStatus } export interface Details { diff --git a/types/sinon-chrome/sinon-chrome-tests.ts b/types/sinon-chrome/sinon-chrome-tests.ts index ab5f050f52..52b6206a03 100644 --- a/types/sinon-chrome/sinon-chrome-tests.ts +++ b/types/sinon-chrome/sinon-chrome-tests.ts @@ -64,7 +64,8 @@ chromeStub.registerPlugin(new chromeStub.plugins.CookiePlugin( secure: false, session: false, storeId: '0', - value: 'COOKIE_VALUE' + value: 'COOKIE_VALUE', + sameSite: 'unspecified' }, { domain: 'other-domain.com', @@ -75,7 +76,8 @@ chromeStub.registerPlugin(new chromeStub.plugins.CookiePlugin( secure: false, session: true, storeId: '0', - value: '123' + value: '123', + sameSite: 'unspecified' } ] ));