Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test in Firefox on CI #169

Merged
merged 2 commits into from
Mar 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ dist: trusty

addons:
chrome: stable
firefox: latest

cache:
yarn: true
Expand Down
11 changes: 10 additions & 1 deletion addon/services/cookies.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ export default Service.extend({
this._writeFastBootCookie(name, value, options);
} else {
assert('Cookies cannot be set to be HTTP-only from a browser!', !options.httpOnly);

options.path = options.path || this._normalizedDefaultPath();
this._writeDocumentCookie(name, value, options);
}
},
Expand All @@ -93,6 +95,7 @@ export default Service.extend({
assert('Expires, Max-Age, and raw options cannot be set when clearing cookies', isEmpty(options.expires) && isEmpty(options.maxAge) && isEmpty(options.raw));

options.expires = new Date('1970-01-01');
options.path = options.path || this._normalizedDefaultPath();
this.write(name, null, options);
},

Expand Down Expand Up @@ -252,6 +255,12 @@ export default Service.extend({
}

return _byteCount < MAX_COOKIE_BYTE_LENGTH;
}
},

_normalizedDefaultPath() {
if (!this.get('_isFastBoot')) {
let pathname = window.location.pathname;
return pathname.substring(0, pathname.lastIndexOf('/'));
}
}
});
12 changes: 10 additions & 2 deletions testem.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,20 @@ module.exports = {
test_page: 'tests/index.html?hidepassed',
disable_watching: true,
launch_in_ci: [
'Chrome'
'Chrome',
'Firefox'
],
launch_in_dev: [
'Chrome'
'Chrome',
'Firefox'
],
browser_args: {
Firefox: {
mode: 'ci',
args: [
'-headless'
]
},
Chrome: {
mode: 'ci',
args: [
Expand Down
10 changes: 8 additions & 2 deletions tests/unit/services/cookies-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,11 @@ describe('CookiesService', function() {
});

afterEach(function() {
let pathname = window.location.pathname;
pathname = pathname.substring(0, pathname.lastIndexOf('/'));
document.cookie = `${COOKIE_NAME}=whatever; expires=${new Date(0).toUTCString()}`;
document.cookie = `${COOKIE_NAME}=whatever; path=${window.location.pathname}; expires=${new Date(0).toUTCString()}`;
document.cookie = `${COOKIE_NAME}=whatever; path=${pathname}; expires=${new Date(0).toUTCString()}`;
document.cookie = `${COOKIE_NAME}=whatever; path=${pathname}/; expires=${new Date(0).toUTCString()}`;
});

describe('reading a cookie', function() {
Expand Down Expand Up @@ -152,6 +155,7 @@ describe('CookiesService', function() {

it('returns the cookie value for a cookie that was written for the same path', function() {
let path = window.location.pathname;
path = path.substring(0, path.lastIndexOf('/'));
let value = randomString();
this.subject().write(COOKIE_NAME, value, { path });

Expand Down Expand Up @@ -328,7 +332,9 @@ describe('CookiesService', function() {

it('clears the cookie', function() {
let value = randomString();
document.cookie = `${COOKIE_NAME}=${value};`;
let pathname = window.location.pathname;
let path = pathname.substring(0, pathname.lastIndexOf('/'));
document.cookie = `${COOKIE_NAME}=${value}; path=${path};`;

expect(this.subject().read(COOKIE_NAME)).to.eq(value);

Expand Down