archives

« Bugzilla Issues Index

#1600 — test ch15/15.2/15.2.3/15.2.3.2/15.2.3.2-2-30.js assumes Object.getPrototypeOf returns an object


Test ch15/15.2/15.2.3/15.2.3.2/15.2.3.2-2-30.js tests Object.getPrototypeOf for the global object. However, it checks the returned prototype by calling isPrototypeOf on it, thus failing if it does not define it (for instance if the prototype is null, or if does not derive from the object prototype object).

Here is a suggested change for the test (credits to Paul Ruizendaal who suggested it on the list):

function testcase() {
var proto = Object.getPrototypeOf(fnGlobalObject());
return proto===null || Object.prototype.isPrototypeOf.call(proto, fnGlobalObject());
}


I worry the global object having Object.prototype *somewhere* in its prototype chain might be required for the web.


Currently, the specification says the following for the global object (15.1):

The values of the [[Prototype]] and [[Class]] internal properties of the global object are implementation- dependent.

If constraints are assumed by web browsers, the specification may need to be changed.


Regardless of whether we end up changing the spec requirement for the global object's [[Prototype]], this test should be changed. Here's my suggestion:

function testcase() {
var proto = {};
return proto === Object.getPrototypeOf(Object.create(proto)) && null === Object.getPrototypeOf(Object.create(null));
}