Skip to content

Commit d806eec

Browse files
committed
[js] Enable cookie tests for safaridriver
1 parent baeee06 commit d806eec

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

javascript/node/selenium-webdriver/test/cookie_test.js

+21-5
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ suite(function(env) {
3636
return driver.quit();
3737
});
3838

39-
// Cookie handling is broken.
40-
ignore(env.browsers(Browser.PHANTOM_JS, Browser.SAFARI)).
4139
describe('Cookie Management;', function() {
4240

4341
beforeEach(async function() {
@@ -154,7 +152,6 @@ suite(function(env) {
154152
ignore(env.browsers(
155153
Browser.ANDROID,
156154
Browser.FIREFOX,
157-
'legacy-' + Browser.FIREFOX,
158155
Browser.IE)).
159156
it('should retain cookie expiry', async function() {
160157
let expirationDelay = 5 * 1000;
@@ -164,8 +161,27 @@ suite(function(env) {
164161
await driver.manage().addCookie(cookie);
165162
await driver.manage().getCookie(cookie.name).then(function(actual) {
166163
assert.equal(actual.value, cookie.value);
167-
// expiry times are exchanged in seconds since January 1, 1970 UTC.
168-
assert.equal(actual.expiry, Math.floor(expiry.getTime() / 1000));
164+
165+
// expiry times should be in seconds since January 1, 1970 UTC
166+
try {
167+
assert.equal(actual.expiry, Math.floor(expiry.getTime() / 1000));
168+
assert.notEqual(
169+
env.browser.name, Browser.SAFARI,
170+
'Safari cookie expiry fixed; update test');
171+
} catch (ex) {
172+
if (env.browser.name !== Browser.SAFARI
173+
|| !(ex instanceof assert.AssertionError)) {
174+
throw ex;
175+
}
176+
177+
// Safari returns milliseconds (and is off by a few seconds...)
178+
let diff = Math.abs(actual.expiry - expiry.getTime());
179+
if (diff > 2000) {
180+
assert.fail(
181+
actual.expiry, expiry.getTime(),
182+
'Expect Safari to return expiry in millis since epoch ± 2s');
183+
}
184+
}
169185
});
170186

171187
await driver.sleep(expirationDelay);

0 commit comments

Comments
 (0)