As per ES5.1 15.3.5 Properties of Function Instances, there is nothing forbidding a function to have a 'name' property. This test results in a false negative in browsers implementing such a property.
The vagueness of the spec should be addressed. Meanwhile, the test is wrong.
Agreed. The test is clearly incorrect here and I'll be disabling it today.
Actually, I was wrong, the spec isn't vague. Section 16:
"An implementation may provide additional types, values, objects, properties, and functions beyond those described in this specification."
I've modified the test in the following manner:
var desc = Object.getOwnPropertyDescriptor(f, "name");
if (desc === undefined) {
return true;
}
return false;
has become:
var desc = Object.getOwnPropertyDescriptor(f, "functionNameHopefullyDoesNotExist");
return desc === undefined;
While I do acknowledge some ECMAScript implementation could in theory add a property named "functionNameHopefullyDoesNotExist" to Function.prototype, the probability of this seems incredibly low, and they'd likely be doing this just to break the test:)
This change will go out with the next set of test case additions from Microsoft. Leaving the bug open until this occurs and I re-enabled it on test262.
(In reply to comment #3)
> I've modified the test in the following manner:
> var desc = Object.getOwnPropertyDescriptor(f, "name");
> if (desc === undefined) {
> return true;
> }
> return false;
>
> has become:
> var desc = Object.getOwnPropertyDescriptor(f,
> "functionNameHopefullyDoesNotExist");
> return desc === undefined;
>
> While I do acknowledge some ECMAScript implementation could in theory add a
> property named "functionNameHopefullyDoesNotExist" to Function.prototype, the
> probability of this seems incredibly low, and they'd likely be doing this just
> to break the test:)
Here (https://bugs.ecmascript.org/show_bug.cgi?id=33#c5) I've provided a method which, based on a object creates a property name which is different from all property names present on the object. Might be useful to add to the harness.
Got ambitious and pushed the change out to Mercurial early.