Bug 1382529 - [Form Autofill] Exception occurs when saving a telephone number like "1234567". r=steveck
authorLuke Chang <lchang@mozilla.com>
Thu, 20 Jul 2017 13:30:53 +0800
changeset 422739 9b266be297891f2ee6425070e2ac336722c5b865
parent 422738 d42bfe2b2e63992b5a201e15f6cb3de8cc11a112
child 422740 a0a41228220bd600b4299758a394bcffebadc0e3
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssteveck
bugs1382529, 1234567
milestone56.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 1382529 - [Form Autofill] Exception occurs when saving a telephone number like "1234567". r=steveck MozReview-Commit-ID: mJ3KJemnme
browser/extensions/formautofill/ProfileStorage.jsm
browser/extensions/formautofill/test/unit/test_transformFields.js
--- a/browser/extensions/formautofill/ProfileStorage.jsm
+++ b/browser/extensions/formautofill/ProfileStorage.jsm
@@ -1336,17 +1336,17 @@ class Addresses extends AutofillRecords 
       number = address["tel-national"];
     } else if (address["tel-local"]) {
       number = (address["tel-area-code"] || "") + address["tel-local"];
     } else if (address["tel-local-prefix"] && address["tel-local-suffix"]) {
       number = (address["tel-area-code"] || "") + address["tel-local-prefix"] + address["tel-local-suffix"];
     }
 
     let tel = PhoneNumber.Parse(number, region);
-    if (tel) {
+    if (tel && tel.internationalNumber) {
       // Force to save numbers in E.164 format if parse success.
       address.tel = tel.internationalNumber;
     } else if (!address.tel) {
       // Save the original number anyway if "tel" is omitted.
       address.tel = number;
     }
 
     TEL_COMPONENTS.forEach(c => delete address[c]);
--- a/browser/extensions/formautofill/test/unit/test_transformFields.js
+++ b/browser/extensions/formautofill/test/unit/test_transformFields.js
@@ -386,16 +386,25 @@ const ADDRESS_NORMALIZE_TESTCASES = [
     address: {
       "tel": "12345",
     },
     expectedResult: {
       "tel": "12345",
     },
   },
   {
+    description: "Has a valid tel-local format \"tel\"",
+    address: {
+      "tel": "1234567",
+    },
+    expectedResult: {
+      "tel": "1234567",
+    },
+  },
+  {
     description: "Has \"tel-national\" and \"tel-country-code\"",
     address: {
       "tel-national": "0212345678",
       "tel-country-code": "+886",
     },
     expectedResult: {
       "tel": "+886212345678",
     },