Skip to content

Commit 61e1101

Browse files
authoredMar 14, 2025
Refactor - auto update credential provider script (#25340)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 7b58fbd commit 61e1101

11 files changed

+575
-52
lines changed
 

‎firefox-ios/Client/Assets/CC_Script/AutofillTelemetry.sys.mjs

+20-6
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,20 @@ class AutofillTelemetryBase {
118118
this.recordGleanFormEvent("formPopupShown", flowId, extra);
119119
}
120120

121-
recordFormFilled(flowId, fieldDetails, data) {
121+
setUpFormFilledExtra(fieldDetails, data) {
122122
// Calculate values for telemetry
123123
const extra = this.#initFormEventExtra("unavailable");
124124

125125
for (const fieldDetail of fieldDetails) {
126126
// It is possible that we don't autofill a field because it is cross-origin.
127127
// When that happens, the data will not include that element.
128-
let { filledState, filledValue } = data.get(fieldDetail.elementId) ?? {};
128+
let { filledState, filledValue, isFilledOnFieldsUpdate } =
129+
data.get(fieldDetail.elementId) ?? {};
129130
switch (filledState) {
130131
case FIELD_STATES.AUTO_FILLED:
131-
filledState = "filled";
132+
filledState = isFilledOnFieldsUpdate
133+
? "filled_on_fields_update"
134+
: "filled";
132135
break;
133136
case FIELD_STATES.NORMAL:
134137
default:
@@ -140,11 +143,20 @@ class AutofillTelemetryBase {
140143
}
141144
this.#setFormEventExtra(extra, fieldDetail.fieldName, filledState);
142145
}
146+
return extra;
147+
}
143148

149+
recordFormFilled(flowId, fieldDetails, data) {
150+
const extra = this.setUpFormFilledExtra(fieldDetails, data);
144151
this.recordFormEvent("filled", flowId, extra);
145152
this.recordGleanFormEvent("formFilled", flowId, extra);
146153
}
147154

155+
recordFormFilledOnFieldsUpdate(flowId, fieldDetails, data) {
156+
const extra = this.setUpFormFilledExtra(fieldDetails, data);
157+
this.recordFormEvent("filled_on_fields_update", flowId, extra);
158+
}
159+
148160
recordFilledModified(flowId, fieldDetails) {
149161
const extra = { field_name: fieldDetails[0].fieldName };
150162
this.recordFormEvent("filled_modified", flowId, extra);
@@ -203,6 +215,8 @@ class AutofillTelemetryBase {
203215
return this.recordPopupShown(flowId, fieldDetails);
204216
case "filled":
205217
return this.recordFormFilled(flowId, fieldDetails, data);
218+
case "filled_on_fields_update":
219+
return this.recordFormFilledOnFieldsUpdate(flowId, fieldDetails, data);
206220
case "filled_modified":
207221
return this.recordFilledModified(flowId, fieldDetails);
208222
case "submitted":
@@ -288,7 +302,7 @@ export class AddressTelemetry extends AutofillTelemetryBase {
288302
HISTOGRAM_PROFILE_NUM_USES = "AUTOFILL_PROFILE_NUM_USES";
289303
HISTOGRAM_PROFILE_NUM_USES_KEY = "address";
290304

291-
// Fields that are record in `address_form` and `address_form_ext` telemetry
305+
// Fields that are recorded in `address_form` and `address_form_ext` telemetry
292306
SUPPORTED_FIELDS = {
293307
"street-address": "street_address",
294308
"address-line1": "address_line1",
@@ -307,7 +321,7 @@ export class AddressTelemetry extends AutofillTelemetryBase {
307321
tel: "tel",
308322
};
309323

310-
// Fields that are record in `address_form` event telemetry extra_keys
324+
// Fields that are recorded in `address_form` event telemetry extra_keys
311325
static SUPPORTED_FIELDS_IN_FORM = [
312326
"street_address",
313327
"address_line1",
@@ -319,7 +333,7 @@ export class AddressTelemetry extends AutofillTelemetryBase {
319333
"country",
320334
];
321335

322-
// Fields that are record in `address_form_ext` event telemetry extra_keys
336+
// Fields that are recorded in `address_form_ext` event telemetry extra_keys
323337
static SUPPORTED_FIELDS_IN_FORM_EXT = [
324338
"name",
325339
"given_name",

‎firefox-ios/Client/Assets/CC_Script/Constants.ios.mjs

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ const IOS_DEFAULT_PREFERENCES = {
3030
"extensions.formautofill.section.enabled": true,
3131
"extensions.formautofill.heuristics.captureOnFormRemoval": false,
3232
"extensions.formautofill.heuristics.captureOnPageNavigation": false,
33+
"extensions.formautofill.heuristics.detectDynamicFormChanges": false,
34+
"extensions.formautofill.heuristics.fillOnDynamicFormChanges": false,
3335
"extensions.formautofill.focusOnAutofill": false,
3436
"extensions.formautofill.test.ignoreVisibilityCheck": false,
3537
"extensions.formautofill.heuristics.autofillSameOriginWithTop": false,

‎firefox-ios/Client/Assets/CC_Script/FormAutofill.sys.mjs

+30
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ const ENABLED_AUTOFILL_CAPTURE_ON_PAGE_NAVIGATION_PREF =
3939
"extensions.formautofill.heuristics.captureOnPageNavigation";
4040
const ENABLED_AUTOFILL_SAME_ORIGIN_WITH_TOP =
4141
"extensions.formautofill.heuristics.autofillSameOriginWithTop";
42+
const ENABLED_AUTOFILL_DETECT_DYNAMIC_FORM_CHANGES_PREF =
43+
"extensions.formautofill.heuristics.detectDynamicFormChanges";
44+
const AUTOFILL_FILL_ON_DYNAMIC_FORM_CHANGES_TIMEOUT_PREF =
45+
"extensions.formautofill.heuristics.fillOnDynamicFormChanges.timeout";
46+
const AUTOFILL_FILL_ON_DYNAMIC_FORM_CHANGES_PREF =
47+
"extensions.formautofill.heuristics.fillOnDynamicFormChanges";
4248

4349
export const FormAutofill = {
4450
ENABLED_AUTOFILL_ADDRESSES_PREF,
@@ -47,9 +53,12 @@ export const FormAutofill = {
4753
ENABLED_AUTOFILL_CAPTURE_ON_PAGE_NAVIGATION_PREF,
4854
ENABLED_AUTOFILL_SAME_ORIGIN_WITH_TOP,
4955
ENABLED_AUTOFILL_CREDITCARDS_PREF,
56+
ENABLED_AUTOFILL_DETECT_DYNAMIC_FORM_CHANGES_PREF,
5057
AUTOFILL_CREDITCARDS_REAUTH_PREF,
5158
AUTOFILL_CREDITCARDS_AUTOCOMPLETE_OFF_PREF,
5259
AUTOFILL_ADDRESSES_AUTOCOMPLETE_OFF_PREF,
60+
AUTOFILL_FILL_ON_DYNAMIC_FORM_CHANGES_PREF,
61+
AUTOFILL_FILL_ON_DYNAMIC_FORM_CHANGES_TIMEOUT_PREF,
5362

5463
_region: null,
5564

@@ -336,6 +345,27 @@ XPCOMUtils.defineLazyPreferenceGetter(
336345
null
337346
);
338347

348+
XPCOMUtils.defineLazyPreferenceGetter(
349+
FormAutofill,
350+
"detectDynamicFormChanges",
351+
"extensions.formautofill.heuristics.detectDynamicFormChanges",
352+
false
353+
);
354+
355+
XPCOMUtils.defineLazyPreferenceGetter(
356+
FormAutofill,
357+
"fillOnDynamicFormChanges",
358+
"extensions.formautofill.heuristics.fillOnDynamicFormChanges",
359+
false
360+
);
361+
362+
XPCOMUtils.defineLazyPreferenceGetter(
363+
FormAutofill,
364+
"fillOnDynamicFormChangeTimeout",
365+
"extensions.formautofill.heuristics.fillOnDynamicFormChanges.timeout",
366+
0
367+
);
368+
339369
ChromeUtils.defineLazyGetter(FormAutofill, "countries", () =>
340370
AddressMetaDataLoader.getCountries()
341371
);

‎firefox-ios/Client/Assets/CC_Script/FormAutofillChild.ios.sys.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export class FormAutofillChild {
111111
onFocusIn(evt) {
112112
const element = evt.target;
113113

114-
if(element.shouldIgnoreAutofill) {
114+
if (element.shouldIgnoreAutofill) {
115115
return;
116116
}
117117

0 commit comments

Comments
 (0)
Failed to load comments.