From 0fcc8e50bd5063a9b32bf1240d9303ee63b974c5 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Sat, 25 Oct 2014 21:27:15 +0200 Subject: [PATCH 1/2] Check for LenientThis when testing attribute getters. --- idlharness.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/idlharness.js b/idlharness.js index bf7e5fa4f94899..806cbec3b76485 100644 --- a/idlharness.js +++ b/idlharness.js @@ -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); @@ -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). From fbdbace3e1435047b77bf62e65c6ee46a977e62b Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Sat, 25 Oct 2014 21:29:47 +0200 Subject: [PATCH 2/2] Test for calling attribute setters on an incorrect object. --- idlharness.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/idlharness.js b/idlharness.js index 806cbec3b76485..e8ac0fd12b3a81 100644 --- a/idlharness.js +++ b/idlharness.js @@ -1738,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"); + } } } //@}