Commit 4ccdb965 authored by Henrique Grandinetti's avatar Henrique Grandinetti Committed by Commit Bot

Handle empty timezone on in-session set date time dialog

Bug: 988107
Change-Id: Ia9c12a9342342bc080f73ddbe5ba86531b29997e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1724696Reviewed-by: default avatarMichael Giuffrida <michaelpg@chromium.org>
Reviewed-by: default avatarAga Wronska <agawronska@chromium.org>
Commit-Queue: Henrique Grandinetti <hgrandinetti@chromium.org>
Cr-Commit-Position: refs/heads/master@{#683159}
parent b9dec276
...@@ -267,11 +267,15 @@ Polymer({ ...@@ -267,11 +267,15 @@ Polymer({
applyTime_: function() { applyTime_: function() {
const now = this.getInputTime_(); const now = this.getInputTime_();
// Add timezone offset to get real time. if (this.isTimezoneVisible_) {
const timezoneDelta = getTimezoneDelta( // Add timezone offset to get real time. This is only necessary when the
/** @type {string} */ (loadTimeData.getValue('currentTimezoneId')), // timezone was updated, which is only possible when the dropdown is
this.selectedTimezone_); // visible.
now.setMilliseconds(now.getMilliseconds() + timezoneDelta); const timezoneDelta = getTimezoneDelta(
/** @type {string} */ (loadTimeData.getValue('currentTimezoneId')),
this.selectedTimezone_);
now.setMilliseconds(now.getMilliseconds() + timezoneDelta);
}
const seconds = Math.floor(now / 1000); const seconds = Math.floor(now / 1000);
this.browserProxy_.setTimeInSeconds(seconds); this.browserProxy_.setTimeInSeconds(seconds);
......
...@@ -187,6 +187,38 @@ TEST_F('SetTimeDialogBrowserTest', 'All', function() { ...@@ -187,6 +187,38 @@ TEST_F('SetTimeDialogBrowserTest', 'All', function() {
assertGT(timeInSeconds, todaySeconds); assertGT(timeInSeconds, todaySeconds);
}); });
}); });
suite('NullTimezone', () => {
suiteSetup(() => {
loadTimeData.overrideValues({
currentTimezoneId: '',
timezoneList: [],
});
});
test('SetDateNullTimezone', () => {
const dateInput = setTimeElement.$$('#dateInput');
assertTrue(!!dateInput);
assertEquals(null, setTimeElement.$$('#timezoneSelect'));
// Simulate the user changing the date picker backward by one hour.
const today = dateInput.valueAsDate;
const nextWeek = new Date(today.getTime() - 60 * 60 * 1000);
dateInput.focus();
dateInput.valueAsDate = nextWeek;
setTimeElement.$$('#doneButton').click();
// Verify the page sends a request to move time backward.
return testBrowserProxy.whenCalled('setTimeInSeconds')
.then(timeInSeconds => {
const todaySeconds = today.getTime() / 1000;
// The exact value isn't important (it depends on the current
// time).
assertGT(todaySeconds, timeInSeconds);
});
});
});
}); });
mocha.run(); mocha.run();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment