Bug 1824473 - Convert toolkit/components/formautofill to ES modules. r=Standard8,credential-management-reviewers,sgalich

Differential Revision: https://phabricator.services.mozilla.com/D173586
This commit is contained in:
Stephanie Cunnane 2023-03-30 17:29:17 +00:00
parent a581d2cd93
commit 4ca2bd8458
23 changed files with 88 additions and 227 deletions

View File

@ -2,17 +2,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const EXPORTED_SYMBOLS = ["AddressComparison", "AddressComponent"];
const { FormAutofill } = ChromeUtils.import(
"resource://autofill/FormAutofill.jsm"
);
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
const lazy = {};
@ -323,7 +317,7 @@ class Email extends AddressField {
/**
* Class to compare two address components and store their comparison result.
*/
class AddressComparison {
export class AddressComparison {
// Store the comparion result in an object, keyed by field name.
#result = {};
@ -465,13 +459,14 @@ class AddressComparison {
return ret;
}
}
/**
* Class that transforms record (created in FormAutofillHandler createRecord)
* into an address component object to more easily compare two address records.
*
* Note. This class assumes records that pass to it have already been normalized.
*/
class AddressComponent {
export class AddressComponent {
#fields = [];
constructor(record) {

View File

@ -2,10 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
var EXPORTED_SYMBOLS = ["AutofillTelemetry", "AddressTelemetry"];
const { FormAutofillUtils } = ChromeUtils.import(
"resource://autofill/FormAutofillUtils.jsm"
);
@ -211,7 +207,7 @@ class AutofillTelemetryBase {
}
}
class AddressTelemetry extends AutofillTelemetryBase {
export class AddressTelemetry extends AutofillTelemetryBase {
EVENT_CATEGORY = "address";
EVENT_OBJECT_FORM_INTERACTION = "address_form";
EVENT_OBJECT_FORM_INTERACTION_EXT = "address_form_ext";
@ -459,7 +455,7 @@ class CreditCardTelemetry extends AutofillTelemetryBase {
}
}
class AutofillTelemetry {
export class AutofillTelemetry {
static #creditCardTelemetry = new CreditCardTelemetry();
static #addressTelemetry = new AddressTelemetry();

View File

@ -15,33 +15,24 @@
* TRAINING REPOSITORY" section.
*/
"use strict";
/**
* CODE UNIQUE TO PRODUCTION--NOT IN THE TRAINING REPOSITORY:
*/
const EXPORTED_SYMBOLS = ["creditCardRulesets"];
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
const {
element: clickedElement,
import {
element as clickedElement,
out,
rule,
ruleset,
score,
type,
} = ChromeUtils.importESModule(
"resource://gre/modules/third_party/fathom/fathom.mjs"
);
const { CreditCard } = ChromeUtils.importESModule(
"resource://gre/modules/CreditCard.sys.mjs"
);
const { NETWORK_NAMES } = ChromeUtils.importESModule(
"resource://gre/modules/CreditCard.sys.mjs"
);
} from "resource://gre/modules/third_party/fathom/fathom.mjs";
import {
CreditCard,
NETWORK_NAMES,
} from "resource://gre/modules/CreditCard.sys.mjs";
const lazy = {};
@ -1203,7 +1194,7 @@ const biases = [
// all the tyoes). When the above case exists, the coefficient of the rule will be
// overwritten, which means, we can't have different coefficient for the same rule on
// different types. To workaround this issue, we create a new ruleset for each type.
var creditCardRulesets = {
export var creditCardRulesets = {
init() {
XPCOMUtils.defineLazyPreferenceGetter(
this,
@ -1223,4 +1214,5 @@ var creditCardRulesets = {
return this.supportedTypes;
},
};
this.creditCardRulesets.init();
creditCardRulesets.init();

View File

@ -2,13 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
var EXPORTED_SYMBOLS = ["FormAutofill"];
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
const lazy = {};
@ -69,7 +63,7 @@ function debug() {
}
}
var FormAutofill = {
export var FormAutofill = {
ENABLED_AUTOFILL_ADDRESSES_PREF,
ENABLED_AUTOFILL_ADDRESSES_CAPTURE_PREF,
ENABLED_AUTOFILL_ADDRESSES_CAPTURE_V2_PREF,

View File

@ -2,13 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
var EXPORTED_SYMBOLS = ["FormAutofillChild"];
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
@ -25,7 +20,7 @@ XPCOMUtils.defineLazyModuleGetters(lazy, {
/**
* Handles content's interactions for the frame.
*/
class FormAutofillChild extends JSWindowActorChild {
export class FormAutofillChild extends JSWindowActorChild {
constructor() {
super();

View File

@ -8,18 +8,10 @@
/* eslint-disable no-use-before-define */
"use strict";
var EXPORTED_SYMBOLS = ["FormAutofillContent"];
const Cm = Components.manager;
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
const { AppConstants } = ChromeUtils.importESModule(
"resource://gre/modules/AppConstants.sys.mjs"
);
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
const lazy = {};
@ -443,7 +435,7 @@ let ProfileAutocomplete = {
*
* NOTE: Declares it by "var" to make it accessible in unit tests.
*/
var FormAutofillContent = {
export var FormAutofillContent = {
/**
* @type {WeakMap} mapping FormLike root HTML elements to FormAutofillHandler objects.
*/

View File

@ -6,16 +6,9 @@
* Defines a handler object to represent forms that autofill can handle.
*/
"use strict";
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
var EXPORTED_SYMBOLS = ["FormAutofillHandler", "FormAutofillCreditCardSection"];
const { AppConstants } = ChromeUtils.importESModule(
"resource://gre/modules/AppConstants.sys.mjs"
);
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
const { FormAutofill } = ChromeUtils.import(
"resource://autofill/FormAutofill.jsm"
);
@ -53,7 +46,7 @@ XPCOMUtils.defineLazyGetter(lazy, "reauthPasswordPromptMessage", () => {
});
XPCOMUtils.defineLazyGetter(lazy, "log", () =>
FormAutofill.defineLogGetter(lazy, EXPORTED_SYMBOLS[0])
FormAutofill.defineLogGetter(lazy, "FormAutofillHandler")
);
const { FIELD_STATES } = FormAutofillUtils;
@ -987,7 +980,7 @@ class FormAutofillAddressSection extends FormAutofillSection {
}
}
class FormAutofillCreditCardSection extends FormAutofillSection {
export class FormAutofillCreditCardSection extends FormAutofillSection {
/**
* Credit Card Section Constructor
*
@ -1437,7 +1430,7 @@ class FormAutofillCreditCardSection extends FormAutofillSection {
/**
* Handles profile autofill for a DOM Form element.
*/
class FormAutofillHandler {
export class FormAutofillHandler {
/**
* Initialize the form from `FormLike` object to handle the section or form
* operations.

View File

@ -6,14 +6,9 @@
* Form Autofill field heuristics.
*/
"use strict";
export let FormAutofillHeuristics;
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
const EXPORTED_SYMBOLS = ["FormAutofillHeuristics", "FieldScanner"];
let FormAutofillHeuristics;
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
const { FormAutofill } = ChromeUtils.import(
"resource://autofill/FormAutofill.jsm"
);
@ -31,7 +26,7 @@ XPCOMUtils.defineLazyModuleGetters(lazy, {
});
XPCOMUtils.defineLazyGetter(lazy, "log", () =>
FormAutofill.defineLogGetter(lazy, EXPORTED_SYMBOLS[0])
FormAutofill.defineLogGetter(lazy, "FormAutofillHeuristics")
);
const PREF_HEURISTICS_ENABLED = "extensions.formautofill.heuristics.enabled";
@ -68,7 +63,7 @@ const MULTI_N_FIELD_NAMES = {
* detail with FormAutofillHeuristics.getInfo function. It also provides a
* cursor (parsingIndex) to indicate which element is waiting for parsing.
*/
class FieldScanner {
export class FieldScanner {
/**
* Create a FieldScanner based on form elements with the existing
* fieldDetails.

View File

@ -2,13 +2,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
var EXPORTED_SYMBOLS = ["FormAutofillNameUtils"];
// FormAutofillNameUtils is initially translated from
// https://cs.chromium.org/chromium/src/components/autofill/core/browser/autofill_data_util.cc?rcl=b861deff77abecff11ae6a9f6946e9cc844b9817
var FormAutofillNameUtils = {
export var FormAutofillNameUtils = {
NAME_PREFIXES: [
"1lt",
"1st",

View File

@ -25,15 +25,10 @@
* ]
*/
"use strict";
// We expose a singleton from this module. Some tests may import the
// constructor via a backstage pass.
var EXPORTED_SYMBOLS = ["FormAutofillParent", "FormAutofillStatus"];
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
const { FormAutofill } = ChromeUtils.import(
"resource://autofill/FormAutofill.jsm"
);
@ -56,7 +51,7 @@ XPCOMUtils.defineLazyModuleGetters(lazy, {
});
XPCOMUtils.defineLazyGetter(lazy, "log", () =>
FormAutofill.defineLogGetter(lazy, EXPORTED_SYMBOLS[0])
FormAutofill.defineLogGetter(lazy, "FormAutofillParent")
);
const {
@ -71,7 +66,7 @@ const {
let gMessageObservers = new Set();
let FormAutofillStatus = {
export let FormAutofillStatus = {
_initialized: false,
/**
@ -291,7 +286,7 @@ XPCOMUtils.defineLazyGetter(lazy, "gFormAutofillStorage", () => {
return formAutofillStorage;
});
class FormAutofillParent extends JSWindowActorParent {
export class FormAutofillParent extends JSWindowActorParent {
constructor() {
super();
FormAutofillStatus.init();

View File

@ -6,10 +6,6 @@
* Injects the form autofill section into about:preferences.
*/
"use strict";
var EXPORTED_SYMBOLS = ["FormAutofillPreferences"];
// Add addresses enabled flag in telemetry environment for recording the number of
// users who disable/enable the address autofill feature.
const BUNDLE_URI = "chrome://formautofill/locale/formautofill.properties";
@ -24,9 +20,7 @@ const { FormAutofill } = ChromeUtils.import(
const { FormAutofillUtils } = ChromeUtils.import(
"resource://autofill/FormAutofillUtils.jsm"
);
const { AppConstants } = ChromeUtils.importESModule(
"resource://gre/modules/AppConstants.sys.mjs"
);
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
@ -49,7 +43,7 @@ const {
const HTML_NS = "http://www.w3.org/1999/xhtml";
function FormAutofillPreferences() {
export function FormAutofillPreferences() {
this.bundle = Services.strings.createBundle(BUNDLE_URI);
}

View File

@ -122,19 +122,8 @@
* this new field.
*/
"use strict";
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
const EXPORTED_SYMBOLS = [
"FormAutofillStorageBase",
"CreditCardsBase",
"AddressesBase",
"ADDRESS_SCHEMA_VERSION",
"CREDIT_CARD_SCHEMA_VERSION",
];
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
const { FormAutofill } = ChromeUtils.import(
"resource://autofill/FormAutofill.jsm"
);
@ -165,7 +154,7 @@ const STORAGE_SCHEMA_VERSION = 1;
// Please talk to the sync team before changing this!
// (And if it did ever change, it must never be "4" due to the reconcile hacks
// below which repairs credit-cards with version=4)
const ADDRESS_SCHEMA_VERSION = 1;
export const ADDRESS_SCHEMA_VERSION = 1;
// Version 2: Bug 1486954 - Encrypt `cc-number`
// Version 3: Bug 1639795 - Update keystore name
@ -173,7 +162,7 @@ const ADDRESS_SCHEMA_VERSION = 1;
// Next version should be 5
// NOTE: It's likely this number can never change.
// Please talk to the sync team before changing this!
const CREDIT_CARD_SCHEMA_VERSION = 3;
export const CREDIT_CARD_SCHEMA_VERSION = 3;
const VALID_ADDRESS_FIELDS = [
"given-name",
@ -1509,7 +1498,7 @@ class AutofillRecords {
async mergeIfPossible(guid, record, strict) {}
}
class AddressesBase extends AutofillRecords {
export class AddressesBase extends AutofillRecords {
constructor(store) {
super(
store,
@ -1829,7 +1818,7 @@ class AddressesBase extends AutofillRecords {
}
}
class CreditCardsBase extends AutofillRecords {
export class CreditCardsBase extends AutofillRecords {
constructor(store) {
super(
store,
@ -2149,7 +2138,7 @@ class CreditCardsBase extends AutofillRecords {
}
}
class FormAutofillStorageBase {
export class FormAutofillStorageBase {
constructor(path) {
this._path = path;
this._initializePromise = null;

View File

@ -2,31 +2,19 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
import {
Changeset,
Store,
SyncEngine,
Tracker,
} from "resource://services-sync/engines.sys.mjs";
import { CryptoWrapper } from "resource://services-sync/record.sys.mjs";
import { Utils } from "resource://services-sync/util.sys.mjs";
var EXPORTED_SYMBOLS = [
"AddressesEngine",
"CreditCardsEngine",
// The items below are exported for test purposes.
"sanitizeStorageObject",
"AutofillRecord",
];
const { Changeset, Store, SyncEngine, Tracker } = ChromeUtils.importESModule(
"resource://services-sync/engines.sys.mjs"
);
const { CryptoWrapper } = ChromeUtils.importESModule(
"resource://services-sync/record.sys.mjs"
);
const { Utils } = ChromeUtils.importESModule(
"resource://services-sync/util.sys.mjs"
);
const { SCORE_INCREMENT_XLARGE } = ChromeUtils.import(
"resource://services-sync/constants.js"
);
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
const lazy = {};
@ -39,7 +27,7 @@ XPCOMUtils.defineLazyModuleGetters(lazy, {
});
// A helper to sanitize address and creditcard records suitable for logging.
function sanitizeStorageObject(ob) {
export function sanitizeStorageObject(ob) {
if (!ob) {
return null;
}
@ -58,7 +46,7 @@ function sanitizeStorageObject(ob) {
return result;
}
function AutofillRecord(collection, id) {
export function AutofillRecord(collection, id) {
CryptoWrapper.call(this, collection, id);
}
@ -353,7 +341,7 @@ AddressesStore.prototype = {
};
Object.setPrototypeOf(AddressesStore.prototype, FormAutofillStore.prototype);
function AddressesEngine(service) {
export function AddressesEngine(service) {
FormAutofillEngine.call(this, service, "Addresses");
}
@ -386,7 +374,7 @@ CreditCardsStore.prototype = {
};
Object.setPrototypeOf(CreditCardsStore.prototype, FormAutofillStore.prototype);
function CreditCardsEngine(service) {
export function CreditCardsEngine(service) {
FormAutofillEngine.call(this, service, "CreditCards");
}

View File

@ -2,14 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const EXPORTED_SYMBOLS = [
"FormAutofillUtils",
"AddressDataLoader",
"LabelUtils",
];
let FormAutofillUtils;
export let FormAutofillUtils;
const ADDRESS_METADATA_PATH = "resource://autofill/addressmetadata/";
const ADDRESS_REFERENCES = "addressReferences.js";
@ -63,9 +56,8 @@ const ELIGIBLE_INPUT_TYPES = ["text", "email", "tel", "number", "month"];
// attacks that fill the user's hard drive(s).
const MAX_FIELD_VALUE_LENGTH = 200;
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
const { FormAutofill } = ChromeUtils.import(
"resource://autofill/FormAutofill.jsm"
);
@ -80,7 +72,7 @@ XPCOMUtils.defineLazyModuleGetters(lazy, {
FormAutofillNameUtils: "resource://autofill/FormAutofillNameUtils.jsm",
});
let AddressDataLoader = {
export let AddressDataLoader = {
// Status of address data loading. We'll load all the countries with basic level 1
// information while requesting conutry information, and set country to true.
// Level 1 Set is for recording which country's level 1/level 2 data is loaded,
@ -1193,7 +1185,7 @@ FormAutofillUtils = {
},
};
const LabelUtils = {
export const LabelUtils = {
// The tag name list is from Chromium except for "STYLE":
// eslint-disable-next-line max-len
// https://cs.chromium.org/chromium/src/components/autofill/content/renderer/form_autofill_util.cc?l=216&rcl=d33a171b7c308a64dc3372fac3da2179c63b419e

View File

@ -2,12 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
var EXPORTED_SYMBOLS = ["AddressResult", "CreditCardResult"];
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
@ -208,7 +204,7 @@ class ProfileAutoCompleteResult {
}
}
class AddressResult extends ProfileAutoCompleteResult {
export class AddressResult extends ProfileAutoCompleteResult {
constructor(...args) {
super(...args);
}
@ -330,7 +326,7 @@ class AddressResult extends ProfileAutoCompleteResult {
}
}
class CreditCardResult extends ProfileAutoCompleteResult {
export class CreditCardResult extends ProfileAutoCompleteResult {
constructor(...args) {
super(...args);
this._cardTypes = this._generateCardTypes(

View File

@ -7,13 +7,7 @@
* the doorhager UI for formautofill related features.
*/
"use strict";
var EXPORTED_SYMBOLS = ["FormAutofillPrompter"];
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
const lazy = {};
@ -33,7 +27,7 @@ const CreditCardStorageHint = {
LOW_CONFIDENCE: 1 << 1,
};
let FormAutofillPrompter = {
export let FormAutofillPrompter = {
_createMessage(creditCards) {
let hint = CreditCardStorageHint.NONE;
return {

View File

@ -6,24 +6,16 @@
* Implements an interface of the storage of Form Autofill for GeckoView.
*/
"use strict";
// We expose a singleton from this module. Some tests may import the
// constructor via a backstage pass.
const EXPORTED_SYMBOLS = ["formAutofillStorage", "FormAutofillStorage"];
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
const {
FormAutofillStorageBase,
CreditCardsBase,
AddressesBase,
} = ChromeUtils.import("resource://autofill/FormAutofillStorageBase.jsm");
const { JSONFile } = ChromeUtils.importESModule(
"resource://gre/modules/JSONFile.sys.mjs"
);
import { JSONFile } from "resource://gre/modules/JSONFile.sys.mjs";
const lazy = {};
@ -248,7 +240,7 @@ class CreditCards extends CreditCardsBase {
}
}
class FormAutofillStorage extends FormAutofillStorageBase {
export class FormAutofillStorage extends FormAutofillStorageBase {
constructor() {
super(null);
}
@ -281,4 +273,4 @@ class FormAutofillStorage extends FormAutofillStorageBase {
}
// The singleton exposed by this module.
const formAutofillStorage = new FormAutofillStorage();
export const formAutofillStorage = new FormAutofillStorage();

View File

@ -7,13 +7,8 @@
* the doorhager UI for formautofill related features.
*/
"use strict";
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
var EXPORTED_SYMBOLS = ["FormAutofillPrompter"];
const { AppConstants } = ChromeUtils.importESModule(
"resource://gre/modules/AppConstants.sys.mjs"
);
const { AutofillTelemetry } = ChromeUtils.import(
"resource://autofill/AutofillTelemetry.jsm"
);
@ -23,9 +18,7 @@ const { FormAutofill } = ChromeUtils.import(
const { FormAutofillUtils } = ChromeUtils.import(
"resource://autofill/FormAutofillUtils.jsm"
);
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
const lazy = {};
@ -34,7 +27,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
});
XPCOMUtils.defineLazyGetter(lazy, "log", () =>
FormAutofill.defineLogGetter(lazy, EXPORTED_SYMBOLS[0])
FormAutofill.defineLogGetter(lazy, "FormAutofillPrompter")
);
const { ENABLED_AUTOFILL_CREDITCARDS_PREF } = FormAutofill;
@ -250,7 +243,7 @@ const CONTENT = {
},
};
let FormAutofillPrompter = {
export let FormAutofillPrompter = {
/**
* Generate the main action and secondary actions from content parameters and
* promise resolve.

View File

@ -6,12 +6,8 @@
* Implements an interface of the storage of Form Autofill.
*/
"use strict";
// We expose a singleton from this module. Some tests may import the
// constructor via a backstage pass.
const EXPORTED_SYMBOLS = ["formAutofillStorage", "FormAutofillStorage"];
const { FormAutofill } = ChromeUtils.import(
"resource://autofill/FormAutofill.jsm"
);
@ -22,9 +18,7 @@ const {
AddressesBase,
} = ChromeUtils.import("resource://autofill/FormAutofillStorageBase.jsm");
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
const lazy = {};
@ -237,7 +231,7 @@ class CreditCards extends CreditCardsBase {
}
}
class FormAutofillStorage extends FormAutofillStorageBase {
export class FormAutofillStorage extends FormAutofillStorageBase {
constructor(path) {
super(path);
}
@ -284,6 +278,6 @@ class FormAutofillStorage extends FormAutofillStorageBase {
}
// The singleton exposed by this module.
const formAutofillStorage = new FormAutofillStorage(
export const formAutofillStorage = new FormAutofillStorage(
PathUtils.join(PathUtils.profileDir, PROFILE_JSON_FILE_NAME)
);

View File

@ -9,9 +9,9 @@ toolkit.jar:
res/autofill/addressmetadata/ (./addressmetadata/*)
res/autofill/content/ (./content/*)
#ifdef ANDROID
res/autofill/FormAutofillPrompter.jsm (./android/FormAutofillPrompter.jsm)
res/autofill/FormAutofillStorage.jsm (./android/FormAutofillStorage.jsm)
res/autofill/FormAutofillPrompter.sys.mjs (./android/FormAutofillPrompter.sys.mjs)
res/autofill/FormAutofillStorage.sys.mjs (./android/FormAutofillStorage.sys.mjs)
#else
res/autofill/FormAutofillPrompter.jsm (./default/FormAutofillPrompter.jsm)
res/autofill/FormAutofillStorage.jsm (./default/FormAutofillStorage.jsm)
res/autofill/FormAutofillPrompter.sys.mjs (./default/FormAutofillPrompter.sys.mjs)
res/autofill/FormAutofillStorage.sys.mjs (./default/FormAutofillStorage.sys.mjs)
#endif

View File

@ -5,13 +5,7 @@
// This library came from https://github.com/andreasgal/PhoneNumber.js but will
// be further maintained by our own in Form Autofill codebase.
"use strict";
var EXPORTED_SYMBOLS = ["PhoneNumber"];
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
const { PHONE_NUMBER_META_DATA } = ChromeUtils.import(
"resource://autofill/phonenumberutils/PhoneNumberMetaData.jsm"
@ -24,7 +18,7 @@ XPCOMUtils.defineLazyModuleGetters(lazy, {
"resource://autofill/phonenumberutils/PhoneNumberNormalizer.jsm",
});
var PhoneNumber = (function(dataBase) {
export var PhoneNumber = (function(dataBase) {
const MAX_PHONE_NUMBER_LENGTH = 50;
const NON_ALPHA_CHARS = /[^a-zA-Z]/g;
const NON_DIALABLE_CHARS = /[^,#+\*\d]/g;

View File

@ -10,11 +10,7 @@
* in this version for now.
*/
"use strict";
var EXPORTED_SYMBOLS = ["PHONE_NUMBER_META_DATA"];
var PHONE_NUMBER_META_DATA = {
export var PHONE_NUMBER_META_DATA = {
"46":
'["SE","00","0",null,null,"$NP$FG","\\\\d{6,12}","[1-35-9]\\\\d{5,11}|4\\\\d{6,8}",[["(8)(\\\\d{2,3})(\\\\d{2,3})(\\\\d{2})","$1-$2 $3 $4","8",null,"$1 $2 $3 $4"],["([1-69]\\\\d)(\\\\d{2,3})(\\\\d{2})(\\\\d{2})","$1-$2 $3 $4","1[013689]|2[0136]|3[1356]|4[0246]|54|6[03]|90",null,"$1 $2 $3 $4"],["([1-469]\\\\d)(\\\\d{3})(\\\\d{2})","$1-$2 $3","1[136]|2[136]|3[356]|4[0246]|6[03]|90",null,"$1 $2 $3"],["(\\\\d{3})(\\\\d{2})(\\\\d{2})(\\\\d{2})","$1-$2 $3 $4","1[2457]|2(?:[247-9]|5[0138])|3[0247-9]|4[1357-9]|5[0-35-9]|6(?:[124-689]|7[0-2])|9(?:[125-8]|3[0-5]|4[0-3])",null,"$1 $2 $3 $4"],["(\\\\d{3})(\\\\d{2,3})(\\\\d{2})","$1-$2 $3","1[2457]|2(?:[247-9]|5[0138])|3[0247-9]|4[1357-9]|5[0-35-9]|6(?:[124-689]|7[0-2])|9(?:[125-8]|3[0-5]|4[0-3])",null,"$1 $2 $3"],["(7\\\\d)(\\\\d{3})(\\\\d{2})(\\\\d{2})","$1-$2 $3 $4","7",null,"$1 $2 $3 $4"],["(77)(\\\\d{2})(\\\\d{2})","$1-$2$3","7",null,"$1 $2 $3"],["(20)(\\\\d{2,3})(\\\\d{2})","$1-$2 $3","20",null,"$1 $2 $3"],["(9[034]\\\\d)(\\\\d{2})(\\\\d{2})(\\\\d{3})","$1-$2 $3 $4","9[034]",null,"$1 $2 $3 $4"],["(9[034]\\\\d)(\\\\d{4})","$1-$2","9[034]",null,"$1 $2"],["(\\\\d{3})(\\\\d{2})(\\\\d{3})(\\\\d{2})(\\\\d{2})","$1-$2 $3 $4 $5","25[245]|67[3-6]",null,"$1 $2 $3 $4 $5"]]]',
"299":

View File

@ -5,11 +5,7 @@
// This library came from https://github.com/andreasgal/PhoneNumber.js but will
// be further maintained by our own in Form Autofill codebase.
"use strict";
var EXPORTED_SYMBOLS = ["PhoneNumberNormalizer"];
var PhoneNumberNormalizer = (function() {
export var PhoneNumberNormalizer = (function() {
const UNICODE_DIGITS = /[\uFF10-\uFF19\u0660-\u0669\u06F0-\u06F9]/g;
const VALID_ALPHA_PATTERN = /[a-zA-Z]/g;
const LEADING_PLUS_CHARS_PATTERN = /^[+\uFF0B]+/g;