Skip to content

Commit

Permalink
cookie: Minor test improvement (#26922)
Browse files Browse the repository at this point in the history
Expect console errors.
  • Loading branch information
mdmower committed Feb 24, 2020
1 parent ff098aa commit d01263b
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions test/unit/test-cookies.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,29 +199,39 @@ describes.fakeWin('test-cookies', {amp: true}, env => {

// Fail if allowOnProxyOrigin is false
expect(() => {
setCookie(win, 'c&1', 'v&1', Date.now() + BASE_CID_MAX_AGE_MILLIS, {});
allowConsoleError(() => {
setCookie(win, 'c&1', 'v&1', Date.now() + BASE_CID_MAX_AGE_MILLIS, {});
});
}).to.throw(/Should never attempt to set cookie on proxy origin\: c\&1/);

win.location = 'https://CDN.ampproject.org/test.html';
expect(() => {
setCookie(win, 'c&1', 'v&1', Date.now() + BASE_CID_MAX_AGE_MILLIS, {});
allowConsoleError(() => {
setCookie(win, 'c&1', 'v&1', Date.now() + BASE_CID_MAX_AGE_MILLIS, {});
});
}).to.throw(/Should never attempt to set cookie on proxy origin\: c\&1/);

win.location = 'https://foo.bar.cdn.ampproject.org/test.html';
expect(() => {
setCookie(win, 'c&1', 'v&1', Date.now() + BASE_CID_MAX_AGE_MILLIS, {});
allowConsoleError(() => {
setCookie(win, 'c&1', 'v&1', Date.now() + BASE_CID_MAX_AGE_MILLIS, {});
});
}).to.throw(/in depth check/);

win.location = 'http://&&&.CDN.ampproject.org/test.html';
expect(() => {
setCookie(win, 'c&1', 'v&1', Date.now() + BASE_CID_MAX_AGE_MILLIS, {});
allowConsoleError(() => {
setCookie(win, 'c&1', 'v&1', Date.now() + BASE_CID_MAX_AGE_MILLIS, {});
});
}).to.throw(/in depth check/);

// Can't use higestAvailableDomain when allowOnProxyOrigin
expect(() => {
setCookie(win, 'c&1', 'v&1', Date.now() + BASE_CID_MAX_AGE_MILLIS, {
allowOnProxyOrigin: true,
highestAvailableDomain: true,
allowConsoleError(() => {
setCookie(win, 'c&1', 'v&1', Date.now() + BASE_CID_MAX_AGE_MILLIS, {
allowOnProxyOrigin: true,
highestAvailableDomain: true,
});
});
}).to.throw(/specify domain explicitly/);

Expand Down

0 comments on commit d01263b

Please sign in to comment.