diff --git a/atom/browser/api/atom_api_cookies.cc b/atom/browser/api/atom_api_cookies.cc index 767d92091324..f55ed136adfb 100644 --- a/atom/browser/api/atom_api_cookies.cc +++ b/atom/browser/api/atom_api_cookies.cc @@ -231,7 +231,15 @@ void SetCookieOnIO(scoped_refptr getter, last_access_time, secure, http_only, net::CookieSameSite::DEFAULT_MODE, net::COOKIE_PRIORITY_DEFAULT)); auto completion_callback = base::BindOnce(OnSetCookie, callback); - if (!canonical_cookie) { + if (!canonical_cookie || !canonical_cookie->IsCanonical()) { + std::move(completion_callback).Run(false); + return; + } + if (url.empty()) { + std::move(completion_callback).Run(false); + return; + } + if (name.empty()) { std::move(completion_callback).Run(false); return; } diff --git a/spec/api-session-spec.js b/spec/api-session-spec.js index 86a347dc1369..7ac14e1f1f88 100644 --- a/spec/api-session-spec.js +++ b/spec/api-session-spec.js @@ -90,13 +90,13 @@ describe('session module', () => { }) }) - // TODO(alexeykuzmin): [Ch66] Fails. Fix it and enable back. - xit('calls back with an error when setting a cookie with missing required fields', (done) => { + it('calls back with an error when setting a cookie with missing required fields', (done) => { session.defaultSession.cookies.set({ url: '', name: '1', value: '1' }, (error) => { + assert(error, 'Should have an error') assert.equal(error.message, 'Setting cookie failed') done() })