Backed out changeset 4e38530aaba0 (bug 1653162) for causing failures in test_autofillFormFields.js CLOSED TREE

This commit is contained in:
Noemi Erli 2020-07-25 00:57:53 +03:00
Родитель efdfcbfe84
Коммит 20a8201c14
7 изменённых файлов: 1 добавлений и 321 удалений

Просмотреть файл

@ -552,15 +552,6 @@ var FormAutofillContent = {
return;
}
records.creditCard.forEach(record => {
Services.telemetry.recordEvent(
"creditcard",
"submitted",
"cc_form",
record.flowId
);
});
this._onFormSubmit(records, domWin, handler.timeStartedFillingMS);
},
@ -837,13 +828,6 @@ var FormAutofillContent = {
"Popup has opened, automatic =",
formFillController.passwordPopupAutomaticallyOpened
);
Services.telemetry.recordEvent(
"creditcard",
"popup_shown",
"cc_form",
this.activeSection.flowId
);
},
_markAsAutofillField(field) {

Просмотреть файл

@ -10,8 +10,6 @@
var EXPORTED_SYMBOLS = ["FormAutofillHandler"];
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { AppConstants } = ChromeUtils.import(
"resource://gre/modules/AppConstants.jsm"
);
@ -62,10 +60,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
CreditCard: "resource://gre/modules/CreditCard.jsm",
});
XPCOMUtils.defineLazyServiceGetters(this, {
gUUIDGenerator: ["@mozilla.org/uuid-generator;1", "nsIUUIDGenerator"],
});
this.log = null;
FormAutofill.defineLazyLogGetter(this, EXPORTED_SYMBOLS[0]);
@ -333,8 +327,6 @@ class FormAutofillSection {
*
* @param {Object} profile
* A profile to be filled in.
* @returns {boolean}
* True if successful, false if failed
*/
async autofillFields(profile) {
let focusedDetail = this._focusedDetail;
@ -344,7 +336,7 @@ class FormAutofillSection {
if (!(await this.prepareFillingProfile(profile))) {
log.debug("profile cannot be filled", profile);
return false;
return;
}
log.debug("profile in autofillFields:", profile);
@ -401,7 +393,6 @@ class FormAutofillSection {
}
}
focusedInput.focus({ preventScroll: true });
return true;
}
/**
@ -576,9 +567,6 @@ class FormAutofillSection {
record: {},
untouchedFields: [],
};
if (this.flowId) {
data.flowId = this.flowId;
}
details.forEach(detail => {
let element = detail.elementWeakRef.get();
@ -636,15 +624,6 @@ class FormAutofillSection {
this._changeFieldState(targetFieldDetail, FIELD_STATES.NORMAL);
if (isCreditCardField) {
Services.telemetry.recordEvent(
"creditcard",
"filled_modified",
"cc_form",
this.flowId
);
}
let isAutofilled = false;
let dimFieldDetails = [];
for (const fieldDetail of this.fieldDetails) {
@ -921,29 +900,6 @@ class FormAutofillCreditCardSection extends FormAutofillSection {
this.handler = handler;
// Identifier used to correlate events relating to the same form
this.flowId = gUUIDGenerator.generateUUID().toString();
log.debug("Creating new credit card section with flowId =", this.flowId);
// Record which fields could be identified
let identified = new Set();
fieldDetails.forEach(detail => identified.add(detail.fieldName));
Services.telemetry.recordEvent(
"creditcard",
"detected",
"cc_form",
this.flowId,
{
cc_name_found: identified.has("cc-name") ? "true" : "false",
cc_number_found: identified.has("cc-number") ? "true" : "false",
cc_exp_found:
identified.has("cc-exp") ||
(identified.has("cc-exp-month") && identified.has("cc-exp-year"))
? "true"
: "false",
}
);
// For valid sections, check whether the section is in an
// <iframe>; and, if so, watch for the <iframe> to pagehide.
// If the section is invalid, then the superclass constructor
@ -1159,54 +1115,6 @@ class FormAutofillCreditCardSection extends FormAutofillSection {
}
return true;
}
async autofillFields(profile) {
if (!(await super.autofillFields(profile))) {
return false;
}
// Calculate values for telemetry
let extra = {
cc_name: "unavailable",
cc_number: "unavailable",
cc_exp: "unavailable",
};
for (let fieldDetail of this.fieldDetails) {
let element = fieldDetail.elementWeakRef.get();
let state = profile[fieldDetail.fieldName] ? "filled" : "not_filled";
if (
fieldDetail.state == FIELD_STATES.NORMAL &&
(ChromeUtils.getClassName(element) == "HTMLSelectElement" ||
(ChromeUtils.getClassName(element) == "HTMLInputElement" &&
element.value.length))
) {
state = "user_filled";
}
switch (fieldDetail.fieldName) {
case "cc-name":
extra.cc_name = state;
break;
case "cc-number":
extra.cc_number = state;
break;
case "cc-exp":
case "cc-exp-month":
case "cc-exp-year":
extra.cc_exp = state;
break;
}
}
Services.telemetry.recordEvent(
"creditcard",
"filled",
"cc_form",
this.flowId,
extra
);
return true;
}
}
/**

Просмотреть файл

@ -24,5 +24,3 @@ skip-if = (verify && (os == 'win' || os == 'mac'))
skip-if = !debug && os == "mac" # perma-fail see Bug 1600059
[browser_anti_clickjacking.js]
skip-if = !debug && os == "mac" # perma-fail see Bug 1600059
[browser_creditCard_telemetry.js]
skip-if = (os == "linux") || (os == "mac" && debug) || (os == "win") # bug 1425884

Просмотреть файл

@ -1,141 +0,0 @@
/* eslint-disable mozilla/no-arbitrary-setTimeout */
"use strict";
const { TelemetryTestUtils } = ChromeUtils.import(
"resource://testing-common/TelemetryTestUtils.jsm"
);
async function assertTelemetry(expected_content = [], expected_parent = []) {
let snapshots;
info(
`Waiting for ${expected_content.length} content events and ` +
`${expected_parent.length} parent events`
);
await TestUtils.waitForCondition(
() => {
snapshots = Services.telemetry.snapshotEvents(
Ci.nsITelemetry.DATASET_PRERELEASE_CHANNELS,
false
);
return (
(snapshots.parent?.length ?? 0) >= expected_parent.length &&
(snapshots.content?.length ?? 0) >= expected_content.length
);
},
"Wait for telemetry to be collected",
100,
100
);
info(JSON.stringify(snapshots, null, 2));
if (expected_content.length) {
expected_content = expected_content.map(([category, method, object]) => {
return { category, method, object };
});
let clear = !expected_parent.length;
TelemetryTestUtils.assertEvents(
expected_content,
{
category: "creditcard",
},
{ clear, process: "content" }
);
}
if (expected_parent.length) {
expected_parent = expected_parent.map(([category, method, object]) => {
return { category, method, object };
});
TelemetryTestUtils.assertEvents(
expected_parent,
{
category: "creditcard",
},
{ process: "parent" }
);
}
}
add_task(async function test_popup_opened() {
Services.telemetry.clearEvents();
Services.telemetry.setEventRecordingEnabled("creditcard", true);
await saveCreditCard(TEST_CREDIT_CARD_1);
await BrowserTestUtils.withNewTab(
{ gBrowser, url: CREDITCARD_FORM_URL },
async function(browser) {
const focusInput = "#cc-number";
await openPopupOn(browser, focusInput);
// Clean up
await closePopup(browser);
}
);
await removeAllRecords();
await assertTelemetry([
["creditcard", "detected", "cc_form"],
["creditcard", "popup_shown", "cc_form"],
]);
});
add_task(async function test_submit_creditCard_saved() {
Services.telemetry.clearEvents();
Services.telemetry.setEventRecordingEnabled("creditcard", true);
await SpecialPowers.pushPrefEnv({
set: [[CREDITCARDS_USED_STATUS_PREF, 0]],
});
await BrowserTestUtils.withNewTab(
{ gBrowser, url: CREDITCARD_FORM_URL },
async function(browser) {
let promiseShown = BrowserTestUtils.waitForEvent(
PopupNotifications.panel,
"popupshown"
);
let onChanged = TestUtils.topicObserved("formautofill-storage-changed");
await SpecialPowers.spawn(browser, [], async function() {
let form = content.document.getElementById("form");
let name = form.querySelector("#cc-name");
name.focus();
name.setUserInput("User 1");
form.querySelector("#cc-number").setUserInput("5038146897157463");
form.querySelector("#cc-exp-month").setUserInput("12");
form.querySelector("#cc-exp-year").setUserInput("2017");
form.querySelector("#cc-type").value = "mastercard";
// Wait 1000ms before submission to make sure the input value applied
await new Promise(resolve => content.setTimeout(resolve, 1000));
form.querySelector("input[type=submit]").click();
});
await promiseShown;
await clickDoorhangerButton(MAIN_BUTTON);
await onChanged;
}
);
is(
SpecialPowers.getIntPref(CREDITCARDS_USED_STATUS_PREF),
2,
"User has seen the doorhanger"
);
SpecialPowers.clearUserPref(CREDITCARDS_USED_STATUS_PREF);
await removeAllRecords();
await assertTelemetry([
["creditcard", "detected", "cc_form"],
["creditcard", "submitted", "cc_form"],
]);
});

Просмотреть файл

@ -10,10 +10,6 @@ const { setTimeout, clearTimeout } = ChromeUtils.import(
{}
);
const { TelemetryTestUtils } = ChromeUtils.import(
"resource://testing-common/TelemetryTestUtils.jsm"
);
var FormAutofillHandler, OSKeyStore;
add_task(async function setup() {
({ FormAutofillHandler } = ChromeUtils.import(
@ -494,10 +490,6 @@ function do_test(testcases, testFn) {
let testcase = tc;
add_task(async function() {
info("Starting testcase: " + testcase.description);
Services.telemetry.clearEvents();
Services.telemetry.setEventRecordingEnabled("creditcard", true);
let ccNumber = testcase.profileData["cc-number"];
if (ccNumber) {
testcase.profileData[
@ -554,13 +546,6 @@ function do_test(testcases, testFn) {
"Check if filledRecordGUID is set correctly"
);
await Promise.all(promises);
if (testcase.expectedResult["cc-number"]) {
TelemetryTestUtils.assertNumberOfEvents(1, {
category: "creditcard",
method: "detected",
});
}
});
})();
}

Просмотреть файл

@ -1,9 +1,5 @@
"use strict";
const { TelemetryTestUtils } = ChromeUtils.import(
"resource://testing-common/TelemetryTestUtils.jsm"
);
var FormAutofillContent;
add_task(async function setup() {
({ FormAutofillContent } = ChromeUtils.import(
@ -636,9 +632,6 @@ TESTCASES.forEach(testcase => {
add_task(async function check_records_saving_is_called_correctly() {
info("Starting testcase: " + testcase.description);
Services.telemetry.clearEvents();
Services.telemetry.setEventRecordingEnabled("creditcard", true);
let form = MOCK_DOC.getElementById("form1");
form.reset();
for (let key in testcase.formValue) {
@ -666,31 +659,11 @@ TESTCASES.forEach(testcase => {
"Check expected onFormSubmit.called"
);
if (FormAutofillContent._onFormSubmit.called) {
let ccFlowIds = [];
for (let ccRecord of FormAutofillContent._onFormSubmit.args[0][0]
.creditCard) {
ccFlowIds.push(ccRecord.flowId);
delete ccRecord.flowId;
}
Assert.deepEqual(
FormAutofillContent._onFormSubmit.args[0][0],
testcase.expectedResult.records
);
let expected = ccFlowIds.map(flowId => {
return {
method: "submitted",
object: "cc_form",
value: flowId,
extra: undefined,
};
});
TelemetryTestUtils.assertEvents(expected, {
category: "creditcard",
method: "submitted",
});
}
FormAutofillContent._onFormSubmit.restore();
});
});

Просмотреть файл

@ -349,33 +349,6 @@ form_autocomplete:
record_in_processes: ["main"]
release_channel_collection: opt-out
creditcard:
cc_form:
description: >-
User interactions for credit card autofill forms
objects:
- "cc_form"
methods:
- "detected"
- "popup_shown"
- "filled"
- "filled_modified"
- "submitted"
bug_numbers: [1653073, 1653162]
notification_emails: ["jmathies@mozilla.com", "chsiang@mozilla.com"]
expiry_version: "93"
products:
- "firefox"
record_in_processes: ["content"]
release_channel_collection: opt-out
extra_keys:
cc_name_found: Whether the cardholder name field was identified
cc_number_found: Whether the credit card number field was identified
cc_exp_found: Whether the expiration date was identified
cc_name: Whether the name was autofilled (autofilled / not_filled / user_filled / unavailable)
cc_number: Whether the credit card number field was autofilled (autofilled / not_filled / user_filled / unavailable)
cc_exp: Whether the expiration date was autofilled (autofilled / not_filled / user_filled / unavailable)
extensions.data:
migrateResult:
objects: ["storageLocal"]