Update web-platform-tests to revision 74d709131e3c91d09f1708378648a01957c47b38

This commit is contained in:
WPT Sync Bot 2018-10-13 21:57:40 -04:00
parent e4657c1496
commit 81f079c722
77 changed files with 2043 additions and 524 deletions

View file

@ -1256,6 +1256,48 @@ IdlInterface.prototype.is_global = function()
});
};
/**
* Value of the LegacyNamespace extended attribute, if any.
*
* https://heycam.github.io/webidl/#LegacyNamespace
*/
IdlInterface.prototype.get_legacy_namespace = function()
{
var legacyNamespace = this.extAttrs.find(function(attribute) {
return attribute.name === "LegacyNamespace";
});
return legacyNamespace ? legacyNamespace.rhs.value : undefined;
};
IdlInterface.prototype.get_interface_object_owner = function()
{
var legacyNamespace = this.get_legacy_namespace();
return legacyNamespace ? self[legacyNamespace] : self;
};
IdlInterface.prototype.assert_interface_object_exists = function()
{
var owner = this.get_legacy_namespace() || "self";
assert_own_property(self[owner], this.name, owner + " does not have own property " + format_value(this.name));
};
IdlInterface.prototype.get_interface_object = function() {
if (this.has_extended_attribute("NoInterfaceObject")) {
throw new IdlHarnessError(this.name + " has no interface object due to NoInterfaceObject");
}
return this.get_interface_object_owner()[this.name];
};
IdlInterface.prototype.get_qualified_name = function() {
// https://heycam.github.io/webidl/#qualified-name
var legacyNamespace = this.get_legacy_namespace();
if (legacyNamespace) {
return legacyNamespace + "." + this.name;
}
return this.name;
};
IdlInterface.prototype.has_to_json_regular_operation = function() {
return this.members.some(function(m) {
return m.is_to_json_regular_operation();
@ -1436,9 +1478,8 @@ IdlInterface.prototype.test_self = function()
// TODO: Should we test here that the property is actually writable
// etc., or trust getOwnPropertyDescriptor?
assert_own_property(self, this.name,
"self does not have own property " + format_value(this.name));
var desc = Object.getOwnPropertyDescriptor(self, this.name);
this.assert_interface_object_exists();
var desc = Object.getOwnPropertyDescriptor(this.get_interface_object_owner(), this.name);
assert_false("get" in desc, "self's property " + format_value(this.name) + " should not have a getter");
assert_false("set" in desc, "self's property " + format_value(this.name) + " should not have a setter");
assert_true(desc.writable, "self's property " + format_value(this.name) + " should be writable");
@ -1448,7 +1489,7 @@ IdlInterface.prototype.test_self = function()
if (this.is_callback()) {
// "The internal [[Prototype]] property of an interface object for
// a callback interface must be the Function.prototype object."
assert_equals(Object.getPrototypeOf(self[this.name]), Function.prototype,
assert_equals(Object.getPrototypeOf(this.get_interface_object()), Function.prototype,
"prototype of self's property " + format_value(this.name) + " is not Object.prototype");
return;
@ -1478,24 +1519,19 @@ IdlInterface.prototype.test_self = function()
// ES6 (rev 30) 19.1.3.6:
// "Else, if O has a [[Call]] internal method, then let builtinTag be
// "Function"."
assert_class_string(self[this.name], "Function", "class string of " + this.name);
assert_class_string(this.get_interface_object(), "Function", "class string of " + this.name);
// "The [[Prototype]] internal property of an interface object for a
// non-callback interface is determined as follows:"
var prototype = Object.getPrototypeOf(self[this.name]);
var prototype = Object.getPrototypeOf(this.get_interface_object());
if (this.base) {
// "* If the interface inherits from some other interface, the
// value of [[Prototype]] is the interface object for that other
// interface."
var has_interface_object =
!this.array
.members[this.base]
.has_extended_attribute("NoInterfaceObject");
if (has_interface_object) {
assert_own_property(self, this.base,
'should inherit from ' + this.base +
', but self has no such property');
assert_equals(prototype, self[this.base],
var inherited_interface = this.array.members[this.base];
if (!inherited_interface.has_extended_attribute("NoInterfaceObject")) {
inherited_interface.assert_interface_object_exists();
assert_equals(prototype, inherited_interface.get_interface_object(),
'prototype of ' + this.name + ' is not ' +
this.base);
}
@ -1513,12 +1549,13 @@ IdlInterface.prototype.test_self = function()
//
// "If I was not declared with a [Constructor] extended attribute,
// then throw a TypeError."
var interface_object = this.get_interface_object();
assert_throws(new TypeError(), function() {
self[this.name]();
}.bind(this), "interface object didn't throw TypeError when called as a function");
interface_object();
}, "interface object didn't throw TypeError when called as a function");
assert_throws(new TypeError(), function() {
new self[this.name]();
}.bind(this), "interface object didn't throw TypeError when called as a constructor");
new interface_object();
}, "interface object didn't throw TypeError when called as a constructor");
}
}.bind(this), this.name + " interface: existence and properties of interface object");
@ -1527,15 +1564,14 @@ IdlInterface.prototype.test_self = function()
// This function tests WebIDL as of 2014-10-25.
// https://heycam.github.io/webidl/#es-interface-call
assert_own_property(self, this.name,
"self does not have own property " + format_value(this.name));
this.assert_interface_object_exists();
// "Interface objects for non-callback interfaces MUST have a
// property named “length” with attributes { [[Writable]]: false,
// [[Enumerable]]: false, [[Configurable]]: true } whose value is
// a Number."
assert_own_property(self[this.name], "length");
var desc = Object.getOwnPropertyDescriptor(self[this.name], "length");
assert_own_property(this.get_interface_object(), "length");
var desc = Object.getOwnPropertyDescriptor(this.get_interface_object(), "length");
assert_false("get" in desc, this.name + ".length should not have a getter");
assert_false("set" in desc, this.name + ".length should not have a setter");
assert_false(desc.writable, this.name + ".length should not be writable");
@ -1545,7 +1581,7 @@ IdlInterface.prototype.test_self = function()
var constructors = this.extAttrs
.filter(function(attr) { return attr.name == "Constructor"; });
var expected_length = minOverloadLength(constructors);
assert_equals(self[this.name].length, expected_length, "wrong value for " + this.name + ".length");
assert_equals(this.get_interface_object().length, expected_length, "wrong value for " + this.name + ".length");
}.bind(this), this.name + " interface object length");
}
@ -1554,22 +1590,21 @@ IdlInterface.prototype.test_self = function()
// This function tests WebIDL as of 2015-11-17.
// https://heycam.github.io/webidl/#interface-object
assert_own_property(self, this.name,
"self does not have own property " + format_value(this.name));
this.assert_interface_object_exists();
// "All interface objects must have a property named “name” with
// attributes { [[Writable]]: false, [[Enumerable]]: false,
// [[Configurable]]: true } whose value is the identifier of the
// corresponding interface."
assert_own_property(self[this.name], "name");
var desc = Object.getOwnPropertyDescriptor(self[this.name], "name");
assert_own_property(this.get_interface_object(), "name");
var desc = Object.getOwnPropertyDescriptor(this.get_interface_object(), "name");
assert_false("get" in desc, this.name + ".name should not have a getter");
assert_false("set" in desc, this.name + ".name should not have a setter");
assert_false(desc.writable, this.name + ".name should not be writable");
assert_false(desc.enumerable, this.name + ".name should not be enumerable");
assert_true(desc.configurable, this.name + ".name should be configurable");
assert_equals(self[this.name].name, this.name, "wrong value for " + this.name + ".name");
assert_equals(this.get_interface_object().name, this.name, "wrong value for " + this.name + ".name");
}.bind(this), this.name + " interface object name");
}
@ -1608,9 +1643,9 @@ IdlInterface.prototype.test_self = function()
if (exposed_in(exposure_set(this, this.exposureSet)) && 'document' in self) {
for (alias of aliases) {
assert_true(alias in self, alias + " should exist");
assert_equals(self[alias], self[this.name], "self." + alias + " should be the same value as self." + this.name);
assert_equals(self[alias], this.get_interface_object(), "self." + alias + " should be the same value as self." + this.get_qualified_name());
var desc = Object.getOwnPropertyDescriptor(self, alias);
assert_equals(desc.value, self[this.name], "wrong value in " + alias + " property descriptor");
assert_equals(desc.value, this.get_interface_object(), "wrong value in " + alias + " property descriptor");
assert_true(desc.writable, alias + " should be writable");
assert_false(desc.enumerable, alias + " should not be enumerable");
assert_true(desc.configurable, alias + " should be configurable");
@ -1636,11 +1671,10 @@ IdlInterface.prototype.test_self = function()
return;
}
assert_own_property(self, this.name,
"self does not have own property " + format_value(this.name));
this.assert_interface_object_exists();
if (this.is_callback()) {
assert_false("prototype" in self[this.name],
assert_false("prototype" in this.get_interface_object(),
this.name + ' should not have a "prototype" property');
return;
}
@ -1652,9 +1686,9 @@ IdlInterface.prototype.test_self = function()
// properties that correspond to the regular attributes and regular
// operations defined on the interface, and is described in more detail
// in section 4.5.4 below."
assert_own_property(self[this.name], "prototype",
assert_own_property(this.get_interface_object(), "prototype",
'interface "' + this.name + '" does not have own property "prototype"');
var desc = Object.getOwnPropertyDescriptor(self[this.name], "prototype");
var desc = Object.getOwnPropertyDescriptor(this.get_interface_object(), "prototype");
assert_false("get" in desc, this.name + ".prototype should not have a getter");
assert_false("set" in desc, this.name + ".prototype should not have a setter");
assert_false(desc.writable, this.name + ".prototype should not be writable");
@ -1687,38 +1721,39 @@ IdlInterface.prototype.test_self = function()
// object %ErrorPrototype%."
//
if (this.name === "Window") {
assert_class_string(Object.getPrototypeOf(self[this.name].prototype),
assert_class_string(Object.getPrototypeOf(this.get_interface_object().prototype),
'WindowProperties',
'Class name for prototype of Window' +
'.prototype is not "WindowProperties"');
} else {
var inherit_interface, inherit_interface_has_interface_object;
var inherit_interface, inherit_interface_interface_object;
if (this.base) {
inherit_interface = this.base;
inherit_interface_has_interface_object =
!this.array
.members[inherit_interface]
.has_extended_attribute("NoInterfaceObject");
var parent = this.array.members[inherit_interface];
if (!parent.has_extended_attribute("NoInterfaceObject")) {
parent.assert_interface_object_exists();
inherit_interface_interface_object = parent.get_interface_object();
}
} else if (this.name === "DOMException") {
inherit_interface = 'Error';
inherit_interface_has_interface_object = true;
inherit_interface_interface_object = self.Error;
} else {
inherit_interface = 'Object';
inherit_interface_has_interface_object = true;
inherit_interface_interface_object = self.Object;
}
if (inherit_interface_has_interface_object) {
assert_own_property(self, inherit_interface,
'should inherit from ' + inherit_interface + ', but self has no such property');
assert_own_property(self[inherit_interface], 'prototype',
if (inherit_interface_interface_object) {
assert_not_equals(inherit_interface_interface_object, undefined,
'should inherit from ' + inherit_interface + ', but there is no such property');
assert_own_property(inherit_interface_interface_object, 'prototype',
'should inherit from ' + inherit_interface + ', but that object has no "prototype" property');
assert_equals(Object.getPrototypeOf(self[this.name].prototype),
self[inherit_interface].prototype,
assert_equals(Object.getPrototypeOf(this.get_interface_object().prototype),
inherit_interface_interface_object.prototype,
'prototype of ' + this.name + '.prototype is not ' + inherit_interface + '.prototype');
} else {
// We can't test that we get the correct object, because this is the
// only way to get our hands on it. We only test that its class
// string, at least, is correct.
assert_class_string(Object.getPrototypeOf(self[this.name].prototype),
assert_class_string(Object.getPrototypeOf(this.get_interface_object().prototype),
inherit_interface + 'Prototype',
'Class name for prototype of ' + this.name +
'.prototype is not "' + inherit_interface + 'Prototype"');
@ -1726,20 +1761,20 @@ IdlInterface.prototype.test_self = function()
}
// "The class string of an interface prototype object is the
// concatenation of the interfaces identifier and the string
// concatenation of the interfaces qualified identifier and the string
// “Prototype”."
// Skip these tests for now due to a specification issue about
// prototype name.
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=28244
// assert_class_string(self[this.name].prototype, this.name + "Prototype",
// assert_class_string(this.get_interface_object().prototype, this.get_qualified_name() + "Prototype",
// "class string of " + this.name + ".prototype");
// String() should end up calling {}.toString if nothing defines a
// stringifier.
if (!this.has_stringifier()) {
// assert_equals(String(self[this.name].prototype), "[object " + this.name + "Prototype]",
// assert_equals(String(this.get_interface_object().prototype), "[object " + this.get_qualified_name() + "Prototype]",
// "String(" + this.name + ".prototype)");
}
}.bind(this), this.name + " interface: existence and properties of interface prototype object");
@ -1751,7 +1786,7 @@ IdlInterface.prototype.test_self = function()
// prototype exotic object."
// https://heycam.github.io/webidl/#interface-prototype-object
if (this.is_global()) {
this.test_immutable_prototype("interface prototype object", self[this.name].prototype);
this.test_immutable_prototype("interface prototype object", this.get_interface_object().prototype);
}
subsetTestByKey(this.name, test, function()
@ -1760,16 +1795,15 @@ IdlInterface.prototype.test_self = function()
return;
}
assert_own_property(self, this.name,
"self does not have own property " + format_value(this.name));
this.assert_interface_object_exists();
if (this.is_callback()) {
assert_false("prototype" in self[this.name],
assert_false("prototype" in this.get_interface_object(),
this.name + ' should not have a "prototype" property');
return;
}
assert_own_property(self[this.name], "prototype",
assert_own_property(this.get_interface_object(), "prototype",
'interface "' + this.name + '" does not have own property "prototype"');
// "If the [NoInterfaceObject] extended attribute was not specified on
@ -1777,15 +1811,15 @@ IdlInterface.prototype.test_self = function()
// property named “constructor” with attributes { [[Writable]]: true,
// [[Enumerable]]: false, [[Configurable]]: true } whose value is a
// reference to the interface object for the interface."
assert_own_property(self[this.name].prototype, "constructor",
assert_own_property(this.get_interface_object().prototype, "constructor",
this.name + '.prototype does not have own property "constructor"');
var desc = Object.getOwnPropertyDescriptor(self[this.name].prototype, "constructor");
var desc = Object.getOwnPropertyDescriptor(this.get_interface_object().prototype, "constructor");
assert_false("get" in desc, this.name + ".prototype.constructor should not have a getter");
assert_false("set" in desc, this.name + ".prototype.constructor should not have a setter");
assert_true(desc.writable, this.name + ".prototype.constructor should be writable");
assert_false(desc.enumerable, this.name + ".prototype.constructor should not be enumerable");
assert_true(desc.configurable, this.name + ".prototype.constructor should be configurable");
assert_equals(self[this.name].prototype.constructor, self[this.name],
assert_equals(this.get_interface_object().prototype.constructor, this.get_interface_object(),
this.name + '.prototype.constructor is not the same object as ' + this.name);
}.bind(this), this.name + ' interface: existence and properties of interface prototype object\'s "constructor" property');
@ -1796,16 +1830,15 @@ IdlInterface.prototype.test_self = function()
return;
}
assert_own_property(self, this.name,
"self does not have own property " + format_value(this.name));
this.assert_interface_object_exists();
if (this.is_callback()) {
assert_false("prototype" in self[this.name],
assert_false("prototype" in this.get_interface_object(),
this.name + ' should not have a "prototype" property');
return;
}
assert_own_property(self[this.name], "prototype",
assert_own_property(this.get_interface_object(), "prototype",
'interface "' + this.name + '" does not have own property "prototype"');
// If the interface has any member declared with the [Unscopable] extended
@ -1814,7 +1847,7 @@ IdlInterface.prototype.test_self = function()
// { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true },
// and whose value is an object created as follows...
var unscopables = this.get_unscopables().map(m => m.name);
var proto = self[this.name].prototype;
var proto = this.get_interface_object().prototype;
if (unscopables.length != 0) {
assert_own_property(
proto, Symbol.unscopables,
@ -1845,7 +1878,7 @@ IdlInterface.prototype.test_self = function()
this.name + '.prototype[Symbol.unscopables] has unexpected property "' + prop + '"');
}
} else {
assert_equals(Object.getOwnPropertyDescriptor(self[this.name].prototype, Symbol.unscopables),
assert_equals(Object.getOwnPropertyDescriptor(this.get_interface_object().prototype, Symbol.unscopables),
undefined,
this.name + '.prototype should not have @@unscopables');
}
@ -1962,21 +1995,20 @@ IdlInterface.prototype.test_member_const = function(member)
subsetTestByKey(this.name, test, function()
{
assert_own_property(self, this.name,
"self does not have own property " + format_value(this.name));
this.assert_interface_object_exists();
// "For each constant defined on an interface A, there must be
// a corresponding property on the interface object, if it
// exists."
assert_own_property(self[this.name], member.name);
assert_own_property(this.get_interface_object(), member.name);
// "The value of the property is that which is obtained by
// converting the constants IDL value to an ECMAScript
// value."
assert_equals(self[this.name][member.name], constValue(member.value),
assert_equals(this.get_interface_object()[member.name], constValue(member.value),
"property has wrong value");
// "The property has attributes { [[Writable]]: false,
// [[Enumerable]]: true, [[Configurable]]: false }."
var desc = Object.getOwnPropertyDescriptor(self[this.name], member.name);
var desc = Object.getOwnPropertyDescriptor(this.get_interface_object(), member.name);
assert_false("get" in desc, "property should not have a getter");
assert_false("set" in desc, "property should not have a setter");
assert_false(desc.writable, "property should not be writable");
@ -1988,22 +2020,21 @@ IdlInterface.prototype.test_member_const = function(member)
// exist on the interface prototype object."
subsetTestByKey(this.name, test, function()
{
assert_own_property(self, this.name,
"self does not have own property " + format_value(this.name));
this.assert_interface_object_exists();
if (this.is_callback()) {
assert_false("prototype" in self[this.name],
assert_false("prototype" in this.get_interface_object(),
this.name + ' should not have a "prototype" property');
return;
}
assert_own_property(self[this.name], "prototype",
assert_own_property(this.get_interface_object(), "prototype",
'interface "' + this.name + '" does not have own property "prototype"');
assert_own_property(self[this.name].prototype, member.name);
assert_equals(self[this.name].prototype[member.name], constValue(member.value),
assert_own_property(this.get_interface_object().prototype, member.name);
assert_equals(this.get_interface_object().prototype[member.name], constValue(member.value),
"property has wrong value");
var desc = Object.getOwnPropertyDescriptor(self[this.name], member.name);
var desc = Object.getOwnPropertyDescriptor(this.get_interface_object(), member.name);
assert_false("get" in desc, "property should not have a getter");
assert_false("set" in desc, "property should not have a setter");
assert_false(desc.writable, "property should not be writable");
@ -2026,13 +2057,12 @@ IdlInterface.prototype.test_member_attribute = function(member)
return;
}
assert_own_property(self, this.name,
"self does not have own property " + format_value(this.name));
assert_own_property(self[this.name], "prototype",
this.assert_interface_object_exists();
assert_own_property(this.get_interface_object(), "prototype",
'interface "' + this.name + '" does not have own property "prototype"');
if (member["static"]) {
assert_own_property(self[this.name], member.name,
assert_own_property(this.get_interface_object(), member.name,
"The interface object must have a property " +
format_value(member.name));
a_test.done();
@ -2045,7 +2075,7 @@ IdlInterface.prototype.test_member_attribute = function(member)
assert_own_property(self, member.name,
"The global object must have a property " +
format_value(member.name));
assert_false(member.name in self[this.name].prototype,
assert_false(member.name in this.get_interface_object().prototype,
"The prototype object should not have a property " +
format_value(member.name));
@ -2073,34 +2103,34 @@ IdlInterface.prototype.test_member_attribute = function(member)
// since it will call done() on a_test.
this.do_interface_attribute_asserts(self, member, a_test);
} else {
assert_true(member.name in self[this.name].prototype,
assert_true(member.name in this.get_interface_object().prototype,
"The prototype object must have a property " +
format_value(member.name));
if (!member.has_extended_attribute("LenientThis")) {
if (member.idlType.generic !== "Promise") {
assert_throws(new TypeError(), function() {
self[this.name].prototype[member.name];
this.get_interface_object().prototype[member.name];
}.bind(this), "getting property on prototype object must throw TypeError");
// do_interface_attribute_asserts must be the last thing we
// do, since it will call done() on a_test.
this.do_interface_attribute_asserts(self[this.name].prototype, member, a_test);
this.do_interface_attribute_asserts(this.get_interface_object().prototype, member, a_test);
} else {
promise_rejects(a_test, new TypeError(),
self[this.name].prototype[member.name])
this.get_interface_object().prototype[member.name])
.then(function() {
// do_interface_attribute_asserts must be the last
// thing we do, since it will call done() on a_test.
this.do_interface_attribute_asserts(self[this.name].prototype,
this.do_interface_attribute_asserts(this.get_interface_object().prototype,
member, a_test);
}.bind(this));
}
} else {
assert_equals(self[this.name].prototype[member.name], undefined,
assert_equals(this.get_interface_object().prototype[member.name], undefined,
"getting property on prototype object must return undefined");
// do_interface_attribute_asserts must be the last thing we do,
// since it will call done() on a_test.
this.do_interface_attribute_asserts(self[this.name].prototype, member, a_test);
this.do_interface_attribute_asserts(this.get_interface_object().prototype, member, a_test);
}
}
}.bind(this));
@ -2125,17 +2155,16 @@ IdlInterface.prototype.test_member_operation = function(member)
return;
}
assert_own_property(self, this.name,
"self does not have own property " + format_value(this.name));
this.assert_interface_object_exists();
if (this.is_callback()) {
assert_false("prototype" in self[this.name],
assert_false("prototype" in this.get_interface_object(),
this.name + ' should not have a "prototype" property');
a_test.done();
return;
}
assert_own_property(self[this.name], "prototype",
assert_own_property(this.get_interface_object(), "prototype",
'interface "' + this.name + '" does not have own property "prototype"');
// "For each unique identifier of an exposed operation defined on the
@ -2150,9 +2179,9 @@ IdlInterface.prototype.test_member_operation = function(member)
// "* If the operation is static, then the property exists on the
// interface object."
if (member["static"]) {
assert_own_property(self[this.name], member.name,
assert_own_property(this.get_interface_object(), member.name,
"interface object missing static operation");
memberHolderObject = self[this.name];
memberHolderObject = this.get_interface_object();
// "* Otherwise, [...] if the interface was declared with the [Global]
// extended attribute, then the property exists
// on every object that implements the interface."
@ -2163,9 +2192,9 @@ IdlInterface.prototype.test_member_operation = function(member)
// "* Otherwise, the property exists solely on the interfaces
// interface prototype object."
} else {
assert_own_property(self[this.name].prototype, member.name,
assert_own_property(this.get_interface_object().prototype, member.name,
"interface prototype object missing non-static operation");
memberHolderObject = self[this.name].prototype;
memberHolderObject = this.get_interface_object().prototype;
}
this.do_member_unscopable_asserts(member);
this.do_member_operation_asserts(memberHolderObject, member, a_test);
@ -2180,7 +2209,7 @@ IdlInterface.prototype.do_member_unscopable_asserts = function(member)
return;
}
var unscopables = self[this.name].prototype[Symbol.unscopables];
var unscopables = this.get_interface_object().prototype[Symbol.unscopables];
var prop = member.name;
var propDesc = Object.getOwnPropertyDescriptor(unscopables, prop);
assert_equals(typeof propDesc, "object",
@ -2308,27 +2337,26 @@ IdlInterface.prototype.test_to_json_operation = function(memberHolderObject, mem
IdlInterface.prototype.test_member_iterable = function(member)
{
var interfaceName = this.name;
var isPairIterator = member.idlType.length === 2;
subsetTestByKey(this.name, test, function()
{
var descriptor = Object.getOwnPropertyDescriptor(self[interfaceName].prototype, Symbol.iterator);
var descriptor = Object.getOwnPropertyDescriptor(this.get_interface_object().prototype, Symbol.iterator);
assert_true(descriptor.writable, "property should be writable");
assert_true(descriptor.configurable, "property should be configurable");
assert_false(descriptor.enumerable, "property should not be enumerable");
assert_equals(self[interfaceName].prototype[Symbol.iterator].name, isPairIterator ? "entries" : "values", "@@iterator function does not have the right name");
}, "Testing Symbol.iterator property of iterable interface " + interfaceName);
assert_equals(this.get_interface_object().prototype[Symbol.iterator].name, isPairIterator ? "entries" : "values", "@@iterator function does not have the right name");
}.bind(this), "Testing Symbol.iterator property of iterable interface " + this.name);
if (isPairIterator) {
subsetTestByKey(this.name, test, function() {
assert_equals(self[interfaceName].prototype[Symbol.iterator], self[interfaceName].prototype["entries"], "entries method is not the same as @@iterator");
}, "Testing pair iterable interface " + interfaceName);
assert_equals(this.get_interface_object().prototype[Symbol.iterator], this.get_interface_object().prototype["entries"], "entries method is not the same as @@iterator");
}.bind(this), "Testing pair iterable interface " + this.name);
} else {
subsetTestByKey(this.name, test, function() {
["entries", "keys", "values", "forEach", Symbol.Iterator].forEach(function(property) {
assert_equals(self[interfaceName].prototype[property], Array.prototype[property], property + " function is not the same as Array one");
});
}, "Testing value iterable interface " + interfaceName);
assert_equals(this.get_interface_object().prototype[property], Array.prototype[property], property + " function is not the same as Array one");
}.bind(this));
}.bind(this), "Testing value iterable interface " + this.name);
}
};
@ -2340,21 +2368,20 @@ IdlInterface.prototype.test_member_stringifier = function(member)
return;
}
assert_own_property(self, this.name,
"self does not have own property " + format_value(this.name));
this.assert_interface_object_exists();
if (this.is_callback()) {
assert_false("prototype" in self[this.name],
assert_false("prototype" in this.get_interface_object(),
this.name + ' should not have a "prototype" property');
return;
}
assert_own_property(self[this.name], "prototype",
assert_own_property(this.get_interface_object(), "prototype",
'interface "' + this.name + '" does not have own property "prototype"');
// ". . . the property exists on the interface prototype object."
var interfacePrototypeObject = self[this.name].prototype;
assert_own_property(self[this.name].prototype, "toString",
var interfacePrototypeObject = this.get_interface_object().prototype;
assert_own_property(interfacePrototypeObject, "toString",
"interface prototype object missing non-static operation");
var stringifierUnforgeable = member.isUnforgeable;
@ -2380,7 +2407,7 @@ IdlInterface.prototype.test_member_stringifier = function(member)
// "Let O be the result of calling ToObject on the this value."
assert_throws(new TypeError(), function() {
self[this.name].prototype.toString.apply(null, []);
interfacePrototypeObject.toString.apply(null, []);
}, "calling stringifier with this = null didn't throw TypeError");
// "If O is not an object that implements the interface on which the
@ -2389,7 +2416,7 @@ IdlInterface.prototype.test_member_stringifier = function(member)
// TODO: Test a platform object that implements some other
// interface. (Have to be sure to get inheritance right.)
assert_throws(new TypeError(), function() {
self[this.name].prototype.toString.apply({}, []);
interfacePrototypeObject.toString.apply({}, []);
}, "calling stringifier with this = {} didn't throw TypeError");
}.bind(this), this.name + " interface: stringifier");
};
@ -2419,10 +2446,10 @@ IdlInterface.prototype.test_members = function()
if (!exposed_in(exposure_set(member, this.exposureSet))) {
subsetTestByKey(this.name, test, function() {
// It's not exposed, so we shouldn't find it anywhere.
assert_false(member.name in self[this.name],
assert_false(member.name in this.get_interface_object(),
"The interface object must not have a property " +
format_value(member.name));
assert_false(member.name in self[this.name].prototype,
assert_false(member.name in this.get_interface_object().prototype,
"The prototype object must not have a property " +
format_value(member.name));
}.bind(this), this.name + " interface: member " + member.name);
@ -2538,9 +2565,8 @@ IdlInterface.prototype.test_primary_interface_of = function(desc, obj, exception
{
assert_equals(exception, null, "Unexpected exception when evaluating object");
assert_equals(typeof obj, expected_typeof, "wrong typeof object");
assert_own_property(self, this.name,
"self does not have own property " + format_value(this.name));
assert_own_property(self[this.name], "prototype",
this.assert_interface_object_exists();
assert_own_property(this.get_interface_object(), "prototype",
'interface "' + this.name + '" does not have own property "prototype"');
// "The value of the internal [[Prototype]] property of the
@ -2548,22 +2574,22 @@ IdlInterface.prototype.test_primary_interface_of = function(desc, obj, exception
// interface from the platform objects associated global
// environment."
assert_equals(Object.getPrototypeOf(obj),
self[this.name].prototype,
this.get_interface_object().prototype,
desc + "'s prototype is not " + this.name + ".prototype");
}.bind(this), this.name + " must be primary interface of " + desc);
}
// "The class string of a platform object that implements one or more
// interfaces must be the identifier of the primary interface of the
// interfaces must be the qualified name of the primary interface of the
// platform object."
subsetTestByKey(this.name, test, function()
{
assert_equals(exception, null, "Unexpected exception when evaluating object");
assert_equals(typeof obj, expected_typeof, "wrong typeof object");
assert_class_string(obj, this.name, "class string of " + desc);
assert_class_string(obj, this.get_qualified_name(), "class string of " + desc);
if (!this.has_stringifier())
{
assert_equals(String(obj), "[object " + this.name + "]", "String(" + desc + ")");
assert_equals(String(obj), "[object " + this.get_qualified_name() + "]", "String(" + desc + ")");
}
}.bind(this), "Stringification of " + desc);
};