Skip to content

Commit

Permalink
Merge pull request web-platform-tests#89 from Ms2ger/lenientthis
Browse files Browse the repository at this point in the history
Support [LenientThis] extended attribute (fixes web-platform-tests#88).
  • Loading branch information
zcorpan committed Oct 28, 2014
2 parents 1652d99 + fbdbace commit e947005
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions idlharness.js
Original file line number Diff line number Diff line change
Expand Up @@ -1266,10 +1266,14 @@ IdlInterface.prototype.test_member_attribute = function(member)
"The prototype object must have a property " +
format_value(member.name));

// TODO: Needs to test for LenientThis.
assert_throws(new TypeError(), function() {
window[this.name].prototype[member.name];
}.bind(this), "getting property on prototype object must throw TypeError");
if (!member.has_extended_attribute("LenientThis")) {
assert_throws(new TypeError(), function() {
window[this.name].prototype[member.name];
}.bind(this), "getting property on prototype object must throw TypeError");
} else {
assert_equals(window[this.name].prototype[member.name], undefined,
"getting property on prototype object must return undefined");
}
do_interface_attribute_asserts(window[this.name].prototype, member);
}
}.bind(this), this.name + " interface: attribute " + member.name);
Expand Down Expand Up @@ -1705,11 +1709,14 @@ function do_interface_attribute_asserts(obj, member)
// value 0."
assert_equals(typeof desc.get, "function", "getter must be Function");
assert_equals(desc.get.length, 0, "getter length must be 0");
// TODO: Account for LenientThis
assert_throws(new TypeError(), function()
{
desc.get.call({});
}.bind(this), "calling getter on wrong object type must throw TypeError");
if (!member.has_extended_attribute("LenientThis")) {
assert_throws(new TypeError(), function() {
desc.get.call({});
}.bind(this), "calling getter on wrong object type must throw TypeError");
} else {
assert_equals(desc.get.call({}), undefined,
"calling getter on wrong object type must return undefined");
}

// TODO: Test calling setter on the interface prototype (should throw
// TypeError in most cases).
Expand All @@ -1731,6 +1738,14 @@ function do_interface_attribute_asserts(obj, member)
{
assert_equals(typeof desc.set, "function", "setter must be function for PutForwards, Replaceable, or non-readonly attributes");
assert_equals(desc.set.length, 1, "setter length must be 1");
if (!member.has_extended_attribute("LenientThis")) {
assert_throws(new TypeError(), function() {
desc.set.call({});
}.bind(this), "calling setter on wrong object type must throw TypeError");
} else {
assert_equals(desc.set.call({}), undefined,
"calling setter on wrong object type must return undefined");
}
}
}
//@}
Expand Down

0 comments on commit e947005

Please sign in to comment.