Closed
Bug 557591
Opened 14 years ago
Closed 13 years ago
code audit and create unit test plan for util.js
Categories
(Firefox :: Sync, defect)
Firefox
Sync
Tracking
()
RESOLVED
FIXED
People
(Reporter: mconnor, Assigned: Mardak)
Details
Attachments
(1 file)
2.62 KB,
patch
|
mconnor
:
review+
|
Details | Diff | Splinter Review |
No description provided.
Reporter | ||
Updated•14 years ago
|
Flags: blocking-weave1.3+
Reporter | ||
Updated•14 years ago
|
Target Milestone: --- → 1.3
Reporter | ||
Updated•14 years ago
|
Whiteboard: [final]
Assignee | ||
Updated•14 years ago
|
Whiteboard: [final]
Reporter | ||
Comment 1•14 years ago
|
||
Unused functions to remove: * xpath * getTmp * makeURL * sha1 ? * _openChromeWindow * openWindow (only caller is _openChromeWindow) Refactor/reexamine: * deref ** Can simply be inlined, only has one consumer (deferGetSet) * isArray ** why isn't this just an instanceof check? * deepCopy ** only used in tests, can we pull out of Utils and put somewhere for test-only things? * formatFrame ** only one consumer, just inline * stackTraceFromFrame ** only one consumer, just inline * digest ** sha1 isn't used anywhere, if we remove that, we can inline into sha256HMAC * openDialog ** one consumer, inline to openGenericDialog * _openWin (if openWindow is removed, only caller is openDialog, and it can be inlined to openGenericDialog) * arraySub ** can be inlined/made an inline function for Engine._processIncoming Functions that we need test coverage for: * catch * lock * notify * makeGUID * anno * ensureOneOpen (filed Bug 564809 on removing the only consumer of this call) * getProfileFile (does this need to be a public method? only consumers are in util.js, except for where it's overridden in the test harnesses) * deferGetSet * lazy(2) * lazyCb(2) * lazySvc * lazyStrings * stackTrace * deepEquals * sha256HMAC * makeURI * jsonLoad * jsonSave * delay * openGenericDialog * getIcon * getErrorString * bind2
Assignee: mconnor → edilee
Assignee | ||
Comment 2•14 years ago
|
||
(In reply to comment #1) > * isArray > ** why isn't this just an instanceof check? Components.utils.import("resource://weave/service.js"); e = Weave.Engines.getAll(); [e instanceof Array, Weave.Utils.isArray(e), e.constructor.name] [false,true,Array] The Array global object is a different instance across scripts. > * deepCopy > ** only used in tests, can we pull out of Utils and put somewhere for test-only I don't think the code is being exercised in the tests either.. Perhaps just remove that and the test code calling it? > * getProfileFile (does this need to be a public method? What do you intend for not-public? Just make it _ or actually scope it to the script? > * lazy(2) > * lazyCb(2) I suppose now isn't the time to rename these functions? > * openGenericDialog Eh.. mm..mm... Is it supposed to test the magic _genericDialogType o.O
Assignee | ||
Comment 3•14 years ago
|
||
http://hg.mozilla.org/labs/weave/rev/352e44c78a54 Add tests for Utils.catch.
Assignee | ||
Comment 4•14 years ago
|
||
http://hg.mozilla.org/labs/weave/rev/68332ec4d321 Add tests for Utils.lock.
Assignee | ||
Comment 5•14 years ago
|
||
http://hg.mozilla.org/labs/weave/rev/c9e24ee9cbf5 Add tests for Utils.notify.
Assignee | ||
Comment 6•14 years ago
|
||
http://hg.mozilla.org/labs/weave/rev/10872842b4e6 Add tests for Utils.makeGUID.
Assignee | ||
Comment 7•14 years ago
|
||
http://hg.mozilla.org/labs/weave/rev/e31f480a1474 Add tests for Utils.anno.
Reporter | ||
Comment 8•14 years ago
|
||
(In reply to comment #2) > (In reply to comment #1) > > * isArray > > ** why isn't this just an instanceof check? > Components.utils.import("resource://weave/service.js"); e = > Weave.Engines.getAll(); [e instanceof Array, Weave.Utils.isArray(e), > e.constructor.name] > > [false,true,Array] > > The Array global object is a different instance across scripts. > > > * deepCopy > > ** only used in tests, can we pull out of Utils and put somewhere for test-only > I don't think the code is being exercised in the tests either.. Perhaps just > remove that and the test code calling it? Works for me. > > * getProfileFile (does this need to be a public method? > What do you intend for not-public? Just make it _ or actually scope it to the > script? just making it _ is fine for now, scoping internal methods to the script is something we should look at doing here and in other places post-1.3. File a bug on that, then forget about it? :) > > * lazy(2) > > * lazyCb(2) > I suppose now isn't the time to rename these functions? Eh, if it's find/replace, go for it. Just post to the dev list. > > * openGenericDialog > Eh.. mm..mm... Is it supposed to test the magic _genericDialogType o.O Yeah, that's probably more of a litmus/mozmill thing, since it's basically a UI element test.
Assignee | ||
Comment 9•14 years ago
|
||
http://hg.mozilla.org/labs/weave/rev/fb20aadca0c0 Add tests for Utils.deferGetSet.
Assignee | ||
Comment 10•14 years ago
|
||
http://hg.mozilla.org/labs/weave/rev/9ab9f161b8d8 Add tests for Utils.lazy/cb.
Assignee | ||
Comment 11•14 years ago
|
||
http://hg.mozilla.org/labs/weave/rev/36b86415eed6 Add tests for Utils.lazy2/cb.
Assignee | ||
Comment 12•14 years ago
|
||
Minor code change that adds a fake service for testing
Attachment #445790 -
Flags: review?(mconnor)
Reporter | ||
Updated•14 years ago
|
Attachment #445790 -
Flags: review?(mconnor) → review+
Assignee | ||
Comment 13•14 years ago
|
||
http://hg.mozilla.org/labs/weave/rev/bee3d7b7c0c9 Add a fake service that definitely won't exist for testing purposes.
Assignee | ||
Comment 14•14 years ago
|
||
http://hg.mozilla.org/labs/weave/rev/186f76392041 Add tests for Utils.stackTrace.
Assignee | ||
Comment 15•14 years ago
|
||
http://hg.mozilla.org/labs/weave/rev/15fc5abd143c Add tests for Utils.sha256HMAC.
Assignee | ||
Comment 16•14 years ago
|
||
http://hg.mozilla.org/labs/weave/rev/0883371a95ce Add tests for Utils.makeURI.
Assignee | ||
Comment 17•14 years ago
|
||
http://hg.mozilla.org/labs/weave/rev/bced60257f86 Add tests for Utils.jsonSave and Utils.jsonLoad.
Assignee | ||
Comment 18•14 years ago
|
||
http://hg.mozilla.org/labs/weave/rev/4cdb979cf004 Add tests for Utils.sha1.
Assignee | ||
Comment 19•14 years ago
|
||
http://hg.mozilla.org/labs/weave/rev/b73f4380b000 (new url from hg magic) Add tests for Utils.anno with invalid uris.
Assignee | ||
Comment 20•14 years ago
|
||
http://hg.mozilla.org/labs/weave/rev/cb1520aff0db (new url from hg magic) Add tests for Utils.sha1.
Reporter | ||
Updated•14 years ago
|
Target Milestone: 1.3 → 2.0
Reporter | ||
Updated•14 years ago
|
Flags: blocking-weave1.3+
Reporter | ||
Updated•13 years ago
|
Target Milestone: 2.0 → ---
Comment 21•13 years ago
|
||
(In reply to Mike Connor [:mconnor] from comment #1) > Unused functions to remove: > * xpath > * getTmp > * makeURL > * sha1 ? > * _openChromeWindow > * openWindow (only caller is _openChromeWindow) These have all been removed apart from makeURL which is actually used in one place. So we could just inline it there. > Refactor/reexamine: > > * deref > ** Can simply be inlined, only has one consumer (deferGetSet) Already done in bug 636478. > * isArray > ** why isn't this just an instanceof check? The correct thing to use these days is Array.isArray and we're doing so as of bug 681863. > * deepCopy > ** only used in tests, can we pull out of Utils and put somewhere for > test-only things? Good point! Can move to head_helpers.js > * formatFrame > ** only one consumer, just inline > * stackTraceFromFrame > ** only one consumer, just inline Yup. > * digest > ** sha1 isn't used anywhere, if we remove that, we can inline into sha256HMAC > * openDialog > ** one consumer, inline to openGenericDialog > * _openWin (if openWindow is removed, only caller is openDialog, and it can > be inlined to openGenericDialog) These are gone. > * arraySub > ** can be inlined/made an inline function for Engine._processIncoming SyncEngine uses arraySub and arrayUnion in several places. > Functions that we need test coverage for: > * catch > * lock > * notify > * makeGUID > * deferGetSet > * lazyStrings > * stackTrace > * deepEquals > * makeURI > * jsonLoad > * jsonSave > * delay > * getIcon > * getErrorString We have tests for these now. > * anno > * lazy(2) > * lazyCb(2) > * lazySvc > * sha256HMAC > * openGenericDialog These are gone. Good riddance. > * ensureOneOpen (filed Bug 564809 on removing the only consumer of this call) It's tested but AFAICT unused. Nuke it. > * getProfileFile (does this need to be a public method? only consumers are > in util.js, except for where it's overridden in the test harnesses) Yup. Now it's just an internal method to Utils.json{Load|Save}. Inline! > * bind2 We should replace all consumers with ES5's Function.prototype.bind. To sum up: * Move Utils.deepCopy to head_helpers.js * Inline use of Utils.makeURL (if it's even necessary) * Inline formatFrame and stackTraceFromFrame into Utils.exceptionStr * Nuke Utils.ensoreOneOpen (no consumers) * Inline Utils.getProfileFile. * Replace Utils.bind2 with Function.prototype.bind. I like this much shorter list :)
Updated•13 years ago
|
Whiteboard: [good first bug]
Reporter | ||
Comment 22•13 years ago
|
||
Spun off bug 701967 for comment 21, resolving this FIXED.
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Whiteboard: [good first bug]
Updated•6 years ago
|
Component: Firefox Sync: Backend → Sync
Product: Cloud Services → Firefox
You need to log in
before you can comment on or make changes to this bug.
Description
•