Closed
Bug 1134850
Opened 10 years ago
Closed 9 years ago
Move password manager recipes to its own file
Categories
(Toolkit :: Password Manager, enhancement)
Toolkit
Password Manager
Tracking
()
Tracking | Status | |
---|---|---|
firefox42 | --- | fixed |
People
(Reporter: MattN, Assigned: rchtara)
References
(Blocks 1 open bug)
Details
(Whiteboard: pwmgr42)
Attachments
(1 file)
Bug 1134846 has recipes inline in the JSM but we will want these in their own file (with the path possibly specified by a pref) so that it's easier to maintain and update (over the wire).
Flags: qe-verify-
Flags: firefox-backlog+
Assignee | ||
Updated•9 years ago
|
Assignee: nobody → rchtara
Assignee | ||
Comment 1•9 years ago
|
||
Bug 1134850 - Move password manager recipes to its own file
Assignee | ||
Comment 2•9 years ago
|
||
Comment on attachment 8630734 [details]
MozReview Request: Bug 1134850 - Move password manager recipes to its own file
https://reviewboard.mozilla.org/r/12791/#review11331
Ship It\!
Attachment #8630734 -
Flags: review+
Assignee | ||
Comment 3•9 years ago
|
||
Comment on attachment 8630734 [details]
MozReview Request: Bug 1134850 - Move password manager recipes to its own file
Bug 1134850 - Move password manager recipes to its own file
Attachment #8630734 -
Flags: review+ → review?(MattN+bmo)
Reporter | ||
Comment 4•9 years ago
|
||
Comment on attachment 8630734 [details]
MozReview Request: Bug 1134850 - Move password manager recipes to its own file
https://reviewboard.mozilla.org/r/12791/#review11333
This is looking pretty good. Please ensure the tests pass locally. I'd like to take another look after the changes below.
::: toolkit/components/passwordmgr/LoginRecipes.jsm:263
(Diff revision 1)
> const DEFAULT_RECIPES = {
> "siteRecipes": [
> {
> "description": "okta uses a hidden password field to disable filling",
> "hosts": ["mozilla.okta.com"],
> "passwordSelector": "#pass-signin"
> },
You forgot to delete the DEFAULT_RECIPES object from this file.
::: toolkit/components/passwordmgr/content/recipes.json
(Diff revision 1)
> -/* This Source Code Form is subject to the terms of the Mozilla Public
> - * 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/. */
Are you able to leave the MPL 2.0 license at the top of the file or does that make the file invalid JSON?
::: toolkit/components/passwordmgr/LoginRecipes.jsm:16
(Diff revision 1)
> Cu.import("resource://gre/modules/Services.jsm");
> Cu.import("resource://gre/modules/XPCOMUtils.jsm");
> +Cu.import("resource://gre/modules/NetUtil.jsm");
Nit: keep these alphabetical
::: toolkit/components/passwordmgr/LoginRecipes.jsm:94
(Diff revision 1)
> - return this;
> + let prefs = Components.classes["@mozgilla.org/preferences-service;1"]
> + .getService(Ci.nsIPrefService).getBranch("signon.");
> + let path = prefs.getComplexValue("recipes.path", Ci.nsISupportsString).data;
You can get the preference service via Services.prefs. It's discouraged to get a branch of the preferences nowadays so you should just do:
`Services.prefs.getComplexValue("signon.recipes.path", Ci.nsISupportsString).data;`
::: toolkit/components/passwordmgr/LoginRecipes.jsm:105
(Diff revision 1)
> + var recipes = JSON.parse(data);
Nit: We almost always use `let` instead of `var`.
::: toolkit/components/passwordmgr/LoginRecipes.jsm:97
(Diff revision 1)
> + let channel = NetUtil.newChannel({uri: NetUtil.newURI(path, "UTF-8"),
> + loadUsingSystemPrincipal: true});
Can you give a content-type hint for better performance as described at https://developer.mozilla.org/en-US/Add-ons/Code_snippets/File_I_O#Read_with_content_type_hint
::: toolkit/components/passwordmgr/LoginRecipes.jsm:102
(Diff revision 1)
> + if (Components.isSuccessCode(result)) {
> + let count = stream.available();
We prefer to use early returns when an error is encountered as it makes the code more readable (less nesting). See https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style#Return_from_errors_immediately
`
if (!Components.isSuccessCode(result)) {
log.error("Error loading recipes:", e);
return;
}
let count = stream.available();
…
`
::: toolkit/components/passwordmgr/LoginRecipes.jsm:113
(Diff revision 1)
> + }
> + catch (e) {
Brace on the same line for JS please
::: toolkit/components/passwordmgr/LoginRecipes.jsm:115
(Diff revision 1)
> + log.error("Error loading recipes: ", e);
Nit: no space before the second double-quote as the logging code adds spaces itself. This applies to both log.error calls.
::: toolkit/components/passwordmgr/LoginRecipes.jsm:110
(Diff revision 1)
> + log.error("Error loading recipes: ", result);
The two log.error messages should be different so the specific failure case can be distinguished in bug reports.
Attachment #8630734 -
Flags: review?(MattN+bmo)
Assignee | ||
Comment 5•9 years ago
|
||
Comment on attachment 8630734 [details]
MozReview Request: Bug 1134850 - Move password manager recipes to its own file
Bug 1134850 - Move password manager recipes to its own file
Attachment #8630734 -
Flags: review?(MattN+bmo)
Assignee | ||
Comment 6•9 years ago
|
||
Assignee | ||
Comment 7•9 years ago
|
||
https://reviewboard.mozilla.org/r/12791/#review11333
> Are you able to leave the MPL 2.0 license at the top of the file or does that make the file invalid JSON?
I tried to do it, but it breaks the json
> Can you give a content-type hint for better performance as described at https://developer.mozilla.org/en-US/Add-ons/Code_snippets/File_I_O#Read_with_content_type_hint
when I add
channel.contentType = "application/json";
an exception is going to be thrown
Reporter | ||
Comment 8•9 years ago
|
||
https://reviewboard.mozilla.org/r/12791/#review11333
> when I add
> channel.contentType = "application/json";
> an exception is going to be thrown
What is the exception message?
Assignee | ||
Comment 9•9 years ago
|
||
Comment on attachment 8630734 [details]
MozReview Request: Bug 1134850 - Move password manager recipes to its own file
Bug 1134850 - Move password manager recipes to its own file
Assignee | ||
Comment 10•9 years ago
|
||
https://reviewboard.mozilla.org/r/12791/#review11333
> What is the exception message?
I have tried it again and it worked, I have just a small issue with the debegger, I was testing this patch by ading a breakpoint into .asyncFetch callback. But, it wasnt stop. But today it worked : magic :)
Reporter | ||
Comment 11•9 years ago
|
||
Comment on attachment 8630734 [details]
MozReview Request: Bug 1134850 - Move password manager recipes to its own file
https://reviewboard.mozilla.org/r/12791/#review11427
::: toolkit/components/passwordmgr/LoginRecipes.jsm:92
(Diff revision 3)
> // XXX: Bug 1134850 will handle reading recipes from a file.
Delete this comment
::: toolkit/components/passwordmgr/LoginRecipes.jsm:31
(Diff revision 3)
> * @param {boolean} [aOptions.defaults=true] whether to load default application recipes.
> */
> function LoginRecipesParent(aOptions = { defaults: true }) {
My original vision was that aOptions.defaults would be the URI to load the recipes from. I still think that makes sense and is easier for unit testing. Can you changing the default value of `aOptions.defaults` to `null` and change the 3 callers[1] for this. The test 2 callers can pass no argument and the "LoginManagerParent.jsm" caller can pass the result of `let path = Services.prefs.getComplexValue("signon.recipes.path", Ci.nsISupportsString).data;`
[1] https://mxr.mozilla.org/mozilla-central/search?string=new+LoginRecipesParent
::: toolkit/components/passwordmgr/LoginRecipes.jsm:95
(Diff revision 3)
> + let channel = NetUtil.newChannel({uri: NetUtil.newURI(path, "UTF-8"),
> + loadUsingSystemPrincipal: true});
replace `path` with `this._defaults`
::: toolkit/components/passwordmgr/LoginRecipes.jsm:93
(Diff revision 3)
> - this.initializationPromise = this.load(DEFAULT_RECIPES).then(resolve => {
> + let self = this;
We generally avoid assigning `this` to temporary variables in most cases since we have modern JS methods like Function.bind instead.
::: toolkit/components/passwordmgr/LoginRecipes.jsm:100
(Diff revision 3)
> + NetUtil.asyncFetch(channel, function (stream, result) {
Bind this function instead of using `self` and give the function a name for stack traces e.g. `fetchedRecipes`
::: toolkit/components/passwordmgr/LoginRecipes.jsm:102
(Diff revision 3)
> + log.error("Error fetching the file of the recipes:", result);
Nit: s/file of the recipes/recipe file/
(Same for the other log.error)
I think we should throw instead of continuing execution:
`throw new Error("Error fetching recipe file:" + result);`
::: toolkit/components/passwordmgr/LoginRecipes.jsm:113
(Diff revision 3)
> + log.error("Error reading the file of the recipes:", e);
log.error("Error reading the recipe file:", e);
throw new Error("Error reading recipe file:" + e);
Attachment #8630734 -
Flags: review?(MattN+bmo)
Assignee | ||
Comment 12•9 years ago
|
||
Comment on attachment 8630734 [details]
MozReview Request: Bug 1134850 - Move password manager recipes to its own file
Bug 1134850 - Move password manager recipes to its own file
Attachment #8630734 -
Flags: review?(MattN+bmo)
Assignee | ||
Comment 13•9 years ago
|
||
Reporter | ||
Comment 14•9 years ago
|
||
Comment on attachment 8630734 [details]
MozReview Request: Bug 1134850 - Move password manager recipes to its own file
https://reviewboard.mozilla.org/r/12791/#review11471
It looks like you have 2 sets of test failures to deal with still.
::: toolkit/components/passwordmgr/LoginManagerParent.jsm:156
(Diff revision 4)
> + defaults: Services.prefs.getComplexValue("signon.recipes.path", Ci.nsISupportsString).data
Nit: Object literals should have trailing commas at the end of the line so that blame doesn't change when a property gets added at the end afterwards.
::: toolkit/components/passwordmgr/LoginRecipes.jsm:60
(Diff revision 4)
> _recipesByHost: null,
> -
> /**
Nit: revert this
Attachment #8630734 -
Flags: review?(MattN+bmo)
Assignee | ||
Comment 15•9 years ago
|
||
Comment on attachment 8630734 [details]
MozReview Request: Bug 1134850 - Move password manager recipes to its own file
Bug 1134850 - Move password manager recipes to its own file
Attachment #8630734 -
Flags: review?(MattN+bmo)
Assignee | ||
Comment 16•9 years ago
|
||
Comment on attachment 8630734 [details]
MozReview Request: Bug 1134850 - Move password manager recipes to its own file
Bug 1134850 - Move password manager recipes to its own file
Reporter | ||
Comment 17•9 years ago
|
||
Comment on attachment 8630734 [details]
MozReview Request: Bug 1134850 - Move password manager recipes to its own file
https://reviewboard.mozilla.org/r/12791/#review11597
This can be simplified a bit: https://mattn.pastebin.mozilla.org/8839213
::: toolkit/components/passwordmgr/LoginRecipes.jsm:99
(Diff revision 6)
> + var dataPromise = new Promise(function(resolve) {
Nit: s/var/let/
::: toolkit/components/passwordmgr/LoginRecipes.jsm:110
(Diff revision 6)
> + var self = this;
This is unused.
Attachment #8630734 -
Flags: review?(MattN+bmo) → review+
Assignee | ||
Updated•9 years ago
|
Attachment #8630734 -
Flags: review+ → review?(MattN+bmo)
Assignee | ||
Comment 18•9 years ago
|
||
Comment on attachment 8630734 [details]
MozReview Request: Bug 1134850 - Move password manager recipes to its own file
Bug 1134850 - Move password manager recipes to its own file
Reporter | ||
Comment 19•9 years ago
|
||
Comment on attachment 8630734 [details]
MozReview Request: Bug 1134850 - Move password manager recipes to its own file
https://reviewboard.mozilla.org/r/12791/#review11607
Ship It!
Attachment #8630734 -
Flags: review?(MattN+bmo) → review+
Assignee | ||
Comment 20•9 years ago
|
||
Assignee | ||
Comment 21•9 years ago
|
||
Assignee | ||
Comment 22•9 years ago
|
||
Comment on attachment 8630734 [details]
MozReview Request: Bug 1134850 - Move password manager recipes to its own file
Bug 1134850 - Move password manager recipes to its own file: fix broken tests
Attachment #8630734 -
Attachment description: MozReview Request: Bug 1134850 - Move password manager recipes to its own file → MozReview Request: Bug 1134850 - Move password manager recipes to its own file: fix broken tests
Attachment #8630734 -
Flags: review+ → review?(MattN+bmo)
Assignee | ||
Updated•9 years ago
|
Attachment #8630734 -
Attachment description: MozReview Request: Bug 1134850 - Move password manager recipes to its own file: fix broken tests → MozReview Request: Bug 1134850 - Move password manager recipes to its own file
Assignee | ||
Comment 23•9 years ago
|
||
Comment on attachment 8630734 [details]
MozReview Request: Bug 1134850 - Move password manager recipes to its own file
Bug 1134850 - Move password manager recipes to its own file
Assignee | ||
Comment 24•9 years ago
|
||
The try job failed. I have an issue which I hope its fixed .
the new try jon is here
https://treeherder.mozilla.org/#/jobs?repo=try&revision=e29070db5ae4
Assignee | ||
Updated•9 years ago
|
Iteration: --- → 42.2 - Jul 27
Assignee | ||
Updated•9 years ago
|
Status: NEW → ASSIGNED
Reporter | ||
Updated•9 years ago
|
Attachment #8630734 -
Flags: review?(MattN+bmo) → review+
Reporter | ||
Comment 25•9 years ago
|
||
Comment on attachment 8630734 [details]
MozReview Request: Bug 1134850 - Move password manager recipes to its own file
https://reviewboard.mozilla.org/r/12791/#review11863
Ship It!
Assignee | ||
Updated•9 years ago
|
Keywords: checkin-needed
Comment 26•9 years ago
|
||
Keywords: checkin-needed
Comment 27•9 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
status-firefox42:
--- → fixed
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla42
Updated•9 years ago
|
Whiteboard: pwmgr42
You need to log in
before you can comment on or make changes to this bug.
Description
•