« Bugzilla Issues Index

#290 — Coverage: Date.prototype.setXXX functions evaluate all parameters

Current engines vary widely in their implementations of the various Date.prototype.setXXX functions.

Some examples per browser:

IE: `new Date(0).setMinutes(void 0, {valueOf:function(){throw 'xxx'}})`
=> returns `NaN` instead of throwing 'xxx'

Opera: `new Date(NaN).setMinutes({valueOf: function(){throw 'xxx'}})`
=> returns `NaN` instead of throwing 'xxx'

Firefox: `new Date(NaN).setMinutes(0, {valueOf:function(){throw 'xxx'}})`
=> returns `NaN` instead of throwing 'xxx'

That means the engines perform different "optimizations" to detect possible invalid date values before evaluating (here: calling ToNumber) all parameters. These optimizations seem to include partial evaluation of the parameters until a NaN value is found and inspection of the current time ([[PrimitiveValue]] of the date object) to check for NaN.