зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 218e6f863de3 (bug 1548878
) for test_autocomplete_new_password.html failures CLOSED TREE
This commit is contained in:
Родитель
d31a26f7f4
Коммит
7a01019cf4
|
@ -32,8 +32,8 @@ const EXPORTED_SYMBOLS = [ "LoginManagerParent" ];
|
|||
|
||||
this.LoginManagerParent = {
|
||||
/**
|
||||
* A map of a principal's origin (including suffixes) to a generated password string and filled flag
|
||||
* so that we can offer the same password later (e.g. in a confirmation field).
|
||||
* A map of a principal's origin (including suffixes) to a generated password string so that we
|
||||
* can offer the same password later (e.g. in a confirmation field).
|
||||
*
|
||||
* We don't currently evict from this cache so entries should last until the end of the browser
|
||||
* session. That may change later but for now a typical session would max out at a few entries.
|
||||
|
@ -391,15 +391,11 @@ this.LoginManagerParent = {
|
|||
// with each search/keystroke and the user can easily re-enter a password in a confirmation field.
|
||||
let generatedPW = this._generatedPasswordsByPrincipalOrigin.get(framePrincipalOrigin);
|
||||
if (generatedPW) {
|
||||
return generatedPW.value;
|
||||
return generatedPW;
|
||||
}
|
||||
|
||||
generatedPW = {
|
||||
value: PasswordGenerator.generatePassword(),
|
||||
filled: false,
|
||||
};
|
||||
generatedPW = PasswordGenerator.generatePassword();
|
||||
this._generatedPasswordsByPrincipalOrigin.set(framePrincipalOrigin, generatedPW);
|
||||
return generatedPW.value;
|
||||
return generatedPW;
|
||||
},
|
||||
|
||||
onFormSubmit(browser, {
|
||||
|
@ -584,16 +580,6 @@ this.LoginManagerParent = {
|
|||
return;
|
||||
}
|
||||
|
||||
let framePrincipalOrigin = browsingContext.currentWindowGlobal.documentPrincipal.origin;
|
||||
let generatedPW = this._generatedPasswordsByPrincipalOrigin.get(framePrincipalOrigin);
|
||||
// This will throw if we can't look up the entry in the password/origin map
|
||||
if (!generatedPW.filled) {
|
||||
// record first use of this generated password
|
||||
Services.telemetry.recordEvent("pwmgr", "autocomplete_field", "generatedpassword");
|
||||
log("autocomplete_field telemetry event recorded");
|
||||
generatedPW.filled = true;
|
||||
}
|
||||
|
||||
if (!Services.logins.getLoginSavingEnabled(formOrigin)) {
|
||||
log("_onGeneratedPasswordFilled: saving is disabled for:", formOrigin);
|
||||
return;
|
||||
|
@ -613,7 +599,7 @@ this.LoginManagerParent = {
|
|||
return;
|
||||
}
|
||||
|
||||
let password = generatedPW.value;
|
||||
let password = this.getGeneratedPassword(browsingContextId);
|
||||
let formLogin = Cc["@mozilla.org/login-manager/loginInfo;1"].createInstance(Ci.nsILoginInfo);
|
||||
formLogin.init(formOrigin, formActionOrigin, null, "", password);
|
||||
Services.logins.addLogin(formLogin);
|
||||
|
|
|
@ -239,17 +239,6 @@ function promiseFormsProcessed(expectedCount = 1) {
|
|||
});
|
||||
}
|
||||
|
||||
function getTelemetryEvents(options) {
|
||||
return new Promise(resolve => {
|
||||
PWMGR_COMMON_PARENT.addMessageListener("getTelemetryEvents", function gotResult(events) {
|
||||
info("CONTENT: getTelemetryEvents gotResult: " + JSON.stringify(events));
|
||||
PWMGR_COMMON_PARENT.removeMessageListener("getTelemetryEvents", gotResult);
|
||||
resolve(events);
|
||||
});
|
||||
PWMGR_COMMON_PARENT.sendAsyncMessage("getTelemetryEvents", options);
|
||||
});
|
||||
}
|
||||
|
||||
function loadRecipes(recipes) {
|
||||
info("Loading recipes");
|
||||
return new Promise(resolve => {
|
||||
|
|
|
@ -123,29 +123,6 @@ addMessageListener("resetRecipes", async function() {
|
|||
sendAsyncMessage("recipesReset");
|
||||
});
|
||||
|
||||
addMessageListener("getTelemetryEvents", options => {
|
||||
options = Object.assign({
|
||||
filterProps: {},
|
||||
clear: false,
|
||||
}, options);
|
||||
let snapshots = Services.telemetry.snapshotEvents(Ci.nsITelemetry.DATASET_PRERELEASE_CHANNELS, options.clear);
|
||||
let events = (options.process in snapshots) ? snapshots[options.process] : [];
|
||||
|
||||
// event is array of values like: [22476,"pwmgr","autocomplete_field","generatedpassword"]
|
||||
let keys = ["id", "category", "method", "object", "value"];
|
||||
events = events.filter(entry => {
|
||||
for (let idx = 0; idx < keys.length; idx++) {
|
||||
let key = keys[idx];
|
||||
if ((key in options.filterProps) && options.filterProps[key] !== entry[idx]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
sendAsyncMessage("getTelemetryEvents", events);
|
||||
});
|
||||
|
||||
|
||||
addMessageListener("proxyLoginManager", msg => {
|
||||
// Recreate nsILoginInfo objects from vanilla JS objects.
|
||||
let recreatedArgs = msg.args.map((arg, index) => {
|
||||
|
|
|
@ -21,8 +21,7 @@ function initLogins() {
|
|||
|
||||
Services.logins.addLogin(login1);
|
||||
}
|
||||
|
||||
runInParent(initLogins);
|
||||
let chromeScript = runInParent(initLogins);
|
||||
|
||||
let readyPromise = registerRunTests();
|
||||
</script>
|
||||
|
@ -50,40 +49,14 @@ let readyPromise = registerRunTests();
|
|||
<script class="testbody" type="text/javascript">
|
||||
const {ContentTaskUtils} =
|
||||
SpecialPowers.Cu.import("resource://testing-common/ContentTaskUtils.jsm", {});
|
||||
const { TestUtils } = SpecialPowers.Cu.import("resource://testing-common/TestUtils.jsm");
|
||||
|
||||
let dateAndTimeFormatter = new SpecialPowers.Services.intl.DateTimeFormat(undefined, {
|
||||
dateStyle: "medium",
|
||||
});
|
||||
|
||||
const TelemetryFilterProps = Object.freeze({
|
||||
category: "pwmgr",
|
||||
method: "autocomplete_field",
|
||||
object: "generatedpassword",
|
||||
});
|
||||
|
||||
async function waitForTelemetryEventsCondition(cond, options = {},
|
||||
errorMsg = "waitForTelemetryEventsCondition timed out", maxTries = 50) {
|
||||
return TestUtils.waitForCondition(async () => {
|
||||
let events = await getTelemetryEvents(options);
|
||||
info("waitForTelemetryEventsCondition, got events: " + JSON.stringify(events));
|
||||
let result;
|
||||
try {
|
||||
result = cond(events);
|
||||
} catch (e) {
|
||||
ok(false, `${e}\n${e.stack}`);
|
||||
}
|
||||
return result ? events : null;
|
||||
}, errorMsg, maxTries);
|
||||
}
|
||||
|
||||
add_task(async function setup() {
|
||||
ok(readyPromise, "check promise is available");
|
||||
await readyPromise;
|
||||
info("setup: waiting for 0 telemetry events");
|
||||
await waitForTelemetryEventsCondition(events => events && events.length == 0,
|
||||
{ process: "parent", filterProps: TelemetryFilterProps },
|
||||
"Wait for 0 telemetry events");
|
||||
});
|
||||
|
||||
add_task(async function test_autofillAutocompleteUsername_noGeneration() {
|
||||
|
@ -200,17 +173,10 @@ add_task(async function test_autofillAutocompletePassword_withGeneration() {
|
|||
synthesizeKey("KEY_ArrowDown");
|
||||
let storageAddPromise = promiseStorageChanged(["addLogin"]);
|
||||
synthesizeKey("KEY_Enter");
|
||||
|
||||
info("waiting for the password field to be filled with the generatedpassword");
|
||||
await SimpleTest.promiseWaitForCondition(() => !!pword.value, "Check generated pw filled");
|
||||
info("Wait for generated password to be added to storage");
|
||||
await storageAddPromise;
|
||||
|
||||
info("filled generated password, check 1 generatedpassword telemetry events");
|
||||
await waitForTelemetryEventsCondition(events => events.length == 1,
|
||||
{ process: "parent", filterProps: TelemetryFilterProps },
|
||||
"Wait for there to be 1 telemetry event");
|
||||
|
||||
let logins = LoginManager.getAllLogins();
|
||||
let timePasswordChanged = logins[logins.length - 1].timePasswordChanged;
|
||||
let time = dateAndTimeFormatter.format(new Date(timePasswordChanged));
|
||||
|
@ -239,15 +205,6 @@ add_task(async function test_autofillAutocompletePassword_withGeneration() {
|
|||
// Same generated password should be used.
|
||||
checkForm(2, "", generatedPW);
|
||||
|
||||
info("filled generated password again, ensure we don't record another generatedpassword autocomplete telemetry event");
|
||||
let telemetryEvents;
|
||||
try {
|
||||
telemetryEvents = await waitForTelemetryEventsCondition(events => events.length == 2,
|
||||
{ process: "parent", filterProps: TelemetryFilterProps },
|
||||
"Wait to see if we get 2 telemetry events", 20);
|
||||
} catch (ex) {}
|
||||
ok(!telemetryEvents, "Expected to timeout waiting for there to be 2 events");
|
||||
|
||||
logins = LoginManager.getAllLogins();
|
||||
is(logins.length, 1, "Still 1 login after filling the generated password a 2nd time");
|
||||
is(logins[0].timePasswordChanged, timePasswordChanged, "Saved login wasn't changed");
|
||||
|
|
|
@ -33,7 +33,7 @@ add_task(async function test_getGeneratedPassword() {
|
|||
notEqual(password1, null, "Check password was returned");
|
||||
equal(password1.length, 15, "Check password length");
|
||||
equal(LMP._generatedPasswordsByPrincipalOrigin.size, 1, "1 added to cache");
|
||||
equal(LMP._generatedPasswordsByPrincipalOrigin.get("https://www.example.com^userContextId=6").value,
|
||||
equal(LMP._generatedPasswordsByPrincipalOrigin.get("https://www.example.com^userContextId=6"),
|
||||
password1, "Cache key and value");
|
||||
let password2 = LMP.getGeneratedPassword(99);
|
||||
equal(password1, password2, "Same password should be returned for the same origin");
|
||||
|
|
|
@ -39,7 +39,7 @@ add_task(async function test_onGeneratedPasswordFilled() {
|
|||
notEqual(password1, null, "Check password was returned");
|
||||
equal(password1.length, 15, "Check password length");
|
||||
equal(LMP._generatedPasswordsByPrincipalOrigin.size, 1, "1 added to cache");
|
||||
equal(LMP._generatedPasswordsByPrincipalOrigin.get("https://www.example.com^userContextId=6").value,
|
||||
equal(LMP._generatedPasswordsByPrincipalOrigin.get("https://www.example.com^userContextId=6"),
|
||||
password1, "Cache key and value");
|
||||
|
||||
let storageChangedPromised = TestUtils.topicObserved("passwordmgr-storage-changed",
|
||||
|
|
|
@ -423,17 +423,6 @@ pwmgr:
|
|||
release_channel_collection: opt-out
|
||||
record_in_processes: [content]
|
||||
|
||||
autocomplete_field:
|
||||
objects: ["generatedpassword"]
|
||||
methods: ["autocomplete_field"]
|
||||
description: >
|
||||
Sent the first time each unique generated password is used to fill a login field - i.e. the user selects it from from the autocomplete dropdown on a password input
|
||||
bug_numbers: [1548878]
|
||||
notification_emails: ["loines@mozilla.com", "passwords-dev@mozilla.org", "sfoster@mozilla.com"]
|
||||
record_in_processes: ["main"]
|
||||
release_channel_collection: opt-out
|
||||
expiry_version: never
|
||||
|
||||
fxa_avatar_menu:
|
||||
click:
|
||||
objects: [
|
||||
|
|
Загрузка…
Ссылка в новой задаче