Update web-platform-tests to revision 78f764c05c229883e87ad135c7153051a66e2851

This commit is contained in:
WPT Sync Bot 2019-03-06 20:32:15 -05:00
parent 55347aa39f
commit bf84a079f9
1983 changed files with 58006 additions and 31437 deletions

View file

@ -1674,7 +1674,122 @@ IdlInterface.prototype.test_self = function()
}.bind(this), this.name + " interface: legacy window alias");
}
// TODO: Test named constructors if I find any interfaces that have them.
if (this.has_extended_attribute("NamedConstructor")) {
var constructors = this.extAttrs
.filter(function(attr) { return attr.name == "NamedConstructor"; });
if (constructors.length !== 1) {
throw new IdlHarnessError("Internal error: missing support for multiple NamedConstructor extended attributes");
}
var constructor = constructors[0];
var min_length = minOverloadLength([constructor]);
subsetTestByKey(this.name, test, function()
{
// This function tests WebIDL as of 2019-01-14.
// "for every [NamedConstructor] extended attribute on an exposed
// interface, a corresponding property must exist on the ECMAScript
// global object. The name of the property is the
// [NamedConstructor]'s identifier, and its value is an object
// called a named constructor, ... . The property has the attributes
// { [[Writable]]: true, [[Enumerable]]: false,
// [[Configurable]]: true }."
var name = constructor.rhs.value;
assert_own_property(self, name);
var desc = Object.getOwnPropertyDescriptor(self, name);
assert_equals(desc.value, self[name], "wrong value in " + name + " property descriptor");
assert_true(desc.writable, name + " should be writable");
assert_false(desc.enumerable, name + " should not be enumerable");
assert_true(desc.configurable, name + " should be configurable");
assert_false("get" in desc, name + " should not have a getter");
assert_false("set" in desc, name + " should not have a setter");
}.bind(this), this.name + " interface: named constructor");
subsetTestByKey(this.name, test, function()
{
// This function tests WebIDL as of 2019-01-14.
// "2. Let F be ! CreateBuiltinFunction(realm, steps,
// realm.[[Intrinsics]].[[%FunctionPrototype%]])."
var name = constructor.rhs.value;
var value = self[name];
assert_equals(typeof value, "function", "type of value in " + name + " property descriptor");
assert_not_equals(value, this.get_interface_object(), "wrong value in " + name + " property descriptor");
assert_equals(Object.getPrototypeOf(value), Function.prototype, "wrong value for " + name + "'s prototype");
}.bind(this), this.name + " interface: named constructor object");
subsetTestByKey(this.name, test, function()
{
// This function tests WebIDL as of 2019-01-14.
// "7. Let proto be the interface prototype object of interface I
// in realm.
// "8. Perform ! DefinePropertyOrThrow(F, "prototype",
// PropertyDescriptor{
// [[Value]]: proto, [[Writable]]: false,
// [[Enumerable]]: false, [[Configurable]]: false
// })."
var name = constructor.rhs.value;
var expected = this.get_interface_object().prototype;
var desc = Object.getOwnPropertyDescriptor(self[name], "prototype");
assert_equals(desc.value, expected, "wrong value for " + name + ".prototype");
assert_false(desc.writable, "prototype should not be writable");
assert_false(desc.enumerable, "prototype should not be enumerable");
assert_false(desc.configurable, "prototype should not be configurable");
assert_false("get" in desc, "prototype should not have a getter");
assert_false("set" in desc, "prototype should not have a setter");
}.bind(this), this.name + " interface: named constructor prototype property");
subsetTestByKey(this.name, test, function()
{
// This function tests WebIDL as of 2019-01-14.
// "3. Perform ! SetFunctionName(F, id)."
var name = constructor.rhs.value;
var desc = Object.getOwnPropertyDescriptor(self[name], "name");
assert_equals(desc.value, name, "wrong value for " + name + ".name");
assert_false(desc.writable, "name should not be writable");
assert_false(desc.enumerable, "name should not be enumerable");
assert_true(desc.configurable, "name should be configurable");
assert_false("get" in desc, "name should not have a getter");
assert_false("set" in desc, "name should not have a setter");
}.bind(this), this.name + " interface: named constructor name");
subsetTestByKey(this.name, test, function()
{
// This function tests WebIDL as of 2019-01-14.
// "4. Initialize S to the effective overload set for constructors
// with identifier id on interface I and with argument count 0.
// "5. Let length be the length of the shortest argument list of
// the entries in S.
// "6. Perform ! SetFunctionLength(F, length)."
var name = constructor.rhs.value;
var desc = Object.getOwnPropertyDescriptor(self[name], "length");
assert_equals(desc.value, min_length, "wrong value for " + name + ".length");
assert_false(desc.writable, "length should not be writable");
assert_false(desc.enumerable, "length should not be enumerable");
assert_true(desc.configurable, "length should be configurable");
assert_false("get" in desc, "length should not have a getter");
assert_false("set" in desc, "length should not have a setter");
}.bind(this), this.name + " interface: named constructor length");
subsetTestByKey(this.name, test, function()
{
// This function tests WebIDL as of 2019-01-14.
// "1. Let steps be the following steps:
// " 1. If NewTarget is undefined, then throw a TypeError."
var name = constructor.rhs.value;
var args = constructor.arguments.map(function(arg) {
return create_suitable_object(arg.idlType);
});
assert_throws(new TypeError(), function() {
self[name](...args);
}.bind(this));
}.bind(this), this.name + " interface: named constructor without 'new'");
}
subsetTestByKey(this.name, test, function()
{