Remove String generics uses in toolkit/components/extensions

RESOLVED FIXED in Firefox 53

Status

defect
P3
normal
RESOLVED FIXED
3 years ago
Last year

People

(Reporter: anba, Assigned: anba)

Tracking

Trunk
mozilla53
Dependency tree / graph

Firefox Tracking Flags

(firefox53 fixed)

Details

(Whiteboard: triaged)

Attachments

(1 attachment, 1 obsolete attachment)

The various String generic methods are non-standard APIs and we plan to warn when they're used (bug 1319926) and eventually want to remove them completely (bug 1222552). As a first step we need to replace all String generic uses in Firefox with the counterpart from String.prototype.


In toolkit/components/extensions/Extension.jsm, String.replace needs to be replaced with a call to String.prototype.replace.
Posted patch bug1319938.patch (obsolete) — Splinter Review
Attachment #8814232 - Flags: review?(aswan)
Comment on attachment 8814232 [details] [diff] [review]
bug1319938.patch

Review of attachment 8814232 [details] [diff] [review]:
-----------------------------------------------------------------

I think in both of those cases we expect the first argument to already be a string.  I'm not sure why the code was originally written in that way but looking forward, getting to either of those cases with something other than a string indicates a programming error somewhere else and should raise an exception.  Or in other words, can you remove the explicit call to the string constructor and just invoke the methods directly?
Priority: -- → P3
Whiteboard: triaged
(In reply to Andrew Swan [:aswan] from comment #2)
> Comment on attachment 8814232 [details] [diff] [review]
> bug1319938.patch
> 
> Review of attachment 8814232 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> I think in both of those cases we expect the first argument to already be a
> string.  I'm not sure why the code was originally written in that way but
> looking forward, getting to either of those cases with something other than
> a string indicates a programming error somewhere else and should raise an
> exception.  Or in other words, can you remove the explicit call to the
> string constructor and just invoke the methods directly?

We can, yes.
Updated patch to remove the explicit call to `String`.
Attachment #8814232 - Attachment is obsolete: true
Attachment #8814232 - Flags: review?(aswan)
Attachment #8815480 - Flags: review?(aswan)
Attachment #8815480 - Flags: review?(aswan) → review+
Thanks for the review!
Keywords: checkin-needed
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/a42ceecb2260
Remove String generics uses in toolkit/components/extensions. r=aswan
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/a42ceecb2260
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla53
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.