Closed Bug 660724 Opened 13 years ago Closed 13 years ago

Make sure page-mod can use regex "include" properties now that match-pattern supports them.

Categories

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

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: KWierso, Assigned: irakli)

Details

Attachments

(1 file)

Match-pattern was updated to support regexes, but page-mod is apparently still only allowing the other match-patterns:
>> let include = options.include;
>>     let rules = this.include = Rules();
>>     rules.on('add', this._onRuleAdd = this._onRuleAdd.bind(this));
>>     rules.on('remove', this._onRuleRemove =
>> this._onRuleRemove.bind(this));
>> 
>>     // Validate 'include'
>>     if (typeof(include) == "object" && !Array.isArray(include))
>>       throw new Error(ERR_INCLUDE);
>>     if (typeof(include) == "number" || typeof(include) == "undefined")
>>       throw new Error(ERR_INCLUDE);
>> 
>>     if (Array.isArray(include))
>>       rules.add.apply(null, include);
>>     else
>>       rules.add(include); 

Shouldn't match-pattern be more than capable of validating/enforcing its own rules?
Perhaps we wanted page-mod's error messages to be more page-mod-specific?

In any case, yes, the page-mod constructor should accept regex patterns, whether it enforces its own parameters or relies on match-pattern to do so for it.

Irakli: any chance you can make this happen?  Keep in mind that the smallest, lowest-risk patch to do this is the best one, even if in the long-term there are bigger refactoring changes we may want to do here.
OS: Windows 7 → All
Priority: -- → P1
Hardware: x86 → All
Target Milestone: --- → 1.0
Assignee: nobody → rFobic
Attachment #536630 - Flags: review?(dietrich)
Comment on attachment 536630 [details]
Pointer to Github pull request: https://github.com/mozilla/addon-sdk/pull/179/files

r=me w/ comments addressed
Attachment #536630 - Flags: review?(dietrich) → review+
Landed with merge commit:

https://github.com/mozilla/addon-sdk/commit/661e294caa97eef7fcbe64d10c6fb8503716c54f

Change commit:

https://github.com/mozilla/addon-sdk/commit/ab88a3dae7b5ae37eecca052822fd9a73291a5d7


Note: this change fixes the problem, but "pattern is undefined" is vague, and it'll be hard for addon developers who encounter the error to figure out that it's about the include option. Which is probably why PageMod has custom validation in the first place.

Anyway, I'm ok with merging this to fix the immediate problem, but we need to make this error message much better.
Status: NEW → RESOLVED
Closed: 13 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: