Andrew Top | ef837fa | 2017-10-04 22:44:25 -0700 | [diff] [blame] | 1 | // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 | // Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 3 | // |
| 4 | // Redistribution and use in source and binary forms, with or without |
| 5 | // modification, are permitted provided that the following conditions |
| 6 | // are met: |
| 7 | // 1. Redistributions of source code must retain the above copyright |
| 8 | // notice, this list of conditions and the following disclaimer. |
| 9 | // 2. Redistributions in binary form must reproduce the above copyright |
| 10 | // notice, this list of conditions and the following disclaimer in the |
| 11 | // documentation and/or other materials provided with the distribution. |
| 12 | // |
| 13 | // THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY |
| 14 | // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 15 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 16 | // DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
| 17 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 18 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 19 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
| 20 | // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 21 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 22 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 23 | |
| 24 | description( |
| 25 | "This test checks that deletion of properties works properly with getters and setters." |
| 26 | ); |
| 27 | |
| 28 | b1 = 1; |
| 29 | this.__defineSetter__("a1", function() {}); |
| 30 | this.__defineSetter__("b1", function() {}); |
| 31 | delete a1; |
| 32 | shouldThrow("b1.property"); |
| 33 | |
| 34 | a2 = 1; |
| 35 | this.__defineSetter__("a2", function() {}); |
| 36 | this.__defineSetter__("b2", function() {}); |
| 37 | delete b2; |
| 38 | shouldThrow("a2.property"); |
| 39 | |
| 40 | b3 = 1; |
| 41 | this.__defineGetter__("a3", function() {}); |
| 42 | this.__defineGetter__("b3", function() {}); |
| 43 | delete a3; |
| 44 | shouldThrow("b3.property"); |
| 45 | |
| 46 | a4 = 1; |
| 47 | this.__defineGetter__("a4", function() {}); |
| 48 | this.__defineGetter__("b4", function() {}); |
| 49 | delete b4; |
| 50 | shouldThrow("a4.property"); |
| 51 | |
| 52 | b5 = 1; |
| 53 | this.__defineSetter__("a5", function() {}); |
| 54 | this.__defineGetter__("b5", function() {}); |
| 55 | delete a5; |
| 56 | shouldThrow("b5.property"); |
| 57 | |
| 58 | a6 = 1; |
| 59 | this.__defineSetter__("a6", function() {}); |
| 60 | this.__defineGetter__("b6", function() {}); |
| 61 | delete b6; |
| 62 | shouldThrow("a6.property"); |
| 63 | |
| 64 | b7 = 1; |
| 65 | this.__defineGetter__("a7", function() {}); |
| 66 | this.__defineSetter__("b7", function() {}); |
| 67 | delete a7; |
| 68 | shouldThrow("b7.property"); |
| 69 | |
| 70 | a8 = 1; |
| 71 | this.__defineGetter__("a8", function() {}); |
| 72 | this.__defineSetter__("b8", function() {}); |
| 73 | delete b8; |
| 74 | shouldThrow("a8.property"); |
| 75 | |
| 76 | var o1 = { b: 1 }; |
| 77 | o1.__defineSetter__("a", function() {}); |
| 78 | o1.__defineSetter__("b", function() {}); |
| 79 | delete o1.a; |
| 80 | shouldThrow("o1.b.property"); |
| 81 | |
| 82 | var o2 = { a: 1 }; |
| 83 | o2.__defineSetter__("a", function() {}); |
| 84 | o2.__defineSetter__("b", function() {}); |
| 85 | delete o2.b; |
| 86 | shouldThrow("o1.a.property"); |
| 87 | |
| 88 | var o3 = { b: 1 }; |
| 89 | o3.__defineGetter__("a", function() {}); |
| 90 | o3.__defineGetter__("b", function() {}); |
| 91 | delete o3.a; |
| 92 | shouldThrow("o3.b.property"); |
| 93 | |
| 94 | var o4 = { a: 1 }; |
| 95 | o4.__defineGetter__("a", function() {}); |
| 96 | o4.__defineGetter__("b", function() {}); |
| 97 | delete o4.b; |
| 98 | shouldThrow("o4.a.property"); |
| 99 | |
| 100 | var o5 = { b: 1 }; |
| 101 | o5.__defineSetter__("a", function() {}); |
| 102 | o5.__defineSetter__("b", function() {}); |
| 103 | delete o5.a; |
| 104 | shouldThrow("o5.b.property"); |
| 105 | |
| 106 | var o6 = { a: 1 }; |
| 107 | o6.__defineSetter__("a", function() {}); |
| 108 | o6.__defineSetter__("b", function() {}); |
| 109 | delete o6.b; |
| 110 | shouldThrow("o6.a.property"); |
| 111 | |
| 112 | var o7 = { b: 1 }; |
| 113 | o7.__defineGetter__("a", function() {}); |
| 114 | o7.__defineGetter__("b", function() {}); |
| 115 | delete o7.a; |
| 116 | shouldThrow("o7.b.property"); |
| 117 | |
| 118 | var o8 = { a: 1 }; |
| 119 | o8.__defineGetter__("a", function() {}); |
| 120 | o8.__defineGetter__("b", function() {}); |
| 121 | delete o8.b; |
| 122 | shouldThrow("o8.a.property"); |