Closed Bug 409691 Opened 17 years ago Closed 17 years ago

XPCOMUtilify nsURLFormatter and add tests

Categories

(Firefox :: General, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
Firefox 3 beta3

People

(Reporter: rflint, Assigned: rflint)

Details

(Keywords: perf)

Attachments

(1 file, 1 obsolete file)

Attached patch Patch (obsolete) — Splinter Review
Found a few potential issues while writing the tests for this:
First is http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/toolkit/components/urlformatter/src/nsURLFormatter.js&rev=1.5&mark=82-94,103-104,108#82 where aFormat.replace() is using a case-insensitive RegExp but then checking against uppercase keys, so any lowercase key is simply removed.

Second is http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/toolkit/components/urlformatter/src/nsURLFormatter.js&rev=1.5&mark=94#93 where only the first space is replaced because the RegExp isn't global.

These looked a bit odd to me, but I wasn't sure if they were intentional or not and what effects changing them would have on consumers of this, so I left them out of this version of the patch.
Flags: in-testsuite?
Attachment #294482 - Flags: review?(dietrich)
(In reply to comment #0)
> Created an attachment (id=294482) [details]
> Patch
> 
> Found a few potential issues while writing the tests for this:
> First is
> http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/toolkit/components/urlformatter/src/nsURLFormatter.js&rev=1.5&mark=82-94,103-104,108#82
> where aFormat.replace() is using a case-insensitive RegExp but then checking
> against uppercase keys, so any lowercase key is simply removed.
> 

could probably remove case-insenstivity from the regex.

> Second is
> http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/toolkit/components/urlformatter/src/nsURLFormatter.js&rev=1.5&mark=94#93
> where only the first space is replaced because the RegExp isn't global.
>

hm, i don't remember offhand why this is here at all. probably best to spin off and look at the consumers of this key.
Comment on attachment 294482 [details] [diff] [review]
Patch

r=me, thanks. about the case insensitivity: i think we should probably just support uppercase keys in order to reduce error by requiring more specificity, as well as being able to easily pick out these keys when creating/editing prefs that use them.
Attachment #294482 - Flags: review?(dietrich) → review+
Attached patch For checkinSplinter Review
Cleans up this component and adds regression tests.
Attachment #294482 - Attachment is obsolete: true
Attachment #295324 - Flags: approval1.9?
Why do we want this?
(In reply to comment #4)
> Why do we want this?
> 

dascher recently blogged about the benefits of this type of cleanup: http://ascher.ca/blog/2008/01/04/gateway-drug-for-thunderbird-devs/

This patch also adds tests to a component that's a pretty instrumental to how our in-product pages work and will ensure any regressions that might affect them will be caught immediately.
Comment on attachment 295324 [details] [diff] [review]
For checkin

k - thanks!
Attachment #295324 - Flags: approval1.9? → approval1.9+
mozilla/toolkit/components/urlformatter/Makefile.in 1.2
mozilla/toolkit/components/urlformatter/src/Makefile.in 1.3
mozilla/toolkit/components/urlformatter/src/nsURLFormatter.js 1.6
mozilla/toolkit/components/urlformatter/tests/unit/head_urlformatter.js 1.1
mozilla/toolkit/components/urlformatter/tests/unit/test_urlformatter.js 1.1
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Flags: in-testsuite?
Flags: in-testsuite+
Flags: in-litmus-
Resolution: --- → FIXED
Target Milestone: --- → Firefox 3 M11
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: