1b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org// Copyright 2011 the V8 project authors. All rights reserved. 2b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org// Redistribution and use in source and binary forms, with or without 3b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org// modification, are permitted provided that the following conditions are 4b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org// met: 5b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org// 6b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org// * Redistributions of source code must retain the above copyright 7b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org// notice, this list of conditions and the following disclaimer. 8b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org// * Redistributions in binary form must reproduce the above 9b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org// copyright notice, this list of conditions and the following 10b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org// disclaimer in the documentation and/or other materials provided 11b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org// with the distribution. 12b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org// * Neither the name of Google Inc. nor the names of its 13b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org// contributors may be used to endorse or promote products derived 14b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org// from this software without specific prior written permission. 15b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org// 16b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org 28b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org// Test that Object.freeze and Object.getOwnPropertyDescriptor do not 29b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org// call toString or valueOf on members of the object. 30b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org 31b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org// See http://code.google.com/p/v8/issues/detail?id=1233. 32b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org 33b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org 34b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.orgvar delicate = new Object(); 35b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.orgdelicate.toString = function(){ throw Error("toString"); }; 36b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.orgdelicate.valueOf = function(){ throw Error("valueOf"); }; 37b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org 38b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.orgvar x = { foo: delicate }; 39b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org 40b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.orgvar status = "fail"; 41b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.orgtry { 42b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org Object.getOwnPropertyDescriptor(x, "foo"); 43b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org Object.freeze(x); 44b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org status = "succeed"; 45b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org} catch (e) {} 46b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.org 47b08986cb66c3f6687247cb6da186c1e73057e399whesse@chromium.orgassertEquals("succeed", status); 48