diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /js/src/jit-test/tests/TypedObject/set-property-with-prototype.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/jit-test/tests/TypedObject/set-property-with-prototype.js')
-rw-r--r-- | js/src/jit-test/tests/TypedObject/set-property-with-prototype.js | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/TypedObject/set-property-with-prototype.js b/js/src/jit-test/tests/TypedObject/set-property-with-prototype.js new file mode 100644 index 000000000..96bba9e54 --- /dev/null +++ b/js/src/jit-test/tests/TypedObject/set-property-with-prototype.js @@ -0,0 +1,72 @@ + +if (typeof TypedObject === "undefined") + quit(); + +// Test the behavior of property sets on typed objects when they are a +// prototype or their prototype has a setter. +var TO = TypedObject; + +function assertThrows(fun, errorType) { + try { + fun(); + assertEq(true, false, "Expected error, but none was thrown"); + } catch (e) { + assertEq(e instanceof errorType, true, "Wrong error type thrown"); + } +} + +var PointType = new TO.StructType({x: TO.int32, y: TO.int32 }); + +function testPoint() { + var p = new PointType(); + var sub = Object.create(p); + var found; + Object.defineProperty(PointType.prototype, "z", {set: function(a) { this.d = a; }}); + Object.defineProperty(PointType.prototype, "innocuous", {set: function(a) { found = a; }}); + + sub.x = 5; + assertEq(sub.x, 5); + assertEq(p.x, 0); + + sub.z = 5; + assertEq(sub.d, 5); + assertEq(sub.z, undefined); + + sub[3] = 5; + assertEq(sub[3], 5); + + p.innocuous = 10; + assertEq(found, 10); + + assertThrows(function() { + p.z = 10; + assertEq(true, false); + }, TypeError); +} +testPoint(); + +var IntArrayType = new TO.ArrayType(TO.int32, 3); + +function testArray() { + var arr = new IntArrayType(); + var found; + Object.defineProperty(IntArrayType.prototype, 5, {set: function(a) { found = a; }}); + + assertThrows(function() { + arr[5] = 5; + }, RangeError); + + assertThrows(function() { + arr[4] = 5; + }, RangeError); + + var p = Object.create(arr); + p.length = 100; + assertEq(p.length, 3); + + assertThrows(function() { + "use strict"; + p.length = 100; + }, TypeError); +} +testArray(); |