mirror of
https://github.com/servo/servo.git
synced 2025-08-13 17:35:36 +01:00
Update web-platform-tests to revision 66f38302334f162d363afcf4a1792d895072f3ef
This commit is contained in:
parent
36f5b69224
commit
b198cd722a
622 changed files with 3374 additions and 2001 deletions
|
@ -48,6 +48,13 @@ policies and contribution forms [3].
|
|||
*/
|
||||
(function(){
|
||||
"use strict";
|
||||
// Support subsetTestByKey from /common/subset-tests-by-key.js, but make it optional
|
||||
if (!('subsetTestByKey' in self)) {
|
||||
self.subsetTestByKey = function(key, callback, ...args) {
|
||||
return callback(...args);
|
||||
}
|
||||
self.shouldRunSubTest = () => true;
|
||||
}
|
||||
/// Helpers ///
|
||||
function constValue (cnt)
|
||||
//@{
|
||||
|
@ -1393,7 +1400,7 @@ IdlInterface.prototype.test = function()
|
|||
}
|
||||
|
||||
if (!this.exposed) {
|
||||
test(function() {
|
||||
subsetTestByKey(this.name, test, function() {
|
||||
assert_false(this.name in self);
|
||||
}.bind(this), this.name + " interface: existence and properties of interface object");
|
||||
return;
|
||||
|
@ -1419,7 +1426,7 @@ IdlInterface.prototype.test = function()
|
|||
IdlInterface.prototype.test_self = function()
|
||||
//@{
|
||||
{
|
||||
test(function()
|
||||
subsetTestByKey(this.name, test, function()
|
||||
{
|
||||
// This function tests WebIDL as of 2015-01-13.
|
||||
|
||||
|
@ -1526,7 +1533,7 @@ IdlInterface.prototype.test_self = function()
|
|||
}.bind(this), this.name + " interface: existence and properties of interface object");
|
||||
|
||||
if (!this.is_callback()) {
|
||||
test(function() {
|
||||
subsetTestByKey(this.name, test, function() {
|
||||
// This function tests WebIDL as of 2014-10-25.
|
||||
// https://heycam.github.io/webidl/#es-interface-call
|
||||
|
||||
|
@ -1553,7 +1560,7 @@ IdlInterface.prototype.test_self = function()
|
|||
}
|
||||
|
||||
if (!this.is_callback() || this.has_constants()) {
|
||||
test(function() {
|
||||
subsetTestByKey(this.name, test, function() {
|
||||
// This function tests WebIDL as of 2015-11-17.
|
||||
// https://heycam.github.io/webidl/#interface-object
|
||||
|
||||
|
@ -1578,7 +1585,7 @@ IdlInterface.prototype.test_self = function()
|
|||
|
||||
|
||||
if (this.has_extended_attribute("LegacyWindowAlias")) {
|
||||
test(function()
|
||||
subsetTestByKey(this.name, test, function()
|
||||
{
|
||||
var aliasAttrs = this.extAttrs.filter(function(o) { return o.name === "LegacyWindowAlias"; });
|
||||
if (aliasAttrs.length > 1) {
|
||||
|
@ -1630,7 +1637,7 @@ IdlInterface.prototype.test_self = function()
|
|||
}
|
||||
// TODO: Test named constructors if I find any interfaces that have them.
|
||||
|
||||
test(function()
|
||||
subsetTestByKey(this.name, test, function()
|
||||
{
|
||||
// This function tests WebIDL as of 2015-01-21.
|
||||
// https://heycam.github.io/webidl/#interface-object
|
||||
|
@ -1757,7 +1764,7 @@ IdlInterface.prototype.test_self = function()
|
|||
this.test_immutable_prototype("interface prototype object", self[this.name].prototype);
|
||||
}
|
||||
|
||||
test(function()
|
||||
subsetTestByKey(this.name, test, function()
|
||||
{
|
||||
if (this.is_callback() && !this.has_constants()) {
|
||||
return;
|
||||
|
@ -1793,7 +1800,7 @@ IdlInterface.prototype.test_self = function()
|
|||
}.bind(this), this.name + ' interface: existence and properties of interface prototype object\'s "constructor" property');
|
||||
|
||||
|
||||
test(function()
|
||||
subsetTestByKey(this.name, test, function()
|
||||
{
|
||||
if (this.is_callback() && !this.has_constants()) {
|
||||
return;
|
||||
|
@ -1863,7 +1870,7 @@ IdlInterface.prototype.test_immutable_prototype = function(type, obj)
|
|||
return;
|
||||
}
|
||||
|
||||
test(function(t) {
|
||||
subsetTestByKey(this.name, test, function(t) {
|
||||
var originalValue = Object.getPrototypeOf(obj);
|
||||
var newValue = Object.create(null);
|
||||
|
||||
|
@ -1886,7 +1893,7 @@ IdlInterface.prototype.test_immutable_prototype = function(type, obj)
|
|||
"of " + type + " - setting to a new value via Object.setPrototypeOf " +
|
||||
"should throw a TypeError");
|
||||
|
||||
test(function(t) {
|
||||
subsetTestByKey(this.name, test, function(t) {
|
||||
var originalValue = Object.getPrototypeOf(obj);
|
||||
var newValue = Object.create(null);
|
||||
|
||||
|
@ -1913,7 +1920,7 @@ IdlInterface.prototype.test_immutable_prototype = function(type, obj)
|
|||
"of " + type + " - setting to a new value via __proto__ " +
|
||||
"should throw a TypeError");
|
||||
|
||||
test(function(t) {
|
||||
subsetTestByKey(this.name, test, function(t) {
|
||||
var originalValue = Object.getPrototypeOf(obj);
|
||||
var newValue = Object.create(null);
|
||||
|
||||
|
@ -1934,7 +1941,7 @@ IdlInterface.prototype.test_immutable_prototype = function(type, obj)
|
|||
"of " + type + " - setting to a new value via Reflect.setPrototypeOf " +
|
||||
"should return false");
|
||||
|
||||
test(function() {
|
||||
subsetTestByKey(this.name, test, function() {
|
||||
var originalValue = Object.getPrototypeOf(obj);
|
||||
|
||||
Object.setPrototypeOf(obj, originalValue);
|
||||
|
@ -1942,7 +1949,7 @@ IdlInterface.prototype.test_immutable_prototype = function(type, obj)
|
|||
"of " + type + " - setting to its original value via Object.setPrototypeOf " +
|
||||
"should not throw");
|
||||
|
||||
test(function() {
|
||||
subsetTestByKey(this.name, test, function() {
|
||||
var originalValue = Object.getPrototypeOf(obj);
|
||||
|
||||
obj.__proto__ = originalValue;
|
||||
|
@ -1950,7 +1957,7 @@ IdlInterface.prototype.test_immutable_prototype = function(type, obj)
|
|||
"of " + type + " - setting to its original value via __proto__ " +
|
||||
"should not throw");
|
||||
|
||||
test(function() {
|
||||
subsetTestByKey(this.name, test, function() {
|
||||
var originalValue = Object.getPrototypeOf(obj);
|
||||
|
||||
assert_true(Reflect.setPrototypeOf(obj, originalValue));
|
||||
|
@ -1967,7 +1974,7 @@ IdlInterface.prototype.test_member_const = function(member)
|
|||
throw new IdlHarnessError("Internal error: test_member_const called without any constants");
|
||||
}
|
||||
|
||||
test(function()
|
||||
subsetTestByKey(this.name, test, function()
|
||||
{
|
||||
assert_own_property(self, this.name,
|
||||
"self does not have own property " + format_value(this.name));
|
||||
|
@ -1993,7 +2000,7 @@ IdlInterface.prototype.test_member_const = function(member)
|
|||
|
||||
// "In addition, a property with the same characteristics must
|
||||
// exist on the interface prototype object."
|
||||
test(function()
|
||||
subsetTestByKey(this.name, test, function()
|
||||
{
|
||||
assert_own_property(self, this.name,
|
||||
"self does not have own property " + format_value(this.name));
|
||||
|
@ -2024,7 +2031,10 @@ IdlInterface.prototype.test_member_const = function(member)
|
|||
IdlInterface.prototype.test_member_attribute = function(member)
|
||||
//@{
|
||||
{
|
||||
var a_test = async_test(this.name + " interface: attribute " + member.name);
|
||||
if (!shouldRunSubTest(this.name)) {
|
||||
return;
|
||||
}
|
||||
var a_test = subsetTestByKey(this.name, async_test, this.name + " interface: attribute " + member.name);
|
||||
a_test.step(function()
|
||||
{
|
||||
if (this.is_callback() && !this.has_constants()) {
|
||||
|
@ -2107,7 +2117,7 @@ IdlInterface.prototype.test_member_attribute = function(member)
|
|||
}
|
||||
}.bind(this));
|
||||
|
||||
test(function () {
|
||||
subsetTestByKey(this.name, test, function () {
|
||||
this.do_member_unscopable_asserts(member);
|
||||
}.bind(this), 'Unscopable handled correctly for ' + member.name + ' property on ' + this.name);
|
||||
};
|
||||
|
@ -2116,7 +2126,10 @@ IdlInterface.prototype.test_member_attribute = function(member)
|
|||
IdlInterface.prototype.test_member_operation = function(member)
|
||||
//@{
|
||||
{
|
||||
var a_test = async_test(this.name + " interface: operation " + member.name +
|
||||
if (!shouldRunSubTest(this.name)) {
|
||||
return;
|
||||
}
|
||||
var a_test = subsetTestByKey(this.name, async_test, this.name + " interface: operation " + member.name +
|
||||
"(" + member.arguments.map(
|
||||
function(m) {return m.idlType.idlType; } ).join(", ")
|
||||
+")");
|
||||
|
@ -2175,7 +2188,7 @@ IdlInterface.prototype.test_member_operation = function(member)
|
|||
this.do_member_operation_asserts(memberHolderObject, member, a_test);
|
||||
}.bind(this));
|
||||
|
||||
test(function () {
|
||||
subsetTestByKey(this.name, test, function () {
|
||||
this.do_member_unscopable_asserts(member);
|
||||
}.bind(this),
|
||||
'Unscopable handled correctly for ' + member.name + "(" +
|
||||
|
@ -2303,7 +2316,7 @@ IdlInterface.prototype.test_to_json_operation = function(memberHolderObject, mem
|
|||
var instanceName = memberHolderObject.constructor.name;
|
||||
if (member.has_extended_attribute("Default")) {
|
||||
var map = this.default_to_json_operation();
|
||||
test(function() {
|
||||
subsetTestByKey(this.name, test, function() {
|
||||
var json = memberHolderObject.toJSON();
|
||||
map.forEach(function(type, k) {
|
||||
assert_true(k in json, "property " + JSON.stringify(k) + " should be present in the output of " + this.name + ".prototype.toJSON()");
|
||||
|
@ -2316,7 +2329,7 @@ IdlInterface.prototype.test_to_json_operation = function(memberHolderObject, mem
|
|||
}, this);
|
||||
}.bind(this), "Test default toJSON operation of " + instanceName);
|
||||
} else {
|
||||
test(function() {
|
||||
subsetTestByKey(this.name, test, function() {
|
||||
assert_true(this.array.is_json_type(member.idlType), JSON.stringify(member.idlType) + " is not an appropriate return value for the toJSON operation of " + instanceName);
|
||||
this.array.assert_type_is(memberHolderObject.toJSON(), member.idlType);
|
||||
}.bind(this), "Test toJSON operation of " + instanceName);
|
||||
|
@ -2329,7 +2342,7 @@ IdlInterface.prototype.test_member_iterable = function(member)
|
|||
{
|
||||
var interfaceName = this.name;
|
||||
var isPairIterator = member.idlType.length === 2;
|
||||
test(function()
|
||||
subsetTestByKey(this.name, test, function()
|
||||
{
|
||||
var descriptor = Object.getOwnPropertyDescriptor(self[interfaceName].prototype, Symbol.iterator);
|
||||
assert_true(descriptor.writable, "property should be writable");
|
||||
|
@ -2339,11 +2352,11 @@ IdlInterface.prototype.test_member_iterable = function(member)
|
|||
}, "Testing Symbol.iterator property of iterable interface " + interfaceName);
|
||||
|
||||
if (isPairIterator) {
|
||||
test(function() {
|
||||
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);
|
||||
} else {
|
||||
test(function() {
|
||||
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");
|
||||
});
|
||||
|
@ -2355,7 +2368,7 @@ IdlInterface.prototype.test_member_iterable = function(member)
|
|||
IdlInterface.prototype.test_member_stringifier = function(member)
|
||||
//@{
|
||||
{
|
||||
test(function()
|
||||
subsetTestByKey(this.name, test, function()
|
||||
{
|
||||
if (this.is_callback() && !this.has_constants()) {
|
||||
return;
|
||||
|
@ -2440,7 +2453,7 @@ IdlInterface.prototype.test_members = function()
|
|||
}
|
||||
|
||||
if (!exposed_in(exposure_set(member, this.exposureSet))) {
|
||||
test(function() {
|
||||
subsetTestByKey(this.name, test, function() {
|
||||
// It's not exposed, so we shouldn't find it anywhere.
|
||||
assert_false(member.name in self[this.name],
|
||||
"The interface object must not have a property " +
|
||||
|
@ -2561,7 +2574,7 @@ IdlInterface.prototype.test_primary_interface_of = function(desc, obj, exception
|
|||
if (!this.has_extended_attribute("NoInterfaceObject")
|
||||
&& (typeof obj != expected_typeof || obj instanceof Object))
|
||||
{
|
||||
test(function()
|
||||
subsetTestByKey(this.name, test, function()
|
||||
{
|
||||
assert_equals(exception, null, "Unexpected exception when evaluating object");
|
||||
assert_equals(typeof obj, expected_typeof, "wrong typeof object");
|
||||
|
@ -2583,7 +2596,7 @@ IdlInterface.prototype.test_primary_interface_of = function(desc, obj, exception
|
|||
// "The class string of a platform object that implements one or more
|
||||
// interfaces must be the identifier of the primary interface of the
|
||||
// platform object."
|
||||
test(function()
|
||||
subsetTestByKey(this.name, test, function()
|
||||
{
|
||||
assert_equals(exception, null, "Unexpected exception when evaluating object");
|
||||
assert_equals(typeof obj, expected_typeof, "wrong typeof object");
|
||||
|
@ -2601,6 +2614,9 @@ IdlInterface.prototype.test_interface_of = function(desc, obj, exception, expect
|
|||
{
|
||||
// TODO: Indexed and named properties, more checks on interface members
|
||||
this.already_tested = true;
|
||||
if (!shouldRunSubTest(this.name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < this.members.length; i++)
|
||||
{
|
||||
|
@ -2609,7 +2625,7 @@ IdlInterface.prototype.test_interface_of = function(desc, obj, exception, expect
|
|||
continue;
|
||||
}
|
||||
if (!exposed_in(exposure_set(member, this.exposureSet))) {
|
||||
test(function() {
|
||||
subsetTestByKey(this.name, test, function() {
|
||||
assert_equals(exception, null, "Unexpected exception when evaluating object");
|
||||
assert_false(member.name in obj);
|
||||
}.bind(this), this.name + " interface: " + desc + ' must not have property "' + member.name + '"');
|
||||
|
@ -2617,7 +2633,7 @@ IdlInterface.prototype.test_interface_of = function(desc, obj, exception, expect
|
|||
}
|
||||
if (member.type == "attribute" && member.isUnforgeable)
|
||||
{
|
||||
var a_test = async_test(this.name + " interface: " + desc + ' must have own property "' + member.name + '"');
|
||||
var a_test = subsetTestByKey(this.name, async_test, this.name + " interface: " + desc + ' must have own property "' + member.name + '"');
|
||||
a_test.step(function() {
|
||||
assert_equals(exception, null, "Unexpected exception when evaluating object");
|
||||
assert_equals(typeof obj, expected_typeof, "wrong typeof object");
|
||||
|
@ -2629,7 +2645,7 @@ IdlInterface.prototype.test_interface_of = function(desc, obj, exception, expect
|
|||
member.name &&
|
||||
member.isUnforgeable)
|
||||
{
|
||||
var a_test = async_test(this.name + " interface: " + desc + ' must have own property "' + member.name + '"');
|
||||
var a_test = subsetTestByKey(this.name, async_test, this.name + " interface: " + desc + ' must have own property "' + member.name + '"');
|
||||
a_test.step(function()
|
||||
{
|
||||
assert_equals(exception, null, "Unexpected exception when evaluating object");
|
||||
|
@ -2649,7 +2665,7 @@ IdlInterface.prototype.test_interface_of = function(desc, obj, exception, expect
|
|||
{
|
||||
described_name += "(" + member.arguments.map(arg => arg.idlType.idlType).join(", ") + ")";
|
||||
}
|
||||
test(function()
|
||||
subsetTestByKey(this.name, test, function()
|
||||
{
|
||||
assert_equals(exception, null, "Unexpected exception when evaluating object");
|
||||
assert_equals(typeof obj, expected_typeof, "wrong typeof object");
|
||||
|
@ -2695,7 +2711,7 @@ IdlInterface.prototype.test_interface_of = function(desc, obj, exception, expect
|
|||
// TODO: Test passing arguments of the wrong type.
|
||||
if (member.type == "operation" && member.name && member.arguments.length)
|
||||
{
|
||||
var a_test = async_test( this.name + " interface: calling " + member.name +
|
||||
var a_test = subsetTestByKey(this.name, async_test, this.name + " interface: calling " + member.name +
|
||||
"(" + member.arguments.map(function(m) { return m.idlType.idlType; }).join(", ") +
|
||||
") on " + desc + " with too few arguments must throw TypeError");
|
||||
a_test.step(function()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue