Closed Bug 757802 Opened 13 years ago Closed 12 years ago

context-menu.URLContext ctor should accept RegExp in addition to strings

Categories

(Add-on SDK Graveyard :: General, defect, P2)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: clement, Assigned: mossop)

References

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20100101 Firefox/12.0 Iceweasel/12.0 Build ID: 20120517164517 Steps to reproduce: I tried to pass a RegExp to URLContext ctor Actual results: An exception was raised due to type checking in the ctor Expected results: URLContext allow the user to pass MatchPattern strings and use MatchPatterns internally. MatchPatterns can be constructed from both MatchPattern string and regular expressions. In the current implementation, URLContext artificially limit the usage of regular expressions in a context-menu. Using regular expressions can be useful to enable an Item only for a specific page. I propose to relax the type checking performed by the ctor to also allow regular expressions.
Attached patch patchSplinter Review
Status: UNCONFIRMED → NEW
Ever confirmed: true
Assignee: nobody → rFobic
Comment on attachment 626399 [details] [diff] [review] patch Review of attachment 626399 [details] [diff] [review]: ----------------------------------------------------------------- I think right way to go about this would be to improve match-pattern module itself and let it handle with validations. ::: packages/addon-kit/lib/context-menu.js @@ +500,4 @@ > let opts = apiUtils.validateOptions({ patterns: patterns }, { > patterns: { > map: function (v) apiUtils.getTypeOf(v) === "array" ? v : [v], > + ok: function (v) v.every(function (p) typeof(p) === "string" || p.constructor.name === "RegExp"), p may not have a constructor so it's error prone. You should just use `isRegExp` from "api-utils/type" module.
Attachment #626399 - Flags: review?(rFobic) → review-
Clément please let me know if you plan to update a patch.
Depends on: 788324
(In reply to Irakli Gozilalishvili [:irakli] [:gozala] [@gozala] from comment #2) > Comment on attachment 626399 [details] [diff] [review] > patch > > Review of attachment 626399 [details] [diff] [review]: > ----------------------------------------------------------------- > > I think right way to go about this would be to improve match-pattern module > itself and let it handle with validations. This happened as a part of bug 627386 so all we need to do is fix the validation bits. I have this fixed in my work on bug 788324
Assignee: rFobic → dtownsend+bugmail
Status: NEW → ASSIGNED
Fixed by bug 788324
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → 1.13
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: