src: ignore invalid mask values

- Avoiding a TypeError exception @ packValueMask.
- Added a test.
This commit is contained in:
Santiago Gimeno 2015-01-08 13:17:30 +01:00
parent ea67111025
commit 76ce6c4141
2 changed files with 21 additions and 6 deletions

View file

@ -213,13 +213,16 @@ function packValueMask(reqname, values)
if (!reqValueMask)
throw new Error(reqname + ': no value mask description');
for (var v in values)
for (var value in values)
{
var valueBit = reqValueMask[v].mask;
if (!valueBit)
throw new Error(reqname + ': incorrect value param ' + v);
masksList.push(valueBit);
bitmask |= valueBit;
var v = reqValueMask[value];
if (v) {
var valueBit = v.mask;
if (!valueBit)
throw new Error(reqname + ': incorrect value param ' + value);
masksList.push(valueBit);
bitmask |= valueBit;
}
}
/* numeric sort */

View file

@ -82,7 +82,19 @@ describe('ConfigureWindow', function() {
this.X.LowerWindow(this.wid);
});
it('should ignore invalid mask values', function(done) {
this.X.once('event', function(ev) {
ev.x.should.equal(0);
done();
});
this.X.ConfigureWindow(this.wid, { foo : 3, x : 0 }, function(err) {
console.log(err);
});
});
after(function(done) {
this.X.removeAllListeners('event');
this.X.DestroyWindow(this.wid);
this.X.DestroyWindow(this.wid_helper);
this.X.on('end', done);