OLD | NEW |
(Empty) | |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are |
| 4 // met: |
| 5 // |
| 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided |
| 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. |
| 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 |
| 28 var x = {}; |
| 29 |
| 30 // Add property a with getter/setter. |
| 31 x.__defineGetter__("a", function() { |
| 32 try { |
| 33 y.x = 40; |
| 34 } catch (e) { |
| 35 assertEquals(3, e.stack.split('\n').length); |
| 36 } |
| 37 return 40; |
| 38 }); |
| 39 |
| 40 x.__defineSetter__("a", function(val) { |
| 41 try { |
| 42 y.x = 40; |
| 43 } catch(e) { |
| 44 assertEquals(3, e.stack.split('\n').length); |
| 45 } |
| 46 }); |
| 47 |
| 48 // Add property b with getter/setter. |
| 49 function getB() { |
| 50 try { |
| 51 y.x = 30; |
| 52 } catch (e) { |
| 53 assertEquals(3, e.stack.split('\n').length); |
| 54 } |
| 55 return 30; |
| 56 } |
| 57 |
| 58 function setB(val) { |
| 59 try { |
| 60 y.x = 30; |
| 61 } catch(e) { |
| 62 assertEquals(3, e.stack.split('\n').length); |
| 63 } |
| 64 } |
| 65 |
| 66 x.__defineGetter__("b", getB); |
| 67 x.__defineSetter__("b", setB); |
| 68 |
| 69 // Add property c with getter/setter. |
| 70 var descriptor = { |
| 71 get: function() { |
| 72 try { |
| 73 y.x = 40; |
| 74 } catch (e) { |
| 75 assertEquals(3, e.stack.split('\n').length); |
| 76 } |
| 77 return 40; |
| 78 }, |
| 79 set: function(val) { |
| 80 try { |
| 81 y.x = 40; |
| 82 } catch(e) { |
| 83 assertEquals(3, e.stack.split('\n').length); |
| 84 } |
| 85 } |
| 86 } |
| 87 |
| 88 Object.defineProperty(x, 'c', descriptor) |
| 89 |
| 90 // Check that the stack for an exception in a getter and setter produce the |
| 91 // expected stack height. |
| 92 x.a; |
| 93 x.b; |
| 94 x.c; |
| 95 x.a = 1; |
| 96 x.b = 1; |
| 97 x.c = 1; |
| 98 |
| 99 // Do the same with the getters/setters on the a prototype object. |
| 100 xx = {} |
| 101 xx.__proto__ = x |
| 102 |
| 103 xx.a; |
| 104 xx.b; |
| 105 xx.c; |
| 106 xx.a = 1; |
| 107 xx.b = 1; |
| 108 xx.c = 1; |
| 109 |
OLD | NEW |