From 7a65ffe33eeabc115ab7cd1ce62f54122aecd707 Mon Sep 17 00:00:00 2001 From: Zibi Braniecki Date: Tue, 10 Nov 2020 04:32:50 +0000 Subject: [PATCH] Bug 1660270 - Revert Part 2: Record address and password usage. r=MattN Depends on D87769 Differential Revision: https://phabricator.services.mozilla.com/D87770 --- .../formautofill/FormAutofillStorage.jsm | 41 ------- .../test/mochitest/formautofill_common.js | 20 ---- .../test_address_level_1_submission.html | 2 - .../test_basic_autocomplete_form.html | 2 - .../components/passwordmgr/storage-json.js | 17 +-- .../passwordmgr/test/mochitest/mochitest.ini | 2 - .../test/mochitest/test_usage_prefs.html | 101 ------------------ 7 files changed, 1 insertion(+), 184 deletions(-) delete mode 100644 toolkit/components/passwordmgr/test/mochitest/test_usage_prefs.html diff --git a/browser/extensions/formautofill/FormAutofillStorage.jsm b/browser/extensions/formautofill/FormAutofillStorage.jsm index c21749f68b7a..1d153f2752e1 100644 --- a/browser/extensions/formautofill/FormAutofillStorage.jsm +++ b/browser/extensions/formautofill/FormAutofillStorage.jsm @@ -307,7 +307,6 @@ class AutofillRecords { if (dataHasChanges) { this._store.saveSoon(); } - this._onDataLoaded(); }); } @@ -544,8 +543,6 @@ class AutofillRecords { * * @param {string} guid * Indicates which record to be notified. - * @returns {Object} - * Record corresponding to the guid that was used */ notifyUsed(guid) { this.log.debug("notifyUsed:", guid); @@ -571,7 +568,6 @@ class AutofillRecords { "formautofill-storage-changed", "notifyUsed" ); - return recordFound; } updateUseCountTelemetry() {} @@ -1443,9 +1439,6 @@ class AutofillRecords { // An interface to be inherited. async mergeIfPossible(guid, record, strict) {} - - // Called once initalization has completed - _onDataLoaded() {} } class Addresses extends AutofillRecords { @@ -1457,15 +1450,6 @@ class Addresses extends AutofillRecords { VALID_ADDRESS_COMPUTED_FIELDS, ADDRESS_SCHEMA_VERSION ); - Services.obs.addObserver(this, "formautofill-storage-changed"); - } - - observe(subject, topic, data) { - switch (topic) { - case "formautofill-storage-changed": - this._recordEntryPresent(); - break; - } } _recordReadProcessor(address) { @@ -1772,31 +1756,6 @@ class Addresses extends AutofillRecords { await this.update(guid, addressToMerge, true); return true; } - - _onDataLoaded() { - this._recordEntryPresent(); - } - - // Record in prefs whether the user has any address entries stored. - // This information is not uploaded as telemetry, and is used to target - // user surveys. See Bug 1654388 for details. - _recordEntryPresent() { - const records = this._data.filter(entry => !entry.deleted); - this.log.debug("Address records:", records); - Services.prefs.setBoolPref( - "extensions.formautofill.addresses.usage.hasEntry", - !!records.length - ); - } - - notifyUsed(guid) { - const record = super.notifyUsed(guid); - Services.prefs.setIntPref( - "extensions.formautofill.addresses.usage.lastUsed", - Math.floor(record.timeLastUsed / 1000) - ); - return record; - } } class CreditCards extends AutofillRecords { diff --git a/browser/extensions/formautofill/test/mochitest/formautofill_common.js b/browser/extensions/formautofill/test/mochitest/formautofill_common.js index 8965c17c61f3..dffe5451b4e1 100644 --- a/browser/extensions/formautofill/test/mochitest/formautofill_common.js +++ b/browser/extensions/formautofill/test/mochitest/formautofill_common.js @@ -441,26 +441,6 @@ function formAutoFillCommonSetup() { ); } -function checkUsagePrefs(hasEntry, lastUsed) { - lastUsed = Math.floor(lastUsed); - is( - SpecialPowers.getBoolPref( - "extensions.formautofill.addresses.usage.hasEntry", - false - ), - hasEntry, - "hasEntry usage pref is " + hasEntry - ); - const lastUsedPref = SpecialPowers.getIntPref( - "extensions.formautofill.addresses.usage.lastUsed", - 0 - ); - ok( - lastUsed - lastUsedPref < 10, - `lastUsed usage pref (${lastUsedPref}) is within 10 seconds of ${lastUsed}` - ); -} - /* * Extremely over-simplified detection of card type from card number just for * our tests. This is needed to test the aria-label of credit card menu entries. diff --git a/browser/extensions/formautofill/test/mochitest/test_address_level_1_submission.html b/browser/extensions/formautofill/test/mochitest/test_address_level_1_submission.html index cb361f9cc27d..0c16b91d3a66 100644 --- a/browser/extensions/formautofill/test/mochitest/test_address_level_1_submission.html +++ b/browser/extensions/formautofill/test/mochitest/test_address_level_1_submission.html @@ -75,8 +75,6 @@ add_task(async function test_form_will_submit_without_sub_keys() { let matching = await checkAddresses(TEST_ADDRESSES); ok(matching, "Address saved as expected"); - checkUsagePrefs(true, Date.now()/1000); - await loadPromise; isnot(window.submit_frame.location.href, "about:blank", "Check form submitted"); }); diff --git a/browser/extensions/formautofill/test/mochitest/test_basic_autocomplete_form.html b/browser/extensions/formautofill/test/mochitest/test_basic_autocomplete_form.html index ef7589bc2f25..a642b2abca3b 100644 --- a/browser/extensions/formautofill/test/mochitest/test_basic_autocomplete_form.html +++ b/browser/extensions/formautofill/test/mochitest/test_basic_autocomplete_form.html @@ -74,9 +74,7 @@ add_task(async function all_saved_fields_less_than_threshold() { // Form with both history and address storage. add_task(async function check_menu_when_both_existed() { - checkUsagePrefs(false, 0); await setupAddressStorage(); - checkUsagePrefs(true, 0); await setInput("#organization", ""); await notExpectPopup(); diff --git a/toolkit/components/passwordmgr/storage-json.js b/toolkit/components/passwordmgr/storage-json.js index cd1053120a15..5722651297c5 100644 --- a/toolkit/components/passwordmgr/storage-json.js +++ b/toolkit/components/passwordmgr/storage-json.js @@ -105,7 +105,6 @@ class LoginManagerStorage_json { // Load the data asynchronously. this.log("Opening database at", this._store.path); await this._store.load(); - this._recordEntryPresent(); })().catch(Cu.reportError); } catch (e) { this.log("Initialization failed:", e); @@ -267,7 +266,6 @@ class LoginManagerStorage_json { // Send a notification that a login was added. LoginHelper.notifyStorageChanged("addLogin", loginClone); - this._recordEntryPresent(); return loginClone; } @@ -286,7 +284,6 @@ class LoginManagerStorage_json { } LoginHelper.notifyStorageChanged("removeLogin", storedLogin); - this._recordEntryPresent(); } modifyLogin(oldLogin, newLoginData) { @@ -352,11 +349,9 @@ class LoginManagerStorage_json { let propBag = Cc["@mozilla.org/hash-property-bag;1"].createInstance( Ci.nsIWritablePropertyBag ); - let now = Date.now(); - propBag.setProperty("timeLastUsed", now); + propBag.setProperty("timeLastUsed", Date.now()); propBag.setProperty("timesUsedIncrement", 1); this.modifyLogin(login, propBag); - Services.prefs.setIntPref("signon.usage.lastUsed", Math.floor(now / 1000)); } async recordBreachAlertDismissal(loginGUID) { @@ -832,16 +827,6 @@ class LoginManagerStorage_json { return result; } - - // Record in prefs whether the user has any password entries stored. - // This information is not uploaded as telemetry, and is used to target - // user surveys. See Bug 1654388 for details. - _recordEntryPresent() { - Services.prefs.setBoolPref( - "signon.usage.hasEntry", - !!this._store.data.logins.length - ); - } } XPCOMUtils.defineLazyGetter(LoginManagerStorage_json.prototype, "log", () => { diff --git a/toolkit/components/passwordmgr/test/mochitest/mochitest.ini b/toolkit/components/passwordmgr/test/mochitest/mochitest.ini index 3cc0973bae7d..9e0b829db586 100644 --- a/toolkit/components/passwordmgr/test/mochitest/mochitest.ini +++ b/toolkit/components/passwordmgr/test/mochitest/mochitest.ini @@ -197,8 +197,6 @@ skip-if = xorigin support-files = subtst_prefilled_form.html skip-if = xorigin -[test_usage_prefs.html] -scheme = https [test_username_focus.html] skip-if = xorigin || toolkit == 'android' # android:autocomplete. [test_xhr.html] diff --git a/toolkit/components/passwordmgr/test/mochitest/test_usage_prefs.html b/toolkit/components/passwordmgr/test/mochitest/test_usage_prefs.html deleted file mode 100644 index 071ca403719f..000000000000 --- a/toolkit/components/passwordmgr/test/mochitest/test_usage_prefs.html +++ /dev/null @@ -1,101 +0,0 @@ - - - - - Test usage prefs - - - - - -Login Manager test: usage prefs collection - - - -

- - - -

-
-
-