| OLD | NEW |
| (Empty) | |
| 1 // Tests <http://heycam.github.io/webidl/#es-stringifier>. |
| 2 function test_stringifier_attribute(aObject, aAttribute, aIsUnforgeable) { |
| 3 // Step 1. |
| 4 test(function() { |
| 5 [null, undefined].forEach(function(v) { |
| 6 assert_throws(new TypeError(), function() { |
| 7 aObject.toString.call(v); |
| 8 }); |
| 9 }); |
| 10 }); |
| 11 |
| 12 // TODO Step 2: security check. |
| 13 |
| 14 // Step 3. |
| 15 test(function() { |
| 16 assert_false("Window" in window && aObject instanceof window.Window); |
| 17 [{}, window].forEach(function(v) { |
| 18 assert_throws(new TypeError(), function() { |
| 19 aObject.toString.call(v) |
| 20 }); |
| 21 }); |
| 22 }); |
| 23 |
| 24 // Step 4-6. |
| 25 var expected_value; |
| 26 test(function() { |
| 27 expected_value = aObject[aAttribute]; |
| 28 assert_equals(aObject[aAttribute], expected_value, |
| 29 "The attribute " + aAttribute + " should be pure."); |
| 30 }); |
| 31 |
| 32 var test_error = { name: "test" }; |
| 33 test(function() { |
| 34 if (!aIsUnforgeable) { |
| 35 Object.defineProperty(aObject, aAttribute, { |
| 36 configurable: true, |
| 37 get: function() { throw test_error; } |
| 38 }); |
| 39 } |
| 40 assert_equals(aObject.toString(), expected_value); |
| 41 }); |
| 42 |
| 43 test(function() { |
| 44 if (!aIsUnforgeable) { |
| 45 Object.defineProperty(aObject, aAttribute, { |
| 46 configurable: true, |
| 47 value: { toString: function() { throw test_error; } } |
| 48 }); |
| 49 } |
| 50 assert_equals(aObject.toString(), expected_value); |
| 51 }); |
| 52 } |
| OLD | NEW |