Bug 1512309 - Set the month of the date object through the Date constructor instead of the UTC time. r=MattN
authorJared Wein <jwein@mozilla.com>
Fri, 07 Dec 2018 14:12:53 +0000
changeset 508827 9317931c9ce1e063a1f557f4d8e2a55ad0799ac0
parent 508826 8442297c6818db346c8252914f7d69fd68094f10
child 508828 8fed3c0c42be40a04e6f48e71019bc9997ac43b3
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1512309
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1512309 - Set the month of the date object through the Date constructor instead of the UTC time. r=MattN The UTC time was generating incorrect months when the browser was used in a timezone that has a negative UTC offset. The value returned from Date.UTC was then parsed by new Date() which was converted to the local timezone. Date.UTC(1970, 0, 1) would return a time of 0 which would then become December 1969. Differential Revision: https://phabricator.services.mozilla.com/D13879
browser/extensions/formautofill/content/autofillEditForms.js
browser/extensions/formautofill/test/browser/browser_editCreditCardDialog.js
--- a/browser/extensions/formautofill/content/autofillEditForms.js
+++ b/browser/extensions/formautofill/content/autofillEditForms.js
@@ -401,17 +401,17 @@ class EditCreditCard extends EditAutofil
 
     // Empty month option
     this._elements.month.appendChild(new Option());
 
     // Populate month list. Format: "month number - month name"
     let dateFormat = new Intl.DateTimeFormat(navigator.language, {month: "long"}).format;
     for (let i = 0; i < count; i++) {
       let monthNumber = (i + 1).toString();
-      let monthName = dateFormat(new Date(Date.UTC(1970, i, 1)));
+      let monthName = dateFormat(new Date(1970, i));
       let option = new Option();
       option.value = monthNumber;
       // XXX: Bug 1446164 - Localize this string.
       option.textContent = `${monthNumber.padStart(2, "0")} - ${monthName}`;
       this._elements.month.appendChild(option);
     }
   }
 
--- a/browser/extensions/formautofill/test/browser/browser_editCreditCardDialog.js
+++ b/browser/extensions/formautofill/test/browser/browser_editCreditCardDialog.js
@@ -20,16 +20,17 @@ add_task(async function test_cancelEditC
 });
 
 add_task(async function test_saveCreditCard() {
   await testDialog(EDIT_CREDIT_CARD_DIALOG_URL, (win) => {
     EventUtils.synthesizeKey("VK_TAB", {}, win);
     EventUtils.synthesizeKey(TEST_CREDIT_CARD_1["cc-number"], {}, win);
     EventUtils.synthesizeKey("VK_TAB", {}, win);
     EventUtils.synthesizeKey("0" + TEST_CREDIT_CARD_1["cc-exp-month"].toString(), {}, win);
+    is(win.document.activeElement.selectedOptions[0].text, "04 - April", "Displayed month should match number and name");
     EventUtils.synthesizeKey("VK_TAB", {}, win);
     EventUtils.synthesizeKey(TEST_CREDIT_CARD_1["cc-exp-year"].toString(), {}, win);
     EventUtils.synthesizeKey("VK_TAB", {}, win);
     EventUtils.synthesizeKey(TEST_CREDIT_CARD_1["cc-name"], {}, win);
     EventUtils.synthesizeKey("VK_TAB", {}, win);
     EventUtils.synthesizeKey(TEST_CREDIT_CARD_1["cc-type"], {}, win);
     EventUtils.synthesizeKey("VK_TAB", {}, win);
     EventUtils.synthesizeKey("VK_TAB", {}, win);